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
[WIP] MP-compatible r2SCAN workflow (and a few general INCAR improvements) #362
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #362 +/- ##
===========================================
- Coverage 75.09% 64.75% -10.35%
===========================================
Files 74 76 +2
Lines 6570 7271 +701
Branches 952 958 +6
===========================================
- Hits 4934 4708 -226
- Misses 1330 2259 +929
+ Partials 306 304 -2
|
This is great! Looking forward to having access to it. |
wrong key user_incar_settings -> INCAR and raises ruamel/yaml/comments.py:881: in update self._ok.add(*kw.keys()) E TypeError: set.add() takes exactly one argument (3 given)
for consistency with MPPreRelaxMaker
…elaxMaker was passed to __init__, needs to be passed to make()
…ests just test_MP2023RelaxMaker_default_values() for now
Linking materialsproject/pymatgen#2325 as a TODO as suggested by @arosen93 so we don't forget about it. |
Note to self while typing on mobile: this might be a swap to add in base.py of vasp/sets. Edit: Just patched it in! |
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 fantastic, thanks so much @arosen93 and @janosh! I have a postdoc starting in about a month who will likely want to make use of this, too. I left a few minor comments but overall it looks good to me (with the caveat that I am still not terribly familiar with atomate2
VASP flows in general).
One enhancement to consider - in Figure 3 of the mixing scheme paper (below), we describe different levels of calculation coverage, and note that sometimes (for large structures) it is useful / necessary to just do a static r2SCAN calculation. This gives you an energy that allows you to apply the mixing scheme even though the structure itself is probably too large to relax with r2SCAN.
If MP wants to adopt this strategy, I suggest breaking the 2nd relaxation into two Job
- a static calculation followed by a relaxation. So the overall workflow would be:
PBESol relax --- CHGCAR----> r2SCAN static ----CHGCAR+WAVECAR----> r2SCAN relax
You could pass everything (CHGCAR
and WAVECAR
) on to the final relaxation so it shouldn't cost much additional time, but this would give you the flexibility to stop after the static calc if you have large structures.
Just food for thought. The argument against this is that it will deviate slightly from what is described in the workflow paper, creating potential for confusion.
fix bandgap doc str in the wrong place
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 @janosh, I've added some comments.
One potential reason for the tests failing could be that module imports for the makers is not inside the test functions themselves. This is necessary for the monkey patching to work properly. I added a comment about this with more details.
src/atomate2/vasp/flows/mp.py
Outdated
""" | ||
|
||
name: str = "MP GGA Relax" | ||
initial_maker: BaseVaspMaker | None = field(default_factory=MPGGARelaxMaker) |
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 think we should add a MPDoubleRelaxMaker
and just use that here instead. This will be in keeping with the other non-mp workflows (and also for Abinit and CP2K).
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.
What do you think about having a more versatile mp_compat_converter()
function that takes in any existing atomate2
Maker
and applies a config_dict
of the user's choosing which defaults to src/atomate2/vasp/sets/BaseMPGGASet.yaml
?
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 think that would be a nice feature. I think I suggested that at some point. Although I think for the canonical MP workflows we should define them explicitly. I image the function you describe (I think it should be a powerup) would be available for other people to convert non-MP workflows into MP compatible ones. If we use it for defining the canonical workflows it will be a bit confusing for users reading the code trying to understand what is going on.
src/atomate2/vasp/sets/mp.py
Outdated
dict | ||
A dictionary of updates to apply. | ||
""" | ||
return {} |
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 need to set these properly so that it will configure the necessary settings for a relaxation. E.g., see here:
atomate2/src/atomate2/vasp/sets/core.py
Line 71 in 18d014a
return {"NSW": 99, "LCHARG": False, "ISIF": 3, "IBRION": 2} |
Although if using the subclassing approach detailed in my previous comment this shouldn't be necessary.
src/atomate2/vasp/sets/mp.py
Outdated
rmin = 25.22 - 2.87 * bandgap | ||
kspacing = 2 * np.pi * 1.0265 / (rmin - 1.0183) | ||
return { | ||
"KSPACING": np.clip(kspacing, 0.22, 0.44), |
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.
Again, this is missing the tags to actually make this a relaxation if continuing from a static calculation.
tests/vasp/flows/test_mp.py
Outdated
from atomate2.vasp.flows.mp import MPMetaGGARelax | ||
from atomate2.vasp.jobs.mp import ( | ||
MPMetaGGARelaxMaker, | ||
MPPreRelaxMaker, | ||
) | ||
|
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.
All imports need to be within the tests themselves otherwise it breaks the tests. This is mentioned at the bottom of this page but perhaps we need to make this more clear elsewhere: https://materialsproject.github.io/atomate2/dev/vasp_tests.html
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 tried moving all imports except pytest
into the test function yesterday which made no difference, tests were failing either way.
Added generic 3-step flow to avoid duplication of code. New / modified WFs: - MPGGARelax now permits GGA and GGA + U calcs via kwarg to maker (previously only did GGA + U) - MPGGADoubleRelaxMaker and MPMetaGGADoubleRelaxMaker per request from @utf. These are the same as MPGGARelax and MPMetaGGARelax excluding final statics
Ensure pre-relax always uses Gaussian smearing for better generality
src/atomate2/vasp/flows/mp.py
Outdated
|
||
|
||
@dataclass | ||
class _MPGenericThreeStep(Maker): |
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.
Personally, I would be against defining the flows like this. It is quite complicated for users trying to understand what is going on. I don't feel that there is much boilerplate in a DoubleRelax + Static Maker.
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've rewritten these: the hidden generic maker has been replaced by MPGGADoubleRelaxMaker. This maker features an optional final static, which is disabled by default. The other flows (MPGGARelax, MPMetaGGARelax, and MPMetaGGADoubleRelaxMaker) all inherit from MPGGADoubleRelaxMaker. Let us (cc. @janosh) know if these are more what you had in mind, @utf?
Updating MP flows consistent with feedback from @utf: - Removed hidden generic maker, replaced this with MPGGADoubleRelaxMaker. This maker has an optional final static which is disabled by default - All subsequent flows inherit from MPGGADoubleRelaxMaker - MPGGARelax = MPGGADoubleRelaxMaker + final GGA static - MPMetaGGADoubleRelaxMaker = MPGGADoubleRelaxMaker with meta-GGA params - MPMetaGGARelax = MPMetaGGADoubleRelaxMaker + final meta-GGA static
field has no args, just kwargs. testing threw this error: `TypeError: field() takes 0 positional arguments but 1 was given`
Iterate over makers and not jobs when applying +U kwarg (job has no attr input_set_generator, but the maker itself does)
Correct ordering of application of GGA + U tag
…grows larger than 8.78 eV
@arosen93 @esoteric-ephemera I just noticed |
It should work correctly now. Also setting GGA = None here is still unfortunately overriden by the previous INCAR, so we should update it in the relax and static meta-GGA makers through user_incar_settings I'm not sure if the following is more transparent, basically defining the kspacing as a discontinuous piecewise function (KSPACING = 0.22 for gap < bandgap_tol, but 0.26 for gap = bandgap_tol):
|
Rather than setting things in the user_incar_settings, can you set them in the actual |
Ok, are you able to handle the unmerging? |
Yes, do you prefer a revert commit or rewriting git history like it never happened? The latter would require people who pulled |
Can you overwrite the history? Should be ok I think. |
Closes #352. Closes #363. Closes #364.
LMAXTAU
should be auto-set when there are f electrons andLASPH
is True for meta-GGA calculations #363LMAXMIX
should be set based on the presence of s, p, d, f electrons not based on Z #364R2SCAN Workflow
Note: This is in close collaboration with @janosh and @esoteric-ephemera.
This PR adds MP-compatible r2SCAN workflows to Atomate2 (#352). We are still adding tests for now, hence the WIP.
VASP INCAR Improvements
I also baked in fixes for several VASP INCAR issues I brought up (#363, #364, #365).
Review Request
@utf: Mind giving this a quick look to make sure we didn't do anything drastically wrong before we go and write all the tests? Thanks!
Also tagging @munrojm, @rkingsbury, and @mkhorton in case they're interested in following this.
ToDo
CHGCAR
(not all the files) from the PBEsol job to the R2SCAN job in order to remain truthful to the original workflow.