-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add callback function for LAMMPS #458
Conversation
Pull Request Test Coverage Report for Build 1546466930
💛 - Coveralls |
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.
Super cool, I think this is absolutely very useful. One small syntax tweak requested in the code itself, and a whole bunch of (sometimes optional) documentation request.
Looking at it from 30k ft, the big issue I see is how to connect this to our serialization and reproducibility. As far as I can see, right now if you activate this functionality the final serialized job will give no indication of what was done, and so you'll just strangely get a trajectory whose forces and evolution don't align with your potential+thermo/barostatting. I guess this is already the case for jobs we mess with interactively. Since you explicitly list this as an "expert feature", I don't think this concern should stop this PR from merging, and I don't have a good solution myself right now anyhow -- but we should think about how to handle this...maybe some sort of my_callback = pr.atomistics.lammps.Callback(fnc=my_function_defined_elsewhere); lmp.set_callback(my_callback.fnc)
(or lmp.set_callback(my_callback)
, where we check if the argument is an instance of our fancy new class and parse accordingly), and then handle serialization of the raw function code under the hood?
*** Expert feature *** | ||
********************** | ||
|
||
Set callback function that modifies forces. |
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.
add example 1 to docstring
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 mean example 2? (1 is already there)
Co-authored-by: Liam Huber <liam.huber@gmail.com>
Co-authored-by: Liam Huber <liam.huber@gmail.com>
callback
is one of the features of LAMMPS which makes it extremely efficient while being still very interactive. In short, you can append a function that returns forces which are then added to the total forces calculated in LAMMPS. You can find more info on this page.Example I: Add random forces
Example II: Push H in (1, 1, 1)-direction