pymatgen.io.lammps.data module

class LammpsData(box_size, atomic_masses, atoms_data)[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 ...], ... ]
as_dict()[source]
static check_box_size(molecule, box_size)[source]

Check the box size and if necessary translate the molecule so that all the sites are contained within the bounding box.

Parameters:
  • molecule (Molecule) –
  • box_size (list) – [[x_min, x_max], [y_min, y_max], [z_min, z_max]]
classmethod from_dict(d)[source]
static from_file(data_file, read_charge=True)[source]

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

Parameters:
  • data_file (string) – data file name
  • read_charge (bool) – if true, read in data files that conform with atom_style = charge else atom_style = atomic
Returns:

LammpsData

static from_structure(input_structure, box_size, set_charge=True)[source]

Set LammpsData from the given structure. If the input structure is a Structure, it is converted to a molecule. TIf the molecule doesnt fit in the input box, 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
  • If true, the charge will be non-zero only if the (Atoms.) –
  • has the "charge" site property set. (input_structure) –
Returns:

LammpsData

static get_atoms_data(structure, atomic_masses_dict, set_charge=True)[source]

return the atoms data: 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”

Parameters:
  • structure (Structure) –
  • 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], ... ]

static get_basic_system_info(structure)[source]

Return basic system info from the given structure.

Parameters:structure (Structure) –
Returns:number of atoms, number of atom types, box size, mapping between the atom id and corresponding atomic masses
static set_lines_from_list(lines, block_name, input_list)[source]

Append the values from the input list that corresponds to the block with name ‘block_name’ to the list of lines.

Parameters:
  • lines (list) –
  • block_name (string) – name of the data block, e.g. ‘Atoms’, ‘Bonds’ etc
  • input_list (list) – list of values
write_data_file(filename)[source]

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

Parameters:filename (string) – data file name
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], ... ]
static 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_param_coeff(forcefield, param_name)[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) –
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, ...], ... ]