4.8.1. LAMMPS Class

The LAMMPS class is encapsulating an MD simulation state and thus it is the class that needs to be created when starting a new simulation system state. The LAMMPS executable essentially creates one instance of this class and passes the command line flags and tells it to process the provided input (a file or stdin). It shuts the class down when control is returned to it and then exits. When using LAMMPS as a library from another code it is required to create an instance of this class, either directly from C++ with new LAMMPS() or through one of the library interface functions like lammps_open() of the C-library interface, or the lammps.lammps class constructor of the Python module, or the lammps() constructor of the Fortran module.

In order to avoid clashes of function names, all of the core code in LAMMPS is placed into the LAMMPS_NS namespace. Functions or variables outside of that namespace must be “static”, i.e. visible only to the scope of the file/object they are defined in. Code in packages or the libraries in the lib folder may not adhere to this as some of them are adapted from legacy code or consist of external libraries with their own requirements and policies.


class LAMMPS_NS::LAMMPS

LAMMPS simulation instance.

The LAMMPS class contains pointers of all constituent class instances and global variables that are used by a LAMMPS simulation. Its contents represent the entire state of the simulation.

The LAMMPS class manages the components of an MD simulation by creating, deleting, and initializing instances of the classes it is composed of, processing command line flags, and providing access to some global properties. The specifics of setting up and running a simulation are handled by the individual component class instances.

Public Functions

const char *match_style(const char *style, const char *name)

Return name of package that a specific style belongs to.

This function checks the given name against all list of styles for all type of styles and if the name and the style match, it returns which package this style belongs to.

Parameters
  • style – Type of style (e.g. atom, pair, fix, etc.)

  • name – Name of style

Returns

Name of the package this style is part of

LAMMPS(int, char**, MPI_Comm)

Create a LAMMPS simulation instance

The LAMMPS constructor starts up a simulation by allocating all fundamental classes in the necessary order, parses input switches and their arguments, initializes communicators, screen and logfile output FILE pointers.

Parameters
  • narg – number of arguments

  • arg – list of arguments

  • communicator – MPI communicator used by this LAMMPS instance

~LAMMPS()

Shut down a LAMMPS simulation instance

The LAMMPS destructor shuts down the simulation by deleting top-level class instances, closing screen and log files for the global instance (aka “world”) and files and MPI communicators in sub-partitions (“universes”). Then it deletes the fundamental class instances and copies of data inside the class.

Public Static Functions

static bool is_installed_pkg(const char *pkg)

Return true if a LAMMPS package is enabled in this binary

Parameters

pkg – name of package

Returns

true if yes, else false

class Pointers

Base class for LAMMPS features.

The Pointers class contains references to many of the pointers and members of the LAMMPS_NS::LAMMPS class. Derived classes thus gain access to the constituent class instances in the LAMMPS composite class and thus to the core functionality of LAMMPS.

This kind of construct is needed, since the LAMMPS constructor should only be run once per LAMMPS instance and thus classes cannot be derived from LAMMPS itself. The Pointers class constructor instead only initializes C++ references to component pointer in the LAMMPS class.

Subclassed by Atom, Input, PotentialFileReader