velocities not written to DCD
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
velocities not written to DCD
Hi, here I am again.
I am trying to use MDTraj's dcdreporter to write both coordinates and velocities to a trajectory. I am using this tool:
https://mdtraj.org/1.9.3/api/generated/ ... ctory%20to.
I set velocitiesbool to True but the velocities are not written to the DCD file.
How can I fix this?
I am trying to use MDTraj's dcdreporter to write both coordinates and velocities to a trajectory. I am using this tool:
https://mdtraj.org/1.9.3/api/generated/ ... ctory%20to.
I set velocitiesbool to True but the velocities are not written to the DCD file.
How can I fix this?
- Peter Eastman
- Posts: 2583
- Joined: Thu Aug 09, 2007 1:25 pm
Re: velocities not written to DCD
I think the docs rendering is messed up. The parameter is called "velocities", not "velocitiesbool". It's leaving out the space between the name and type.
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
Re: velocities not written to DCD
Oh ok. Thank you. I thought there was something odd about the naming!
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
Re: velocities not written to DCD
An update: I tried "velocities" and while it successfully sets the parameter to True (checked vars()), velocities are still not written. Is it possible that the MDTraj DCDReporter hasn't implemented velocity writing yet and the documentation is ahead of the code? Should I just use DCDReporter from the main OpenMM tools?
- lewis martin
- Posts: 63
- Joined: Tue Mar 06, 2018 8:56 pm
Re: velocities not written to DCD
DCD files don't specify velocities - the `velocities: bool` in the MDTraj docs was probably intended for the other reporters like HDF5Reporter or NetCDFReporter, either of which can store velocities. So if you wanted to store the velocities alongside the trajectory, use one of those. But if you're stuck with DCD, then you'll need to record the velocities elsewhere.
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
Re: velocities not written to DCD
It seems the MDtraj netcdf reporter can't write velocities. Is the MDTraj/OpenMM team planning to add velocities to this tool soon?
- lewis martin
- Posts: 63
- Joined: Tue Mar 06, 2018 8:56 pm
Re: velocities not written to DCD
My bad, looks like AMBER can write velocities to a netcdf file ( https://ambermd.org/FileFormats.php#trajectory ) but perhaps the MDTraj NetCDF writer doesn't do a similar thing since I see no mention of 'velocities' in the code: https://github.com/mdtraj/mdtraj/blob/m ... /netcdf.py
You know, looking at the mdtraj 'Trajectory' object, it doesn't even let you access velocities anyway. So how about this:
use hdf5reporter, setting both 'coordinates' and 'velocities' to True. If you want to visualize the trajectory, load the trajectory with mdtraj (i.e. `traj = load_hdf5('my_traj.h5')` ) and then save it as a DCD to view with VMD or whatever ( `traj.save('my_traj.dcd')` ) .
Next, to load the velocities:
You'll need to install h5py to read the .h5 file.
You know, looking at the mdtraj 'Trajectory' object, it doesn't even let you access velocities anyway. So how about this:
use hdf5reporter, setting both 'coordinates' and 'velocities' to True. If you want to visualize the trajectory, load the trajectory with mdtraj (i.e. `traj = load_hdf5('my_traj.h5')` ) and then save it as a DCD to view with VMD or whatever ( `traj.save('my_traj.dcd')` ) .
Next, to load the velocities:
Code: Select all
vel = h5py.File('my_traj.h5', 'r')
velocities = vel['velocities'][:]
vel.close()
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
Re: velocities not written to DCD
I tried the advice above with hdf5 reporter and the even though i said velocities = True, the hdf5 file doesn't have velocities, only coordinates. Is it possible that mdtrajreporters.hdf5reporter just hasn't implemented velocity writing yet, despite the documentation? It would be really great if OpenMM had a straightforward way to save velocities like what AMBER has.
- Peter Eastman
- Posts: 2583
- Joined: Thu Aug 09, 2007 1:25 pm
Re: velocities not written to DCD
I would try posting on the MDTraj github. If their documentation is incorrect it should be fixed. But more likely there's some other reason it isn't giving you velocities.
- Daniel Konstantinovsky
- Posts: 77
- Joined: Tue Jun 11, 2019 12:21 pm
Re: velocities not written to DCD
Update: velocities are included if velocities=True is specified when initializing the reporter, but not if reporter.velocities = True is set later.