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

Update DictSet to allow direct initialisation #3031

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,6 @@ def __init__(
if (valid_potcars := self._valid_potcars) and user_potcar_functional not in valid_potcars:
raise ValueError(f"Invalid {user_potcar_functional=}, must be one of {valid_potcars}")

struct_has_Yb = any(specie.symbol == "Yb" for site in structure for specie in site.species)
uses_Yb_2_psp = self.CONFIG["POTCAR"]["Yb"] == "Yb_2"
if struct_has_Yb and uses_Yb_2_psp:
warnings.warn(
"The structure contains Ytterbium (Yb) and this InputSet uses the Yb_2 PSP.\n"
"Yb_2 is known to often give bad results since Yb has oxidation state 3+ in most compounds.\n"
"See https://github.com/materialsproject/pymatgen/issues/2968 for details.",
BadInputSetWarning,
)
if reduce_structure:
structure = structure.get_reduced_structure(reduce_structure)
if sort_structure:
Expand All @@ -366,6 +357,19 @@ def __init__(
# when using 5.4 POTCARs, default Tungsten POTCAR to W_Sv but still allow user to override
user_potcar_settings = {"W": "W_sv", **(user_potcar_settings or {})}

struct_has_Yb = any(specie.symbol == "Yb" for site in structure for specie in site.species)
potcar_settings = config_dict.get("POTCAR", {})
if user_potcar_settings:
potcar_settings.update(user_potcar_settings)
uses_Yb_2_psp = potcar_settings.get("Yb", None) == "Yb_2"
if struct_has_Yb and uses_Yb_2_psp:
warnings.warn(
"The structure contains Ytterbium (Yb) and this InputSet uses the Yb_2 PSP.\n"
"Yb_2 is known to often give bad results since Yb has oxidation state 3+ in most compounds.\n"
"See https://github.com/materialsproject/pymatgen/issues/2968 for details.",
BadInputSetWarning,
)

self._structure = structure
self._config_dict = deepcopy(config_dict)
self.files_to_transfer = files_to_transfer or {}
Expand Down Expand Up @@ -404,7 +408,7 @@ def __init__(
self.potcar_functional = user_potcar_functional or self._config_dict.get("POTCAR_FUNCTIONAL", "PBE")

# warn if a user is overriding POTCAR_FUNCTIONAL
if self.potcar_functional != self._config_dict.get("POTCAR_FUNCTIONAL"):
if self.potcar_functional != self._config_dict.get("POTCAR_FUNCTIONAL", "PBE"):
warnings.warn(
"Overriding the POTCAR functional is generally not recommended "
" as it significantly affect the results of calculations and "
Expand Down