Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #259 +/- ##
=======================================
Coverage 84.02% 84.02%
=======================================
Files 49 49
Lines 6787 6787
Branches 786 786
=======================================
Hits 5703 5703
Misses 878 878
Partials 206 206
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Hey, thanks for the PR! Can I just double check, was Jakub using the latest ABIN version, i.e. the current master branch? Because I believe I have already fixed this bug when I was updating and testing your original PR, since we were also seeing a blow up when simulating our system (methylhydroperoxide molecule). |
|
according to him, he was. and I actually rerun his experiments on my machine with the latest version as well. could you give it a try yourself? input.in mini.xyz i used |
|
Thank you, I'll test (probably next week since I am out of office). We're using our own trained model so that might be the reason for the different behaviour that we're seeing somehow. |
|
Sorry for the delay, I've finally tested things and I indeed see a blowup with the MACE-OFF23_medium model on master branch, and correct dynamics on this PR. On the other hand, our custom MACE model for the methylhydroperoxide molecule is working on both the master branch and this branch, and I don't yet understand why exactly. The difference seems to be that our model is in dtype=float32 wherease the MACE-OFF23 is in dtype64. Need to think a bit more how that could possibly influence the shape / ordering of things... |
hello,
I was informed by Jakub Vokrouhlicky, that during his experiments with alanine, all the simulations using MACE potential were ending with an explosion.
investigation of the cause confirmed that there is a critical bug in the way forces are transferred between python server and fortran. the bug was missed during reviews due to an unfortunate selection of test molecule and a bug in
HarmonicModel.the bug
the fortran expects matrix in (3, natom) column-major ordered array$\big[F_{x,0}, F_{y,0}, F_{z,0}, F_{x,1}, F_{y,1}, F_{z,1} \dots\big]$ , however, calling $\big[F_{x,0}, F_{x,1},\dots, F_{y,0}, F_{y,1}, \dots, F_{z,0}, F_{z,1} \dots\big]$ .
forces.T.copy()creates an array of shape (3, natom) in row-major order (which is default for C lang - CPython)ABIN/interfaces/MACE/mace_server.py
Lines 303 to 309 in 9c4c611
why test passed
that's a combination of two problems.
harmonic model has accidental transposition
fortran sends (3, natom) in column-major order, which means (natom, 3) in python's row-major order. calling
.Tmakes it (3, natom) instead. another transposition is done inmain().ABIN/interfaces/MACE/mace_server.py
Line 145 in 9c4c611
water molecule was used for testing
3 atoms & 3 coords. this means the matrix is a square and therefore all subsequent calculation run without problems. the second transposition in
main()then canceled out the wrong order of send values.the fix
coords_bohr.Ttransposition inHarmonicModelforces.Ttransposition inmace_server.pyto match to format of array expected by fortran