pymatgen.io.lammps.data module

class LammpsData(box_size, atomic_masses, atoms_data, box_tilt=None, atom_style='full')[source]

Bases: monty.json.MSONable

Basic Lammps data: just the atoms section

Parameters:
  • box_size (list) – [[x_min, x_max], [y_min,y_max], [z_min,z_max]]
  • atomic_masses (list) – [[atom type, mass],…]
  • atoms_data (list) – [[atom id, mol id, atom type, charge, x, y, z …], … ]
  • box_tilt (list) – [xy, xz, yz] for non-orthogonal systems
TEMPLATE = 'Generated by pymatgen.io.lammps.data.LammpsData\n\n{natoms} atoms\n\n{natom_types} atom types\n\n{xlo:.6f} {xhi:.6f} xlo xhi\n{ylo:.6f} {yhi:.6f} ylo yhi\n{zlo:.6f} {zhi:.6f} zlo zhi\n{tilt}\n\nMasses \n\n{masses}\n\nAtoms \n\n{atoms}\n'
as_dict()[source]
static check_box_size(structure, box_size, translate=False)[source]

For Molecule objects: check the box size and if necessary translate the molecule so that all the sites are contained within the bounding box. Structure objects: compute the tilt. See

Parameters:
  • structure (Structure/Molecule) –
  • box_size (list) – [[x_min, x_max], [y_min, y_max], [z_min, z_max]]
  • translate (bool) – if true move the molecule to the center of the new box.
Returns:

box_size, box_tilt

classmethod from_dict(d)[source]
classmethod from_file(data_file, atom_style='full')[source]

Return LammpsData object from the data file. Note: use this to read in data files that conform with atom_style = charge or atomic or full

Parameters:
  • data_file (string) – data file name
  • atom_style (string) – “full” or “charge” or “atomic”
Returns:

LammpsData

classmethod from_structure(input_structure, box_size=None, set_charge=True, translate=True)[source]

Set LammpsData from the given structure or molecule object. If the input structure is a Molecule and if it doesnt fit in the input box then the box size is updated based on the max and min site coordinates of the molecules.

Parameters:
  • input_structure (Molecule/Structure) –
  • box_size (list) – [[x_min, x_max], [y_min, y_max], [z_min, z_max]]
  • set_charge (bool) – whether or not to set the charge field in Atoms. If true, the charge will be non-zero only if the input_structure has the “charge” site property set.
  • translate (bool) – if true move the molecule to the center of the new box(it that is required).
Returns:

LammpsData

classmethod get_atoms_data(structure, atomic_masses_dict, set_charge=True)[source]
return the atoms data:
Molecule:

atom_id, molecule tag, atom_type, charge(if present else 0), x, y, z. The molecule_tag is set to 1(i.e the whole structure corresponds to just one molecule). This corresponds to lammps command: “atom_style charge” or

“atom_style full”
Structure:
atom_id, atom_type, species oxidation state, x, y, z atom_style = atomic/charge
Parameters:
  • structure (Structure/Molecule) –
  • atomic_masses_dict (dict) – { atom symbol : [atom_id, atomic mass], … }
  • set_charge (bool) – whether or not to set the charge field in Atoms
Returns:

[[atom_id, molecule tag, atom_type, charge(if present),

x, y, z], … ]

For Structure:

[[atom_id, atom_type, charge(if present), x, y, z], … ]

Return type:

For Molecule

static get_basic_system_info(structure)[source]

Return basic system info from the given structure.

Parameters:structure (Structure/Molecule) –
Returns:number of atoms, number of atom types, box size, mapping between the atom id and corresponding atomic masses
structure

Transform from LammpsData file to a pymatgen structure object

Returns:A pymatgen structure object
write_file(filename, significant_figures=6)[source]

write lammps data input file from the string representation of the data.

Parameters:
  • filename (string) – data file name
  • significant_figures (int) – No. of significant figures to output. Default to 6.
class LammpsForceFieldData(box_size, atomic_masses, pair_coeffs, bond_coeffs, angle_coeffs, dihedral_coeffs, improper_coeffs, atoms_data, bonds_data, angles_data, dihedrals_data, imdihedrals_data)[source]

Bases: pymatgen.io.lammps.data.LammpsData

Sets Lammps data input file from force field parameters. It is recommended that the the convenience method from_forcefield_and_topology be used to create the object.

Parameters:
  • box_size (list) – [[x_min,x_max], [y_min,y_max], [z_min,z_max]]
  • atomic_masses (list) – [ [atom type, atomic mass], … ]
  • pair_coeffs (list) – pair coefficients, [[unique id, sigma, epsilon ], … ]
  • bond_coeffs (list) – bond coefficients, [[unique id, value1, value2 ], … ]
  • angle_coeffs (list) – angle coefficients, [[unique id, value1, value2, value3 ], … ]
  • dihedral_coeffs (list) – dihedral coefficients, [[unique id, value1, value2, value3, value4], … ]
  • improper_coeffs (list) – improper dihedral coefficients, [[unique id, value1, value2, value3, value4], … ]
  • atoms_data (list) – [[atom id, mol id, atom type, charge, x,y,z, …], … ]
  • bonds_data (list) – [[bond id, bond type, value1, value2], … ]
  • angles_data (list) – [[angle id, angle type, value1, value2, value3], … ]
  • dihedrals_data (list) – [[dihedral id, dihedral type, value1, value2, value3, value4], … ]
  • imdihedrals_data (list) – [[improper dihedral id, improper dihedral type, value1, value2, value3, value4], … ]
