Skip to content

Commit 63728ff

Browse files
updates for consistency with atomate2 updates
1 parent a9da16e commit 63728ff

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,16 @@ class DictSet(VaspInputSet):
343343
SIGMA=0.2; if the system is an insulator, then ISMEAR=-5 (tetrahedron
344344
smearing). Note, this only works when generating the input set from a
345345
previous VASP directory.
346+
auto_ispin (bool) = False:
347+
If generating input set from a previous calculation, this controls whether
348+
to disable magnetisation (ISPIN = 1) if the absolute value of all magnetic
349+
moments are less than 0.02.
350+
auto_lreal (bool) = False:
351+
If True, automatically use the VASP recommended LREAL based on cell size.
352+
auto_metal_kpoints
353+
If true and the system is metallic, try and use ``reciprocal_density_metal``
354+
instead of ``reciprocal_density`` for metallic systems. Note, this only works
355+
if the bandgap is not None.
346356
bandgap_tol (float): Tolerance for determining if a system is metallic when
347357
KSPACING is set to "auto". If the bandgap is less than this value, the
348358
system is considered metallic. Defaults to 1e-4 (eV).
@@ -373,6 +383,9 @@ class DictSet(VaspInputSet):
373383
validate_magmom: bool = True
374384
inherit_incar: bool | list[str] = False
375385
auto_ismear: bool = False
386+
auto_ispin: bool = False
387+
auto_lreal: bool = False
388+
auto_metal_kpoints: bool = False
376389
bandgap_tol: float = 1e-4
377390
bandgap: float | None = None
378391
prev_incar: str | dict | None = None
@@ -405,9 +418,9 @@ def __post_init__(self):
405418

406419
if self.vdw:
407420
vdw_par = loadfn(MODULE_DIR / "vdW_parameters.yaml")
408-
try:
409-
self._config_dict["INCAR"].update(vdw_par[self.vdw])
410-
except KeyError:
421+
if vdw_param := vdw_par.get(self.vdw):
422+
self._config_dict["INCAR"].update(vdw_param)
423+
else:
411424
raise KeyError(
412425
f"Invalid or unsupported van-der-Waals functional. Supported functionals are {', '.join(vdw_par)}."
413426
)
@@ -721,6 +734,9 @@ def incar(self) -> Incar:
721734
else:
722735
auto_updates.update(ISMEAR=-5, SIGMA=0.05) # insulator
723736

737+
if self.auto_lreal:
738+
auto_updates.update(LREAL=_get_recommended_lreal(structure))
739+
724740
kpoints = self.kpoints
725741
if kpoints is not None:
726742
# unset KSPACING as we are using a KPOINTS file
@@ -759,14 +775,13 @@ def incar(self) -> Incar:
759775
and incar.get("NSW", 0) > 0
760776
and (ismear < 0 or (ismear == 0 and sigma > 0.05))
761777
):
762-
ismear_docs = "https://www.vasp.at/wiki/index.php/ISMEAR"
763778
msg = ""
764779
if ismear < 0:
765780
msg = f"Relaxation of likely metal with ISMEAR < 0 ({ismear})."
766781
elif ismear == 0 and sigma > 0.05:
767782
msg = f"ISMEAR = 0 with a small SIGMA ({sigma}) detected."
768783
warnings.warn(
769-
f"{msg} See VASP recommendations on ISMEAR for metals ({ismear_docs}).",
784+
f"{msg} See VASP recommendations on ISMEAR for metals (" "https://www.vasp.at/wiki/index.php/ISMEAR).",
770785
BadInputSetWarning,
771786
stacklevel=1,
772787
)
@@ -3058,6 +3073,11 @@ def _get_ispin(vasprun: Vasprun | None, outcar: Outcar | None) -> int:
30583073
return 2
30593074

30603075

3076+
def _get_recommended_lreal(structure: Structure) -> str | bool:
3077+
"""Get recommended LREAL flag based on the structure."""
3078+
return "Auto" if structure.num_sites > 16 else False
3079+
3080+
30613081
def _combine_kpoints(*kpoints_objects: Kpoints) -> Kpoints:
30623082
"""Combine multiple Kpoints objects."""
30633083
_labels: list[list[str]] = []

0 commit comments

Comments
 (0)