Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The rules for this file:
* 2.11.0

Fixes
* Fixes msd for non-linear frames, when non_linear is not explicitly
provided (Issue #5100, PR #5254)
* Fixes TypeError with np.int64 indexing in GSD Reader (Issue #5224)
* Fixed bug in add_transformations allowing non-callable transformations
(Issue #2558, PR #2558)
Expand Down
7 changes: 6 additions & 1 deletion package/MDAnalysis/analysis/msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ def _single_frame(self):
]

def _conclude(self):
if self.non_linear:
delta_time = np.diff(self.times)

if self.non_linear or (
len(delta_time) > 1
and not (np.allclose(delta_time, delta_time[0]))
):
self._conclude_non_linear()
else:
if self.fft:
Expand Down
15 changes: 15 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1848,3 +1848,18 @@ def test_start_stop_step(self, u_nonlinear):
assert_allclose(
result_msd_per_particle, expected_msd_per_particle, rtol=1e-5
)

def test_detect_non_linear_from_frames(self, step_traj):
msd_auto = MSD(step_traj, select="all", msd_type="xyz", fft=False)
res1 = msd_auto.run(frames=[0, 1, 3, 6])

msd_explicit = MSD(
step_traj, select="all", msd_type="xyz", non_linear=True
)
res2 = msd_explicit.run(frames=[0, 1, 3, 6])

assert_allclose(
res1.results.msds_by_particle,
res2.results.msds_by_particle,
rtol=1e-5,
)
Loading