-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement MD workflows #1672
base: main
Are you sure you want to change the base?
Implement MD workflows #1672
Conversation
Can one of the admins verify this patch? |
@tomdemeyere: Happy to respond to each question but before I do, I just wanted to check that this is the full commit you wanted to share --- just the args/kwargs, right? (In short, I really would love to have MD flows and am willing to work together to figure out how to get this done the best way possible) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1672 +/- ##
==========================================
- Coverage 99.02% 98.99% -0.04%
==========================================
Files 82 84 +2
Lines 3387 3481 +94
==========================================
+ Hits 3354 3446 +92
- Misses 33 35 +2 ☔ View full report in Codecov by Sentry. |
Yes, before doing more I wanted to make sure we are on the same page. I guess my main question here is: how to make these flows common to all codes? Should they call code specific MD jobs? Or, should a calculator be attached to the Atoms object being sent to the MD flow? Once I know this we can work on details |
@tomdemeyere: Good question. Personally, I think what would likely make the most sense is to make a From there, we get to the recipes, and my answer is: "it depends." If it is just a simple If we are talking about a To get started, I would suggest making I should also note that we can always refactor later if there is something we can refactor. No need to prematurely optimize.
If the workflow logic is staying the same regardless of thermostat, then I would suggest one job/workflow where thermostat would be a keyword argument with a sensible default.
See comment above. If we are talking about a
Hard for me to tell from the commit you shared here, but I am not opposed to complexity. In fact, we should not rely on the users to build something complex. If the
This is a good point. However, I think it is solvable. Let's circle back to this when the time is right. |
@Andrew-S-Rosen Thanks for all these details. I will come back to it at some point |
@Andrew-S-Rosen I think this is now a good point to have your input |
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.
Thank you for kicking this off, @tomdemeyere! Really appreciate the contribution!
This is looking good. I have some comments that are mostly related to some minor restructuring.
Starting with this isolated EMT example is very helpful for me in understanding the process and figuring out what should be refactored, so I thank you for doing that.
src/quacc/recipes/emt/core.py
Outdated
|
||
if temperature: | ||
MaxwellBoltzmannDistribution( | ||
atoms, temperature_K=temperature, **initial_temperature_params |
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.
With the fixcm
and fixrot
as dedicated keyword arguments, the **kwargs
here can be more clearly described as simply being the **maxwell_boltzmann_distribution_kwargs
. That is a mouthful (although nobody is calling the name directly). Could try something like **maxwell_boltzmann_kwargs
. Either way, the point is that both the docstring and name would be much clearer this way. At a glance, it's not clear what an **initial_temperature_params
is.
I see that your comment is different than the one I received by email from git. But yes, originally my plan was to have these "_base" functions. Either per calculator or in common like you previously said. After discussing that along with other details I was then planning to introduce recipes for the other ensembles (NVT, NPT). Didn't see your comments originally (github mobile) will work on it at some point |
Apologies about the edits! I was trying to sort out where to place them and was going back-and-forth so decided to just save it for a future discussion to avoid confusion. But you got the right idea anyway.
That would be great!
Thank you! |
Few comments:
We are currently working on a Because you said you might be interested in error handling I am leaving that there.
|
The
I agree that a
One could catch the typical
Indeed. This is a limitation of Parsl/Dask, which is really best thought of a task manager. Other true workflow tools like Prefect or Covalent or FireWorks have a separate database for the task metadata and would highlight when/where the job fails. But since Parsl does not have a task database of its own, there is no mechanism to easily store that info. The recommended approach would be to launch your calculations in a
I like that a lot more! |
Some news on this? Just to know if it is waiting on https://gitlab.com/ase/ase/-/merge_requests/3310 |
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.
@tomdemeyere: Thank you for your enormous amount of patience with this PR. I didn't see your comment from 3 weeks ago, so my apologies about not responding and for keeping you in the dark about this.
The reason I had been reluctant to merge this was that there was a fair bit of refactoring I wanted to do to remove code duplication in the run_md
method and also in the schema. This was dependent on some other PRs I had in the pipeline. I was finally able to devote time to do so properly, and now it is much cleaner. 👍 I didn't change any functionality (to the best of my knowledge).
At this point, I am quite pleased with this. Whenever you have a moment, however, I have a few remaining questions outlined below. I am happy to take over of any (small) changes that result from my questions --- but I wanted to get your professional input before attempting to proceed since I am not an MD expert. Finally, before I merge, if you have a moment to look at a similar attempt recently implemented in matcalc, it'd be nice to know if we are missing anything particularly useful that's in there. For instance, there is something about upper triangular cells that is entirely foreign to me.
Additionally, Quacc uses the keywords `fix_com` and `fix_rot` instead of | ||
`fixcm` and `fixrot` to fix the center of mass and rotation, respectively. |
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.
If this is just a matter of renaming and nothing else, let's just stick with the ASE ones. If you approve, let me know and I can revert the change 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.
Yes sure!
As of March 2024, ASE still accept deprecated keywords such as: | ||
- temperature instead of temperature_K | ||
- pressure instead of pressure_au | ||
- compressibility instead of compressibility_au | ||
- dt instead of timestep | ||
All of these keywords will be accepted by Quacc, but it is recommended to use the | ||
new keywords to avoid confusion. Everything will always be converted to the Quacc | ||
units mentioned above. |
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.
We probably don't need to mention this since ASE itself will raise a deprecation warning if they are used, right? Ultimately, it's on the user to use the current ASE names. Or maybe I'm misunderstanding the context.
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 can probably be deleted yes
if "temperature" in dynamics_kwargs or "temp" in dynamics_kwargs: | ||
LOGGER.warning( | ||
"In quacc `temperature`, `temp` and `temperature_K` are" | ||
" equivalent and will be interpreted in Kelvin." | ||
) | ||
dynamics_kwargs["temperature_K"] = dynamics_kwargs.pop( | ||
"temperature", None | ||
) or dynamics_kwargs.pop("temp", None) | ||
|
||
if "pressure" in dynamics_kwargs: | ||
LOGGER.warning( | ||
"In quacc `pressure` and `pressure_au` are equivalent and will be" | ||
" interpreted in GPA." | ||
) | ||
dynamics_kwargs["pressure_au"] = dynamics_kwargs.pop("pressure") | ||
|
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.
Do we need all these checks, or can we just rely on the fact that the user should be using the up-to-date names and if they don't, ASE will warn them or a crash will happen.
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.
The thing is that, parameters are a very big mess currently, for example for NVT Berendsen we have:
temperature: float
The desired temperature, in Kelvin.
temperature_K: float
Alias for temperature
And for NPT (Nose-Hoover) :
temperature: float (deprecated)
The desired temperature in eV.
temperature_K: float
The desired temperature in K.
Sometimes temperature
is in eV, sometimes in K, you don't know, surprise!
I know it's a lot of time to ask from you but your support on https://gitlab.com/ase/ase/-/merge_requests/3391 (probably not everything in this PR is good to take) would be more than welcome.
If/when this goes, I would rewrite the entire MD doc and we can finally move on with X-years old deprecated keywords and have user-friendliness and consistency.
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.
Ooof, yeah that is a mess! Thanks for the reminder.
Let's see how the discussion plays out and then I am happy to proceed how you suggest. I am happy to review on ASE's side if/when we get a blessing from Ask on certain components.
I had a look at the code you sent me and I am afraid I have never had issues with the upper vs lower triangular matrix (mainly because I don't often run NPT) but from what I understand this is taken care by a PR in ASE (https://gitlab.com/ase/ase/-/merge_requests/3277) by just modifying the NPT class without the need of modifying the atoms object like in matcalc. For more context: left is my slab before, right is the slab after being passed in matcalc. To refresh the current challenges in this PR:
For the first point, I am afraid this is not for today :/. For the later I tried to make things as clean as I could but of course feel free to discard these suggestions and do as you like. |
Thanks for the reply, @tomdemeyere! Regarding the triangular stuff, thanks for linking me to the MR. If this is just an ASE bug/inconvenience, we will take care of that upstream. I'll keep tabs on the MR. As for this PR, not to worry about restarts. I don't think it is a dealbreaker, and I disagree that it defeats the purpose of a workflow. After all, one might want to do a non-MD job afterwards (e.g. a DFT relaxation) which would be fully supported. It's just that MD-->MD might be tricky. I wouldn't let that hold up this PR. Let me know if/when your upstream ASE MR though needs any attention from me. The second point is really the only one I feel is necessary to make sure we get right. I trust your opinion on this and am content with leaving it as-is. So, I think the plan (unless you disagree) should be:
Thoughts? |
Oh, but also I still had the question about |
Most of the time you will find
Yes! I think that's a great plan |
Summary of Changes
Closes #1577.
Before going further a little consultation:
MD users use workflows all the time, just for the NVE example in this commit there is pretty much a thousand ways you can run that; doing a first NVT to relax to the desired temperature, or a first NPT to relax to the desired density, etc...
Checklist
main
.black
,isort
, andruff
as described in the style guide.