Skip to content

Commit

Permalink
Initial attempt at MP workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Jun 2, 2023
1 parent c2d098a commit 0d30189
Show file tree
Hide file tree
Showing 7 changed files with 1,389 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/atomate2/vasp/flows/mp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Module defining flows for Materials Project r2SCAN workflows
Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801
"""

from __future__ import annotations

from copy import deepcopy
from dataclasses import dataclass, field

from jobflow import Flow, Maker
149 changes: 149 additions & 0 deletions src/atomate2/vasp/jobs/mp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
"""
Module defining jobs for Materials Project r2SCAN workflows
Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

import numpy as np
from monty.serialization import loadfn
from pkg_resources import resource_filename

from atomate2.vasp.jobs.base import BaseVaspMaker
from atomate2.vasp.sets.base import VaspInputGenerator
from atomate2.vasp.sets.core import RelaxSetGenerator, StaticSetGenerator

__all__ = ["MPPrelaxMaker", "MPRelaxMaker", "MPStaticMaker"]

_BASE_MP_R2SCAN_RELAX_SET = loadfn(
resource_filename("atomate2.vasp.sets", "BaseMPr2SCANRelaxSet.yaml")
)


class MPRelaxR2SCANGenerator(VaspInputGenerator):
config_dict: dict = field(lambda: _BASE_MP_R2SCAN_RELAX_SET)


@dataclass
class MPPreRelaxMaker(BaseVaspMaker):
"""
Maker to create VASP pre-relaxation job using PBEsol 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 = "MP-PreRelax"
input_set_generator: VaspInputGenerator = field(
default_factory=lambda: MPRelaxR2SCANGenerator(
{"user_incar_settings": {"EDIFFG": -0.05, "METAGGA": None, "GGA": "PS"}}
)
)


@dataclass
class MPRelaxMaker(BaseVaspMaker):
"""
Maker to create VASP relaxation job using r2SCAN by default.
Parameters
----------
name : str
The job name.
bandgap : float
The bandgap of the material in eV. Used to determine the k-point density.
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 = "MP-Relax"
bandgap: float = 0.0
input_set_generator: VaspInputGenerator = field(
default_factory=MPRelaxR2SCANGenerator
)

def __post_init__(self):
if self.bandgap < 1e-4:
kspacing = 0.22
else:
rmin = 25.22 - 2.87 * self.bandgap
kspacing = 2 * np.pi * 1.0265 / (rmin - 1.0183)

self.input_set_generator.config_dict["user_incar_settings"].update(
KSPACING=kspacing if 0.22 < kspacing < 0.44 else 0.44, ISMEAR=0.05, SIGMA=-5
)


@dataclass
class MPStaticMaker(MPRelaxMaker):
"""
Maker to create VASP static job using r2SCAN by default.
Parameters
----------
name : str
The job name.
bandgap : float
The bandgap of the material in eV. Used to determine the k-point density.
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 = "MP-Static"
input_set_generator: VaspInputGenerator = field(StaticSetGenerator)
160 changes: 160 additions & 0 deletions src/atomate2/vasp/sets/BaseMPR2SCANRelaxSet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Default VASP settings for calculations in the Materials Project
# using the Regularized-Restored Strongly Constrained and Appropriately
# Normed functional (r2SCAN).
INCAR:
ALGO: ALL
EDIFF: 1.e-05
EDIFFG: -0.02
ENAUG: 1360
ENCUT: 680
IBRION: 2
ISIF: 3
ISMEAR: 2
ISPIN: 2
KSPACING: 0.22
LAECHG: True # Output AECCAR
LASPH: True
LCHARG: True # Output CHGCAR
LELF: True # Output ELFCAR
LMIXTAU: True
LORBIT: 11
LREAL: Auto
LVTOT: True # Output LOCPOT
LWAVE: False # Don't output WAVECAR
METAGGA: R2SCAN
NELM: 200
NSW: 99
PREC: Accurate
SIGMA: 0.2
MAGMOM:
Ce: 5
Ce3+: 1
Co: 0.6
Co3+: 0.6
Co4+: 1
Cr: 5
Dy3+: 5
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ect thermodynamics for most systems with Yb3+
# https://github.com/materialsproject/pymatgen/issues/2968
Yb: Yb_3
Zn: Zn
Zr: Zr_sv
2 changes: 1 addition & 1 deletion src/atomate2/vasp/sets/BaseVaspSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ INCAR:
ISMEAR: 0
LORBIT: 11
LASPH: True
LDAU: true
LDAU: True
LDAUJ:
F:
Co: 0
Expand Down
32 changes: 32 additions & 0 deletions src/atomate2/vasp/sets/MPMAGMOM.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
INCAR:
MAGMOM:
Ce: 5
Ce3+: 1
Co: 0.6
Co3+: 0.6
Co4+: 1
Cr: 5
Dy3+: 5
Er3+: 3
Eu: 10
Eu2+: 7
Eu3+: 6
Fe: 5
Gd3+: 7
Ho3+: 4
La3+: 0.6
Lu3+: 0.6
Mn: 5
Mn3+: 4
Mn4+: 3
Mo: 5
Nd3+: 3
Ni: 5
Pm3+: 4
Pr3+: 2
Sm3+: 5
Tb3+: 6
Tm3+: 2
V: 5
W: 5
Yb3+: 1
3 changes: 2 additions & 1 deletion src/atomate2/vasp/sets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def get_incar_updates(
bandgap: float = None,
vasprun: Vasprun = None,
outcar: Outcar = None,
**kwargs: Any,
) -> dict:
"""
Get updates to the INCAR for a relaxation job.
Expand All @@ -68,7 +69,7 @@ def get_incar_updates(
dict
A dictionary of updates to apply.
"""
return {"NSW": 99, "LCHARG": False, "ISIF": 3, "IBRION": 2}
return {"NSW": 99, "LCHARG": False, "ISIF": 3, "IBRION": 2, **kwargs}


@dataclass
Expand Down
Loading

0 comments on commit 0d30189

Please sign in to comment.