-
Notifications
You must be signed in to change notification settings - Fork 103
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
Molecular dynamics job #134
Conversation
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.
Hey @mjwen, thanks for the PR. I realise this is a WIP but here are some initial comments.
src/atomate2/vasp/jobs/core.py
Outdated
``{"my_file:txt": "contents of the file"}``. | ||
""" | ||
|
||
# TODO expose basic setting of INCAR parameters to user |
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.
Please don't put these controls in the job maker, instead put them in the input set generator to be consistent with the other input sets.
Also, I'd advise against exposing the basic incar settings as those are easily overriden using user_incar_settings
. Instead you could add a several "presets", specified by a string, e.g., "nvt", "npt", "long" or whatever you think is useful
src/atomate2/vasp/sets/core.py
Outdated
# use VASP default ENCUT | ||
update["ENCUT"] = None | ||
|
||
if defaults["ISPIN"] == 1: |
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.
Not sure what defaults is here?
Instead of this, you might want to set auto_ispin: bool = True
in this dataclass. See the docstring for that setting here:
atomate2/src/atomate2/vasp/sets/base.py
Line 257 in 6445c2b
auto_ispin |
And this is an example of where I've turned it on:
atomate2/src/atomate2/vasp/sets/core.py
Line 528 in 6445c2b
auto_ispin: bool = True |
tests/vasp/jobs/test_core.py
Outdated
|
||
# generate transmuter job | ||
job = MDMaker( | ||
transformations=["SupercellTransformation"], |
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 guess you don't need these options?
thanks for the suggestions @utf ! The npt, nvt, ... are great suggestions; will definitely do it. I've got another questions for you. For MD run, I believe a user would want all ionic steps being parsed and stored.
|
I think the full ionic information is parsed. For each ionic step you get the energy, forces, and structure - do you need anything else? E.g., it is here:
You're right that this will likely be huge for an MD simulation. One option would be to parse a pymatgen Trajectory object instead and store this in the data store (this shouldn't be enabled by default though). My suggestion would be:
Hope that makes sense, I can clarify further if not. |
Also, did you see this page in the documentation on how to write VASP tests? https://materialsproject.github.io/atomate2/dev/vasp_tests.html |
I did a quick run of the MD job but did not find the Besides energy, forces, and structure at each ionic step, I may want other properties, like stress (if ISIF gives it) and partial charges (via bader analysis?) in the long run. I agree that pymatgen Trajectory may be a good option to store the data. I think I get the idea of how to make it happen and will let you know if I need more help. |
There isn't any logic in the task document for storing ionic_steps depending on the value of IBRION. It should always be stored. Maybe you weren't looking in the right place. They should be in And I've no idea about the custodian changing IBRION! You may have to look in the source code or ask on the issues page. |
Good point! I double checked and these are the keys that are stored for each ionic step:
So that should cover most things. Bader might be a little more difficult because you'd have to continuously run Bader as the calculation is progressing as the CHGCAR at the end only has the data for the last step. |
Yeah, it seems a second run is needed to get Bader for each ionic step. For now, I do not need it and let's leave it for a second.
Nice, this is great! Now that we have these nice schemas, instead of using pymartgen Trajectory, I think maybe we want to create a atomate2 schema for trajectory. Simply,
will do it. This will make it cleaner that we simply store ionic_steps in a different store than using a pymatgen Trajectory object. Also, the pymatgen Trajectory has lots of additional stuff and may not be the cleanest object to store the data. |
Unfortunately, creating a Trajectory |
Codecov Report
@@ Coverage Diff @@
## main #134 +/- ##
==========================================
+ Coverage 72.99% 73.51% +0.51%
==========================================
Files 49 49
Lines 4229 4349 +120
Branches 672 686 +14
==========================================
+ Hits 3087 3197 +110
- Misses 973 980 +7
- Partials 169 172 +3
|
I've come up with a way to deal with this. But before proceeding, I'd like to hear what you think. I've created a This is basically what we've discussed before, with the only difference being that we use a Trajectory BaseModel instead of a pmg Trajectory class. The good side is that we store the same This is the major issue for now; and of course there are other TODOs and the tests I need to do before you want to review it. |
Just adding a note to say I'm keeping an eye on the pymatgen PR -- I am absolutely ok with merging in edits to this to make it cleaner or more useful for your workflows. As far as I know, current uses of this class are minimal (we do use it in the MP API to return the |
@utf what's your thoughts on this? |
Hi @mjwen, Sorry for the delay on this. I think I like the |
Two reasons I did not want to do it:
But if we want it this way, we can definite do it---there is not any technical issue. And the benefit is obvious: the CalculationOutput model will be cleaner; it does not need to have a |
@utf Ready for review. In addition to adding the MDSetGenerator and MDMaker, major addition/changes include:
|
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 @mjwen, thanks very much for this PR and for your work on the Trajectory!
Here are some minor comments.
src/atomate2/vasp/schemas/task.py
Outdated
@@ -187,27 +190,47 @@ class OutputSummary(BaseModel): | |||
) | |||
|
|||
@classmethod | |||
def from_vasp_calc_doc(cls, calc_doc: Calculation) -> "OutputSummary": | |||
def from_vasp_calc_doc_and_trajectory( |
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.
Can you leave this name as it was before?
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.
done.
src/atomate2/vasp/schemas/task.py
Outdated
""" | ||
Create a summary of VASP calculation outputs from a VASP calculation document. | ||
Create a summary of VASP calculation outputs from a VASP calculation document |
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 first part of a docstring should fit on one line. I think you can remove the part about trajectory. It is obvious from the rest of the 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.
done.
src/atomate2/vasp/sets/core.py
Outdated
# LREAL: True -> AUTO | ||
updates.update( | ||
{ | ||
"ENCUT": None, # None to use VASP default |
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.
Is this a good idea? Seems like it could result in very low ENCUTS
. Was this taken from the old workflow?
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, it is taken from pmg MPMDSet.
I agree with you that this may not be good. The MVLNPTMDSet uses a slightly larger value, 1.5*ENCUT, but still may not be ideal since the ENCUT changes from material to material. I prefer to set it to a const value, but smaller than that in the BaseVaspSet.yaml, like 520.
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.
Yeah, I think 520 is good.
src/atomate2/vasp/sets/core.py
Outdated
"NSW": self.nsteps, | ||
"POTIM": self.time_step, | ||
"ISPIN": 2 if self.spin_polarized else 1, | ||
"EDIFF_PER_ATOM": 0.00001, |
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 have moved away from EDIFF_PER_ATOM in atomate2. It is reasonable to set a lower EDIFF here than the default but ultimately, I worry EDIFF_PER_ATOM could result in very large EDIFFS for large supercells.
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.
agreed. EDIFF_PER_ATOM could be really bad for large cells, especially in MD. Removed it. I believe the default EDIFF=1e-5 in BaseVaspSet.yaml
is good enough for MD runs.
src/atomate2/vasp/sets/core.py
Outdated
"KBLOCK": 100, | ||
"PREC": "Normal", | ||
"LDAU": False, | ||
"ADDGRID": True, |
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 have also removed ADDGRID from most VASP calculations based on the VASP developers advice.
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.
done.
…r large MD calculations
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.
Thanks @mjwen, this is nearly there I think. I just spotted a few more edits.
src/atomate2/vasp/sets/core.py
Outdated
# LREAL: True -> AUTO | ||
updates.update( | ||
{ | ||
"ENCUT": None, # None to use VASP default |
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.
Yeah, I think 520 is good.
src/atomate2/vasp/sets/core.py
Outdated
end_temp: float = 300 | ||
nsteps: int = 1000 | ||
time_step: int = 2 | ||
spin_polarized: bool = False |
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.
Can you remove this parameter and set auto_ispin: bool = True
. This means, if you're starting from a previous calculation, and that one has no magnetic moments, then ISPIN will be disabled automatically.
If you aren't starting from a previous calculation it is quite dangerous to set spin polarised to False by default.
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.
done
src/atomate2/vasp/sets/core.py
Outdated
"TEEND": self.end_temp, | ||
"NSW": self.nsteps, | ||
"POTIM": self.time_step, | ||
"ISPIN": 2 if self.spin_polarized else 1, |
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.
Remove this and see note about auto_ispin
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.
done
src/atomate2/vasp/sets/core.py
Outdated
"BMIX": 1, | ||
"MAXMIX": 20, | ||
"NELM": 500, | ||
"NSIM": 4, |
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 is the default so can be removed. Same with a few others. So you can remove:
- NSIM
- LSCALU
- BMIX
- NBLOCK
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.
done. I also removed LREAL=AUTO
and ISMEAR=0
. For LREAL, the default setting in the yaml files have AUTO
. For ISMEAR, I believer it is reasonable to follow the default yaml files.
src/atomate2/vasp/sets/core.py
Outdated
"NBLOCK": 1, | ||
"KBLOCK": 100, | ||
"PREC": "Normal", | ||
"LDAU": False, |
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.
Why is DFT+U disabled? Shouldn't we just use the default U values from pymatgen? In that case just remove this tag and they will be applied automatically!
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.
From a code hygiene perspective, @munrojm and I were discussing recently that there's a big advantage to having all calculations map cleanly to a pymatgen input set, since this greatly simplifies the task validation logic. If it's at all possible to inherit the settings from a specific input set, rather than copying manually, I think this would be very useful.
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.
@mkhorton Just to make sure I understand, by simplifies the task validation logic
, are you referring to the emmet building process or something else? And can you expand a bit on this...
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.
Also, @mkhorton could you clarify what you mean by "inherit the settings from a specific input set, rather than copying manually"?
Hello @mjwen and @utf , this is really nice work. Just my 2 cents, discussing with @gpetretto, one thing that may often happen in a MD job is that you need to continue it (you most probably cannot do e.g. 50000 steps in the timelimit). From what we have seen, it is not clear whether the velocities are passed down when you restart. Actually, we think that they are not and the MD job would restart with random or 0 velocities. What do you think ? |
This is a timely comment @davidwaroquiers; I'm actually at a workshop on checkpoint/restart today... I think we're at a point where we need to establish an ideal pattern in atomate2 for how best handle checkpointed states and/or continuation jobs, @utf and I have had some offline discussions about this. Perhaps better to discuss in a separate issue? I haven't reviewed this PR in detail, does it already have logic for continuation jobs included? |
@utf Besides removing some default params, I've also removed |
Hi @mkhorton @davidwaroquiers @mjwen. Agreed that we need a proper discussion about restarting. This is something @jmmshn has opinions about too. I have some ideas for how we could do it but each with their own tradeoffs. I'd be interested to hear if there were any good ideas from your workshop @mkhorton. I will create a separate issue to discuss this further. |
src/atomate2/vasp/sets/core.py
Outdated
"POTIM": self.time_step, | ||
"LCHARG": False, | ||
"LPLANE": False, | ||
"LWAVE": True, |
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.
Does this write the wavecar after each step? Could this be very expensive due to IO time of writing supercell wave functions?
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.
Removed. Also removed LPLANE, which has nothing to do with an MD run and depends on the type of machine.
Hi @utf, for abinit (PR #81 ), we have restart capabilities so we would indeed be very interested to discuss this and provide some of our ideas. |
Great, thanks so much for this @mjwen! |
Add basic MD job, based on
MPMDSet
in pymatgenMDFlow
in atomate1