DCD file reader
For loading molecular dynamics trajectories stored in the binary DCD format,
which originates from the X-PLOR and CHARMM simulation packages and is written by
NAMD, LAMMPS (dump dcd command),
CP2K, and many other simulation and trajectory-processing codes.
The file reader handles both the X-PLOR and the CHARMM flavor of the format.
A DCD file stores only the time-dependent atomic coordinates of a simulation, but no static information such as atom names, chemical elements, atom types, or bond connectivity. Simulation codes therefore write a separate topology file alongside the DCD trajectory file, e.g. a PDB file (NAMD, CHARMM) or a LAMMPS data file. To visualize such a trajectory in OVITO, first load the topology file using the corresponding file reader (e.g. PDB file reader or LAMMPS data file reader), then insert the Load trajectory modifier into the pipeline and let it load the DCD file. The modifier replaces the static positions from the topology file with the time-dependent positions read from the DCD file. Since DCD files contain no atom identifiers, the modifier assumes that the storage order of atoms is the same in both files.
You can also open a DCD file directly in OVITO without a topology file. The trajectory is then displayed as a set of untyped particles.
Imported data
- Header
The reader parses the standard 84-byte DCD header, which begins with the
CORDsignature. Both little-endian and big-endian files are recognized automatically. The CHARMM flavor of the format is detected from the CHARMM version number stored in the header; the time step sizeDELTAis read as a single-precision value from CHARMM files and as a double-precision value from X-PLOR files. The title/remark lines of the file are ignored.- Trajectory frames
Each coordinate set in the file becomes one animation frame in OVITO. The number of frames is determined from the file size rather than from the
NSETheader field, so that files still being written by a running simulation, or files with an incorrect (e.g. zero) frame count, are read correctly. Each frame is labeled with its simulation timestep number, computed from theISTARTandNSAVCheader fields. Frames are accessed by random access, so jumping to an arbitrary frame of a large trajectory file is fast.- Atomic positions
The reader creates the particle property Position from the single-precision x, y, and z coordinate blocks of each frame. This is the only per-atom property stored in a DCD file; no Particle Identifier and no Particle Type property is generated.
- Fixed atoms
CHARMM files with fixed atoms (
NAMNF> 0), in which subsequent frames contain the coordinates of the free atoms only, are supported. The reader merges the coordinates of the fixed atoms taken from the first frame with the free-atom coordinates of the requested frame using the free-atom index list from the file header.- Simulation cell
CHARMM-style files may contain a unit cell record (six double-precision values) preceding the coordinates of each frame. The reader supports the different conventions used by the writing programs to encode the cell shape: cell angles given as cosines (CHARMM, NAMD 2.6 and later), cell angles given in degrees (NAMD 2.5), and the six independent components of a symmetric cell shape matrix (some CHARMM versions). Angle values in the range \([-1,1]\) are interpreted as cosines, and any negative value or an angle exceeding 180° signals the shape matrix representation. The cell parameters are converted to a triclinic simulation cell with periodic boundary conditions enabled in all three directions. The cell vector \(\mathbf{a}\) is aligned with the Cartesian x-axis, \(\mathbf{b}\) lies in the x-y plane, and one corner of the cell is placed at the coordinate origin (see the Center simulation box on coordinate origin option below). The simulation cell may vary from frame to frame.
X-PLOR files and CHARMM files without unit cell record contain no cell information. For such files, OVITO creates no simulation cell unless the Generate bounding box if needed option is enabled.
- Global attributes
The reader creates the global attributes
Timestep(simulation timestep number of the current frame,ISTART+ frame index ×NSAVC) andTime(product of the timestep number and the time step sizeDELTAstored in the file header).Timeis given in the time unit used by the writing program (e.g. AKMA units for CHARMM and NAMD); no unit conversion is performed.
Limitations
Only coordinate files carrying the
CORDsignature are accepted. CHARMM velocity trajectory files (VELDsignature) cannot be loaded.Only files with 32-bit Fortran record markers can be read. DCD files written with 64-bit record markers are rejected as invalid.
Files containing a fourth coordinate dimension (CHARMM 4D flag) are read, but the fourth coordinate block is skipped.
Atom coordinates are always interpreted as Cartesian coordinates in the length unit used by the writing program. No unit conversion takes place.
DCD files provide no atom types, names, or elements. If a DCD file is opened directly, the imported particles have no Particle Type property, and the bond generation function of OVITO is not available for this reader. Use a topology file and the Load trajectory modifier as described above to obtain typed atoms and bonds, or apply the Create bonds modifier.
Compressed (gzipped) DCD files are not supported.
Options
- Generate bounding box if needed
If this option is enabled and the DCD file contains no unit cell record, OVITO generates an axis-aligned bounding box enclosing all atoms of the current frame. This bounding box has open boundary conditions and serves as an approximate simulation cell.
- Center simulation box on coordinate origin
If enabled (the default), OVITO translates the simulation cell and all atom coordinates such that the geometric center of the cell coincides with the coordinate origin. Otherwise, one corner of the cell is placed at the coordinate origin and the atom coordinates are imported as they are stored in the file.
Python parameters
The file reader accepts the following optional keyword parameters in a call to the import_file() or load() Python functions.
- import_file(location, bounding_box=False, centering=True)
- Parameters:
bounding_box (bool) – Generate an ad-hoc simulation cell as a bounding box around the imported atoms when the file contains no unit cell record.
centering (bool) – If set to
True, the simulation cell and all atomic coordinates are translated to center the box at the coordinate origin. If set toFalse, one corner of the simulation cell remains fixed at the coordinate origin.