<HTML>
<CENTER><A HREF = "https://sparta.github.io">SPARTA WWW Site</A> - <A HREF = "Manual.html">SPARTA Documentation</A> - <A HREF = "Section_commands.html#comm">SPARTA Commands</A> 
</CENTER>






<HR>

<H3>compute thermal/grid command 
</H3>
<H3>compute thermal/grid/kk command 
</H3>
<P><B>Syntax:</B>
</P>
<PRE>compute ID thermal/grid group-ID mix-ID value1 value2 ... 
</PRE>
<UL><LI>ID is documented in <A HREF = "compute.html">compute</A> command 

<LI>thermal/grid = style name of this compute command 

<LI>group-ID = group ID for which grid cells to perform calculation on 

<LI>mix-ID = mixture ID to perform calculation on 

<LI>one or more values can be appended 

<LI>value = <I>temp</I> or <I>press</I> 

<PRE>  <I>temp</I> = temperature
  <I>press</I> = pressure 
</PRE>

</UL>
<P><B>Examples:</B>
</P>
<PRE>compute 1 thermal/grid all species temp
compute 1 thermal/grid subset air temp press 
</PRE>
<P>These commands will dump time averaged thermal temperatures for
each species and each grid cell to a dump file every 1000 steps:
</P>
<PRE>compute 1 thermal/grid species temp
fix 1 ave/grid 10 100 1000 c_1[*]
dump 1 grid all 1000 tmp.grid id f_1[*] 
</PRE>
<P><B>Description:</B>
</P>
<P>Define a computation that calculates one or more values for each grid
cell in a grid cell group, which are based on the thermal temperature
of the particles in each grid cell.  The values are tallied separately
for each group of species in the specified mixture, as described in
the Output section below.  See the mixture command for how a set of
species can be partitioned into groups.
</P>
<P>Only grid cells in the grid group specified by <I>group-ID</I> are included
in the calculation.  See the <A HREF = "group.html">group grid</A> command for info
on how grid cells can be assigned to grid groups.
</P>
<P>The values listed above rely on first computing a thermal temperature
which subtracts the center-of-mass (COM) velocity for all particles in
the group and grid cell from each particle to yield a thermal
velocity.  This thermal velocity is used to compute the temperature,
as described below.  This is in contrast to some of the values tallied
by the <A HREF = "compute_grid.html">compute grid temp</A> command which simply uses
the full velocity of each particle to compute a temperature.  For
non-streaming simulations, the two results should be similar, but for
streaming flows, they will be different.
</P>
<P>The results of this compute can be used by different commands in
different ways.  The values for a single timestep can be output by the
<A HREF = "dump.html">dump grid</A> command.
</P>
<P>The values over many sampling timesteps can be averaged by the <A HREF = "fix_ave_grid.html">fix
ave/grid</A> command.  It does its averaging as if the
particles in the cell at each sampling timestep were combined together
into one large set of particles to compute the formulas below.  
</P>
<P>Note that this is a different form of averaging than taking the values
produced by the formulas below for a single timestep, summing those
values over the sampling timesteps, and then dividing by the number of
sampling steps.
</P>
<P>Also note that the center-of-mass (COM) velocity that is subtracted
from each particle to yield a squared thermal velocity Csq for each
particle, as described below, is also computed over one large set of
particles (across all timesteps).  This is in contrast to using a COM
velocity computed only for particles in the current timestep, which is
what the <A HREF = "compute_sonine_grid.html">compute sonine/grid</A> command does.
</P>
<HR>

