Globals
Global variables can be declared outside of any particular block, and
they control various general aspects of the simulation. For example,
the global variable dimension
defines the number of dimensions for
your simulation. When running your simulation from the command line,
you can override values set in your .pre file for required global
variables by using the variable’s command line parameter to define a new
value. Not all global variables have command line parameters, in which
case they must be defined in your .pre file.
Required global variables are as follows:
- floattype (string, required)
Variable that defines the precision of real numbers in the simulation. For greater precision, use the value
double
, otherwise use the optionfloat
. You must definefloattype
in your input file.Example use of
floattype
:
floattype = double
- dimension (integer, required)
Variable that defines the dimensionality (1D, 2D, or 3D) of the simulation. Its command line parameter is
-dim
.Example use of
dimension
:
dimension = 2
- dt (real, required)
Time step size for your simulation. When choosing the step size, you also must consider stability requirements. For example, you must satisfy the Courant condition when selecting a step size in electromagnetic simulations. Its command line parameter is
-dt
.Example use of
dt
:
dt = 1.49731212265e-16
- nsteps (integer, required)
Number of steps to take. (In the case of a restart,
nsteps
is the number of additional steps.) Its command line parameter is-n
.Example use of
nsteps
:
nsteps = 22277
Optional global variables include the following, and are discussed in the “Global Variables” section in the Reference Manual.
dumpPeriodicity
dumpSteps
maxcellxing
sortPtcls
dnSortMin
dnSortMax
useGridBndryRestore
stepPrintPeriodicity
timingAnalysisPeriodicity
Global Variables Specific to Moving Windows
The moving window feature allows the simulation window to move at the speed of light in the chosen direction. This feature is used to reduce the size of the simulation box while following the physics phenomenon of interest, such as a laser pulse or a particle beam that is propagating at a velocity close to the speed of light.
This feature and its parameters are as follows:
moving window
downShiftDir
downShiftPos
OAFuncshiftSpeed
These, as well as example code, are given in detail in the “Global Variables” section in the Reference Manual.
Global Variables from Inside a Block
It is possible to declare your own global variable in VSim. This is done by first defining the variable, then declaring it global. For example:
<Block>
$ X = 4
$ global X
</Block
This will cause the variable X to equal 4 outside of the block. The variable must be defined and declared global on separate lines. For example,
$ global X = 4
will not define X as a global variable with value 4.
Defining Basic Simulation Parameters
Your simulation will include at least the following global parameters:
dimension
floattype
dt
nsteps
dumpPeriodicity
You can either set these equal to actual values, or you can set them equal to variables already defined in your .pre file.