diff --git a/src/atomate2/vasp/sets/base.py b/src/atomate2/vasp/sets/base.py index 5dd52353d0..82429658bc 100644 --- a/src/atomate2/vasp/sets/base.py +++ b/src/atomate2/vasp/sets/base.py @@ -312,6 +312,8 @@ class VaspInputGenerator(InputGenerator): force_gamma: bool = True symprec: float = SETTINGS.SYMPREC vdw: str = None + # copy _BASE_VASP_SET to ensure each class instance has its own copy + # otherwise in-place changes can affect other instances config_dict: dict = field(default_factory=lambda: _BASE_VASP_SET) inherit_incar: bool = None diff --git a/tests/vasp/test_sets.py b/tests/vasp/test_sets.py index f07e2b5a8c..c9cecb0c63 100644 --- a/tests/vasp/test_sets.py +++ b/tests/vasp/test_sets.py @@ -2,6 +2,7 @@ from pymatgen.core import Lattice, Species, Structure from atomate2.vasp.sets.core import StaticSetGenerator +from atomate2.vasp.sets.mp import MPMetaGGARelaxSetGenerator @pytest.fixture(scope="module") @@ -172,10 +173,10 @@ def test_set_u_params(structure, request) -> None: (10, {"KSPACING": 0.44, "ISMEAR": -5, "SIGMA": 0.05}), ], ) -def test_set_kspacing_and_auto_ismear(struct_no_magmoms, bandgap, expected_params): - static_set = StaticSetGenerator(auto_ismear=True, auto_kspacing=True) - # need to indicate to atomate2 to use KSPACING instead of KPOINTS - static_set.config_dict["INCAR"]["KSPACING"] = 42 # dummy value +def test_set_kspacing_and_auto_ismear( + struct_no_magmoms, bandgap, expected_params, monkeypatch +): + static_set = MPMetaGGARelaxSetGenerator(auto_ismear=True, auto_kspacing=True) incar = static_set._get_incar( structure=struct_no_magmoms,