-
Notifications
You must be signed in to change notification settings - Fork 647
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
Fix for issue #3383 triclinic lammpsdump #3403
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3403 +/- ##
===========================================
+ Coverage 94.11% 94.15% +0.03%
===========================================
Files 190 190
Lines 24654 24659 +5
Branches 3309 3309
===========================================
+ Hits 23204 23217 +13
+ Misses 1404 1396 -8
Partials 46 46
Continue to review full report at Codecov.
|
Sorry @Agorfa, I am trying to triage and get to this ASAP. |
Hey @hmacdope no problem, thanks so much! With triaging you mean the failing checks or the issue this pr is concerned with? These checks for python builds 3.7+ all fail due to not having permission to read 'C:\Users\VssAdministrator\AppData\Local\Temp\pytest-of-VssAdministrator\pytest-0\popen-gw1\test_write_with_drivers_core_0h5md-writer-test.h5md' which should be something unrelated!? For the actual issue I couldnt find versions older than 2019 of lammps to see if this has always been their way of dumping boxes. |
@Agorfa for the H5MD failures, if you could update your branch against develop that should be fixed now. |
Sorry @Agorfa, by triage I meant hopefully move up my priority list. :) Don't worry about the CI failures, they are unrelated as @IAlibay has just pointed out as I write this. :) |
Ah ok awesome :) Will do! |
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.
Just an initial quick review, it'd be really useful if you could add some tests that cover the use case being covered.
@@ -560,10 +560,15 @@ def _read_next_timestep(self): | |||
|
|||
triclinic = len(f.readline().split()) == 9 # ITEM BOX BOUNDS | |||
if triclinic: | |||
xlo, xhi, xy = map(float, f.readline().split()) | |||
ylo, yhi, xz = map(float, f.readline().split()) | |||
xlo_bound, xhi_bound, xy = map(float, f.readline().split()) |
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.
Would it be possible to add a relevant test (maybe based on the issue this aims to fix) that covers these lines?
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.
Ah of course, I can write a test that reads in a triclinic box. This would test that it doesnt fail. Testing that the actual issue would be resolved is difficult/impossible?. I think one would have to create a triclinic box in lammps, then actually run lammps and read the output to see if the dimensions are the same.
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.
So here that's what we would require to do - create a triclinic box in lammps and then check that we reproduce expected outcomes (calculated by hand and/or comparing to a lammps output).
If we can't do such a correctness check then we might have to discuss further whether or not we can offer this option.
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 have a first correctness check here:
triclinic_lammps_2021_09_02.zip
I use the values from the input data file for lammps that require xlo, xhi etc. directly and compare those dimensions to the ones imported from the lammpsdump file of the same system:
import MDAnalysis as mda
import numpy as np
from MDAnalysis.lib import mdamath
u = mda.Universe("dump.atom", topology_format='LAMMPSDUMP')
## Direct values from lammps data file
xlo = -0.32115478301032807
xhi = 16.831069399898624
ylo = -0.12372358703610897
yhi = 25.95896427399614
zlo = -0.045447071698045266
zhi = 12.993982724334792
xy = 1.506743915478767
xz = - 6.266414551929444
yz = - 0.42179319547892025
box = np.zeros((3, 3), dtype=np.float64)
box[0] = xhi - xlo, 0.0, 0.0
box[1] = xy, yhi - ylo, 0.0
box[2] = xz, yz, zhi - zlo
direct_dimensions = mdamath.triclinic_box(*box)
print(direct_dimensions == u.dimensions)
resulting in the same dimensions
[ True True True True True True]
Would this be sufficient? Should I then write this procedure into a test file or what would be the best practice for testing specifications set in other software?
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.
You can write something like this into the testsuite! the relevant file is here.
You will need to learn a bit of pytest, and use the text fixtures but hopefully the file is commented enough to be comprehensible. The numpy testing functions will be very helpful. See here for how to run the testsuite.
If you need to add an additional file to the test data, please do add it to the mdanalysis/testsuite/MDAnalysisTests/data/lammps
folder and import it in
mdanalysis/testsuite/MDAnalysisTests/datafiles.py
I am going to tag @richardjgowers in case I am missing something about ortho
vs triclinic
in MDA/LAMMPS here?
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.
Ah awesome thank you! I will get the keywords you recommended and then write it up in there!
Note we should also improve checking for keywords in the |
Sorry for the spam, but it might be good to use the |
Ah thats a good idea! I will do a short simulation with these keywords |
Hello @Agorfa! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-03-23 01:39:02 UTC |
7166179
to
5c10286
Compare
Just ping me when you want a review @Agorfa 👍 |
Hey @Agorfa, any progress on this? No rush, but I think it would be good to fix this up so that LAMMPs users are getting the right triclinic boxes. :) I'm happy to contribute code and/or discuss if anything is unclear. |
Hey @hmacdope! Sorry, it has really been on my mind but I didnt do all that much yet.. Yes, I think it would be really good to finish this. I will try to make good progress this week! |
No rush :) Only when you have time 👍 |
Hey @hmacdope, at long last, I finally have something new to show. In my test I compare the boxes between a .dump file to the .data file to my expectation, all for the same system. Is this ok? |
Hi @Agorfa thank you! This seems like the right approach to me. :) I will leave a detailed review soon. |
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.
Hi @agorfa looking really good! Just a few nitpicks here and there.
Thanks so much for the review! I will implement it as soon as I can! |
@Agorfa, we would love to get this fixed soon if you are interested in continuing this PR. :) |
Hi @hmacdope ! Yes sry of course I will implement it asap! |
@Agorfa no need to apologise! We are super grateful for the contribution. :) |
Hey I implemented your conversations! I dont understand why codecov/project complains :S |
@orbeckst I would love a second set of eyes on this box math |
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 only reviewed the triclinic math. This all looks good to me so I approve. Thank you for your contribution!
Please update the docs for the LAMMPS reader to note that triclinic boxes are read and link to the LAMMPS documentation.
I am leaving it to @hmacdope and @IAlibay to also make sure that you also add yourself to AUTHORS and include a CHANGELOG entry.
Thanks @orbeckst! @Agorfa, would you be able to update the docs as suggested and add yourself to AUTHORS and an entry to CHANGELOG please? Then we will be ready to merge. 🥇 |
@Agorfa we're trying to get a means of contacting folks in the future as we consider changing the MDAnalysis license. Could you please send an email to the MDAnalysis developer list introducing yourself (with your GitHub handle) before we merge this PR? |
Hey everyone! Thanks so much for your guidance! I wrote docs, changelogs and authors. I'm not sure about the .. versionchanged:: 2.2.0 I added I guessed it is helpful for some users? I hope everything else is at the right place |
Hey @IAlibay of course I just sent it! |
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.
This all looks good to me with CHANGELOG and CONTRIBUTORS updated along with adequate docs Thanks so much for your contribution @Agorfa. Have I missed anything @IAlibay?
Should be resolved! |
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.
Just a couple of small things, please do address. I'll give this an approval so my review isn't blocking.
length unit (Å), and angles are in degrees. | ||
|
||
.. versionchanged:: 2.2.0 | ||
Triclinic simulation boxes are supported. (Issue #3383) |
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 might be good to make that issue number a link to the actual issue.
Ah sorry thanks I got confused with the order when I resolved the conflict.. I also made the link and pep8 seems happy |
Congratulations @Agorfa! We appreciate your contribution. |
Thank you for your contribution @Agorfa , well done! I hope you feel encouraged to contribute more in the future! |
Fixes #3383
Changes made in this Pull Request:
PR Checklist