# compute heat/flux command

## Syntax

```
compute ID group-ID heat/flux ke-ID pe-ID stress-ID
```

- ID, group-ID are documented in compute command
- heat/flux = style name of this compute command
- ke-ID = ID of a compute that calculates per-atom kinetic energy
- pe-ID = ID of a compute that calculates per-atom potential energy
- stress-ID = ID of a compute that calculates per-atom stress

## Examples

```
compute myFlux all heat/flux myKE myPE myStress
```

## Description

Define a computation that calculates the heat flux vector based on contributions from atoms in the specified group. This can be used by itself to measure the heat flux through a set of atoms (e.g. a region between two thermostatted reservoirs held at different temperatures), or to calculate a thermal conductivity using the equilibrium Green-Kubo formalism.

For other non-equilibrium ways to compute a thermal conductivity, see the Howto kappa doc page.. These include use of the fix thermal/conductivity command for the Muller-Plathe method. Or the fix heat command which can add or subtract heat from groups of atoms.

The compute takes three arguments which are IDs of other
computes. One calculates per-atom kinetic energy
(*ke-ID*), one calculates per-atom potential energy (*pe-ID)*, and the
third calculates per-atom stress (*stress-ID*).

Note

These other computes should provide values for all the atoms in the group this compute specifies. That means the other computes could use the same group as this compute, or they can just use group “all” (or any group whose atoms are superset of the atoms in this compute’s group). LAMMPS does not check for this.

The Green-Kubo formulas relate the ensemble average of the auto-correlation of the heat flux J to the thermal conductivity kappa:

Ei in the first term of the equation for J is the per-atom energy
(potential and kinetic). This is calculated by the computes *ke-ID*
and *pe-ID*. Si in the second term of the equation for J is the
per-atom stress tensor calculated by the compute *stress-ID*. The
tensor multiplies Vi as a 3x3 matrix-vector multiply to yield a
vector. Note that as discussed below, the 1/V scaling factor in the
equation for J is NOT included in the calculation performed by this
compute; you need to add it for a volume appropriate to the atoms
included in the calculation.

Note

The compute pe/atom and compute stress/atom commands have options for which terms to include in their calculation (pair, bond, etc). The heat flux calculation will thus include exactly the same terms. Normally you should use compute stress/atom virial so as not to include a kinetic energy term in the heat flux.

This compute calculates 6 quantities and stores them in a 6-component vector. The first 3 components are the x, y, z components of the full heat flux vector, i.e. (Jx, Jy, Jz). The next 3 components are the x, y, z components of just the convective portion of the flux, i.e. the first term in the equation for J above.

The heat flux can be output every so many timesteps (e.g. via the thermo_style custom command). Then as a post-processing operation, an auto-correlation can be performed, its integral estimated, and the Green-Kubo formula above evaluated.

The fix ave/correlate command can calculate the auto-correlation. The trap() function in the variable command can calculate the integral.

An example LAMMPS input script for solid Ar is appended below. The result should be: average conductivity ~0.29 in W/mK.

**Output info:**

This compute calculates a global vector of length 6 (total heat flux vector, followed by convective heat flux vector), which can be accessed by indices 1-6. These values can be used by any command that uses global vector values from a compute as input. See the Howto output doc page for an overview of LAMMPS output options.

The vector values calculated by this compute are “extensive”, meaning they scale with the number of atoms in the simulation. They can be divided by the appropriate volume to get a flux, which would then be an “intensive” value, meaning independent of the number of atoms in the simulation. Note that if the compute is “all”, then the appropriate volume to divide by is the simulation box volume. However, if a sub-group is used, it should be the volume containing those atoms.

The vector values will be in energy*velocity units. Once divided by a volume the units will be that of flux, namely energy/area/time units

## Restrictions

none