Skip to content

DCDReader calculates wrong time (istart is in integrator steps not frames) #1819

@orbeckst

Description

@orbeckst

Expected behaviour

The DCDReader should correctly set the time step of a DCD file.

Actual behaviour

The starting frame is not zero but a large number (actually, it is nsavc to larger, see below)

Code to reproduce the behaviour

import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
u = mda.Universe(PSF,DCD)

times = [ts.time for ts in u.trajectory]
print(times[:10], "...", times[-10:])

gives

[999.9999119200186, 1000.9999118319386, 1001.9999117438587, 1002.9999116557786, 1003.9999115676986, 1004.9999114796186, 1005.9999113915387, 1006.9999113034587, 1007.9999112153787, 1008.9999111272988] ... [1087.9999041689803, 1088.9999040809003, 1089.9999039928202, 1090.9999039047402, 1091.9999038166602, 1092.9999037285804, 1093.9999036405004, 1094.9999035524204, 1095.9999034643404, 1096.9999033762604]

but it should be

[0.0 1.0 ... 97.0]

Note the header

print(u.trajectory._file.header)

contains istart = 1000

{'natoms': 3341, 'istart': 1000, 'nsavc': 1000, 'delta': 0.020454827696084976, 'is_periodic': False, 'remarks': '* DIMS ADK SEQUENCE FOR PORE PROGRAM                                            * WRITTEN BY LIZ DENNING (6.2008)                                               *  DATE:     6/ 6/ 8     17:23:56      CREATED BY USER: denniej0                '}

which is wrongly interpreted as frames instead of integrator steps in various places:

Background

From readdcd.h:

/*
 * Read the header information from a dcd file.
 * Input: fd - a file struct opened for binary reading.
 * Output: 0 on success, negative error code on failure.
 * Side effects: *natoms set to number of atoms per frame
 *               *nsets set to number of frames in dcd file
 *               *istart set to starting timestep of dcd file
 *               *nsavc set to timesteps between dcd saves
 *               *delta set to value of trajectory timestep
 *               *nfixed set to number of fixed atoms 
 *               *freeind may be set to heap-allocated space
 *               *reverse set to one if reverse-endian, zero if not.
 *               *charmm set to internal code for handling charmm data.
 */

https://www.charmm.org/charmm/documentation/by-version/c42b1/params/doc/dynamc/

  1. Query a trajectory file
    TRAJectory QUERy UNIT integer

The query command rewinds an open trajectory file and then reads the header information from this trajectory file. It prints a summary and sets the following command line substitution parameters:

  • 'NFILE' - Number of frames in the trajectory file
  • 'START' - Step number for the first frame
  • 'SKIP' - Frequency at which frames were saved (NSTEP=NFILE*SKIP when not using restart files)
  • 'NSTEP' - Total number of steps from the simulation
  • 'NDEGF' - Number of degrees of freedom from the simulation (Can be use to get the temperature with velocity files).
  • 'DELTA' - The dynamics step length (in picoseconds).

Currently version of MDAnalysis:

(run python -c "import MDAnalysis as mda; print(mda.__version__)")

develop

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions