API

Functions

nme.nme.atomic_mass_to_atomic_number(atomic_mass)[source]

Convert an atomic mass to an atomic number by guessing what the element is by finding the element with the closest atomic mass

nme.nme.atomic_mass_to_symbol(atomic_mass)[source]

Convert an atomic mass to a symbol

nme.nme.atomic_number_to_atomic_mass(atomic_number)[source]

Convert an atomic number to that element’s atomic mass

nme.nme.atomic_number_to_symbol(atomic_number)[source]

Convert an atomic number to a symbol

nme.nme.read_xyz(filepath)[source]

Read a .xyz file into an array of atoms

Parameters:filepath (str) – The path of the xyz file
Returns:A Molecule object containing the atoms in the .xyz file
Return type:Molecule
nme.nme.symbol_to_atomic_mass(symbol)[source]

Convert an element’s symbol to its atomic mass

nme.nme.symbol_to_atomic_number(symbol)[source]

Convert an element’s symbol to its atomic number

nme.nme.write_lammps(molecules, filename, bbox=None, boundary_margin=0.8)[source]

Write the given molecules to a LAMMPS data file

Parameters:
  • molecules – A molecule or array of molecules to be written
  • filename – The path that the LAMMPS data should be written to
  • bbox – (optional) The bounding box of the simulation area, specified as a pair of cartesian coordinates corresponding to the minimum coordinates and the maximum coordinates (e.g. [ [0, 0, 0], [1, 1, 1] ])
  • boundary_margin – (optional) If a bounding box is not supplied, compute a bounding box automatically by padding the area taken up by the molecules by this many atoms

Atom

class nme.nme.Atom(element, xyz)[source]

Initialize an Atom. This is the fundamental object of nme.

Parameters:
  • element (int) – The atomic number of the element
  • xyz – A tuple, list, or numpy array of size 3 corresponding to the atom’s coordinates

Molecule

class nme.nme.Molecule(atoms=None)[source]

Initialize a Molecule. A Molecule acts a container for Atom objects and can be used to manipulate groups of atoms or write a group of atoms to the disk.

Parameters:atoms (list) – (optional) A list of Atom objects. If no atoms are provied then an empty molecule is returned.
append(other)[source]

Append atoms or molecules to the atoms array

Parameters:other – An Atom, Molecule, or a list of atoms and molecules
bbox_intersects(molecule, padding=0)[source]

Test whether the bounding box of the current molecule intersects the bounding box of another molecule

Parameters:
  • molecule (Molecule) – The other molecule
  • padding (float) – (optional) A number to pad the bounding boxes by to increase their size
Returns:

True if the bounding box of this molecule intersects the bounding box of another molecule; False otherwise.

Return type:

bool

copy()[source]

Create a copy of this molecule

Returns:A copy of this molecule
Return type:Molecule
find_bonds(bond_radius=1.8)[source]

Find bonds between molecules

Parameters:bond_radius (float) – (optional) The distance, in angstroms, between two atoms under which a bond will be assumed
Returns:A two-dimensional array of atoms where each pair of atoms represents a bond
Return type:list
move_to(xyz)[source]

Move the molecule such that its centroid is at the desired position

Parameters:xyz – A tuple, list, or numpy array of size 3, corresponding to the location that the molecule should be moved to
offset(offset)[source]

Offset the current molecule

Parameters:offset – A tuple, list, or numpy array of size 3 corresponding to the translation that should be applied to all of the molecule’s atoms
rotate(theta, phi, psi, degrees=False)[source]

Rotate the molecule about its centroid in 3D space

Parameters:
  • theta (float) – The angle to rotate the molecule around its X axis
  • phi (float) – The angle to rotate the molecule around its Y axis
  • psi (float) – The angle to rotate the molecule around its Z axis
  • degrees (bool) – (optional) If True, the angles given are assumed to be in degrees and will be converted to radians before being used
write_lammps(filename, *args, **kwargs)[source]

Syntactic sugar: see nme.nme.write_lammps()

write_xyz(filename, comment='generated with nme')[source]

Write the current molecule to an XYZ file

Parameters:
  • filename (str) – The path that the XYZ data should be written to
  • comment (str) – (optional) A comment to include in the XYZ file

Workspace

class nme.nme.Workspace[source]

Initialize a Workspace. A Workspace is a container for :class:`Atom`s and :class:`Molecule`s. The primary purpose of a Workspace is to facilitate writing multiple atoms and molecules to a single output file.

append(object_)[source]

Append atoms or molecules to the workspace

Parameters:object – An Atom or Molecule
write_lammps(filename, *args, **kwargs)[source]

Syntactic sugar: see nme.nme.write_lammps()

write_xyz(filename, comment='generated with nme')[source]

Write the current workspace to an XYZ file

Parameters:
  • filename (str) – The path that the XYZ data should be written to
  • comment (str) – (optional) A comment to include in the XYZ file