<P>Calculation of the thermal temperature is done by first calcuating the
center-of-mass (COM) velocity of particles for each group within a
grid cell.  This is done as follows:
</P>
<PRE>COMx = Sum_i (mass_i Vx_i) / Sum_i (mass_i)
COMy = Sum_i (mass_i Vy_i) / Sum_i (mass_i)
COMz = Sum_i (mass_i Vz_i) / Sum_i (mass_i)
Cx = Vx - COMx
Cy = Vy - COMy
Cz = Vz - COMz
Csq = Cx*Cx + Cy*Cy + Cz*Cz 
</PRE>
<P>The COM velocity is (COMx,COMy,COMz).  The thermal velocity of each
particle is (Cx,Cy,Cz), i.e. its velocity minus the COM velocity of
particles in its group and cell.  This allows computation of Csq for
each particle which is used to calculate the total kinetic energy due
to particles in the group as follows:
</P>
<PRE>thermal_KE = Sum_i (1/2 mass_i Csq_i) 
</PRE>
<P>The <I>temp</I> value computes the thermal temperature T, due to particles
in each group:
</P>
<PRE>T = thermal_KE / (3/2 N kB) 
</PRE>
<P>The <I>press</I> value uses the thermal_KE to compute a pressure P for the
grid cell due to particles in the group:
</P>
<PRE>P = 2/3 fnum/volume * thermal_KE 
</PRE>
<P>Note that if multiple groups are defined in the mixture, one group's
value is effectively a partial pressure due to particles in the group.
When accumulated over multiple sampling steps, this value is
normalized by the number of sampling steps.  Note that if particle
weighting is enabled via the <A HREF = "global.html">global weight</A> command, then
the volume used in the formula is divided by the weight assigned to
the grid cell.
</P>
<HR>

<P><B>Output info:</B>
</P>
<P>This compute calculates a per-grid array, with the number of columns
equal to the number of values times the number of groups.  The
ordering of columns is first by values, then by groups.  I.e. if the
<I>temp</I> and <I>press</I> values were specified as keywords, then the first
two columns would be <I>temp</I> and <I>press</I> for the first group, the 3rd
and 4th columns would be <I>temp</I> and <I>press</I> for the second group, etc.
</P>
<P>This compute performs calculations for all flavors of child grid cells
in the simulation, which includes unsplit, cut, split, and sub cells.
See <A HREF = "Section_howto.html#howto_8">Section 6.8</A> of the manual gives
details of how SPARTA defines child, unsplit, split, and sub cells.
Note that cells inside closed surfaces contain no particles.  These
could be unsplit or cut cells (if they have zero flow volume).  Both
of these kinds of cells will compute a zero result for all their
values.  Likewise, split cells store no particles and will produce a
zero result.  This is because their sub-cells actually contain the
particles that are geometrically inside the split cell.
</P>
<P>Grid cells not in the specified <I>group-ID</I> will output zeroes for all
their values.
</P>
<P>The array can be accessed by any command that uses per-grid values
from a compute as input.  See <A HREF = "Section_howto.html#howto_4">Section 6.4</A>
for an overview of SPARTA output options.
</P>
<P>The per-grid array values will be in the <A HREF = "units.html">units</A>
appropriate to the individual values as described above.  <I>Temp</I> is in
temperature units.  <I>Press</I> is in prsesure units.
</P>
<HR>

<P>Styles with a <I>kk</I> suffix are functionally the same as the
corresponding style without the suffix.  They have been optimized to
run faster, depending on your available hardware, as discussed in the
<A HREF = "Section_accelerate.html">Accelerating SPARTA</A> section of the manual.
The accelerated styles take the same arguments and should produce the
same results, except for different random number, round-off and
precision issues.
</P>
<P>These accelerated styles are part of the KOKKOS package. They are only
enabled if SPARTA was built with that package.  See the <A HREF = "Section_start.html#start_3">Making
SPARTA</A> section for more info.
</P>
<P>You can specify the accelerated styles explicitly in your input script
by including their suffix, or you can use the <A HREF = "Section_start.html#start_7">-suffix command-line
switch</A> when you invoke SPARTA, or you can
use the <A HREF = "suffix.html">suffix</A> command in your input script.
</P>
<P>See the <A HREF = "Section_accelerate.html">Accelerating SPARTA</A> section of the
manual for more instructions on how to use the accelerated styles
effectively.
</P>
<HR>

<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "compute_grid.txt">compute grid</A>, <A HREF = "fix_ave_grid.html">fix ave/grid</A>,
<A HREF = "dump.html">dump grid</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>
