-
Notifications
You must be signed in to change notification settings - Fork 657
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
Restructured WaterOrientationalRelaxation #3247
Restructured WaterOrientationalRelaxation #3247
Conversation
Hello @PicoCentauri! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-04-30 21:06:00 UTC |
417e20e
to
a104835
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3247 +/- ##
===========================================
+ Coverage 92.81% 92.84% +0.03%
===========================================
Files 170 170
Lines 22801 22810 +9
Branches 3239 3241 +2
===========================================
+ Hits 21162 21179 +17
+ Misses 1591 1583 -8
Partials 48 48 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few drive-by copy edit and test suggestions, but maybe you want to avoid adding more changes to keep the diff small for now.
Are these changes are backwards-compatible? |
In some way:
|
It sounds as if these changes get an entry under "Fixes" in the CHANGELOG. Then this PR can go in anytime after 2.0.0. |
@alejob could you please review this PR? Thanks! |
Hi there!
edit: Ok, I see that it has a new name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure yet if dtmax
is the same as step
— @alejob I'd be grateful for a quick explanation (see comments).
We did not announce/deprecate these changes in 1.x so we have to provide ways to use the old usage during 2.x.
.. versionchanged:: 2.0.0 | ||
`t0`, `tf` and `dtmax` are renamed to start, stop, step as attributes | ||
of the `run` method providing a consistent behaviour with other | ||
modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did not deprecate t0, tf, dtmax in 1.1.1 — they are still all documented as standard
mdanalysis/package/MDAnalysis/analysis/waterdynamics.py
Lines 685 to 696 in 1e456e8
frame where analysis begins | |
tf : int | |
frame where analysis ends | |
dtmax : int | |
Maximum dt size, `dtmax` < `tf` or it will crash. | |
.. versionadded:: 0.11.0 | |
.. versionchanged:: 1.0.0 | |
Changed `selection` keyword to `select` | |
""" |
This means that for 2.x, it still needs to be possible to use the old code. But you can make them optional kwargs
def __init__(self, universe, select, t0=None, tf=None, dtmax=None):
If they are not None, issue a deprecation warning. Fail with TypeError("If the deprecated t0, tf, and dtmax are used, all of them are required")
if not all three of them are set (as the original code would have done).
You might have to subclass run()
to substitute t0, tf, dtmax for start, stop, step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If run()
replaces start/stop/step then issue a deprecation warning, too.
""" | ||
|
||
def __init__(self, universe, select, t0, tf, dtmax, nproc=1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document removal of nproc
as a versionchanged ("Removed optional nproc
kwarg that was not used.") and in CHANGELOG Changes.
I think we can get away without deprecations for this one.
|
||
def _get_repeated_indices(self, selection, frame): | ||
""" | ||
Indicates the comparasion between the current frame and all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison
a unit vector along HH, OH or dipole vector. | ||
|
||
where :math:`P_2=(3x^2-1)/2` is the second-order Legendre polynomial | ||
and :math:`\hat{u}` is a unit vector along HH, OH or dipole vector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a warning that this class assumes a 3-point water model where each water residue contains O as the first entry and hydrogen 1 and 2 as second and third entry.
This warning should have been here from the beginning. Even better would be a more robust approach to choosing O and H1, H2 but that's not the job of this PR.
|
||
for j in range(totalFrames // dt - 1): | ||
a = self._getOneDeltaPoint(universe, repInd, j, sumsdt, dt) | ||
for i in range(self.start, self.stop // self.frame - 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why self.stop // self.frame - 1
. Can you add a comment here explaining what this loop does?
dtmax : int | ||
Maximum dt size, `dtmax` < `tf` or it will crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alejob what is dtmax
supposed to be doing?
Is it the same as a stride when you subselect frames from a trajectory as in trajectory[start:stop:step]
? If not, please explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not the same as trajectory[start:stop:step].
First, we need to define dt
. dt
is the delta time in which WOR is calculated. For instance, if dt=5
this means that WOR will be calculated comparing frame 1 with frame 5, and then comparing frame 6 with 10, then 11 with 15, and so on. Then we get the mean of these values and get the final value for dt=5
. If dt=8
, WOR will be calculated between frame 1 and frame 8, between 9 and 16 and repeat all the process. Now, dtmax
indicates the maximum value that dt
could have, and indicates that all the minor dt
will be calculated, in other words, if you plot the output of this analysis, dtmax
is the maximum value of the x
axis.
Here an example modified from the docs:
If you have that t0 = 0
, tf = 1000
and dtmax = 20
, we create 20 windows
timesteps (20 values in the x axis), the first window is created with 1000
timestep average (1000/1), the second window is created with 500 timestep
average(1000/2), the third window is created with 333 timestep average (1000/3)
and so on. Obtaining the mean of many timesteps gives us a better statistic for the WOR value, i.e, a smoother curve.
Because of this to fix dtmax
in dtmax=2
has non sense, dtmax
should be chosen by the user.
@PicoCentauri is this PR something you might want to come back to? |
Currently, I have to no time to look into this in great details. When we had the last round of nice feedback I had the feeling that the current state of the class is physically broken and that a transition to the AnalysisBase is not as straightforward as I thought in the beginning. |
@PicoCentauri this is on the 2.2.0 milestone, from this comment shall I assume that this is not going to make it? (I've not been keeping up with the review comments sorry). If so, which future milestone shall I add this to? 2.3.0 or 3.0.0? |
Probabaly 3.0.0 |
Partly Fixes MDAnalysis/waterdynamics#22
Changes made in this Pull Request:
The
WaterOrientationalRelaxation
was restructured to follow thestart
,stop
andstep
attributes of theAnalysisBase
.The documentation was also improved and the example was adjusted to a pure water system. I also moved everything
into the class documentation.
It seems that the results after my restructuring are okay but maybe somebody who knows how these correlation function should look takes a look at the results.
PR Checklist