Skip to content

Commit

Permalink
Add progress bars to _conclude in MSD analysis (#4072)
Browse files Browse the repository at this point in the history
* add progress bars

* update pbar maxval

* fix format

* use tqdm

* move import of tqdm up

* changelog

* author and changelog

* Update package/CHANGELOG

Co-authored-by: Hugo MacDermott-Opeskin <hugomacdermott@gmail.com>

---------

Co-authored-by: SophiaRuan <xiaoxu_ruan@berkeley.edu>
Co-authored-by: Hugo MacDermott-Opeskin <hugomacdermott@gmail.com>
  • Loading branch information
3 people authored Mar 29, 2023
1 parent 1207578 commit 75f0fb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Chronological list of authors
- Ahmed Salah Ghoneim
- Alexander Schlaich
- Josh Vermaas
- Xiaoxu Ruan

External code
-------------
Expand Down
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The rules for this file:

??/??/?? IAlibay, pgbarletta, mglagolev, hmacdope, manuel.nuno.melo, chrispfae,
ooprathamm, MeetB7, BFedder, v-parmar, MoSchaeffler, jbarnoud, jandom,
xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00, schlaicha
xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00, schlaicha, SophiaRuan
* 2.5.0

Fixes
Expand Down Expand Up @@ -49,6 +49,8 @@ Enhancements
and SegmentGroup. (PR #3953)

Changes
* Add progress bars to track the progress of _conclude() functions
(_conclude_simple() and _conclude_fft()) in msd.py (Issue #4070, PR #4072)
* As per NEP29 the minimum supported NumPy version has been raised to 1.21
(note: in practice later versions of NumPy may be used depending on your
architecture, operating system, or Python version) (PR #3983)
Expand Down
5 changes: 3 additions & 2 deletions package/MDAnalysis/analysis/msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
from ..due import due, Doi
from .base import AnalysisBase
from ..core import groups
from tqdm import tqdm

logger = logging.getLogger('MDAnalysis.analysis.msd')

Expand Down Expand Up @@ -387,7 +388,7 @@ def _conclude_simple(self):
"""
lagtimes = np.arange(1, self.n_frames)
positions = self._position_array.astype(np.float64)
for lag in lagtimes:
for lag in tqdm(lagtimes):
disp = positions[:-lag, :, :] - positions[lag:, :, :]
sqdist = np.square(disp).sum(axis=-1)
self.results.msds_by_particle[lag, :] = np.mean(sqdist, axis=0)
Expand All @@ -411,7 +412,7 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required.
or set fft=False""")

positions = self._position_array.astype(np.float64)
for n in range(self.n_particles):
for n in tqdm(range(self.n_particles)):
self.results.msds_by_particle[:, n] = tidynamics.msd(
positions[:, n, :])
self.results.timeseries = self.results.msds_by_particle.mean(axis=1)

0 comments on commit 75f0fb9

Please sign in to comment.