pymatgen.io.lammps.inputs module

This module implements methods for writing LAMMPS input files.

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

Bases: MSONable

Examples for various simple LAMMPS runs with given simulation box, force field and a few more settings. Experienced 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.

Parameters:
  • 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 eamnpair_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 = '/Users/shyue/repos/pymatgen/pymatgen/io/lammps/templates'[source]
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.

class LammpsTemplateGen[source]

Bases: TemplateInputGen

Creates an InputSet object for a LAMMPS run based on a template file. The input script is constructed by substituting variables into placeholders in the template file using python’s Template.safe_substitute() function. The data file containing coordinates and topology information can be provided as a LammpsData instance. Alternatively, you can include a read_data command in the template file that points to an existing data file. Other supporting files are not handled at the moment.

To write the input files to a directory, call LammpsTemplateSet.write_input() See pymatgen.io.template.py for additional documentation of this method.

get_input_set(script_template: str | Path, settings: dict | None = None, script_filename: str = 'in.lammps', data: LammpsData | CombinedData | None = None, data_filename: str = 'system.data')[source]
Parameters:
  • script_template – String template for input script with placeholders. The format for placeholders has to be ‘$variable_name’, e.g., ‘$temperature’

  • settings – Contains values to be written to the placeholders, e.g., {‘temperature’: 1}. Default to None.

  • data – Data file as a LammpsData instance. Default to None, i.e., no data file supplied. Note that a matching ‘read_data’ command must be provided in the script template in order for the data file to actually be read.

  • script_filename – Filename for the input file.

  • data_filename – Filename for the data file, if provided.