apply selection and scaling with current box after delta in jumps has been cached or calculated directly. this should fix using nojump on NPT simulations #6

Open
robin wants to merge 2 commits from fix/nojump_and_npt_caching into main
Member

Analysing NPT simulations with .nojump lead to wrong coordinates. The issue was that caching was the default and that the cached values were already multiplied by the box matrix for the requested frame. Since box sizes change during NPT, using the cached result lead to accumulating displacements.
The new version simply does the multiplication afterwards and the cache only saves the delta in raw jumps.

Code to test this is with the old version before this fix:

import mdevaluate as md
traj = md.open('/data/robin/sim/fst_tip4p2005/T170_tb_q-14_P-850_NPT', trajectory='out/traj.xtc')
nojump = traj.nojump
last0 = nojump[-1] # result for no cache yet
[nojump[i] for i in range(0,len(nojump), 10)] # fill cache and accumulate mistakes
last1 = nojump[-1] # wrong result
del nojump.frames._nojump_cache # reset cache
last2 = nojump[-1] # again result for no cache

print((last0 == last2).all()) # should be True
print((last1 == last2).all()) # should be False in the old version and True in the new one

Analysing NPT simulations with .nojump lead to wrong coordinates. The issue was that caching was the default and that the cached values were already multiplied by the box matrix for the requested frame. Since box sizes change during NPT, using the cached result lead to accumulating displacements. The new version simply does the multiplication afterwards and the cache only saves the delta in raw jumps. Code to test this is with the old version before this fix: import mdevaluate as md traj = md.open('/data/robin/sim/fst_tip4p2005/T170_tb_q-14_P-850_NPT', trajectory='out/traj.xtc') nojump = traj.nojump last0 = nojump[-1] # result for no cache yet [nojump[i] for i in range(0,len(nojump), 10)] # fill cache and accumulate mistakes last1 = nojump[-1] # wrong result del nojump.frames._nojump_cache # reset cache last2 = nojump[-1] # again result for no cache print((last0 == last2).all()) # should be True print((last1 == last2).all()) # should be False in the old version and True in the new one
robin added 1 commit 2025-08-09 14:19:52 +00:00
markusro was assigned by robin 2025-08-09 14:20:01 +00:00
robin added 1 commit 2025-08-14 14:33:42 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/nojump_and_npt_caching:fix/nojump_and_npt_caching
git checkout fix/nojump_and_npt_caching
Sign in to join this conversation.
No description provided.