Hi all,
I'm doing umbrella sampling using a large system (~420,000 particles).
I'd like to record the position of one particle representing the umbrella as efficiently and as frequently as possible.
DCDReporter is quite slow for frequent writing, and I am not interested in frequently writing the position of all atoms in the system.
DCDReporter does "self._dcd.writeModel(state.getPositions(), periodicBoxVectors=state.getPeriodicBoxVectors())" to get the positions to pass to DCDfile.
However, might there be a way to write the position of one (or a subset) of particles in the system without accessing state? Or would it be about as fast as possible to just modify this line in DCDReporter to only access the atom index or indices of interest?
Record xyz coordinates of one particle quickly?
- George Pantelopulos
- Posts: 64
- Joined: Mon Jun 01, 2015 2:15 pm
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Record xyz coordinates of one particle quickly?
There's two parts to this: getting the positions from the context, and saving them. There's no other way to get positions than calling getState() (short of writing a plugin, anyway), and it always retrieves every particle. But the cost of writing them to disk of course scales with the number you're writing, so writing just one position will be faster than writing all of them.
The one other optimization I'd suggest is calling state.getPositions(asNumpy=True). Getting the positions as a Numpy array is faster than getting them as a list of Vec3s.
The one other optimization I'd suggest is calling state.getPositions(asNumpy=True). Getting the positions as a Numpy array is faster than getting them as a list of Vec3s.
- George Pantelopulos
- Posts: 64
- Joined: Mon Jun 01, 2015 2:15 pm
Re: Record xyz coordinates of one particle quickly?
Hi Peter,
Doing this with state.getPositions(asNumpy=True) is quite fast! I don't notice any loss in speed.
Thank you once again.
Doing this with state.getPositions(asNumpy=True) is quite fast! I don't notice any loss in speed.
Thank you once again.