<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 boundary command 
</H3>
<P><B>Syntax:</B>
</P>
<PRE>compute ID boundary mix-ID value1 value2 ... 
</PRE>
<PRE>compute ID boundary/kk mix-ID value1 value2 ... 
</PRE>
<UL><LI>ID is documented in <A HREF = "compute.html">compute</A> command 

<LI>boundary = style name of this compute command 

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

<LI>one or more values can be appended 

<LI>value = <I>n</I> or <I>nwt</I> or <I>nflux</I> or <I>mflux</I> or <I>press</I> or <I>shx</I> or <I>shy</I> or <I>shz</I> or <I>ke</I> or <I>erot</I> or <I>evib</I> or <I>etot</I> 

<PRE>  n = count of particles hitting boundary
  nwt = weighted count of particles hitting boundary
  nflux = flux of particles on boundary
  mflux = flux of mass on boundary
  press = magnitude of normal pressure on boundary
  shx,shy,shz = components of shear stress on boundary
  ke = flux of particle kinetic energy on boundary 
  erot = flux of particle rotational energy on boundary 
  evib = flux of particle vibrational energy on boundary 
  etot = flux of particle total energy on boundary 
</PRE>

</UL>
<P><B>Examples:</B>
</P>
<PRE>compute 1 boundary all n press eng
compute mine boundary species press shx shy shz 
</PRE>
<P>These commands will print values for the current timestep for 
the xlo and xhi boundaryies, as part of statistical output:
</P>
<PRE>compute 1 boundary all n press
stats_style step np c_1[1][1] c_1[1][2] c_1[2][1] c_1[2][2] 
</PRE>
<P>These commands will dump time averages for each species and each
boundary to a file every 1000 steps:
</P>
<PRE>compute 1 boundary species n press shx shy shz
fix 1 ave/time 10 100 1000 c_1[*] mode vector file tmp.boundary 
</PRE>
<P><B>Description:</B>
</P>
<P>Define a computation that calculates one or more values for each
boundary (i.e. face) of the simulation box, based on the particles
that cross or collide with the boundary.  The values are summed for
each group of species in the specified mixture.  See the
<A HREF = "mixture.html">mixture</A> command for how a set of species can be
partitioned into groups.
</P>
<P>Note that depending on the settings for the <A HREF = "boundary.html">boundary</A>
command, when a particle collides with a boundary, it can exit the
simulation box (outflow), re-enter from the other side (periodic),
reflect specularly from the boundary, or interact with it as if it
were a surface.  In the surface case, the incident particle may bounce
off (possibly as a different species), be captured by the boundary
(vanish), or a 2nd particle can also be emitted.  The formulas below
account for all these possible scenarios.  As an example, the pressure
exerted on an outflow boundary versus a specularly reflecting boundary
is different, since in the former case there is no net momentum flux
back into the simulation box by reflected particles.
</P>
<P>Also note that all values for a boundary collision are tallied based
on the species group of the incident particle.  Quantities associated
with outgoing particles are part of the same tally, even if they are
in different species groups.
</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 = "stats_style.html">stats_style</A> command.
</P>
<P>The values over many sampling timesteps can be averaged by the <A HREF = "fix_ave_time.html">fix
ave/time</A> command.  It does its averaging as if the
particles striking the boundary at each sampling timestep were
combined together into one large set to compute the formulas below.
The answer is then divided by the number of sampling timesteps if it
is not otherwise normalized by the number of particles.  Note that in
general this is a different normalization than taking the values
produced by the formulas below for a single timestep, summing them
over the sampling timesteps, and then dividing by the number of
sampling steps.  However for the current values listed below, the two
normalization methods are the same.
</P>
<P>NOTE: If particle weighting is enabled via the <A HREF = "global.html">global
weight</A> command, then all of the values below are scaled
by the weight assigned to the grid cell in which the particle
collision with the boundary occurs.  The only exception is the the <I>n</I>
value, which is NOT scaled by the weight; it is a simple count of
particle crossings or collisions with the boundary.
</P>
<HR>

