Skip to content

Fix RelaxConstVolSetGenerator #1247

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

Merged
merged 2 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
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
30 changes: 6 additions & 24 deletions src/atomate2/vasp/sets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if TYPE_CHECKING:
from emmet.core.math import Vector3D
from pymatgen.core import Structure
from pymatgen.io.vasp import Kpoints, Outcar, Vasprun
from pymatgen.io.vasp import Kpoints


logger = logging.getLogger(__name__)
Expand All @@ -38,31 +38,13 @@ def incar_updates(self) -> dict:
return {"NSW": 99, "LCHARG": False, "ISIF": 3, "IBRION": 2}


@dataclass
class RelaxConstVolSetGenerator(VaspInputGenerator):
"""Class to generate VASP constant volume relaxation input sets."""

def get_incar_updates(
self,
structure: Structure,
prev_incar: dict = None,
bandgap: float = None,
vasprun: Vasprun = None,
outcar: Outcar = None,
) -> dict:
"""Get updates to the INCAR for a constant volume relaxation job.

Parameters
----------
structure
A structure.
prev_incar
An incar from a previous calculation.
bandgap
The band gap.
vasprun
A vasprun from a previous calculation.
outcar
An outcar from a previous calculation.
@property
def incar_updates(self) -> dict:
"""Get updates to the INCAR for a tight constant volume relaxation job.

Returns
-------
Expand Down Expand Up @@ -104,7 +86,7 @@ class TightRelaxConstVolSetGenerator(VaspInputGenerator):

@property
def incar_updates(self) -> dict:
"""Get updates to the INCAR for a static VASP job.
"""Get updates to the INCAR for a constant volume tight relaxation job.

Returns
-------
Expand Down
95 changes: 94 additions & 1 deletion tests/vasp/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
from pymatgen.core import Lattice, Species, Structure
from pymatgen.io.vasp.sets import MPScanRelaxSet

from atomate2.vasp.sets.core import StaticSetGenerator
from atomate2.vasp.sets.core import (
ElectronPhononSetGenerator,
HSEBSSetGenerator,
HSERelaxSetGenerator,
HSEStaticSetGenerator,
HSETightRelaxSetGenerator,
LobsterTightStaticSetGenerator,
MDSetGenerator,
NonSCFSetGenerator,
RelaxConstVolSetGenerator,
RelaxSetGenerator,
StaticSetGenerator,
TightRelaxConstVolSetGenerator,
TightRelaxSetGenerator,
)


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -199,3 +213,82 @@ def test_set_kspacing_bandgap_tol_and_auto_ismear(

actual = {key: incar[key] for key in expected_params}
assert actual == pytest.approx(expected_params)


def test_core(struct_no_magmoms):
input_gen = RelaxSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["ISIF"] == 3
assert incar["IBRION"] == 2

input_gen = RelaxConstVolSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["ISIF"] == 2
assert incar["IBRION"] == 2
assert incar["EDIFF"] == 1e-5

input_gen = TightRelaxSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["ISIF"] == 3
assert incar["IBRION"] == 2
assert incar["EDIFF"] == 1e-7

input_gen = TightRelaxConstVolSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["ISIF"] == 2
assert incar["IBRION"] == 2
assert incar["EDIFF"] == 1e-7

input_gen = StaticSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["ISMEAR"] == -5
assert incar["NSW"] == 0

input_gen = NonSCFSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["NSW"] == 0
assert incar["ISYM"] == 0

input_gen = HSERelaxSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["PRECFOCK"] == "Fast"
assert incar["HFSCREEN"] == 0.2
assert incar["EDIFF"] == 1e-5

input_gen = HSETightRelaxSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["PRECFOCK"] == "Fast"
assert incar["HFSCREEN"] == 0.2
assert incar["EDIFF"] == 1e-7

input_gen = HSEStaticSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["PRECFOCK"] == "Fast"
assert incar["HFSCREEN"] == 0.2
assert incar["EDIFF"] == 1e-5
assert incar["NSW"] == 0

input_gen = HSEBSSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["PRECFOCK"] == "Fast"
assert incar["HFSCREEN"] == 0.2
assert incar["EDIFF"] == 1e-5
assert incar["NSW"] == 0
assert incar["ISMEAR"] == 0

input_gen = ElectronPhononSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["PHON_NSTRUCT"] == 0
assert incar["NSW"] == 1
assert incar["ISMEAR"] == 0

input_gen = MDSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["TEBEG"] == 300
assert incar["TEEND"] == 300

input_gen = LobsterTightStaticSetGenerator()
incar = input_gen.get_input_set(struct_no_magmoms, potcar_spec=True)["INCAR"]
assert incar["EDIFF"] == 1e-7
assert incar["ISYM"] == 0
assert incar["LWAVE"] is True
Loading