Skip to content

Commit

Permalink
move ValueError Unrecognized {xc_functional=} to top
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 31, 2023
1 parent 9d6ee83 commit a89090a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,18 +1239,19 @@ def __init__(
are prioritized over inputs from previous runs.
**kwargs: Passed to DictSet.
"""
valid_xc_functionals = ("R2SCAN", "PBE", "PBE+U")
if xc_functional.upper() not in valid_xc_functionals:
raise ValueError(
f"Unrecognized {xc_functional=}. Supported exchange-correlation functionals are {valid_xc_functionals}"
)

super().__init__(structure, MatPESStaticSet.CONFIG, **kwargs)

if xc_functional.upper() == "R2SCAN":
self.user_incar_settings["METAGGA"] = "R2SCAN"
self.user_incar_settings["ALGO"] = "ALL"
elif xc_functional.upper() == "PBE+U":
self.user_incar_settings["LDAU"] = True
elif xc_functional.upper() != "PBE":
raise ValueError(
f"{xc_functional} is not supported."
" The supported exchange-correlation functionals are PBE, PBE+U and R2SCAN."
)
if user_potcar_functional.upper() != "PBE_54":
warnings.warn(
f"POTCAR version ({user_potcar_functional}) is inconsistent with the recommended PBE_54.", UserWarning
Expand Down

0 comments on commit a89090a

Please sign in to comment.