# compute heat/flux command ## Syntax ``` LAMMPS compute ID group-ID heat/flux ke-ID pe-ID stress-ID ``` - ID, group-ID are documented in [compute](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 ``` LAMMPS 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](Howto_kappa) doc page. These include use of the [fix thermal/conductivity](fix_thermal_conductivity) command for the Muller-Plathe method. Or the [fix heat](fix_heat) command which can add or subtract heat from groups of atoms. The compute takes three arguments which are IDs of other [computes](compute). 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 ::: title 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. :::: In case of two-body interactions, the heat flux $\mathbf{J}$ is defined as $$\begin{aligned} \mathbf{J} &= \frac{1}{V} \left[ \sum_i e_i \mathbf{v}_i - \sum_{i} \mathbf{S}_{i} \mathbf{v}_i \right] \\ &= \frac{1}{V} \left[ \sum_i e_i \mathbf{v}_i + \sum_{i none ## Related commands [fix thermal/conductivity](fix_thermal_conductivity), [fix ave/correlate](fix_ave_correlate), [variable](variable) ## Default none ------------------------------------------------------------------------ ### Example Input File ``` LAMMPS # Sample LAMMPS input script for thermal conductivity of solid Ar units real variable T equal 70 variable V equal vol variable dt equal 4.0 variable p equal 200 # correlation length variable s equal 10 # sample interval variable d equal $p*$s # dump interval # convert from LAMMPS real units to SI variable kB equal 1.3806504e-23 # [J/K] Boltzmann variable kCal2J equal 4186.0/6.02214e23 variable A2m equal 1.0e-10 variable fs2s equal 1.0e-15 variable convert equal ${kCal2J}*${kCal2J}/${fs2s}/${A2m} # setup problem dimension 3 boundary p p p lattice fcc 5.376 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1 region box block 0 4 0 4 0 4 create_box 1 box create_atoms 1 box mass 1 39.948 pair_style lj/cut 13.0 pair_coeff * * 0.2381 3.405 timestep ${dt} thermo $d # equilibration and thermalization velocity all create $T 102486 mom yes rot yes dist gaussian fix NVT all nvt temp $T $T 10 drag 0.2 run 8000 # thermal conductivity calculation, switch to NVE if desired #unfix NVT #fix NVE all nve reset_timestep 0 compute myKE all ke/atom compute myPE all pe/atom compute myStress all stress/atom NULL virial compute flux all heat/flux myKE myPE myStress variable Jx equal c_flux[1]/vol variable Jy equal c_flux[2]/vol variable Jz equal c_flux[3]/vol fix JJ all ave/correlate $s $p $d & c_flux[1] c_flux[2] c_flux[3] type auto file J0Jt.dat ave running variable scale equal ${convert}/${kB}/$T/$T/$V*$s*${dt} variable k11 equal trap(f_JJ[3])*${scale} variable k22 equal trap(f_JJ[4])*${scale} variable k33 equal trap(f_JJ[5])*${scale} thermo_style custom step temp v_Jx v_Jy v_Jz v_k11 v_k22 v_k33 run 100000 variable k equal (v_k11+v_k22+v_k33)/3.0 variable ndens equal count(all)/vol print "average conductivity: $k[W/mK] @ $T K, ${ndens} /A\^3" ``` ------------------------------------------------------------------------ ::: {#Surblys3} **(Surblys2019)** Surblys, Matsubara, Kikugawa, Ohara, Phys Rev E, 99, 051301(R) (2019). ::: ::: {#Boone} **(Boone)** Boone, Babaei, Wilmer, J Chem Theory Comput, 15, 5579\--5587 (2019). ::: ::: {#Surblys4} **(Surblys2021)** Surblys, Matsubara, Kikugawa, Ohara, J Appl Phys 130, 215104 (2021). :::