pair_style mliap command


pair_style mliap ... keyword values ...
  • two keyword/value pairs must be appended

  • keyword = model or descriptor

    model values = style filename
      style = linear or quadratic or nn or mliappy
      filename = name of file containing model definitions
    descriptor values = style filename
      style = sna
      filename = name of file containing descriptor definitions


pair_style mliap model linear InP.mliap.model descriptor sna InP.mliap.descriptor
pair_style mliap model quadratic W.mliap.model descriptor sna W.mliap.descriptor
pair_coeff * * In P


Pair style mliap provides a general interface to families of machine-learning interatomic potentials. It allows separate definitions of the interatomic potential functional form (model) and the geometric quantities that characterize the atomic positions (descriptor). By defining model and descriptor separately, it is possible to use many different models with a given descriptor, or many different descriptors with a given model. The pair style currently supports just one descriptor style, but it is is straightforward to add new descriptor styles. The SNAP descriptor style sna is the same as that used by pair_style snap, including the linear, quadratic, and chem variants. The available models are linear, quadratic, nn, and mliappy. The mliappy style can be used to couple python models, e.g. PyTorch neural network energy models, and requires building LAMMPS with the PYTHON package (see below). In order to train a model, it is useful to know the gradient or derivative of energy, force, and stress w.r.t. model parameters. This information can be accessed using the related compute mliap command.

The pair_style mliap command must be followed by two keywords model and descriptor in either order. A single pair_coeff command is also required. The first 2 arguments must be * * so as to span all LAMMPS atom types. This is followed by a list of N arguments that specify the mapping of MLIAP element names to LAMMPS atom types, where N is the number of LAMMPS atom types.

The model keyword is followed by the model style. This is followed by a single argument specifying the model filename containing the parameters for a set of elements. The model filename usually ends in the .mliap.model extension. It may contain parameters for many elements. The only requirement is that it contain at least those element names appearing in the pair_coeff command.

The top of the model file can contain any number of blank and comment lines (start with #), but follows a strict format after that. The first non-blank non-comment line must contain two integers:

  • nelems = Number of elements

  • nparams = Number of parameters

When the model keyword is linear or quadratic, this is followed by one block for each of the nelem elements. Each block consists of nparams parameters, one per line. Note that this format is similar, but not identical to that used for the pair_style snap coefficient file. Specifically, the line containing the element weight and radius is omitted, since these are handled by the descriptor.

When the model keyword is nn (neural networks), the model file can contain blank and comment lines (start with #) anywhere. The second non-blank non-comment line must contain the string NET, followed by two integers:

  • ndescriptors = Number of descriptors

  • nlayers = Number of layers (including the hidden layers and the output layer)

and followed by a sequence of a string and an integer for each layer:

  • Activation function (linear, sigmoid, tanh or relu)

  • nnodes = Number of nodes

This is followed by one block for each of the nelem elements. Each block consists of scale0 minimum value, scale1 (maximum - minimum) value, in order to normalize the descriptors, followed by nparams parameters, including bias and weights of the model, starting with the first node of the first layer and so on, with a maximum of 30 values per line.

Notes on mliappy models: When the model keyword is mliappy, the filename should end in ‘.pt’, ‘.pth’ for pytorch models, or be a pickle file. To load a model from memory (i.e. an existing python object), specify the filename as “LATER”, and then call lammps.mliap.load_model(model) from python before using the pair style. When using lammps via the library mode, you will need to call lammps.mliappy.activate_mliappy(lmp) on the active lammps object before the pair style is defined. This call locates and loads the mliap-specific python module that is built into lammps.

The descriptor keyword is followed by a descriptor style, and additional arguments. Currently the only descriptor style is sna, indicating the bispectrum component descriptors used by the Spectral Neighbor Analysis Potential (SNAP) potentials of pair_style snap. A single additional argument specifies the descriptor filename containing the parameters and setting used by the SNAP descriptor. The descriptor filename usually ends in the .mliap.descriptor extension.

The SNAP descriptor file closely follows the format of the pair_style snap parameter file. The file can contain blank and comment lines (start with #) anywhere. Each non-blank non-comment line must contain one keyword/value pair. The required keywords are rcutfac and twojmax. There are many optional keywords that are described on the pair_style snap doc page. In addition, the SNAP descriptor file must contain the nelems, elems, radelems, and welems keywords. The nelems keyword specifies the number of elements provided in the other three keywords. The elems keyword is followed by a list of nelems element names that must include the element names appearing in the pair_coeff command, but can contain other names too. Similarly, the radelems and welems keywords are followed by lists of nelems numbers giving the element radius and element weight of each element. Obviously, the order in which the elements are listed must be consistent for all three keywords.

See the pair_coeff doc page for alternate ways to specify the path for these model and descriptor files.

Mixing, shift, table, tail correction, restart, rRESPA info

For atom type pairs I,J and I != J, where types I and J correspond to two different element types, mixing is performed by LAMMPS with user-specifiable parameters as described above. You never need to specify a pair_coeff command with I != J arguments for this style.

This pair style does not support the pair_modify shift, table, and tail options.

This pair style does not write its information to binary restart files, since it is stored in potential files. Thus, you need to re-specify the pair_style and pair_coeff commands in an input script that reads a restart file.

This pair style can only be used via the pair keyword of the run_style respa command. It does not support the inner, middle, outer keywords.


This pair style is part of the MLIAP package. It is only enabled if LAMMPS was built with that package. In addition, building LAMMPS with the MLIAP package requires building LAMMPS with the SNAP package. The mliappy model requires building LAMMPS with the PYTHON package. See the Build package doc page for more info.