make_whole
- mdtools.box.make_whole(ag, compound='fragments', reference='cog', inplace=True, debug=False)[source]
Make compounds of a MDAnalysis
AtomGroup
whole that are split across periodic boundaries.Note that all
Atoms
of the inputAtomGroup
are wrapped back into the primary unit cell before making compounds whole.- Parameters:
ag (
MDAnalysis.core.groups.AtomGroup instance
) – The MDAnalysisAtomGroup
whose compounds shall be made whole.compound (
{'group', 'segments', 'residues', 'molecules', 'fragments'}
, optional) – Which type of component to make whole. Note that in any case, allAtoms
within each compound must be interconnected by bonds, i.e. compounds must correspond to (parts of) molecules. This is always fulfilled forfragments
, because a MDAnalysisfragment
is what is typically considered a molecule, i.e. anAtomGroup
where anyAtom
is reachable from any otherAtom
in theAtomGroup
by traversing bonds, and none of itsAtoms
is bonded to anyAtom
outside theAtomGroup
. A ‘molecule’ in MDAnalysis refers to a GROMACS-specific concept. See the MDAnalysis user guide for further information. Note that in any case, even if compound is e.g.'residues'
, only theAtoms
belonging to ag are taken into account, even if the compound might comprise additionalAtoms
that are not contained in ag. If you want entire molecules to be made whole, make sure that allAtoms
of these molecules are part of ag.reference (
{'cog', 'com', None}
, optional) – If ‘cog’ (center of geometry) or ‘com’ (center of mass), the compounds that were made whole will be shifted such that their individual reference point lies within the primary unit cell. IfNone
, no such shift is performed.inplace (
bool
, optional) – IfTrue
, coordinates are modified in place.debug (
bool
, optional) – IfTrue
, check the input arguments. Default:False
- Returns:
pos (
numpy.ndarray
) – Array of shape(ag.n_atoms, 3)
containing the coordinates of allAtoms
in ag after the specified compounds of ag were made whole.
See also
MDAnalysis.core.groups.AtomGroup.unwrap()
Move
Atoms
in theAtomGroup
such that bonds within the group’s compounds aren’t split across periodic boundariesMDAnalysis.lib.mdamath.make_whole()
Move all
Atoms
in an MDAnalysisAtomGroup
such that bonds don’t split over periodic imagesmdtools.box.wrap()
Shift compounds of a MDAnalysis
AtomGroup
back into the primary unit cell`
Notes
This function is just a wrapper around the
unwrap()
method of the inputAtomGroup
that additionally checks the masses of allAtoms
in ag when reference is set to'com'
. Seemdtools.check.masses_new()
for further information.Before making any compound whole, all
Atoms
in ag are wrapped back into the primary unit cell. This is done to make sure that the unwrap algorithm (better “make whole” algorithm) ofunwrap()
is working properly. This means that making compounds whole in an unwrappedtrajectory
while keeping thetrajectory
unwrapped is not possible with this function.Todo
Check if it is really necessary to wrap all
Atoms
back into the primary unit before callingunwrap()
. This is a serious problem, because it implies an inplace change of theAtom
coordinates.Because
MDAnalysis
will pulltrajectory
data directly from the file it is reading from, changes toAtom
coordinates and boxdimensions
will not persist once theframe
is changed (even if inplace isTrue
). The only way to make these changes permanent is to load thetrajectory
into memory, or to write a newtrajectory
to file for everyframe
. See the MDAnalysis user guide about trajectories (second last paragraph) and in-memory trajectories.