<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 command 
</H3>
<P><B>Syntax:</B>
</P>
<PRE>compute ID style args 
</PRE>
<UL><LI>ID = user-assigned name for the computation
<LI>style = one of a list of possible style names (see below)
<LI>args = arguments used by a particular style 
</UL>
<P><B>Examples:</B>
</P>
<PRE>compute 1 ke/particle 
compute myGrid all n mass u usq temp 
</PRE>
<P><B>Description:</B>
</P>
<P>Define a computation that will be performed on a collection of
particles or grid cells or surface elements.  Quantities calculated by
a compute are instantaneous values, meaning they are calculated from
information about the current timestep.  Examples include calculation
of the system temperature or counting collisions of particles with
surface elements.  Code for new computes can be added to SPARTA; see
<A HREF = "Section_modify.html">Section 10</A> of the manual for details.
</P>
<P>Note that defining a compute does not perform a computation.  Instead
computes are invoked by other SPARTA commands as needed, e.g. to
generate statistics or dump file output.  See <A HREF = "Section_howto.html#howto_4">Section
4.4</A> for a summary of various SPARTA output
options, many of which involve computes.
</P>
<P>The ID for a compute is used to identify the compute in other
commands.  Each compute ID must be unique.  The ID can only contain
alphanumeric characters and underscores.  You can specify multiple
computees of the same style so long as they have different IDs.  A
compute can be deleted with the <A HREF = "uncompute.html">uncompute</A> command,
after which its ID can be re-used.
</P>
<HR>

<P>Each compute style has its own doc page which describes its arguments
and what it does.  Here is an alphabetic list of compute styles
available in SPARTA:
</P>
<UL><LI><A HREF = "compute_boundary.html">boundary</A> - various quantities on each global boundary 
<LI><A HREF = "compute_count.html">count</A> - particle counts for species and mixtures and mixture groups
<LI><A HREF = "compute_distsurf_grid.html">distsurf/grid</A> - distance from grid cells to surface
<LI><A HREF = "compute_dt_grid.html">dt/grid</A> - optimal timestep per grid cell
<LI><A HREF = "compute_eflux_grid.html">eflux/grid</A> - energy flux density per grid cell
<LI><A HREF = "compute_fft_grid.html">fft/grid</A> - FFTs across grid cells
<LI><A HREF = "compute_grid.html">grid</A> - various per grid cell quantities
<LI><A HREF = "compute_isurf_grid.html">isurf/grid</A> - various implicit surface element quantities
<LI><A HREF = "compute_ke_particle.html">ke/particle</A> - temperature per particle
<LI><A HREF = "compute_lambda_grid.html">lambda/grid</A> - mean-free path per grid cell
<LI><A HREF = "compute_pflux_grid.html">pflux/grid</A> - momentum flux density per grid cell
<LI><A HREF = "compute_property_grid.html">property/grid</A> - per grid cell properties
<LI><A HREF = "compute_property_surf.html">property/surf</A> - per surface element properties
<LI><A HREF = "compute_react_boundary.html">react/boundary</A> - reaction stats on global boundary
<LI><A HREF = "compute_react_surf.html">react/surf</A> = reaction stats for explicit surfs
<LI><A HREF = "compute_react_isurf_grid.html">react/isurf/grid</A> - reactions stats for implicit surfs
<LI><A HREF = "compute_reduce.html">reduce</A> - reduce vectors to scalars
<LI><A HREF = "compute_sonine_grid.html">sonine/grid</A> - Sonine moments per grid cell
<LI><A HREF = "compute_surf.html">surf</A> - various explicit surface element quantities
<LI><A HREF = "compute_thermal_grid.html">thermal/grid</A> - thermal temperature per grid cell
<LI><A HREF = "compute_temp.html">temp</A> - temperature of particles
<LI><A HREF = "compute_tvib_grid.html">tvib/grid</A> - vibrational temperature per grid cell 
</UL>
<P>There are also additional accelerated compute styles included in the
SPARTA distribution for faster performance on specific hardware.  The
list of these with links to the individual styles are given in the
pair section of <A HREF = "Section_commands.html#cmd_5">this page</A>.
</P>
<HR>

<P>Computes calculate one of four styles of quantities: global,
per-particle, per-grid, or per-surf.  A global quantity is one or more
system-wide values, e.g. the temperature of the system.  A
per-particle quantity is one or more values per particle, e.g. the
kinetic energy of each particle.  A per-grid quantity is one or more
values per grid cell.  A per-surf quantity is one or more values per
surface element.
</P>
<P>Global, per-particle, per-grid, and per-surf quantities each come in
two forms: a single scalar value or a vector of values.  Additionaly,
global quantities can also be a 2d array of values.  The doc page for
each compute describes the style and kind of values it produces,
e.g. a per-particle vector.  Some computes can produce more than one
form of a single style, e.g. a global scalar and a global vector.
</P>
<P>When a compute quantity is accessed, as in many of the output commands
discussed below, it can be referenced via the following bracket
notation, where ID is the ID of the compute:
</P>
<DIV ALIGN=center><TABLE  BORDER=1 >
<TR><TD >c_ID </TD><TD > entire scalar, vector, or array</TD></TR>
<TR><TD >c_ID[I] </TD><TD > one element of vector, one column of array</TD></TR>
<TR><TD >c_ID[I][J] </TD><TD > one element of array 
</TD></TR></TABLE></DIV>

<P>In other words, using one bracket reduces the dimension of the
quantity once (vector -> scalar, array -> vector).  Using two brackets
reduces the dimension twice (array -> scalar).  Thus a command that
uses scalar compute values as input can also process elements of a
vector or array.
</P>
<P>Note that commands and <A HREF = "variable.html">variables</A> which use compute
quantities typically do not allow for all kinds, e.g. a command may
require a vector of values, not a scalar.  This means there is no
ambiguity about referring to a compute quantity as f_ID even if it
produces, for example, both a scalar and vector.  The doc pages for
various commands explain the details.
</P>
<HR>

<P>The values generated by a compute can be used in several ways:
</P>
<UL><LI>Global values can be output via the <A HREF = "stats_style.html">stats_style</A>
command.  Or the values can be referenced in a <A HREF = "variable.html">variable
equal</A> or <A HREF = "variable.html">variable atom</A> command. 

<LI>Per-particle values can be output via the <A HREF = "dump.html">dump particle</A>
command.  Or the values can be referenced in a <A HREF = "variable.html">particle-style
variable</A>. 

<LI>Per-grid values can be output via the <A HREF = "dump.html">dump grid</A> command.
They can be time-averaged via the <A HREF = "fix_ave_grid.html">fix ave/grid</A>
command.  

<LI>Per-surf values can be output via the <A HREF = "dump.html">dump surf</A> command.
They can be time-averaged via the <A HREF = "fix_ave_surf.html">fix ave/surf</A>
command.  
</UL>
<HR>

<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "uncompute.html">uncompute</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>
