<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 dt/grid command 
</H3>
<H3>compute dt/grid/kk command 
</H3>
<P><B>Syntax:</B>
</P>
<PRE>compute ID dt/grid group-ID tfraction cfraction lambda temperature usq vsq wsq 
</PRE>
<UL><LI>ID is documented in <A HREF = "compute.html">compute</A> command 

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

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

<LI>tfraction = fraction of grid cell transit time used to calculate timestep 

<LI>cfraction = fraction of grid cell mean collision time used to calculate timestep 

<LI>lambda = compute or fix column for mean free path, prefaced by "c_" or "f_" 

<LI>temperature = compute or fix column for temperature, prefaced by "c_" or "f_" 

<LI>usq = compute or fix column for x component of velocity squared, prefaced by "c_" or "f_" 

<LI>vsq = compute or fix column for y component of velocity squared, prefaced by "c_" or "f_" 

<LI>wsq = compute or fix column for z component of velocity squared, prefaced by "c_" or "f_" 


</UL>
<P><B>Examples:</B>
</P>
<PRE>compute 1 grid all mymixture nrho temp usq vsq wsq
fix 1 ave/grid all 10 50 500 c_1[*]
compute lambda lambda/grid f_1[1] f_1[2] Ar
compute tstep dt/grid all 0.25 0.1 c_lambda f_1[2] f_1[3] f_1[4] f_1[5] 
</PRE>
<P><B>Description:</B>
</P>
<P>Calculate a current timestep for each grid cell in a grid cell group,
based on the properties of particles currently in the cell and the
grid cell size.  The per-grid cell timesteps can be output in a
per-grid dump file for post analyses.  Or they can be used as input to
the <A HREF = "fit_dt_reset.html">fix dt/reset</A> command to adjust the global
timestep for a variable timestep simulation.  See this
<A HREF = "Section_howto.html#howto_17">section</A> of the manual for more
information on variable timestep simulations.
</P>
<P>Only grid cells in the grid group specified by <I>group-ID</I> are included
in the calculations.  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 <I>tfraction</I> and <I>cfraction</I> arguments are both values from 0.0 to
1.0 which are applied to the transit term and collision term in the
example formula for a candidate cell timestep below.
</P>
<CENTER><IMG SRC = "Eqs/cell_timestep.jpg">
</CENTER>
<P>In practice, multiple transit-based timestep candidates are
constructed based on the cell dimensions in each coordinate direction
and the associated average particle velocity components in addition to
the maximum most probable speed.  The selected cell timestep is the
minumum of all candidate timesteps. The collision and transit
fractions simply provide a user-defined safety margin for the
collision time and transit time estimates. In <A HREF = "#Bird2013">(Bird2013)</A>,
Bird recomnmends setting the collision fraction to 0.2, which is
likely a good starting point for the selection of both of these
fractions.
</P>
<P>The remaining 5 arguments specify either computes which calculate various per
grid cell quantities or fixes which time average those
per grid cell quantities.  The 5 quantities are per grid cell mean
free path (lambda), temperature, and the xyz components of the
velocity squared for particles in the grid cell.  The <A HREF = "compute_lambda.html">compute
lambda</A> calculates a mean free path.  The <A HREF = "compute_grid.html">compute
grid</A> command can calculate the other 4 quantities.
The <A HREF = "compute_thermal_grid.html">compute thermal/grid</A> command can also
compute a per grid cell temperature.
</P>
<P>This is done by specifying the lambda, temperature, usq, vsq, wsq
arguments like this:
</P>
<UL><LI>c_ID = compute with ID that calculates a per grid cell quantity as a vector output
<LI>c_ID[m] = compute with ID that calculates a quantity as its Mth column of array output
<LI>f_ID[m] = fix with ID that calculates a time-averaged quantity as a vector output
<LI>f_ID[m] = fix with ID that calculates a time-averaged quantity as its Mth column of array output 
</UL>
<P>See the Example section above for an example of how these arguments
can be specified.
</P>
<P>IMPORTANT NOTE: If the IDs of one or more <A HREF = "fix_ave_grid.html">fix
ave/grid</A> commands is used for these 5 arguments,
they only produce output on timesteps that are multiples of their
<I>Nfreq</I> argument.  Thus this compute can only be invoked on those
timesteps.
</P>
<HR>

<P><B>Output info:</B>
</P>
<P>This compute calculates a per-grid vector.
</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 for
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 the cell timestep.
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.  Additionally, any cell that is able
to store particles but does not have any particles when this compute is
invoked produces a zero result.  Finally, a zero result is produced if any
cell data to be used in the timestep calculation is sufficiently close to
zero (including the maximum most probable speed, the velocity magnitude, and
the mean free path).
</P>
<P>The vector 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 4.4</A>
for an overview of SPARTA output options.
</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>
</P>
<P>As explained above, to use this compute with <I>nrho</I> or <I>temp</I> defined
as input from a <A HREF = "fix_ave_grid.html">fix ave/grid</A> command, this compute
must only be invoked on timesteps that are multiples of the <I>Nfreq</I>
argument used by the fix, since those are the steps when it produces
output.
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "fix_dt_reset.html">fix dt/reset</A>, <A HREF = "compute_grid.html">compute grid</A>,
<A HREF = "compute_thermal/grid.html">compute thermal/grid</A>, <A HREF = "fix_ave_grid.html">fix
ave/grid</A>
</P>
<P><B>Default:</B> none
</P>
<HR>

<A NAME = "Bird2013"></A>

<P><B>(Bird2013)</B> G. A. Bird, The DSMC method, CreateSpace Independent Publishing Platform, 2013.
</P>
</HTML>
