-
Notifications
You must be signed in to change notification settings - Fork 4
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
waterdynamics does NOT respect PBC #19
Comments
Hi @JosipL I'm not very familiar with the code for |
@alejob could you please look into this question regarding waterdynamics? |
Hi, |
Sorry my mentioning the dipole moment was just an example. The same applies to the OH and HH vectors - if they're split across a periodic boundary in a given dimension, then their length will be approximately equal to the length of that dimension, and the orientation will be in the plane of that dimension. For your similar system, had you already made the molecules whole, using e.g. gromacs trjconv? If so then there would be no molecules split across periodic boundaries and you wouldn't see this artefact. Looking at the code for AngularDistribution I think this is indeed the issue:
So periodic boundaries are not being considered here, and there is no option to do so. Until there is a fix for this, the easiest solution might be to make your molecules whole, either using gromacs or an on-the-fly transformation in MDAnalsis (see here for details of this and Example 1 for how to make your molecules whole: https://www.mdanalysis.org/2020/03/09/on-the-fly-transformations/ although currently this will probably be quite slow to make all of your water molecules whole at each frame). |
Thanks for your time. You were right. PBC was the issue. |
Hi Paul,
Thanks for the detailed analysis (and solving the problem!). Would you mind raising an issue for the lack of PBC awareness in the AngularDistribution code? Just pointing someone to the problematic code might motivate someone to fix the code.
On that note: do we have a library function to make vectors conform to minimum-image (similar to what calc_bonds() does internally)?
Oliver
… On Nov 12, 2021, at 2:41 AM, Paul Smith ***@***.***> wrote:
Looking at the code for AngularDistribution <https://github.com/MDAnalysis/mdanalysis/blob/develop/package/MDAnalysis/analysis/waterdynamics.py#L652-L661> I think this is indeed the issue:
OHVector0 = H1t0 - Ot0
HHVector0 = H1t0 - H2t0
dipVector0 = (H1t0 + H2t0) * 0.5 - Ot0
unitOHVector0 = OHVector0 / \
np.linalg.norm(OHVector0, axis=1)[:, None]
unitHHVector0 = HHVector0 / \
np.linalg.norm(HHVector0, axis=1)[:, None]
unitdipVector0 = dipVector0 / \
np.linalg.norm(dipVector0, axis=1)[:, None]
So periodic boundaries are not being considered here, and there is no option to do so.
--
Oliver Beckstein (he/his/him)
email: ***@***.***
twitter: @orbeckst
MDAnalysis – a NumFOCUS fiscally sponsored project
https://www.mdanalysis.org/
|
I renamed the issue and update the report. If someone gets to adding PBC to waterdynamics please reference this issue. |
Sorry for not getting back to you - things have been quite hectic. If no one gets around to fixing it by next week then I should have some time then to do it. Would it be okay to call calc_bonds() directly, or would there be a better way to do it? |
@p-j-smith I've implemented the function I suspect you need over in MDAnalysis/mdanalysis#3472 |
Thanks @richardjgowers ! |
(EDIT): The original issue report (see below) indicates that analysis.waterdynamics required PBC-remapped trajectories, which is apparently not clear from the docs. More generally, it should be able to deal with trajectories under PBC directly.
Expected behavior
Hi,
First, I am not sure if this is bug, I just think it is :).
I am using MDAnalysis AngularDistribution library to analyze some water/organic systems. Code produce figure without error but I get a strange peak around costheta=0 for all try types of vectors. I do not expect this peak.
Is due to some 0 dividing? Any ideas?
Code to reproduce the behavior
Current version of MDAnalysis
x
The text was updated successfully, but these errors were encountered: