Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nongaussian parameter #3896

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Conversation

jaclark5
Copy link
Contributor

@jaclark5 jaclark5 commented Oct 29, 2022

Fixes #3895

Changes made in this Pull Request:

  • Added second order nongaussian parameter to simple msd algorithm.

Tests were added to existing msd tests, but here a comparison of TIP4P2005 water at 300K is compared to the published result [DOI: 10.1073/pnas.1900239116].

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

pnas 1900239116
msd_alpha_tip4p2005_10

@codecov
Copy link

codecov bot commented Oct 29, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.59%. Comparing base (cfa4438) to head (6d91004).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3896      +/-   ##
===========================================
- Coverage    93.60%   93.59%   -0.01%     
===========================================
  Files          171      183      +12     
  Lines        21235    22316    +1081     
  Branches      3933     3938       +5     
===========================================
+ Hits         19876    20886    +1010     
- Misses         899      971      +72     
+ Partials       460      459       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hmacdope
Copy link
Member

@jaclark5, very exciting. I'll need to read the paper and understand the equations first. I'll try and get to it by the end of the week.

package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! A few comments, main one is to make calculating non-gaussian parameter switchable with a kwarg to reduce unnecessary computation if the user doesn't want it.

@@ -267,6 +268,10 @@
class EinsteinMSD(AnalysisBase):
r"""Class to calculate Mean Squared Displacement by the Einstein relation.

If `fft=False` so that the "windowed" algorithm is used, the second order
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to make the parameter an optional addition to the fft=False run. MSDs are already expensive (esp without an FFT) and tacking on more compulsory computation is not ideal. Much better to have it as an optional kwarg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, that also begs the question on whether this package will move toward cython modules?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the MSD package? There is likely some benefit there. We are generally encouraging of Cython contributions and have a bunch of extensions already written in Cython.

If you go down the cython side and need a hand feel free to ping. See setup.py for the minimal setup for a cython extension.

package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, see my comments.

package/MDAnalysis/analysis/msd.py Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, looking really good.

A selection string. Defaults to "all" in which case
all atoms are selected.
msd_type : {'xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z'}
msd_type : {'xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z'} (optional)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, idk what other people would say but personally I wouldn't say optional because has a default and will raise exception otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually changed the doc string to include the dtype instead of the allowed options. As for the use of optional, let me know what you want, but I thought the fact that it's a keyword argument with a default is what makes this an optional input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JK I realized that listing the options is a convention in MDAnalysis

package/MDAnalysis/analysis/msd.py Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/msd.py Outdated Show resolved Hide resolved
testsuite/MDAnalysisTests/analysis/test_msd.py Outdated Show resolved Hide resolved
@jaclark5 jaclark5 requested a review from hmacdope November 29, 2022 02:50
@jaclark5 jaclark5 marked this pull request as draft December 10, 2022 13:57
@hmacdope
Copy link
Member

Sorry @jaclark5 I'll try and get to this ASAP. I just need to read some theory first. 😅

@jaclark5
Copy link
Contributor Author

jaclark5 commented Jan 20, 2023

Really don't worry about it, I downgraded this PR to a draft to look into use of cython. I have three other PRs that are closer to being done and I think more impactful:
3905 Gyration moments
3849 Generalize continuous check in chain trajectory
3834 Ensure Timestep in ChainReader is updated for multiple trajectory files

Conflicts:
	package/CHANGELOG
	package/doc/sphinx/source/references.bib
@jaclark5 jaclark5 marked this pull request as ready for review April 2, 2023 13:46
@hmacdope
Copy link
Member

hmacdope commented Jul 1, 2023

@jaclark5, lets not let this fantastic PR go stale, was there any more you were planning to add or should I review?

@hmacdope
Copy link
Member

hmacdope commented Oct 2, 2023

@jaclark5 bump, there is also the option to move this to the transport-analysis MDAKit https://github.com/MDAnalysis/transport-analysis

Conflicts:
	package/CHANGELOG
	package/MDAnalysis/analysis/msd.py
@pep8speaks
Copy link

pep8speaks commented Oct 15, 2023

Hello @jaclark5! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 276:74: W291 trailing whitespace
Line 277:76: W291 trailing whitespace
Line 278:26: W291 trailing whitespace
Line 281:1: W293 blank line contains whitespace
Line 282:80: E501 line too long (94 > 79 characters)
Line 283:80: E501 line too long (91 > 79 characters)
Line 313:73: W291 trailing whitespace
Line 316:68: W291 trailing whitespace
Line 327:72: W291 trailing whitespace
Line 355:77: W291 trailing whitespace
Line 438:68: W291 trailing whitespace

Comment last updated at 2024-07-02 12:50:20 UTC

@github-actions
Copy link

github-actions bot commented Oct 15, 2023

Linter Bot Results:

Hi @jaclark5! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ⚠️ Possible failure

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/9761280912/job/26941963713


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

@orbeckst
Copy link
Member

@hmacdope can I please assign you to manage the PR? If this doesn't work for you please unassign yourself and let me know. Thanks!

@hmacdope
Copy link
Member

@jaclark5 are you still interested in pursuing this PR?

@jaclark5
Copy link
Contributor Author

@hmacdope, it's ready to go here and I'm open to moving forward with it. However, isn't it the main developers' preference that it be incorporated into an MDAkit?

@hmacdope
Copy link
Member

hmacdope commented Jul 2, 2024

@jaclark5 I think the way forward here will be to migrate this to transport-analysis MDAKit? Are you happy with that?

@jaclark5
Copy link
Contributor Author

jaclark5 commented Jul 9, 2024

That's fine. I did take a quick look at that and it's rougher than I thought. The existing MSD functionality isn't there yet. Is there a plan to have the existing msd tool contents moved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Second order nongaussian parameter
5 participants