LAMMPS

The LAMMPS calculator first appeared in ASE version 3.5.0. At the time of the release of ASE 3.17.0, the LAMMPS calculator is still a thin wrapper containing basic features to enable the use of LAMMPS in ASE (missing some feature might have been added in the source code development tree or some more recent version of ASE).

class ase.calculators.lammpsrun.LAMMPS(label='lammps', **kwargs)[source]

LAMMPS (https://lammps.sandia.gov/) calculator

The environment variable ASE_LAMMPSRUN_COMMAND must be defined to tell ASE how to call a LAMMPS binary. This should contain the path to the lammps binary, or more generally, a command line possibly also including an MPI-launcher command.

For example (in a Bourne-shell compatible environment):

export ASE_LAMMPSRUN_COMMAND=/path/to/lmp_binary

or possibly something similar to

export ASE_LAMMPSRUN_COMMAND="/path/to/mpirun --np 4 lmp_binary"
Parameters:
  • files (list[str]) – List of files needed by LAMMPS. Typically a list of potential files.

  • parameters (dict[str, Any]) – Dictionary of settings to be passed into the input file for calculation.

  • specorder (list[str]) – Within LAAMPS, atoms are identified by an integer value starting from 1. This variable allows the user to define the order of the indices assigned to the atoms in the calculation, with the default if not given being alphabetical

  • keep_tmp_files (bool, default: False) – Retain any temporary files created. Mostly useful for debugging.

  • tmp_dir (str, default: None) – path/dirname (default None -> create automatically). Explicitly control where the calculator object should create its files. Using this option implies ‘keep_tmp_files=True’.

  • no_data_file (bool, default: False) – Controls whether an explicit data file will be used for feeding atom coordinates into lammps. Enable it to lessen the pressure on the (tmp) file system. THIS OPTION MIGHT BE UNRELIABLE FOR CERTAIN CORNER CASES (however, if it fails, you will notice…).

  • keep_alive (bool, default: True) – When using LAMMPS as a spawned subprocess, keep the subprocess alive (but idling when unused) along with the calculator object.

  • always_triclinic (bool, default: False) – Force LAMMPS to treat the cell as tilted, even if the cell is not tilted, by printing xy, xz, yz in the data file.

  • reduce_cell (bool, default: False) – If True, reduce cell to have shorter lattice vectors.

  • write_velocities (bool, default: False) – If True, forward ASE velocities to LAMMPS.

  • verbose (bool, default: False) – If True, print additional debugging output to STDOUT.

Examples

Provided that the respective potential file is in the working directory, one can simply run (note that LAMMPS needs to be compiled to work with EAM potentials)

from ase import Atom, Atoms
from ase.build import bulk
from ase.calculators.lammpsrun import LAMMPS

parameters = {'pair_style': 'eam/alloy',
            'pair_coeff': ['* * NiAlH_jea.eam.alloy H Ni']}

files = ['NiAlH_jea.eam.alloy']

Ni = bulk('Ni', cubic=True)
H = Atom('H', position=Ni.cell.diagonal()/2)
NiH = Ni + H

lammps = LAMMPS(parameters=parameters, files=files)

NiH.calc = lammps
print("Energy ", NiH.get_potential_energy())

Basic calculator implementation.

restart: str

Prefix for restart file. May contain a directory. Default is None: don’t restart.

ignore_bad_restart_file: bool

Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.

directory: str or PurePath

Working directory in which to read and write files and perform calculations.

label: str

Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.

atoms: Atoms object

Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.

Setting up an OPLS calculation

There are some modules to facilitate the setup of an OPLS force field calculation, see ase.io.opls.