-
Notifications
You must be signed in to change notification settings - Fork 139
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
🌟 [FEATURE] Stress tensor #69
Comments
Hi @keano130 , This should not be too hard to implement; the main thing is adding the displacement. (Since our edge vectors are calculated from |
Thank you for the quick response, I am definitely willing to help test it. |
@keano130 check out the https://github.com/mir-group/nequip/tree/stress branch, which contains a first stab at an implementation (untested so far) |
Added some basic tests, the model does run and produce numbers for the stress when PBC are used. (See One thing I'm not sure about is the multiplication conventions at https://github.com/mir-group/nequip/blob/stress/nequip/nn/_grad_output.py#L187. I had to modify them from the For running simple NPT simulations, the easiest thing to do would be to add the stress to the ASE calculator ( |
The stress_key should to be added to the rescaleoutput layer , I tested the stresses using finite difference and this test passes correctly. |
Furthermore, I compared the stress predictions of the network trained on ab initio (dft) generated data with the stress predictions of dft and they seemed to be relatively close (relative mean absolute error of 30%) which is very possible as the network was not yet fully trained. |
Great! That's partially trained on forces, predicting stresses? Looking at EDIT: I've added stress to the rescaling |
Oh that's my bad, somehow i uploaded everything but the python file (I'm don't have my laptop with me, so I will upload it tomorrow, sorry for the delay) |
Stress_test.zip |
Hi @keano130 , Wanted to let you know that stress is now being implemented in the |
Hi @keano130, Just a heads up that I've gone ahead and merged the (now much more complete) That said, stress support is still very much in beta and, as the warning I added says, please sanity check your results and let us know if you find things that seem strange or wrong. |
Hi @Linux-cpp-lisp . I've checked out the develop branch and tried calculating stress with two different methods, both giving me a Key Error: 'stress' suggesting stress isn't an available option. Could you point me on how to calculate stress with a NequIP calculator? The most straightforward way I've tried it, which I thought should work is
Giving an error such as
Similarily adding the calculator to an Atoms object and running get_stress() doesn't work with the same error. |
@davidleocadio does your model include a The good news is that if it doesn't, you can still reuse your trained weights an build a new model with a |
@Linux-cpp-lisp great thanks. I wasn't aware of |
@davidleocadio it'll be something like this:
|
Is your feature request related to a problem? Please describe.
In order to execute npt-simulations, the stress of the system is needed, I wonder if it is possible to implement the option to calculate the stress. To calculate this stress, the derivative of the energy wrt the cell is needed, In evaluation mode however, the model does not store the gradients and therefore, this value can not be computed. In training mode everything is rescaled, and using training mode in inference is not the purpose of training mode I think. Adding a cell and stress key in GradientOutput causes an error that there is no key 'cell' in irreps_in[wrt] in line 62 in _grad_output.py. As I figure that the cell should not be included in the irreps_in, this options seems bad too.
Describe the solution you'd like
Method on the final_model (RescaleOutput) or GradientOutput to calculate stress, if a stress parameter in the config file is True
Additional context
In schnetpack this is implemented in https://github.com/atomistic-machine-learning/schnetpack/blob/master/src/schnetpack/atomistic/output_modules.py and https://github.com/atomistic-machine-learning/schnetpack/blob//src/schnetpack/atomistic/model.py
The text was updated successfully, but these errors were encountered: