Skip to content

Conversation

@junchichen21
Copy link

This pull request updates the MPScanRelaxSet class in src/pymatgen/io/vasp/sets.py to improve support for the r2SCAN+rVV10 functional. It adds a new reference for r2SCAN+rVV10 and ensures that the appropriate BPARAM value is set in the INCAR when using this functional.

Functional and documentation enhancements:

  • Added a new literature reference for r2SCAN+rVV10 to the class docstring to improve citation accuracy.
  • Updated the __post_init__ method to automatically set BPARAM = 11.95 in the INCAR when vdw is set to "rvv10" and METAGGA is "R2SCAN". If the user specifies user_incar_settings={"METAGGA": "SCAN"}, then BPARAM keeps the same value as defined in the vdW_parameters.yaml file.

-Add the code to update rVV10 parameters ("BPARAM"=11.95) for r2SCAN+rVV10 if vdw is set to "rvv10" and METAGGA is "R2SCAN"
@esoteric-ephemera
Copy link
Contributor

Hey @junchichen21 can you take a look at how this is already done in MP24RelaxSet and perhaps merge the incar updates into a common function for both the older MPScanRelaxSet and newer MP24RelaxSet?

@shyuep
Copy link
Member

shyuep commented Oct 7, 2025

Also, unittests are needed. Thanks.

@junchichen21
Copy link
Author

Hey @junchichen21 can you take a look at how this is already done in MP24RelaxSet and perhaps merge the incar updates into a common function for both the older MPScanRelaxSet and newer MP24RelaxSet?

Hi @esoteric-ephemera, I somehow missed your message last week. Sorry about that. No problem, I will update it soon.

@junchichen21
Copy link
Author

Hi @esoteric-ephemera and @shyuep, I have made some updates as shown below:

Refactoring and code unification:

  • Introduced a new _config_updates helper function to centralize the logic for updating INCAR settings for different XC functionals and dispersion corrections, and refactored both MPScanRelaxSet and MP24RelaxSet to use this function. This eliminates duplicated code and ensures consistent behavior. [1] [2] [3]

API and interface changes:

  • Changed the MPScanRelaxSet interface to use xc_functional and dispersion arguments instead of the previous vdw and user_incar_settings for specifying functionals and dispersion corrections, and updated the class documentation and references accordingly. [1] [2] [3]

Validation and error handling improvements:

  • Added stricter validation and error messages for unsupported XC/dispersion combinations, including raising errors when an invalid dispersion correction is specified for MPScanRelaxSet, and when unsupported XC functionals are given to MP24RelaxSet. [1] [2]

Test updates and additions:

  • Updated and expanded tests in test_sets.py to reflect the new interface and stricter validation, including new tests for allowed and disallowed XC/dispersion combinations and updated test names and assertions for clarity. [1] [2] [3]

Please let me know whether the above refactoring and interface changes align with the intended update policy.

@shyuep
Copy link
Member

shyuep commented Oct 16, 2025

Looks ok to me. @esoteric-ephemera To review.

Copy link
Member

@mkhorton mkhorton left a comment

Choose a reason for hiding this comment

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

Thanks @junchichen21 for this. Added a brief review just to make this more robust/future-proof.

@esoteric-ephemera if you don't have any objections to this will merge after these changes.

try:
config_updates |= rvv10_params_by_xc[xc]
except KeyError:
raise ValueError(
Copy link
Member

Choose a reason for hiding this comment

The 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 BPARAM of 10.

Copy link
Member

Choose a reason for hiding this comment

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

May be safer to also add "IVDW_NL": 2 too, as well as "LASPH": True (the latter should already be set, but should also be harmless to specify just in case).

Copy link
Contributor

Choose a reason for hiding this comment

The 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

if xc not in d4_pars:
raise ValueError(f"D4 parameters for XC functional '{xc_functional}' are not defined yet.")
pars = d4_pars[xc]
config_updates |= {"IVDW": 13, **{f"VDW_{k}": v for k, v in pars.items()}}
Copy link
Member

Choose a reason for hiding this comment

The 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 LUSE_VDW if already present should be un-set.

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.

Copy link
Member

Choose a reason for hiding this comment

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

so maybe something like this at the start of the function:

# Clean existing tags
for tag in ("LUSE_VDW", "BPARAM", "CPARAM", "IVDW", "VDW_S6", "VDW_S8", "VDW_A1", "VDW_A2", "IVDW_NL"):
    if tag in incar:
        val = incar.pop(k)
        # possibly warn user of ambiguity too

CONFIG = _load_yaml_config("MPRelaxSet")


def _config_updates(
Copy link
Member

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

@esoteric-ephemera
Copy link
Contributor

Sorry I missed this will look today and give comments

"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.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you expand this line to refer to the dftd4 code where all possible functional params are defined:
https://github.com/dftd4/dftd4/blob/30aa423f3ca90f21789c3a89a0ad4b464081290e/src/dftd4/param.f90#L353

This is also where I took the PBEsol params from

@shyuep
Copy link
Member

shyuep commented Nov 7, 2025

I will wait for @mkhorton and @esoteric-ephemera 's comments to be resolved first. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants