Table Of Contents

Previous topic

7.3. Atom selection Hierarchy — MDAnalysis.core.Selection

Next topic

7.5. Fast distance array computation — MDAnalysis.core.distances

This Page

7.4. Compute observable timeseries from trajectories — MDAnalysis.core.Timeseries

The collection of timeseries (such as Atom, Bond, Dihedral...) can be computed from a trajectory in one go, foregoing the need to iterate through the trajectory frame by frame in python. Inspired by CHARMM’s correl command.

The disadvantage is that the timeseries ‘plugins’ must be implemented in C-code. Hence not all trajectory readers (see MDAnalysis.coordinates) support them.

7.4.1. Basic classes

class MDAnalysis.core.Timeseries.Timeseries(code, atoms, dsize)[source]

Base timeseries class - define subclasses for specific timeseries computations

shape[source]

shape tuple of the underlying numpy array

class MDAnalysis.core.Timeseries.TimeseriesCollection[source]

A collection of timeseries objects.

The collection of timeseries (such as Atom, Bond, Dihedral...) can be computed from a trajectory in one go, foregoing the need to iterate through the trajectory frame by frame in python. Inspired by CHARMM’s correl command.

The disadvantage is that the timeseries ‘plugins’ must be implemented in C-code.

collection = TimeseriesCollection()
collection.addTimeseries(Timeseries.Atom(...)) - add a new Timeseries object
collection.compute(...)                        - compute the collection of timeseries from the trajectory
collection.clear()                             - clear the collection
collection[i]                                  - access the i'th timeseries
len(collection)                                - return the number of Timeseries added to the collection
addTimeseries(ts)[source]

add a Timeseries object to the collection

clear()[source]

clear the timeseries collection

compute(trj, start=0, stop=-1, skip=1)[source]

Iterate through the trajectory trj and compute the time series.

trj
dcd trajectory object (i.e. Universe.trajectory)
start, stop, skip
Frames to calculate parts of the trajectory. It is important to note that start and stop are inclusive

7.4.2. Timeseries of observables

class MDAnalysis.core.Timeseries.Atom(code, atoms)[source]

Create a timeseries that returns coordinate data for an atom or group of atoms

t = Atom(code, atoms)
code
is one of ‘x’, ‘y’, ‘z’, or ‘v’ (‘vector’, which returns all three dimensions)
atoms
can be a single Atom object, a list of Atom objects, or an AtomGroup
class MDAnalysis.core.Timeseries.Bond(atoms)[source]

Create a timeseries that returns a timeseries for a bond

t = Bond(atoms)

atoms must contain 2 Atom instances, either as a list or an AtomGroup

class MDAnalysis.core.Timeseries.Angle(atoms)[source]

Create a timeseries that returns a timeseries for an angle

t = Angle(atoms)

atoms must contain 3 Atom instances, either as a list or an AtomGroup

class MDAnalysis.core.Timeseries.Dihedral(atoms)[source]

Create a timeseries that returns a timeseries for a dihedral angle

t = Dihedral(atoms)

atoms must contain 4 Atom objects, either as a list or an AtomGroup

class MDAnalysis.core.Timeseries.Distance(code, atoms)[source]

Create a timeseries that returns distances between 2 atoms

t = Distance(code, atoms)

code is one of ‘d’ (distance vector), or ‘r’ (scalar distance) atoms must contain 2 Atom objects, either as a list or an AtomGroup

class MDAnalysis.core.Timeseries.CenterOfGeometry(atoms)[source]

Create a timeseries that returns the center of geometry of a group of atoms

t = CenterOfGeometry(atoms)

atoms can be a list of Atom objects, or a AtomGroup

class MDAnalysis.core.Timeseries.CenterOfMass(atoms)[source]

Create a timeseries that returns the center of mass of a group of atoms

t = CenterOfMass(atoms)

atoms can be a list of Atom objects or a AtomGroup

class MDAnalysis.core.Timeseries.WaterDipole(atoms)[source]

Create a Timeseries that returns a timeseries for the bisector vector of a 3-site water

d = WaterDipole(atoms)

atoms must contain 3 Atom objects, either as a list or an AtomGroup; the first one must be the oxygen, the other two are the hydrogens.

The vector d, multiplied by the partial charge on the oxygen atom (e.g. q = -0.0.834 for TIP3P water), gives the actual dipole moment.

The vector is calculated from the positions of the oxygen atom (\(\mathbf{x}_{\text{O}}\)) and the two hydrogen atoms (\(\mathbf{x}_{\text{H}_1}\), \(\mathbf{x}_{\text{H}_2}\)) as

\[\mathbf{d} = \mathbf{x}_{\text{O}} - \frac{1}{2}(\mathbf{x}_{\text{H}_1} + \mathbf{x}_{\text{H}_2})\]

and the dipole moment vector is

\[\boldsymbol{\mu} = q_{\text{O}} \mathbf{d}\]

Note

This will only work for water models that have half of the oxygen charge on each hydrogen. The vector \(\mathbf{d}\) has the opposite direction of the dipole moment; multiplying with the oxygen charge (\(q_{\text{O}}<0\)) will flip the direction and produce the correct orientation.

There are no sanity checks; if the first atom in a water molecule is not oxygen then results will be wrong.