Skip to content

Commit 528b512

Browse files
authored
Added NoJump on-the-fly example to MSD documentation (Issue #4169) (#5165)
* Fixes #4169 * This PR updates the MSD documentation inside MDAnalysis.analysis.msd to show users how to correctly apply the NoJump transformation using on-the-fly trajectory transformations. - A minimal working example demonstrating NoJump usage - Clarification that wrapped coordinates must be unwrapped - A modern MDAnalysis-based workflow that does not require external tools * The example was tested, with scripts and output available on the PR #5165
1 parent 8a8e7b2 commit 528b512

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

  • package/MDAnalysis/analysis

package/MDAnalysis/analysis/msd.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,34 @@
7070
7171
In MDAnalysis you can use the
7272
:class:`~MDAnalysis.transformations.nojump.NoJump`
73-
transformation.
73+
transformation to unwrap coordinates on-the-fly.
74+
75+
A minimal example:
76+
77+
.. code-block:: python
78+
79+
import MDAnalysis as mda
80+
from MDAnalysis.transformations import NoJump
81+
82+
u = mda.Universe(TOP, TRAJ)
83+
84+
# Apply NoJump transformation to unwrap coordinates
85+
u.trajectory.add_transformations(NoJump(u))
86+
87+
# Now the trajectory is unwrapped and MSD can be computed normally:
88+
from MDAnalysis.analysis.msd import EinsteinMSD
89+
MSD = EinsteinMSD(u, select="all", msd_type="xyz")
90+
MSD.run()
91+
92+
This example assumes that the trajectory contains periodic box
93+
dimensions. If no periodic boundary information is present, box
94+
dimensions must be defined before applying ``NoJump``, which can
95+
be accomplished by applying the
96+
:class:`~MDAnalysis.transformations.boxdimensions.set_dimensions`
97+
transformation *before* the
98+
:class:`~MDAnalysis.transformations.nojump.NoJump` transformation.
99+
100+
This replaces the need to preprocess trajectories externally.
74101
75102
In GROMACS, for example, this can be done using `gmx trjconv`_ with the
76103
``-pbc nojump`` flag.

0 commit comments

Comments
 (0)