-
Notifications
You must be signed in to change notification settings - Fork 922
Update rVV10 parameters for r2SCAN+rVV10 in MPScanRelaxSet() #4504
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
base: master
Are you sure you want to change the base?
Changes from all commits
2d94e73
437c9bb
c5841e4
83fcf44
eb71a23
d41b501
251f2b9
3842833
0660d76
d23d9ea
dabe7fe
035eab5
61a9f04
8a9fb02
78f85ea
171fd61
6b6a3d9
06cc0b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1299,6 +1299,77 @@ class MPRelaxSet(VaspInputSet): | |
| CONFIG = _load_yaml_config("MPRelaxSet") | ||
|
|
||
|
|
||
| def _config_updates( | ||
| vasp_input_set: VaspInputSet, | ||
| xc_functional: str, | ||
| dispersion: str | None = None, | ||
| ) -> None: | ||
| """Update the INCAR settings for a given XC functional and dispersion correction. | ||
|
|
||
| Args: | ||
| vasp_input_set (VaspInputSet): The VaspInputSet instance to update. | ||
| Supported types are MPScanRelaxSet and MP24RelaxSet. | ||
| xc_functional (str): The exchange-correlation functional to use. | ||
| Supported values are "SCAN", "r2SCAN", "PBE", and "PBEsol". | ||
| dispersion (str | None): The dispersion correction to use. | ||
| Supported values are "rVV10" and "D4". If None, no dispersion correction is applied. | ||
|
|
||
| Returns: | ||
| None: The function updates the INCAR settings of the VaspInputSet in place. | ||
| """ | ||
|
|
||
| xc = xc_functional.lower() | ||
| vdw = dispersion.lower() if dispersion is not None else None | ||
|
|
||
| to_func_metagga = {"scan": "SCAN", "r2scan": "R2SCAN"} | ||
| to_func_gga = {"pbe": "PE", "pbesol": "PS"} | ||
|
|
||
| config_updates: dict[str, Any] = {} | ||
|
|
||
| # Update the XC functional flags | ||
| if xc in to_func_metagga: | ||
| config_updates |= {"METAGGA": to_func_metagga[xc]} | ||
| vasp_input_set._config_dict["INCAR"].pop("GGA", None) | ||
| elif xc in to_func_gga: | ||
| config_updates |= {"GGA": to_func_gga[xc]} | ||
| vasp_input_set._config_dict["INCAR"].pop("METAGGA", None) | ||
| else: | ||
| raise ValueError(f"Unknown XC functional {xc_functional}!") | ||
|
|
||
| # Update the van der Waals parameters | ||
| if vdw == "rvv10": | ||
| rvv10_params_by_xc = { | ||
| "scan": {"BPARAM": 15.7, "CPARAM": 0.0093, "LUSE_VDW": True}, | ||
| "r2scan": {"BPARAM": 11.95, "CPARAM": 0.0093, "LUSE_VDW": True}, | ||
| } | ||
| try: | ||
| config_updates |= rvv10_params_by_xc[xc] | ||
| except KeyError: | ||
| raise ValueError( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed: as of VASP 6.4.0 you can use rVV10 with other functionals including GGAs. PBE is explicitly supported with a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be safer to also add
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe raising a warning instead if a GGA is requested? Still see lots of works with older VASP versions |
||
| "Use of rVV10 with functionals other than r2SCAN / SCAN is not currently supported in VASP." | ||
| ) | ||
|
|
||
| elif vdw == "d4": | ||
| d4_pars = { | ||
| "r2scan": {"S6": 1.0, "S8": 0.60187490, "A1": 0.51559235, "A2": 5.77342911}, | ||
| "pbe": {"S6": 1.0, "S8": 0.95948085, "A1": 0.38574991, "A2": 4.80688534}, | ||
| "pbesol": {"S6": 1.0, "S8": 1.71885698, "A1": 0.47901421, "A2": 5.96771589}, | ||
| } | ||
| if xc not in d4_pars: | ||
| raise ValueError(f"D4 parameters for XC functional '{xc_functional}' are not defined yet.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you expand this line to refer to the This is also where I took the PBEsol params from |
||
| pars = d4_pars[xc] | ||
| config_updates |= {"IVDW": 13, **{f"VDW_{k}": v for k, v in pars.items()}} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want some kind of guard here: if setting e.g. D4, other keys like In principle if a user had already set some INCAR parameters manually, then this function is called, it would be possible that the INCAR file would either end up with contradictory or ambiguous settings.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so maybe something like this at the start of the function: |
||
|
|
||
| elif isinstance(vdw, str): | ||
| warnings.warn( | ||
| f"Dispersion correction '{dispersion}' with {xc} is not supported in this class and will be ignored.", | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| if len(config_updates) > 0: | ||
| vasp_input_set._config_dict["INCAR"].update(config_updates) | ||
|
|
||
|
|
||
| @due.dcite( | ||
| Doi("10.1021/acs.jpclett.0c02405"), | ||
| description="Accurate and Numerically Efficient r2SCAN Meta-Generalized Gradient Approximation", | ||
|
|
@@ -1315,13 +1386,13 @@ class MPRelaxSet(VaspInputSet): | |
| class MPScanRelaxSet(VaspInputSet): | ||
| """Write a relaxation input set using the accurate and numerically | ||
| efficient r2SCAN variant of the Strongly Constrained and Appropriately Normed | ||
| (SCAN) metaGGA density functional. | ||
| (SCAN) meta-GGA density functional. | ||
|
|
||
| Notes: | ||
| 1. This functional is officially supported in VASP 6.0.0 and above. On older version, | ||
| source code may be obtained by contacting the authors of the referenced manuscript. | ||
| The original SCAN functional, available from VASP 5.4.3 onwards, maybe used instead | ||
| by passing `user_incar_settings={"METAGGA": "SCAN"}` when instantiating this InputSet. | ||
| by passing `xc_functional="SCAN"` when instantiating this InputSet. | ||
| r2SCAN and SCAN are expected to yield very similar results. | ||
|
|
||
| 2. Meta-GGA calculations require POTCAR files that include | ||
|
|
@@ -1346,10 +1417,12 @@ class MPScanRelaxSet(VaspInputSet): | |
| and Mueller [1] (see References). Note that if 'user_incar_settings' | ||
| or 'user_kpoints_settings' override KSPACING, the calculation from | ||
| bandgap is not performed. | ||
| vdw (str): set "rVV10" to enable SCAN+rVV10, which is a versatile | ||
| van der Waals density functional by combing the SCAN functional | ||
| with the rVV10 non-local correlation functional. rvv10 is the only | ||
| dispersion correction available for SCAN at this time. | ||
| xc_functional (str): set "r2SCAN" (default) or "SCAN" to choose the meta-GGA | ||
| exchange-correlation functional. | ||
| dispersion (str | None): set "rVV10" (default None) to enable r2SCAN+rVV10 or | ||
| SCAN+rVV10, which is a versatile van der Waals density functional by combing | ||
| the r2SCAN/SCAN functional with the rVV10 non-local correlation functional. | ||
| rVV10 is the only dispersion correction available for r2SCAN and SCAN in MPScanRelaxSet class. | ||
| **kwargs: Keywords supported by VaspInputSet. | ||
|
|
||
| References: | ||
|
|
@@ -1360,8 +1433,16 @@ class MPScanRelaxSet(VaspInputSet): | |
| James W. Furness, Aaron D. Kaplan, Jinliang Ning, John P. Perdew, and Jianwei Sun. | ||
| Accurate and Numerically Efficient r2SCAN Meta-Generalized Gradient Approximation. | ||
| The Journal of Physical Chemistry Letters 11, 8208-8215 (2022) DOI: 10.1021/acs.jpclett.0c02405 | ||
|
|
||
| Jinliang Ning, Manish Kothakonda, James W. Furness, Aaron D. Kaplan, Sebastian Ehlert, | ||
| Jan Gerit Brandenburg, John P. Perdew, and Jianwei Sun. | ||
| Workhorse minimally empirical dispersion-corrected density functional with tests for | ||
| weakly bound systems: r2SCAN+rVV10. | ||
| Phys. Rev. B 106, 075422 (2022) DOI: 10.1103/PhysRevB.106.075422 | ||
| """ | ||
|
|
||
| xc_functional: Literal["r2SCAN", "SCAN"] = "r2SCAN" | ||
| dispersion: Literal["rVV10"] | None = None | ||
| bandgap: float | None = None | ||
| auto_kspacing: bool = True | ||
| user_potcar_functional: UserPotcarFunctional = "PBE_54" | ||
|
|
@@ -1371,15 +1452,9 @@ class MPScanRelaxSet(VaspInputSet): | |
|
|
||
| def __post_init__(self) -> None: | ||
| super().__post_init__() | ||
| if self.vdw and self.vdw != "rvv10": | ||
| warnings.warn( | ||
| "Use of van der waals functionals other than rVV10 with SCAN is not supported at this time. ", | ||
| stacklevel=2, | ||
| ) | ||
| # Delete any vdw parameters that may have been added to the INCAR | ||
| vdw_par = loadfn(f"{MODULE_DIR}/vdW_parameters.yaml") | ||
| for k in vdw_par[self.vdw]: | ||
| self._config_dict["INCAR"].pop(k, None) | ||
| if isinstance(self.dispersion, str) and self.dispersion.lower() != "rvv10": | ||
| raise ValueError("Only rVV10 (or None) is supported for dispersion in MPScanRelaxSet.") | ||
| _config_updates(self, self.xc_functional, self.dispersion) | ||
|
|
||
|
|
||
| @dataclass | ||
|
|
@@ -1431,56 +1506,9 @@ class MP24RelaxSet(VaspInputSet): | |
|
|
||
| def __post_init__(self) -> None: | ||
| super().__post_init__() | ||
|
|
||
| to_func = { | ||
| "r2SCAN": "R2SCAN", | ||
| "PBE": "PE", | ||
| "PBEsol": "PS", | ||
| } | ||
|
|
||
| config_updates: dict[str, Any] = {} | ||
| if self.xc_functional == "r2SCAN": | ||
| config_updates |= {"METAGGA": to_func[self.xc_functional]} | ||
| self._config_dict["INCAR"].pop("GGA", None) | ||
| elif self.xc_functional in ["PBE", "PBEsol"]: | ||
| config_updates |= {"GGA": to_func[self.xc_functional]} | ||
| self._config_dict["INCAR"].pop("METAGGA", None) | ||
| else: | ||
| raise ValueError(f"Unknown XC functional {self.xc_functional}!") | ||
|
|
||
| if self.dispersion == "rVV10": | ||
| if self.xc_functional == "r2SCAN": | ||
| config_updates |= {"BPARAM": 11.95, "CPARAM": 0.0093, "LUSE_VDW": True} | ||
| else: | ||
| raise ValueError( | ||
| "Use of rVV10 with functionals other than r2 / SCAN is not currently supported in VASP." | ||
| ) | ||
|
|
||
| elif self.dispersion == "D4": | ||
| d4_pars = { | ||
| "r2SCAN": { | ||
| "S6": 1.0, | ||
| "S8": 0.60187490, | ||
| "A1": 0.51559235, | ||
| "A2": 5.77342911, | ||
| }, | ||
| "PBE": { | ||
| "S6": 1.0, | ||
| "S8": 0.95948085, | ||
| "A1": 0.38574991, | ||
| "A2": 4.80688534, | ||
| }, | ||
| "PBEsol": { | ||
| "S6": 1.0, | ||
| "S8": 1.71885698, | ||
| "A1": 0.47901421, | ||
| "A2": 5.96771589, | ||
| }, | ||
| } | ||
| config_updates |= {"IVDW": 13, **{f"VDW_{k}": v for k, v in d4_pars[self.xc_functional].items()}} | ||
|
|
||
| if len(config_updates) > 0: | ||
| self._config_dict["INCAR"].update(config_updates) | ||
| if self.xc_functional.lower() not in {"r2scan", "pbe", "pbesol"}: | ||
| raise ValueError("xc_functional must be one of 'r2SCAN', 'PBE', or 'PBEsol'.") | ||
| _config_updates(self, self.xc_functional, self.dispersion) | ||
|
|
||
| @staticmethod | ||
| def _sigmoid_interp( | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Should probably call this function something like
_set_dispersion_correction