mooonpy.molspace.atoms module
This module provides a class to organize atoms information
- class mooonpy.molspace.atoms.Atoms(astyles, **kwargs)[source]
Bases:
dict- COM(masses, atom_ids='all') Tuple[float, float, float][source]
Mass-weighted center of mass of the selected atoms.
- Parameters:
masses – A
{type: mass}dict. Pass either a plain dict ormol.ff.masses(theParametersobject’scoeffs[0]is unwrapped automatically).atom_ids –
'all'or an iterable of atom ids.
- Returns:
(x, y, z)center of mass.- Raises:
KeyError – If a selected atom’s
typeis not inmasses.
- centroid(atom_ids='all') Tuple[float, float, float][source]
Unweighted centroid of the selected atoms.
- Parameters:
atom_ids –
'all'or an iterable of atom ids.- Returns:
(x, y, z)centroid.
- copy(deepcopy=False)[source]
Return a fully independent copy of this Atoms container (independence verified in
tests/test_molspace_copy.py).The Atom factory class and defaults are frozen, so the copy references the SAME factory and read-only
stylesinstance by design; atom instances andboxare rebuilt fresh.- Parameters:
deepcopy – if True, use the
copy.deepcopyfallback (same result, ~5x slower; for cross-checking only).
- move(vect=None, mode='offset', atom_ids='all')[source]
Translate or scale atom coordinates in place.
- Parameters:
vect (tuple[float, float, float] or None) – Displacement / target / scale vector.
Noneis a no-op.mode –
How
vectis interpreted:'offset'— addvectto each atom’s coordinates.'centroid'— shift the selection so its centroid lands atvect(computed viacentroid()).'scale'— multiply each coordinate component byvect. This also scales the simulationBoxparameters about the origin (xlo *= vxetc., tilt factors scale with the relevant axis).
atom_ids –
'all'or an iterable of atom ids to apply the move to.'scale'always scales the box regardless of the selection.
For mass-weighted re-centering, compute the COM externally with
COM()and pass the desired delta withmode='offset'.
- shrinkwrap(pad=0.0)[source]
Resize
boxto tightly enclose every atom, with optional padding on each face.- Parameters:
pad (float) – Distance (Å) added to each face beyond the atom extent.
- Raises:
ValueError – If the box is triclinic (any of
xy/xz/yzis nonzero); shrinkwrap on tilted boxes is ill-defined here.