TEMPLATE = '\n Generated by pymatgen.io.lammps.data.LammpsForceFieldData\n\n{natoms} atoms\n{nbonds} bonds\n{nangles} angles\n{ndihedrals} dihedrals\n{nimdihedrals} impropers\n\n{natom_types} atom types\n{nbond_types} bond types\n{nangle_types} angle types\n{ndihedral_types} dihedral types\n{nimdihedral_types} improper types\n\n{xlo:.6f} {xhi:.6f} xlo xhi\n{ylo:.6f} {yhi:.6f} ylo yhi\n{zlo:.6f} {zhi:.6f} zlo zhi\n{tilt}\n\nMasses\n\n{masses}\n\nPair Coeffs\n\n{pair_coeffs}\n\nBond Coeffs\n\n{bond_coeffs}\n\nAngle Coeffs\n\n{angle_coeffs}\n\nDihedral Coeffs \n\n{dihedral_coeffs}\n\nImproper Coeffs \n\n{improper_coeffs}\n\nAtoms\n\n{atoms}\n\nBonds\n\n{bonds}\n\nAngles\n\n{angles}\n\nDihedrals\n\n{dihedrals}\n\nImpropers\n\n{dihedrals}\n'
classmethod from_file(data_file)[source]

Return LammpsForceFieldData object from the data file. It is assumed that the forcefield paramter sections for pairs, bonds, angles, dihedrals and improper dihedrals are named as follows(not case sensitive): “Pair Coeffs”, “Bond Coeffs”, “Angle Coeffs”, “Dihedral Coeffs” and “Improper Coeffs”. For “Pair Coeffs”, values for factorial(n_atom_types) pairs must be specified.

Parameters:data_file (string) – the data file name
Returns:LammpsForceFieldData
static from_forcefield_and_topology(mols, mols_number, box_size, molecule, forcefield, topologies)[source]

Return LammpsForceFieldData object from force field and topology info for the ‘molecule’ assembled from the constituent molecules specified in the ‘mols’ list with their count specified in the ‘mols_number’ list.

Parameters:
  • mols (list) – List of Molecule objects
  • mols_number (list) – List of number of molecules of each molecule type in mols
  • box_size (list) – [[x_min,x_max], [y_min,y_max], [z_min,z_max]]
  • molecule (Molecule) – The molecule that is assembled from mols and mols_number
  • forcefield (ForceFiled) – Force filed information
  • topologies (list) – List of Topology objects, one for each molecule type in mols.
Returns:

LammpsForceFieldData

static get_atoms_data(mols, mols_number, molecule, atomic_masses_dict, topologies, atom_to_mol=None)[source]

Return the atoms data.

Parameters:
  • mols (list) – list of Molecule objects.
  • mols_number (list) – number of each type of molecule in mols list.
  • molecule (Molecule) – the molecule assembled from the molecules in the mols list.
  • topologies (list) – list of Topology objects, one for each molecule type in mols list
  • atom_to_mol (dict) – maps atom_id –> [mol_type, mol_id, local atom id in the mol with id mol_id]
Returns:

[[atom id, mol type, atom type, charge, x, y, z], … ] molid_to_atomid: [ [global atom id 1, id 2, ..], …], the

index will be the global mol id

Return type:

atoms_data

static get_basic_system_info(molecule)[source]
static get_param_coeff(forcefield, param_name, atom_types_map=None)[source]

get the parameter coefficients and mapping from the force field.

Parameters:
  • forcefield (ForceField) – ForceField object
  • param_name (string) – name of the parameter for which
  • coefficients are to be set. (the) –
  • atom_types_map (dict) – maps atom type to the atom type id. Used to set hthe pair coeffs. e.g. {“C2”: [3], “H2”: [1], “H1”: [2]}
Returns:

[[parameter id, value1, value2, … ], … ] and {parameter key: parameter id, …}

static get_param_data(param_name, param_map, mols, mols_number, topologies, molid_to_atomid)[source]

set the data for the parameter named param_name from the topology.

Parameters:
  • param_name (string) – parameter name, example: “bonds”
  • param_map (dict) –

    { mol_type: {parameter_key : unique parameter id, … }, … } example: {0: {(“c1”,”c2”): 1}} ==> c1-c2 bond in mol_type=0

    has the global id of 1
  • mols (list) – list of molecules.
  • mols_number (list) – number of each type of molecule in mols list.
  • topologies (list) – list of Topology objects, one for each molecule type in mols list
  • molid_to_atomid (list) – [ [gloabal atom id 1, id 2, ..], …], the index is the global mol id
Returns:

[ [parameter id, parameter type, global atom id1, global atom id2, …], … ]

parse_data_file(filename)[source]

A very general parser for arbitrary lammps data files.

Parameters:filename (str) – path to the data file
Returns:dict