conversions
This module enables conversion between MDMC Structure objects and ASE Atom and Atoms objects.
- class MDMC.MD.ase.conversions.ASEAtoms(*args, **kwargs)[source]
A subclass of
ase.atoms.Atoms
with explicit bonds defined between atoms- bonds
An
array
oftuple
, where eachtuple
is an atom pair, which are specified by the indexes (int) of each atom.- Type
- Raises
ValueError – If there are not the same number of
ID
as there are atoms
- class MDMC.MD.ase.conversions.X3D(atoms: ase.atoms.Atoms)[source]
Class to write X3D or X3DOM (html) which can be read by web browers
This is used for inline IPython (Jupyter) visualisation with X3DOM. It overrides the write method of the base class, in order to display bonds as defined within MDMC.
- Parameters
atoms (ase.atoms.Atoms) – The
ase.atoms.Atoms
object to write
- atom_lines(atom: ase.atom.Atom) list [source]
Generates a segment of X3D lines representing an atom
- Parameters
atom (ase.atom.Atom) – The
ase.atom.Atom
for which the X3D html will be generated- Returns
A list of (indent, str) pairs for each line requied to describe the atom
- Return type
- get_center_of_rotation() numpy.ndarray [source]
Get the center of rotation for the viewpoint
- Returns
The center of atoms.cell if this has been set, or the center of the extents of atoms.positions
- Return type
- get_viewpoint_z() float [source]
Get the z position of the viewpoint which will display all of the atoms
- Returns
The z position of the viewpoint
- Return type
- MDMC.MD.ase.conversions.convert_bond(bond: MDMC.MD.interactions.Bond, index_conv: dict = None) numpy.ndarray [source]
Converts
Bond
objects into the form required by the ASE GUI- Parameters
bond (Bond) – The bond which will be converted.
index_conv (dict) – A dictionary of
MDMC_ID
:ASE_index
pairs, whereMDMC_ID
is an int specifying anAtom.ID
, andASE_index
is the correspondingase.atom.Atom.index
. The default is None, which means that theID
andindex
will be assumed to be identical.
- Returns
An
array
of 2 element list where each element is the intindex
of an atom between which the bond exists.- Return type
- MDMC.MD.ase.conversions.convert_bonds(bonds: list[MDMC.MD.interactions.Bond], index_conv: dict = None) numpy.ndarray [source]
Converts
Bond
objects into the form required by the ASE GUI- Parameters
bonds (list) – The list of
Bond
objects to be convertedindex_conv (dict) – A dict of
MDMC_ID
:ASE_index
pairs, whereMDMC_ID
is an int specifying anAtom.ID
, andASE_index
is the correspondingase.atom.Atom.index
. The default is None, which means that theID
andindex
will be assumed to be identical.
- Returns
An
array
of 2 element list where each element is the intindex
of an atom between which the bond exists.- Return type
- MDMC.MD.ase.conversions.convert_from_ase_atom(ase_atom: MDMC.MD.ase.conversions.ASEAtoms, atom_type: int = None, name: str = None, set_charge: bool = True, cutoff: float = None) MDMC.MD.structures.Atom [source]
Converts an
ase.atom.Atom
to an MDMCAtom
.As MDMC automatically generates atom
ID
,ase_atom.index
is not passed when initializing anAtom
.- Parameters
ase_atom (ASEAtom) – An
ASEAtom
object to be converted to an MDMCAtom
objectatom_type (int) – The atom_type of the MDMC
Atom
object.name (str, optional) – A name for the MDMC
Atom
. The default is the element symbol.set_charge (bool, optional) – Whether the
charge
is set to thecharge
of thease.atom.Atom, or left unset. All ``ase.atom.Atom
objects have acharge
, which is set to 0. if it is uninitialized. As MDMCAtom
objects can havecharge=None`, in some cases it might be preferential to leave the ``charge
unset. The default is to set thecharge
.cutoff (float, optional) – The cutoff value for the atom’s charge interaction. Must be set if set_charge is True.
- Returns
An MDMC
Atom
object which is equivalent toase_atom
- Return type
Atom
- MDMC.MD.ase.conversions.convert_to_ase_atom(atom: MDMC.MD.structures.Atom, index: int = None) ase.atom.Atom [source]
Converts an MDMC
Atom
to anase.atom.Atom
- Parameters
atom (Atom) – An MDMC
Atom
object to be converted to anase.atom.Atom
objectindex (int, optional) – The
index
of thease.atom.Atom
object which is created. If this is not set, the MDMCAtom.ID
is used.
- Returns
An
ASE.atom.Atom
object which is equivalent toatom
- Return type
- MDMC.MD.ase.conversions.get_ase_atoms(atoms: Iterable, cell: numpy.ndarray = None) MDMC.MD.ase.conversions.ASEAtoms [source]
Gets an
ASEAtoms
object equivalent toatoms
, including the bonding- Parameters
atoms (iterable) – An
iterable
of MDMCAtom
objects to be converted to anASEAtoms
objectcell (numpy.ndarray, optional) – A 3 element
array
specifying the unit cell of theASEAtoms
object. The default is None.
- Returns
An
ASEAtoms
object which is equivalent toatoms
- Return type