Skip to content

Commit

Permalink
Merge pull request #673 from esoteric-ephemera/main
Browse files Browse the repository at this point in the history
Ensure MP VASP sets don't use auto_ismear, few other fixes
  • Loading branch information
utf authored Jan 11, 2024
2 parents fcc0713 + 3d00f3e commit b9b97fe
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/atomate2/cp2k/sets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import os
from copy import deepcopy
from dataclasses import dataclass, field
from importlib.resources import files as get_mod_path
from pathlib import Path
from typing import Any

import numpy as np
from monty.io import zopen
from monty.serialization import loadfn
from pkg_resources import resource_filename
from pymatgen.core.structure import Molecule, Structure
from pymatgen.io.core import InputGenerator, InputSet
from pymatgen.io.cp2k.inputs import (
Expand All @@ -29,8 +29,8 @@

from atomate2 import SETTINGS

_BASE_CP2K_SET = loadfn(resource_filename("atomate2.cp2k.sets", "BaseCp2kSet.yaml"))
_BASE_GAPW_SET = loadfn(resource_filename("atomate2.cp2k.sets", "BaseAllSet.yaml"))
_BASE_CP2K_SET = loadfn(get_mod_path("atomate2.cp2k.sets") / "BaseCp2kSet.yaml")
_BASE_GAPW_SET = loadfn(get_mod_path("atomate2.cp2k.sets") / "BaseAllSet.yaml")


class Cp2kInputSet(InputSet):
Expand Down
4 changes: 2 additions & 2 deletions src/atomate2/vasp/sets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import warnings
from copy import deepcopy
from dataclasses import dataclass, field
from importlib.resources import files as get_mod_path
from itertools import groupby
from pathlib import Path
from typing import TYPE_CHECKING, Any

import numpy as np
from monty.io import zopen
from monty.serialization import loadfn
from pkg_resources import resource_filename
from pymatgen.electronic_structure.core import Magmom
from pymatgen.io.core import InputGenerator, InputSet
from pymatgen.io.vasp import Incar, Kpoints, Outcar, Poscar, Potcar, Vasprun
Expand All @@ -34,7 +34,7 @@
from pymatgen.core import Structure


_BASE_VASP_SET = loadfn(resource_filename("atomate2.vasp.sets", "BaseVaspSet.yaml"))
_BASE_VASP_SET = loadfn(get_mod_path("atomate2.vasp.sets") / "BaseVaspSet.yaml")


class VaspInputSet(InputSet):
Expand Down
6 changes: 3 additions & 3 deletions src/atomate2/vasp/sets/matpes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from __future__ import annotations

from dataclasses import dataclass, field
from importlib.resources import files as get_mod_path
from typing import TYPE_CHECKING

from monty.serialization import loadfn
from pkg_resources import resource_filename

from atomate2.vasp.sets.base import VaspInputGenerator

Expand All @@ -21,10 +21,10 @@

# POTCAR section comes from PARENT but atomate2 does not support inheritance yet
_BASE_MATPES_PBE_STATIC_SET_NO_POTCAR = loadfn(
resource_filename("pymatgen.io.vasp", "MatPESStaticSet.yaml")
get_mod_path("pymatgen.io.vasp") / "MatPESStaticSet.yaml"
)
_POTCAR_BASE_FILE = f"{_BASE_MATPES_PBE_STATIC_SET_NO_POTCAR['PARENT']}.yaml"
_POTCAR_SET = loadfn(resource_filename("pymatgen.io.vasp", _POTCAR_BASE_FILE))
_POTCAR_SET = loadfn(get_mod_path("pymatgen.io.vasp") / _POTCAR_BASE_FILE)
_BASE_MATPES_PBE_STATIC_SET = {**_POTCAR_SET, **_BASE_MATPES_PBE_STATIC_SET_NO_POTCAR}


Expand Down
14 changes: 11 additions & 3 deletions src/atomate2/vasp/sets/mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from __future__ import annotations

from dataclasses import dataclass, field
from importlib.resources import files as get_mod_path
from typing import TYPE_CHECKING

from monty.serialization import loadfn
from pkg_resources import resource_filename

from atomate2.vasp.sets.core import RelaxSetGenerator, StaticSetGenerator

Expand All @@ -21,10 +21,10 @@
from pymatgen.io.vasp import Outcar, Vasprun

_BASE_MP_GGA_RELAX_SET = loadfn(
resource_filename("atomate2.vasp.sets", "BaseMPGGASet.yaml")
get_mod_path("atomate2.vasp.sets") / "BaseMPGGASet.yaml"
)
_BASE_MP_R2SCAN_RELAX_SET = loadfn(
resource_filename("atomate2.vasp.sets", "BaseMPR2SCANRelaxSet.yaml")
get_mod_path("atomate2.vasp.sets") / "BaseMPR2SCANRelaxSet.yaml"
)


Expand All @@ -33,15 +33,19 @@ class MPGGARelaxSetGenerator(RelaxSetGenerator):
"""Class to generate MP-compatible VASP GGA relaxation input sets."""

config_dict: dict = field(default_factory=lambda: _BASE_MP_GGA_RELAX_SET)
auto_ismear: bool = False
auto_kspacing: bool = True
inherit_incar: bool | None = False


@dataclass
class MPGGAStaticSetGenerator(StaticSetGenerator):
"""Class to generate MP-compatible VASP GGA static input sets."""

config_dict: dict = field(default_factory=lambda: _BASE_MP_GGA_RELAX_SET)
auto_ismear: bool = False
auto_kspacing: bool = True
inherit_incar: bool | None = False

def get_incar_updates(
self,
Expand Down Expand Up @@ -87,8 +91,10 @@ class MPMetaGGAStaticSetGenerator(StaticSetGenerator):
"""Class to generate MP-compatible VASP GGA static input sets."""

config_dict: dict = field(default_factory=lambda: _BASE_MP_R2SCAN_RELAX_SET)
auto_ismear: bool = False
auto_kspacing: bool = True
bandgap_tol: float = 1e-4
inherit_incar: bool | None = False

def get_incar_updates(
self,
Expand Down Expand Up @@ -145,7 +151,9 @@ class MPMetaGGARelaxSetGenerator(RelaxSetGenerator):

config_dict: dict = field(default_factory=lambda: _BASE_MP_R2SCAN_RELAX_SET)
bandgap_tol: float = 1e-4
auto_ismear: bool = False
auto_kspacing: bool = True
inherit_incar: bool | None = False

def get_incar_updates(
self,
Expand Down
16 changes: 14 additions & 2 deletions tests/forcefields/flows/test_elastic.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
from pathlib import Path

from jobflow import run_locally
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

from atomate2.common.schemas.elastic import ElasticDocument
from atomate2.forcefields.flows.elastic import ElasticMaker
from atomate2.forcefields.jobs import MACERelaxMaker

_mace_model_path = (
f"{Path(__file__).parent.parent.parent}/test_data/forcefields/mace/MACE.model"
)


def test_elastic_wf_with_mace(clean_dir, si_structure):
si_prim = SpacegroupAnalyzer(si_structure).get_primitive_standard_structure()

job = ElasticMaker(
bulk_relax_maker=MACERelaxMaker(
relax_cell=True, relax_kwargs={"fmax": 0.00001}
relax_cell=True,
relax_kwargs={"fmax": 0.00001},
model=_mace_model_path,
model_kwargs={"default_dtype": "float64"},
),
elastic_relax_maker=MACERelaxMaker(
relax_cell=False, relax_kwargs={"fmax": 0.00001}
relax_cell=False,
relax_kwargs={"fmax": 0.00001},
model=_mace_model_path,
model_kwargs={"default_dtype": "float64"},
),
).make(si_prim)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/vasp/Si_mp_gga_relax/GGA_Relax_1/inputs/INCAR
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EDIFF = 0.0001
ENCUT = 520
IBRION = 2
ISIF = 3
ISMEAR = 0
ISMEAR = -5
ISPIN = 2
LASPH = True
LORBIT = 11
Expand All @@ -14,4 +14,4 @@ MAGMOM = 2*0.6
NELM = 100
NSW = 99
PREC = Accurate
SIGMA = 0.2
SIGMA = 0.05
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ MAGMOM = 2*0.6
NELM = 200
NSW = 99
PREC = Accurate
SIGMA = 0.2
SIGMA = 0.05
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENAUG = 1360.0
ENCUT = 680.0
IBRION = 2
ISIF = 3
ISMEAR = -5
ISMEAR = 0
ISPIN = 2
KSPACING = 0.28253269576667883
LAECHG = True
Expand Down
2 changes: 1 addition & 1 deletion tests/vasp/sets/test_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_mp_sets(set_generator: VaspInputGenerator) -> None:
else "PBE"
)
assert mp_set.inherit_incar is False
assert mp_set.auto_ismear is True
assert mp_set.auto_ismear is False
assert mp_set.auto_kspacing is True
assert mp_set.force_gamma is True
assert mp_set.auto_lreal is False
Expand Down

0 comments on commit b9b97fe

Please sign in to comment.