-
Book Overview & Buying
-
Table Of Contents
Extending and Modifying LAMMPS Writing Your Own Source Code
By :
In this section, we will outline the Variable class and its source code in the variable.cpp and variable.h files. This class can assign variables in order to store constants or calculate atom and group properties, among other functionalities (see https://lammps.sandia.gov/doc/variable.html).
A variable can return scalar values or arrays of values that are useful for conveying information from one part of the script to another during a simulation run. An equal style variable sets the variable to a provided constant value or to a formula that performs a mathematical calculation or extracts a group, atom, region, compute, fix property, and more. The following screenshot from the set() method shows the relevant code:
Figure 8.5 – Code snippet from the Variable::set() method showing the equal style variables
As you can see, upon detecting the equal keyword (line 401), the find() method is used to locate the name of the variable...