SPARTA WWW Site - SPARTA Documentation - SPARTA Commands

compute lambda/grid command

compute lambda/grid/kk command

Syntax:

compute ID lambda/grid nrho temp value1 value2 ... 

Examples:

compute 1 lambda/grid c_GR[*] NULL lambda tau
compute 1 lambda/grid f_ave[*] f_ave[3] lambda knall 

These commands will dump time averages for the mean free path and mean collision time for each grid cell to a dump file every 1000 steps:

compute 1 grid all species nrho temp
fix 1 ave/grid all 10 100 1000 c_1[*]
compute 2 lambda/grid f_1[*] f_1[2] lambda tau
dump 1 grid all 1000 tmp.grid id c_2[*] 

Description:

This command calculates properties related to the gas collision mean free path for each grid cell based on the number density nrho and thermal tempearture temp of particles in the cell.

If the lambda value is specified, the mean free path (MFP) of particles between collisions will be computed. If the tau value is specified, the mean collision time (MCT) between molecular collisions will be computed.

If one or more of the knall or knx or kny or knz values are specified, the dimensionless Knudsen number will be calculated, which is the ratio of the MFP to the cell size. For knall, the cell size is the average of the three grid cell side lengths (or two cell lengths for a 2d simulation). For knx, kny, or knz, the cell size is the single cell side length in the corresponding x,y,z dimension.

The Knudsen number can be useful for estimating the optimal grid cell size when adapting the grid, e.g. via the adapt_grid or fix adapt/grid commands, as well as for estimating the optimal timestep size.

Note that unlike other computes which calculate per-grid values, this compute does not take a "group-ID" for a grid cell group or a particle mixture ID as an argument. This is because it uses the number density and thermal temperature calculated by other computes or fixes as input, and those computes or fixes use grid group IDs or mixture IDs as part of their computations.

The results of this compute can be used by different commands in different ways. For example, the values can be output by the dump grid command. Or as indicated above the compute can be used as an argument for the adapt_grid or fix adapt commands, e.g. to trigger grid cell refinement or coarsening based on a mean free path metric.


The formula used to calculate the mean free path (lambda) is given in (Bird94) as equation 4.77:

IMPORTANT NOTE: Prior to October 2024, a simpler formula was used for the mean free path, also from (Bird94), equation 4.65:

The new formula is more accurate as it uses the number densities and VSS parameters of all gas species (sum over s) in the system, as opposed to using the total number density and the VSS parameters of only one species. This can make a significant difference for gas mixtures, in particular for reacting flow problems where the composition of the mixture changes significantly over time.

The formula used to calculate the mean collision time (tau) is given in (Bird94) as equation 1.38 combined with 4.75:

These two formulas are the exact mean free path (MFP) and mean collision time (MCT) for a multi-species mixture, suitable for estimating optimal grid cell sizes and timestep as explained above.

The dref and Tref and omega values in the two formulas are collision properties for a pair of species in the flow, subscripted as *pq*. Specifically, dref is the diameter of molecules of the species pair, Tref is the reference temperature, and omega is the viscosity temperature-dependence for the species pair.

In the two formulas, n_q is the number density of species q within a grid cell. T is the thermal temperature of all particles (all species) in a grid cell. These per-grid values are specified for use by this command as the nrho and temp arguments in one of these forms:

c_ID[*] = compute with ID that calculates nrho for each species as an array output
f_ID[*] = fix with ID that calculates a time-averaged nrho for each species as an array output 
c_ID = compute with ID that calculates temp for all particles a vector output
c_ID[m] = compute with ID that calculates temp for all particles as its Mth column of array output
f_ID = fix with ID that calculates a time-averaged temp for all particles as a vector output
f_ID[m] = fix with ID that calculates a time-averaged temp for all particles as its Mth column of array output 

The temp argument can also be specified as NULL, which drops the (Tref/T) and (T/Tref) ratios from the two formulas above.

NOTE for next paragraph: Is it correct that currently, this command requires that you use a compute grid nrho command which calculates nrho for every species in the system, not simply every species in a mixture that the user defines (used as an arg with the compute grid command) ? And this is intentional (for accuracy), not a limitation of the current implementation?

Note that because the MFP and MFT formulas require a number density nrho for all species in the system, you should use a compute grid command in this form:

compute 1 grid all species nrho 

to reference by this command as c_ID[*]. Or similarly for a fix ave/grid command that takes c_ID[*] as an argument, which is then referenced by this command as f_ID[*].

NOTE: check that this next paragraph is correct about the meaning of T in the 2 formulas.

For the compute or fix referenced by the temp argument, this is meant in the two formulas to be the aggregate thermal temperature of all the particles in a grid cell.

For systems with a zero of small streaming velocity, this can be calculated using this command:

compute 2 grid all all temp 

which uses the velocity of each particle to calculate a temperature.

For systems with a streaming flow, an appropriate therml temperature can be calculated by the compute thermal/grid thermal/grid command. Its doc page explain that the the center-of-mass velocity for the particles in each grid cell is subtracted from each particle's individual velocity to yield its thermal velocity, from which a thermal temperature is calculated. The corresponding command to use with this compute would be:

compute 2 thermal/grid all all temp 

Note that using fixes, rather than computes, for the nrho and temp arguments will typically result in less noisy MFP and MCT values, due to the time averaging which the fix ave/grid command can perform.

IMPORTANT NOTE: If the IDs of one or more fix ave/grid commands is used for the nrho or temp arguments, they only produce output on timesteps that are multiples of their Nfreq argument. Thus this compute can only be invoked on those timesteps.


Output info:

If only one output value is specified, this compute outputs a per-grid vector. Otherwise it outputs a per-grid array with two or more columns, in the order the output values were specified.

This compute performs calculations for all flavors of child grid cells in the simulation, which includes unsplit, cut, split, and sub cells. See Section 6.8 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 the individual 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.

The vector or array can be accessed by any command that uses per-grid values from a compute as input. See Section 4.4 for an overview of SPARTA output options.

The per-grid values for a column of output for lambda will be in distance units. A column of output for tau will be time units. Columns of output for knall or knx or kny or knz will be dimensionless.

If the value of nrho for a grid cell is 0.0 (no particles), its MFP and MCT will be set to 1.0e20 (infinite length and time). This "infinite" MFP value will also be used for the calculation of Knudsen numbers.


Styles with a kk 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 Accelerating SPARTA 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.

These accelerated styles are part of the KOKKOS package. They are only enabled if SPARTA was built with that package. See the Making SPARTA section for more info.

You can specify the accelerated styles explicitly in your input script by including their suffix, or you can use the -suffix command-line switch when you invoke SPARTA, or you can use the suffix command in your input script.

See the Accelerating SPARTA section of the manual for more instructions on how to use the accelerated styles effectively.


Restrictions:

To use this compute, a collision style must be defined via the collide.html command, which defines properties for the mixture species.

As explained above, to use this compute with nrho or temp defined as input from a fix_ave_grid.html ave/grid command, this compute must only be invoked on timesteps that are multiples of the Nfreq argument used by the fix, since those are the steps when it produces output.

One or more output values must be specified. The same output value cannot be repeated more than once. The knz value cannot but used in a two-dimensional simulation.

Related commands:

compute grid, compute thermal/grid, fix ave/grid, dump grid

Default: none


(Bird94) G. A. Bird, Molecular Gas Dynamics and the Direct Simulation of Gas Flows, Clarendon Press, Oxford (1994).