LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

variable command

Syntax:

variable name style arg1 arg2 ... 

Examples:

variable x proc 1 2 3 4
variable t proc 300.0 310.0 320.0 330.0
variable d index run1 run2 run3 run4 run5 run6 run7 run8 

Description:

This command sets values for a variable name that can be substituted for in later input script commands. As explained in this section, all occurences of $X in an input script line are treated as a variable, where X is a single lower-case character from "a" to "z". Variables can also be set (with a single value) by using the command-line switch -var; see this section for details.

For proc style variables, the -partition command-line switch must be used when LAMMPS is run; see this section. All processors in the Ith partition will substitute the Ith argument for the variable $X. For example, in a simulation with 4 partitions and the variables x and t defined as above, these commands

read_data data.peptide.$x
temper 100000 100 $t settemp 0 45928 

will run a parallel tempering simulation at 4 temperatures, using 4 different data files as inputs.

The substitution behavior of index style variables depends on whether LAMMPS is running on a single partition or multiple partitions. See this section for a discussion of the -partition command-line switch. See the next command for a discussion of how substitutions take place in both scenarios.

If a variable command is encountered when the variable has already been defined, the command is ignored. Thus allows an input script with a variable command to be processed multiple times; see the jump or include commands. It also means that the use of the command-line switch -var will override a corresponding variable setting in the input script.

Restrictions: none

Related commands:

next, jump, include, temper

Default: none