Unrecognized DCD header in CP2K

DCD files are quite versatile but suffer from nearly non-existing documentation. They can hold atomic coordinates, velocities and forces - all designated by a different DCD file header: CORD, VEL, FRC. CP2K allows the user to write out all the aforementioned information for a trajectory, but many software packages have limited support for reading forces and velocities from DCD files, mostly, because they use the original source from VMD which only reads coordinates. The ones I tested are VMD/catdcd, mdtraj, and MDAnalysis. The typical error message would be:

CatDCD 4.0
dcdplugin) unrecognized DCD header:
dcdplugin)   [0]: 1409286144  [1]:  541282886
dcdplugin)   [0]: 0x54000000  [1]: 0x20435246
dcdplugin) read_dcdheader: corruption or unrecognized file structure
Error: could not open file 'for-frc-1.dcd' for reading.

If the header is "wrong" in the sense that the bytes read "FRC" instead of "CORD", you can either change this in a hex editor (make sure you do not insert bytes to the file) or you can use the dumpdcd tool in CP2K.
Update, 04.02.2016
Please use the updated version of dumpdcd.f90. The author of the tool, Matthias Krack, has updated the code such that no patching is necessary. Thank you!

Only if you happen to be stuck with former versions (CP2K svn revision < 16559) for whatever reason, feel free to follow this approach: It is in the cp2k/tools folder and needs a bit of patching first: open dumpdcd.f90, and find line 443: [code]ELSE IF (TRIM(ADJUSTL(id_dcd)) == "CORD") THEN[/code] and exchange "CORD" for "FRC". Then add the following line in the IF branch. [code]id_dcd = "CORD"[/code] Now compile and you can write new DCD files from them: [code]./dumpdcd -i -o output.dcd -of dcd input.dcd[/code] The resulting DCD file has the "CORD" header and can be read by any of the tools mentioned above.

You may also like...

2 Responses

  1. Matthias says:

    This command line does the job without changing the dumpdcd code:

    dumpdcd -o new.dcd -of dcd -vel2cord old.dcd

    or

    dumpdcd -o new.dcd -of dcd -frc2cord old.dcd

    (dump old.dcd as new.dcd and change only the DCD id string from VEL/FRC to CORD)

    Use

    dumpdcd -h

    to print help info.

    • Guido says:

      Thank you for extending the functionality of your tool! This helps a lot. I updated the text to reflect this.

Leave a Reply

Your email address will not be published.