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_number_to_atomic_mass
(atomic_number)[source]¶ Convert an atomic number to that element’s atomic mass
-
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 fileReturn type: Molecule
-
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¶
Molecule¶
-
class
nme.nme.
Molecule
(atoms=None)[source]¶ Initialize a
Molecule
. AMolecule
acts a container forAtom
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
-
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()
-
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()
-