calc_heat_flux¶
- torch_sim.quantities.calc_heat_flux(momenta, masses, velocities, energies, stresses, batch=None, *, is_centroid_stress=False, is_virial_only=False)[source]¶
Calculate the heat flux vector.
Computes the microscopic heat flux, \(\mathbf{J}\) defined as:
\[\mathbf{J} = \mathbf{J}^c + \mathbf{J}^v\]where the convective part \(\mathbf{J}^c\) and virial part \(\mathbf{J}^v\) are:
\[\begin{split}\mathbf{J}^c &= \sum_i \epsilon_i \mathbf{v}_i \\ \mathbf{J}^v &= \sum_i \sum_j \mathbf{S}_{ij} \cdot \mathbf{v}_j\end{split}\]where \(\epsilon_i\) is the per-atom energy (p.e. + k.e.), \(\mathbf{v}_i\) is velocity, and \(\mathbf{S}_{ij}\) is the per-atom stress tensor.
- Parameters:
momenta (Tensor | None) – Particle momenta, shape (n_particles, n_dim)
masses (Tensor) – Particle masses, shape (n_particles,)
velocities (Tensor | None) – Particle velocities, shape (n_particles, n_dim)
energies (Tensor) – Per-atom energies (p.e. + k.e.), shape (n_particles,)
stresses (Tensor) –
Per-atom stress tensor components: - If is_centroid_stress=False: shape (n_particles, 6) for
\([\sigma_{xx}, \sigma_{yy}, \sigma_{zz}, \sigma_{xy}, \sigma_{xz}, \sigma_{yz}]\)
If is_centroid_stress=True: shape (n_particles, 9) for \([\mathbf{r}_{ix}f_{ix}, \mathbf{r}_{iy}f_{iy}, \mathbf{r}_{iz}f_{iz}, \mathbf{r}_{ix}f_{iy}, \mathbf{r}_{ix}f_{iz}, \mathbf{r}_{iy}f_{iz}, \mathbf{r}_{iy}f_{ix}, \mathbf{r}_{iz}f_{ix}, \mathbf{r}_{iz}f_{iy}]\)
batch (Tensor | None) – Optional tensor indicating system membership
is_centroid_stress (bool) – Whether stress uses centroid formulation
is_virial_only (bool) – If True, returns only virial part \(\mathbf{J}^v\)
- Returns:
Heat flux vector of shape (3,) or (n_systems, 3)
- Return type: