Skip to content
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 VASP input set MatPESStaticSet #3254

Merged
merged 20 commits into from
Aug 28, 2023

Conversation

SophiaRuan
Copy link
Contributor

Summary

Major changes:

  • feature 1: add MatPESStaticSet class

Todos

If this is work in progress, what else needs to be done?

  1. make sure all the input set default settings are right.
  2. write unit tests

Checklist

  • Google format doc strings added. Check with ruff.
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • If applicable, new classes/functions/modules have duecredit @due.dcite decorators to reference relevant papers by DOI (example)

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install

@janosh janosh added enhancement A new feature or improvement to an existing one io Input/output functionality vasp Vienna Ab initio Simulation Package labels Aug 19, 2023
@janosh janosh changed the title add MatPESStaticSet to sets.py (WIP) Add MatPESStaticSet to VASP input set Aug 19, 2023
@janosh janosh changed the title Add MatPESStaticSet to VASP input set Add VASP input set MatPESStaticSet Aug 19, 2023
pymatgen/io/vasp/MatPESStaticSet.yaml Outdated Show resolved Hide resolved
pymatgen/io/vasp/MatPESStaticSet.yaml Show resolved Hide resolved
# using the Regularized-Restored Strongly Constrained and Appropriately
# Normed functional (PBE, PBE+U or r2SCAN).
INCAR:
ALGO: ALL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default ALGO should be Normal for PBE. R2SCAN uses All. But our input set is written with PBE as a default.

pymatgen/io/vasp/MatPESStaticSet.yaml Outdated Show resolved Hide resolved
W: 5
Yb3+: 1
POTCAR_FUNCTIONAL: PBE_54
POTCAR:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be hard coding POTCARs or U values in this input set. The VASP input sets support inheritance. E.g., VASPIncarBase defines U values. We should write a base for PBE54 that incorporates things we feel would be common across all calculations. E.g., POTCAR_FUNCTIONAL, POTCAR and maybe the U values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt confused about how we make sure all the MatPES static calculations have the same PSP, so that's why I incorporate the POTCAR values here. When you mentioned write a base for PBE54, do you mean to include another PBE54Base.yaml used for all the PBE54 POTCARs, POTCAR_FUNCTIONAL, and U values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

pymatgen/io/vasp/sets.py Outdated Show resolved Hide resolved
pymatgen/io/vasp/sets.py Outdated Show resolved Hide resolved
pymatgen/io/vasp/sets.py Outdated Show resolved Hide resolved
@@ -750,6 +751,116 @@ def test_grid_size_from_struct(self):
assert matched


class TestMatPESStaticSet(PymatgenTest):
def setUp(self):
self.tmp = tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, just use self.tmp_path inherited from PymatgenTest.

Comment on lines 763 to 773
assert vis.incar["NSW"] == 0
assert vis.incar["NELM"] == 200
assert vis.incar["ENCUT"] == 680
assert vis.incar["ENAUG"] == 1360
assert vis.incar["EDIFF"] == 1.0e-05
assert vis.incar["LREAL"] is False
assert vis.incar["LORBIT"] == 11
assert vis.incar["LVHAR"]
assert vis.incar["ISMEAR"] == 0
assert vis.incar["KSPACING"] == 0.22
assert vis.incar["GGA"] == "PE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to assert keys one by one. If you want to make sure they match the values in pymatgen/io/vasp/MatPESStaticSet.yaml, you can load that file into a dict and compare vis.incar against that dict.

@shyuep
Copy link
Member

shyuep commented Aug 25, 2023

@SophiaRuan This looks good. But I would like @JiQi535 to go through it carefully and make sure everything is correct.

@esoteric-ephemera
Copy link
Contributor

A few remarks given the updates to MP's GGA and r2SCAN WFs:

  • LREAL should be False for statics (consistent with how we do MP statics)
  • It says this is set is intended to r2SCAN, but the default is PBE? Otherwise, GGA = None and METAGGA = R2SCAN is needed (the GGA = None is needed for the more recent versions of VASP)
  • LAECHG should be False unless you plan on using the AECCAR* files
  • Same with LCHARG and the CHG/CHGCAR files
  • Same with LVTOT and the LOCPOT / POT files

If you want to contribute the statics to MP-core, then unfortunately you need LAECHG, LCHARG, and LOCPOT set to true for consistency with the r2SCAN WF. It'll just slow things down slightly with the file I/O

We're working on independently testing the differences in energies / forces / stresses for ISMEAR = 0 and -5. We may ultimately stay with ISMEAR = -5 for DOS / bandstructures / thermo properties, but that does mean incorrect forces for metals

@shyuep
Copy link
Member

shyuep commented Aug 25, 2023

@esoteric-ephemera this input set is for MatPES (as the name implies). While we are happy to contribute to MPstatics if MP wants them, forces are a priority here. Perhaps more so than even energies.

I am unsure why MP would want to stick to ISMEAR -5 for all statics. The evidence is quite conclusive than 0 works as well for insulators and certainly better for metals. So what is the advantage of sticking with -5?

@esoteric-ephemera
Copy link
Contributor

@shyuep I saw the work from your group for these differences, my only concern is that the average absolute energy differences between the two smearing methods is ~1 eV, which can be large on the scale of energy differences relevant for thermoprops (~5-10 meV/atom). Would be good to see these differences in eV/atom instead of eV

I'm also not sure what the effect of ISMEAR is on the DOS / KS eigenvalues / bandgap. We usually assume ISMEAR = -5 gives a better description of the actual electronic structure, but we're testing this now

@shyuep
Copy link
Member

shyuep commented Aug 25, 2023

@esoteric-ephemera ok. Would be good to have independent validation.

@JaGeo
Copy link
Member

JaGeo commented Aug 25, 2023

-5 should give a much better band gap based on DOS.

@shyuep
Copy link
Member

shyuep commented Aug 26, 2023

@esoteric-ephemera This is just my intuition. But if you use a small enough SIGMA, the DOS effect is small. After all, a smearing of 0.02 can't lead to more than a 0.04 eV error in band edges. In the grand scheme of DFT errors in band gaps, it is practically nothing.

@JiQi535
Copy link
Contributor

JiQi535 commented Aug 26, 2023

@SophiaRuan This looks good. But I would like @JiQi535 to go through it carefully and make sure everything is correct.

I have checked @SophiaRuan's implementation of MatPESStaticSet, and it looks nice to me. I have below questions.

  1. It seems to me that +U is by default not added. Isn’t this conflicting with the default in MPRelaxSet and MPStaticSet?
  2. In MPRelaxSet, there are 89 elements, same as the current coverage by MP. While for the new set, we have 97 elements. Some of the extra elements are Fr, Ra, Rn. @janosh I’m curious if and why they are added 😃
  3. LVTOT=True. We don’t have this in MPStaticSet. Is MP storing this data? @janosh

@JaGeo
Copy link
Member

JaGeo commented Aug 26, 2023

Just adding this paper here for my comment on the DOS computations (a smearing of 0.05 was used):
https://www.sciencedirect.com/science/article/pii/S277294942200002X

@janosh
Copy link
Member

janosh commented Aug 26, 2023

2 In MPRelaxSet, there are 89 elements, same as the current coverage by MP. While for the new set, we have 97 elements. Some of the extra elements are Fr, Ra, Rn. @janosh I’m curious if and why they are added 😃

@JiQi535 They were copied from MPSCANRelaxSet IIRC.

3 LVTOT=True. We don’t have this in MPStaticSet. Is MP storing this data? @janosh

No.

LMIXTAU: True
LORBIT: 11
LREAL: Auto
LVTOT: True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be removed. The LOCPOT file is going to consume storage space.

def __init__(
self,
structure: str,
functional: Literal["R2SCAN", "R2SCAN+U", "PBE", "PBE+U"] = "PBE",
Copy link
Contributor

@JiQi535 JiQi535 Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SophiaRuan Here, I think we should have PBE+U as default, inline with default of MPRelaxSet and MPStaticSet. Also, I don't think we should distinguish PBE and PBE+U as two functionals. Instead, +U can be disabled in the same way as in MPRelaxSet and MPStaticSet with user_incar_settings={"LDAU": False}.

@shyuep Please kindly comment if you agree.

@shyuep
Copy link
Member

shyuep commented Aug 26, 2023

No. PBE default. U and r2scan as options. This is not MP.

@shyuep
Copy link
Member

shyuep commented Aug 28, 2023

The lint and test failures are unrelated to the PR. I am merging.

@shyuep shyuep merged commit 5a1a9d2 into materialsproject:master Aug 28, 2023
14 of 19 checks passed
@janosh
Copy link
Member

janosh commented Aug 28, 2023

They're not unrelated. The 1st TestMatPESStaticSet assert fails:

pytest tests/io/vasp/test_sets.py -k TestMatPESStaticSet -vv
_____________________________ TestMatPESStaticSet.test_init ______________________________

self = <tests.io.vasp.test_sets.TestMatPESStaticSet testMethod=test_init>

    def test_init(self):
        prev_run = f"{TEST_FILES_DIR}/relaxation"
    
        vis = MatPESStaticSet.from_prev_calc(prev_calc_dir=prev_run)
        # Check that INCAR settings were load from yaml, check the default functional is PBE.
        CONFIG = _load_yaml_config("MatPESStaticSet")
>       assert vis.incar == CONFIG["INCAR"]
E       AssertionError: assert {'PREC': 'acc...ORBIT': False} == {'ALGO': 'Nor...5, 'Yb3+': 1}}
E         Omitting 3 identical items, use -vv to show
E         Differing items:
E         {'PREC': 'accurate'} != {'PREC': 'Accurate'}
E         {'ISMEAR': -5} != {'ISMEAR': 0}
E         {'MAGMOM': [0.6]} != {'MAGMOM': {'Ce': 5, 'Ce3+': 1, 'Co': 0.6, 'Co3+': 0.6, 'Co4+': 1, 'Cr': 5, 'Dy3+': 5, 'Er3+': 3, 'Eu': 10, 'Eu2+': 7,...4+': 3, 'Mo': 5, 'Nd3+': 3, 'Ni': 5, 'Pm3+': 4, 'Pr3+': 2, 'Sm3+': 5, 'Tb3+': 6, 'Tm3+': 2, 'V': 5, 'W': 5, 'Yb3+': 1}}
E         {'SIGMA': 0.2} != {'SIGMA': 0.05}
E         {'LORBIT': False} != {'LORBIT': 11}...

@shyuep
Copy link
Member

shyuep commented Aug 28, 2023

I just noticed one problem. Why is the INCAR written as return Incar(self.prev_incar or parent_incar)? This is wrong. If the prev_incar is a relaxation, this will make it a relaxation calculator too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement to an existing one io Input/output functionality vasp Vienna Ab initio Simulation Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants