Skip to content

Commit

Permalink
Merge pull request #532 from materialsproject/matpes
Browse files Browse the repository at this point in the history
Add MatPES GGA and r2SCAN static makers
  • Loading branch information
janosh authored Oct 18, 2023
2 parents dc78b85 + c800f16 commit 26d7a31
Show file tree
Hide file tree
Showing 55 changed files with 490 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ jobs:
cache-dependency-path: pyproject.toml

- name: Install dependencies
# ERROR: Cannot install atomate2 and atomate2[strict,tests]==0.0.1 because these package versions have conflicting dependencies.
# The conflict is caused by:
# atomate2[strict,tests] 0.0.1 depends on pymatgen>=2023.10.4
# atomate2[strict,tests] 0.0.1 depends on pymatgen==2023.10.4; extra == "strict"
# ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
# chgnet 0.2.1 depends on pymatgen>=2023.5.31
# emmet-core 0.70.0 depends on pymatgen>=2023.10.11
run: |
python -m pip install --upgrade pip
pip install .[strict,tests]
Expand Down
1 change: 1 addition & 0 deletions ADMIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Version releases on Pypi and GitHub are handled automatically through GitHub
actions. The steps to push a new release are:

1. Update `CHANGELOG.md` with a new version and release notes.
2. Create a tagged Git commit with the above changes: `git tag v0.0.1`
3. Push the commit and tags to GitHub using: `git push origin --tags`
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"PyYAML",
"click",
"custodian>=2023.3.10",
"emmet-core>=0.70.0",
"emmet-core>=0.70.5",
"jobflow>=0.1.11",
"monty>=2023.9.25",
"numpy",
Expand Down Expand Up @@ -66,7 +66,7 @@ strict = [
"click==8.1.7",
"custodian==2023.10.9",
"dscribe==2.1.0",
"emmet-core==0.70.4",
"emmet-core==0.70.5",
"jobflow==0.1.14",
"lobsterpy==0.3.2",
"matgl==0.8.3",
Expand Down
67 changes: 67 additions & 0 deletions src/atomate2/vasp/flows/matpes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Module defining MatPES flows.
In case of questions, consult @janosh or @esoteric-ephemera. Makes PBE + r2SCAN
cheaper than running both separately.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from jobflow import Flow, Maker

from atomate2.vasp.jobs.matpes import MatPesGGAStaticMaker, MatPesMetaGGAStaticMaker

if TYPE_CHECKING:
from pathlib import Path

from pymatgen.core import Structure


@dataclass
class MatPesGGAPlusMetaGGAStaticMaker(Maker):
"""MatPES flow doing a GGA static followed by meta-GGA static.
Uses the GGA WAVECAR to speed up electronic convergence on the meta-GGA static.
Parameters
----------
name : str
Name of the flows produced by this maker.
static1 : .BaseVaspMaker
Maker to generate the first VASP static.
static2 : .BaseVaspMaker
Maker to generate the second VASP static.
"""

name: str = "MatPES GGA plus meta-GGA static"
static1: Maker | None = field(default_factory=MatPesGGAStaticMaker)
static2: Maker = field(
default_factory=lambda: MatPesMetaGGAStaticMaker(
# could copy CHGCAR from GGA to meta-GGA directory too but is redundant
# since VASP can reconstruct it from WAVECAR
copy_vasp_kwargs={"additional_vasp_files": ("WAVECAR",)}
)
)

def make(self, structure: Structure, prev_vasp_dir: str | Path | None = None):
"""
Create a flow with two chained statics.
Parameters
----------
structure : .Structure
A pymatgen structure object.
prev_vasp_dir : str or Path or None
A previous VASP calculation directory to copy output files from.
Returns
-------
Flow
A flow containing two statics.
"""
static1 = self.static1.make(structure, prev_vasp_dir=prev_vasp_dir)
static2 = self.static2.make(structure, prev_vasp_dir=static1.output.dir_name)
return Flow([static1, static2], output=static2.output, name=self.name)
2 changes: 1 addition & 1 deletion src/atomate2/vasp/flows/mp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Module defining flows for Materials Project workflows.
Module defining Materials Project workflows.
Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801
Expand Down
91 changes: 91 additions & 0 deletions src/atomate2/vasp/jobs/matpes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""
Module defining MatPES job makers.
In case of questions, contact @janosh or @shyuep.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from atomate2.vasp.jobs.base import BaseVaspMaker
from atomate2.vasp.sets.matpes import (
MatPesGGAStaticSetGenerator,
MatPesMetaGGAStaticSetGenerator,
)

if TYPE_CHECKING:
from atomate2.vasp.sets.base import VaspInputGenerator


@dataclass
class MatPesGGAStaticMaker(BaseVaspMaker):
"""
Maker to create VASP static job using r2SCAN by default.
Parameters
----------
name : str
The job name.
input_set_generator : .VaspInputGenerator
A generator used to make the input set.
write_input_set_kwargs : dict
Keyword arguments that will get passed to :obj:`.write_vasp_input_set`.
copy_vasp_kwargs : dict
Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`.
run_vasp_kwargs : dict
Keyword arguments that will get passed to :obj:`.run_vasp`.
task_document_kwargs : dict
Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`.
stop_children_kwargs : dict
Keyword arguments that will get passed to :obj:`.should_stop_children`.
write_additional_data : dict
Additional data to write to the current directory. Given as a dict of
{filename: data}. Note that if using FireWorks, dictionary keys cannot contain
the "." character which is typically used to denote file extensions. To avoid
this, use the ":" character, which will automatically be converted to ".". E.g.
``{"my_file:txt": "contents of the file"}``.
"""

name: str = "MatPES GGA static"
input_set_generator: VaspInputGenerator = field(
default_factory=MatPesGGAStaticSetGenerator
)
inherit_incar: bool = False


@dataclass
class MatPesMetaGGAStaticMaker(BaseVaspMaker):
"""
Maker to create VASP static job using r2SCAN by default.
Parameters
----------
name : str
The job name.
input_set_generator : .VaspInputGenerator
A generator used to make the input set.
write_input_set_kwargs : dict
Keyword arguments that will get passed to :obj:`.write_vasp_input_set`.
copy_vasp_kwargs : dict
Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`.
run_vasp_kwargs : dict
Keyword arguments that will get passed to :obj:`.run_vasp`.
task_document_kwargs : dict
Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`.
stop_children_kwargs : dict
Keyword arguments that will get passed to :obj:`.should_stop_children`.
write_additional_data : dict
Additional data to write to the current directory. Given as a dict of
{filename: data}. Note that if using FireWorks, dictionary keys cannot contain
the "." character which is typically used to denote file extensions. To avoid
this, use the ":" character, which will automatically be converted to ".". E.g.
``{"my_file:txt": "contents of the file"}``.
"""

name: str = "MatPES meta-GGA static"
input_set_generator: VaspInputGenerator = field(
default_factory=MatPesMetaGGAStaticSetGenerator
)
inherit_incar: bool = False
10 changes: 1 addition & 9 deletions src/atomate2/vasp/jobs/mp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Module defining jobs for Materials Project r2SCAN workflows.
Module defining Materials Project job makers.
Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801
Expand All @@ -22,14 +22,6 @@
if TYPE_CHECKING:
from atomate2.vasp.sets.base import VaspInputGenerator

__all__ = [
"MPGGARelaxMaker",
"MPGGAStaticMaker",
"MPPreRelaxMaker",
"MPMetaGGARelaxMaker",
"MPMetaGGAStaticMaker",
]


@dataclass
class MPGGARelaxMaker(BaseVaspMaker):
Expand Down
87 changes: 87 additions & 0 deletions src/atomate2/vasp/sets/matpes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""
Module defining MatPES input set generators.
In case of questions, contact @janosh or @shyuep.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from monty.serialization import loadfn
from pkg_resources import resource_filename

from atomate2.vasp.sets.core import StaticSetGenerator

if TYPE_CHECKING:
from pymatgen.core import Structure
from pymatgen.io.vasp import Outcar, Vasprun


# 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")
)
_BASE_PBE54_SET = loadfn(resource_filename("pymatgen.io.vasp", "PBE54Base.yaml"))
_BASE_MATPES_PBE_STATIC_SET = {
**_BASE_PBE54_SET,
**_BASE_MATPES_PBE_STATIC_SET_NO_POTCAR,
}


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

config_dict: dict = field(default_factory=lambda: _BASE_MATPES_PBE_STATIC_SET)
auto_ismear: bool = False
auto_kspacing: bool = True
user_incar_settings: dict = field(
# ensure _set_kspacing doesn't override input set ISMEAR
default_factory=lambda: {"ISMEAR": 0, "SIGMA": 0.05}
)


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

config_dict: dict = field(default_factory=lambda: _BASE_MATPES_PBE_STATIC_SET)
auto_ismear: bool = False
auto_kspacing: bool = True
user_incar_settings: dict = field(
# ensure _set_kspacing doesn't override input set ISMEAR
default_factory=lambda: {"ISMEAR": 0, "SIGMA": 0.05}
)

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 this calculation type.
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.
Returns
-------
dict
A dictionary of updates to apply.
"""
return {"METAGGA": "R2SCAN", "ALGO": "ALL", "GGA": None} # unset GGA
2 changes: 1 addition & 1 deletion src/atomate2/vasp/sets/mp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Module defining jobs for Materials Project r2SCAN workflows.
Module defining Materials Project input set generators.
Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ALGO = Normal
EDIFF = 1e-05
ENAUG = 1360
ENCUT = 680
GGA = Pe
ISMEAR = 0
ISPIN = 2
KSPACING = 0.22
LAECHG = True
LASPH = True
LCHARG = True
LMAXMIX = 6
LMIXTAU = True
LORBIT = 11
LREAL = False
LWAVE = False
NELM = 200
NSW = 0
PREC = Accurate
SIGMA = 0.05
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Si2
1.0
3.3488982826904379 0.0000000000000000 1.9334873250000004
1.1162994275634794 3.1573715802591895 1.9334873250000004
0.0000000000000000 0.0000000000000000 3.8669746500000000
Si
2
direct
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ALGO = All
EDIFF = 1e-05
ENAUG = 1360.0
ENCUT = 680
ISMEAR = 0
ISPIN = 2
KSPACING = 0.28754316109307704
LAECHG = True
LASPH = True
LCHARG = True
LMAXMIX = 6
LMIXTAU = True
LORBIT = 11
LREAL = False
LWAVE = False
METAGGA = R2scan
NELM = 200
NSW = 0
PREC = Accurate
SIGMA = 0.05
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Si2
1.0
3.3488982826904379 0.0000000000000000 1.9334873250000004
1.1162994275634794 3.1573715802591895 1.9334873250000004
0.0000000000000000 0.0000000000000000 3.8669746500000000
Si
2
direct
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 26d7a31

Please sign in to comment.