<P>The <I>n</I> value counts the number of particles in the group crossing or
colliding with the boundary.
</P>
<P>The <I>nwt</I> value counts the number of particles in the group crossing
or colliding with the boundary and weights the count by the weight
assigned to the grid cell in which the particle collision with the
boundary occurs.  The <I>nwt</I> quantity will only be different than <I>n</I>
if particle weighting is enabled via the <A HREF = "global.html">global weight</A>
command.
</P>
<P>The <I>nflux</I> value calculates the number flux imparted to the boundary by
particles in the group.  This is computed as
</P>
<PRE>Nflux = N / (A * dt / fnum) 
</PRE>
<P>where N is the number of all contributing particles, normalized by
A = the area of the surface element, dt = the timestep, and fnum = the
real/simulated particle ratio set by the <A HREF = "global.html">global fnum</A>
command.
</P>
<P>The <I>mflux</I> value calculates the mass flux imparted to the boundary by
particles in the group.  This is computed as
</P>
<PRE>Mflux = Sum_i (mass_i) / (A * dt / fnum) 
</PRE>
<P>where the sum is over all contributing particle masses, normalized by
the area of the surface element, dt and fnum as defined before.
</P>
<P>The <I>press</I> value calculates the pressure <I>P</I> exerted on the boundary
in the normal direction by particles in the group, such that outward
pressure is positive.  This is computed as
</P>
<PRE>p_delta = mass * (V_post - V_pre)
P = Sum_i (p_delta_i dot N) / (A * dt / fnum) 
</PRE>
<P>where A, dt, fnum are defined as before.  P_delta is the change in
momentum of a particle, whose velocity changes from V_pre to V_post
when colliding with the boundary.  The pressure exerted on the
boundary is the sum over all contributing p_delta dotted into the
normal N of the boundary which is directed into the box, normalized by
A = the area of the boundary face and dt = the timestep and fnum = the
real/simulated particle ratio set by the <A HREF = "global.html">global fnum</A>
command.
</P>
<P>The <I>shx</I>, <I>shy</I>, <I>shz</I> values calculate the shear pressure components
Sx, Sy, Sz extered on the boundary in the tangential direction to its
normal by particles in the group, with respect to the x, y, z
coordinate axes.  These are computed as
</P>
<PRE>p_delta = mass * (V_post - V_pre)
p_delta_t = p_delta - (p_delta dot N) N
Sx = - Sum_i (p_delta_t_x) / (A * dt / fnum)
Sy = - Sum_i (p_delta_t_y) / (A * dt / fnum)
Sz = - Sum_i (p_delta_t_z) / (A * dt / fnum) 
</PRE>
<P>where p_delta, V_pre, V_post, N, A, dt, and fnum are defined as
before.  P_delta_t is the tangential component of the change in
momentum vector p_delta of a particle.  P_delta_t_x (and y,z) are its
x, y, z components.
</P>
<P>The <I>ke</I> value calculates the kinetic energy flux <I>Eflux</I> imparted to
the boundary by particles in the group, such that energy lost by a
particle is a positive flux.  This is computed as
</P>
<PRE>e_delta = 1/2 mass (V_post^2 - V_pre^2)
Eflux = - Sum_i (e_delta) / (A * dt / fnum) 
</PRE>
<P>where e_delta is the kinetic energy change in a particle, whose
velocity changes from V_pre to V_post when colliding with the
boundary.  The energy flux imparted to the boundary is the sum over
all contributing e_delta, normalized by A = the area of the boundary
face and dt = the timestep and fnum = the real/simulated particle
ratio set by the <A HREF = "global.html">global fnum</A> command.
</P>
<P>The <I>erot</I> value calculates the rotational energy flux <I>Eflux</I>
imparted to the boundary by particles in the group, such that energy
lost by a particle is a positive flux.  This is computed as
</P>
<PRE>e_delta = Erot_post - Erot_pre
Eflux = - Sum_i (e_delta) / (A * dt / fnum) 
</PRE>
<P>where e_delta is the rotational energy change in a particle, whose
internal rotational energy changes from Erot_pre to Erot_post when
colliding with the boundary.  The flux equation is the same as for the
<I>ke</I> value.
</P>
<P>The <I>evib</I> value calculates the vibrational energy flux <I>Eflux</I>
imparted to the boundary by particles in the group, such that energy
lost by a particle is a positive flux.  This is computed as
</P>
<PRE>e_delta = Evib_post - Evib_pre
Eflux = - Sum_i (e_delta) / (A * dt / fnum) 
</PRE>
<P>where e_delta is the vibrational energy change in a particle, whose
internal vibrational energy changes from Evib_pre to Evib_post when
colliding with the boundary.  The flux equation is the same as for the
<I>ke</I> value.
</P>
<P>The <I>etot</I> value calculates the total energy flux imparted to the
boundary by particles in the group, such that energy lost by a
particle is a positive flux.  This is simply the sum of kinetic,
rotational, and vibrational energies.  Thus the total energy flux is
the sum of what is computed by the <I>ke</I>, <I>erot</I>, and <I>evib</I> values.
</P>
<HR>

<P><B>Output info:</B>
</P>
<P>This compute calculates a global 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>n</I> and <I>u</I> values were specified as keywords, then the first two
columns would be <I>n</I> and <I>u</I> for the first group, the 3rd and 4th
columns would be <I>n</I> and <I>u</I> for the second group, etc.  The number of
rows is 4 for a 2d simulation for the 4 faces (xlo, xhi, ylo, yhi),
and it is 6 for a 3d simulation (xlo, xhi, ylo, yhi, zlo, zhi).
</P>
<P>The array can be accessed by any command that uses global array 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 array values will be in the <A HREF = "units.html">units</A> appropriate to the
individual values as described above.  <I>N</I> is unitless. <I>Press</I>,
<I>shx</I>, <I>shy</I>, <I>shz</I> are in pressure units.  <I>Ke</I>, <I>erot</I>, <I>evib</I>, and
<I>etot</I> are in energy/area-time units for 3d simulations and
energy/length-time units for 2d simulations.
</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>If specified with a <I>kk</I> suffix, this compute can be used no more than
twice in the same input script (active at the same time).
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "fix_ave_time.html">fix ave/time</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>
