pymatgen.io.lammps.inputs module

class LammpsRun(script_template, settings, data, script_filename)[source]

Bases: monty.json.MSONable

Examples for various simple LAMMPS runs with given simulation box, force field and a few more settings. Experience LAMMPS users should consider using write_lammps_inputs method with more sophisticated templates.

Base constructor.

Parameters:
  • script_template (str) – String template for input script with placeholders. The format for placeholders has to be ‘$variable_name’, e.g., ‘$temperature’
  • settings (dict) – Contains values to be written to the placeholders, e.g., {‘temperature’: 1}.
  • data (LammpsData or str) – Data file as a LammpsData instance or path to an existing data file. Default to None, i.e., no data file supplied. Useful only when read_data cmd is in the script.
  • script_filename (str) – Filename for the input script.
classmethod md(data, force_field, temperature, nsteps, other_settings=None)[source]

Example for a simple MD run based on template md.txt.

Args:
data (LammpsData or str): Data file as a LammpsData
instance or path to an existing data file.
force_field (str): Combined force field related cmds. For
example, ‘pair_style eam
pair_coeff * * Cu_u3.eam’.

temperature (float): Simulation temperature. nsteps (int): No. of steps to run. other_settings (dict): other settings to be filled into

placeholders.
template_dir = u'/Users/work/git/pymatgen-release/pymatgen/pymatgen/io/lammps/templates'
write_inputs(output_dir, **kwargs)[source]

Writes all input files (input script, and data if needed). Other supporting files are not handled at this moment.

Parameters:
  • output_dir (str) – Directory to output the input files.
  • **kwargs – kwargs supported by LammpsData.write_file.
write_lammps_inputs(output_dir, script_template, settings=None, data=None, script_filename=u'in.lammps', make_dir_if_not_present=True, **kwargs)[source]

Writes input files for a LAMMPS run. Input script is constructed from a str template with placeholders to be filled by custom settings. Data file is either written from a LammpsData instance or copied from an existing file if read_data cmd is inspected in the input script. Other supporting files are not handled at the moment.

Parameters:
  • output_dir (str) – Directory to output the input files.
  • script_template (str) – String template for input script with placeholders. The format for placeholders has to be ‘$variable_name’, e.g., ‘$temperature’
  • settings (dict) – Contains values to be written to the placeholders, e.g., {‘temperature’: 1}. Default to None.
  • data (LammpsData or str) – Data file as a LammpsData instance or path to an existing data file. Default to None, i.e., no data file supplied. Useful only when read_data cmd is in the script.
  • script_filename (str) – Filename for the input script.
  • make_dir_if_not_present (bool) – Set to True if you want the directory (and the whole path) to be created if it is not present.
  • **kwargs – kwargs supported by LammpsData.write_file.

Examples

>>> eam_template = '''units           metal
... atom_style      atomic
...
... lattice         fcc 3.615
... region          box block 0 20 0 20 0 20
... create_box      1 box
... create_atoms    1 box
...
... pair_style      eam
... pair_coeff      1 1 Cu_u3.eam
...
... velocity        all create $temperature 376847 loop geom
...
... neighbor        1.0 bin
... neigh_modify    delay 5 every 1
...
... fix             1 all nvt temp $temperature $temperature 0.1
...
... timestep        0.005
...
... run             $nsteps'''
>>> write_lammps_inputs('.', eam_template, settings={'temperature': 1600.0, 'nsteps': 100})
>>> with open('in.lammps') as f:
...     script = f.read()
...
>>> print(script)
units           metal
atom_style      atomic

lattice fcc 3.615 region box block 0 20 0 20 0 20 create_box 1 box create_atoms 1 box

pair_style eam pair_coeff 1 1 Cu_u3.eam

velocity all create 1600.0 376847 loop geom

neighbor 1.0 bin neigh_modify delay 5 every 1

fix 1 all nvt temp 1600.0 1600.0 0.1

timestep 0.005

run 100