Skip to content

Commit

Permalink
Merge pull request #634 from JaGeo/add_lobster_mp_workflow
Browse files Browse the repository at this point in the history
Add lobster mp workflow
  • Loading branch information
utf authored Jan 26, 2024
2 parents c3f126b + 3a83e49 commit 4e50400
Show file tree
Hide file tree
Showing 78 changed files with 297 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/user/codes/vasp.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ VASP_CMD: <<VASP_CMD>>
LOBSTER_CMD: <<LOBSTER_CMD>>
```
```{note}
A LOBSTER workflow with settings compatible to LOBSTER database (Naik, A.A., et al. Sci Data 10, 610 (2023). https://doi.org/10.1038/s41597-023-02477-5 , currently being integrated into Materials Project) is also available now,
which could be used by simply importing from atomate2.vasp.flows.mp > MPVaspLobsterMaker
instead of VaspLobsterMaker. Rest of the things to execute the workflow stays same as
shown below.
```

The corresponding flow could, for example, be started with the following code:

```py
Expand Down
4 changes: 2 additions & 2 deletions src/atomate2/lobster/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ class StrongestBonds(BaseModel):
)


class LobsterTaskDocument(StructureMetadata):
class LobsterTaskDocument(StructureMetadata, extra="allow"): # type: ignore[call-arg]
"""Definition of LOBSTER task document."""

structure: Structure = Field(description="The structure used in this task")
Expand Down Expand Up @@ -742,7 +742,7 @@ def from_directory(
LobsterTaskDocument
A task document for the lobster calculation.
"""
additional_fields = additional_fields or {}
additional_fields = {} if additional_fields is None else additional_fields
dir_name = Path(dir_name)

# Read in lobsterout and lobsterin
Expand Down
73 changes: 73 additions & 0 deletions src/atomate2/vasp/flows/mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@

from jobflow import Flow, Maker

from atomate2.lobster.jobs import LobsterMaker
from atomate2.vasp.flows.core import DoubleRelaxMaker
from atomate2.vasp.flows.lobster import VaspLobsterMaker
from atomate2.vasp.jobs.mp import (
MPGGARelaxMaker,
MPGGAStaticMaker,
MPMetaGGARelaxMaker,
MPMetaGGAStaticMaker,
MPPreRelaxMaker,
)
from atomate2.vasp.sets.mp import MPGGAStaticSetGenerator

if TYPE_CHECKING:
from pathlib import Path

from pymatgen.core.structure import Structure

from atomate2.vasp.jobs.base import BaseVaspMaker


@dataclass
class MPGGADoubleRelaxMaker(DoubleRelaxMaker):
Expand Down Expand Up @@ -185,3 +190,71 @@ def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow
jobs += [static_job]

return Flow(jobs=jobs, output=output, name=self.name)


# update potcars to 54, use correct W potcar
# use staticmaker for compatibility


@dataclass
class MPVaspLobsterMaker(VaspLobsterMaker):
"""
Maker to perform a Lobster computation.
The calculations performed are:
1. Optional optimization.
2. Static calculation with ISYM=0.
3. Several Lobster computations testing several basis sets are performed.
.. Note::
The basis sets can only be changed with yaml files.
Parameters
----------
name : str
Name of the flows produced by this maker.
relax_maker : .BaseVaspMaker or None
A maker to perform a relaxation on the bulk. Set to ``None`` to skip the
bulk relaxation.
lobster_static_maker : .BaseVaspMaker
A maker to perform the computation of the wavefunction before the static run.
Cannot be skipped. It can be LOBSTERUNIFORM or LobsterStaticMaker()
lobster_maker : .LobsterMaker
A maker to perform the Lobster run.
delete_wavecars : bool
If true, all WAVECARs will be deleted after the run.
address_min_basis : str
A path to a yaml file including basis set information.
address_max_basis : str
A path to a yaml file including basis set information.
"""

name: str = "lobster"
relax_maker: BaseVaspMaker | None = field(
default_factory=lambda: MPGGADoubleRelaxMaker()
)
lobster_static_maker: BaseVaspMaker = field(
default_factory=lambda: MPGGAStaticMaker(
input_set_generator=MPGGAStaticSetGenerator(
user_potcar_functional="PBE_54",
user_potcar_settings={"W": "W_sv"},
user_kpoints_settings={"reciprocal_density": 310},
user_incar_settings={
"EDIFF": 1e-6,
"NSW": 0,
"LWAVE": True,
"ISYM": 0,
"IBRION": -1,
"ISMEAR": -5,
"LORBIT": 11,
"ALGO": "Normal",
},
)
)
)
lobster_maker: LobsterMaker | None = field(default_factory=lambda: LobsterMaker())
delete_wavecars: bool = True
address_min_basis: str | None = None
address_max_basis: str | None = None
19 changes: 19 additions & 0 deletions tests/test_data/lobster/Fe_lobster/lobster_0/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ALGO = Normal
EDIFF = 1e-06
ENCUT = 520
IBRION = -1
ISMEAR = -5
ISPIN = 2
ISYM = 0
LASPH = True
LCHARG = True
LMAXMIX = 4
LORBIT = 11
LREAL = False
LWAVE = True
MAGMOM = 2*2.758
NBANDS = 18
NELM = 100
NSW = 0
PREC = Accurate
SIGMA = 0.05
6 changes: 6 additions & 0 deletions tests/test_data/lobster/Fe_lobster/lobster_0/inputs/lobsterin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
COHPstartEnergy -5.0
COHPendEnergy 5.0
basisSet pbeVaspFit2015
cohpGenerator from 0.1 to 3.0 orbitalwise
saveProjectionToFile
basisfunctions Fe 3d 3p 4s
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
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.
18 changes: 18 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_1/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ALGO = Fast
EDIFF = 0.0001
ENCUT = 520
IBRION = 2
ISIF = 3
ISMEAR = -5
ISPIN = 2
LASPH = True
LCHARG = False
LMAXMIX = 4
LORBIT = 11
LREAL = Auto
LWAVE = False
MAGMOM = 2*2.758
NELM = 100
NSW = 99
PREC = Accurate
SIGMA = 0.05
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_1/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 211 / number of atoms
0
Gamma
5 5 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_1/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Fe2
1.0
2.3361450900000000 0.0001116700000000 -0.8258229300000000
-1.1680779800000001 2.0230472399999999 -0.8260822000000000
1.1700738700000000 2.0273050000000001 3.3103279600000000
Fe
2
direct
0.5000000200000000 0.5000000800000000 0.4999999900000000 Fe
0.9999999800000000 0.9999999200000000 0.0000000100000000 Fe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_2/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ALGO = Fast
EDIFF = 0.0001
ENCUT = 520
IBRION = 2
ISIF = 3
ISMEAR = -5
ISPIN = 2
LASPH = True
LCHARG = False
LMAXMIX = 4
LORBIT = 11
LREAL = Auto
LWAVE = False
MAGMOM = 1*2.106 1*2.107
NELM = 100
NSW = 99
PREC = Accurate
SIGMA = 0.05
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_2/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 220 / number of atoms
0
Gamma
5 5 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_relax_2/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Fe2
1.0
2.3247697431142709 0.0011158394059855 -0.8224083286119700
-1.1615226345878924 2.0137000999124477 -0.8226732920954348
1.1372826593766157 1.9704788611038830 3.2175225091681869
Fe
2
direct
0.4999999975681003 0.5000000220874210 0.5000000028567035 Fe
0.0000000024318998 0.9999999779125790 -0.0000000028567036 Fe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_static/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ALGO = Normal
EDIFF = 1e-06
ENCUT = 520
IBRION = -1
ISMEAR = -5
ISPIN = 2
ISYM = 0
LASPH = True
LCHARG = True
LMAXMIX = 4
LORBIT = 11
LREAL = False
LWAVE = True
MAGMOM = 2*2.105
NBANDS = 18
NELM = 100
NSW = 0
PREC = Accurate
SIGMA = 0.05
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_static/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 221 / number of atoms
0
Gamma
5 5 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Fe_lobster_mp/GGA_static/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Fe2
1.0
2.3191222174320663 0.0022375575036685 -0.8210990887096972
-1.1577271585521238 2.0093705129625041 -0.8213633337288552
1.1366928212633334 1.9694568925378289 3.2158537811988110
Fe
2
direct
0.4999999975681035 0.5000000220874199 0.5000000028567015 Fe
0.0000000024318965 0.9999999779125801 0.9999999971432985 Fe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fe_pv
Binary file not shown.
Binary file not shown.
86 changes: 86 additions & 0 deletions tests/vasp/lobster/flows/test_lobster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from atomate2.lobster.jobs import LobsterMaker
from atomate2.lobster.schemas import LobsterTaskDocument
from atomate2.vasp.flows.lobster import VaspLobsterMaker
from atomate2.vasp.flows.mp import MPVaspLobsterMaker
from atomate2.vasp.jobs.lobster import LobsterStaticMaker
from atomate2.vasp.powerups import update_user_incar_settings

Expand Down Expand Up @@ -246,3 +247,88 @@ def test_lobstermaker_delete(mock_vasp, mock_lobster, clean_dir, memory_jobstore
.resolve(memory_jobstore),
LobsterTaskDocument,
)


def test_mp_vasp_lobstermaker(
mock_vasp, mock_lobster, clean_dir, memory_jobstore, vasp_test_dir
):
# mapping from job name to directory containing test files
ref_paths = {
"MP GGA relax 1": "Fe_lobster_mp/GGA_relax_1",
"MP GGA relax 2": "Fe_lobster_mp/GGA_relax_2",
"MP GGA static": "Fe_lobster_mp/GGA_static",
}

# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings
fake_run_vasp_kwargs = {
"MP GGA relax 1": {
"incar_settings": ["NSW", "ISMEAR"],
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
},
"MP GGA relax 2": {
"incar_settings": ["NSW", "ISMEAR"],
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
},
"MP GGA static": {
"incar_settings": ["NSW", "LWAVE", "ISMEAR", "ISYM", "NBANDS", "ISPIN"],
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
},
}

ref_paths_lobster = {
"lobster_run_0": "Fe_lobster/lobster_0",
"delete_lobster_wavecar": "Fe_lobster/lobster_0",
}

# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings
fake_run_lobster_kwargs = {
"lobster_run_0": {"lobsterin_settings": ["basisfunctions"]},
}

# automatically use fake VASP and write POTCAR.spec during the test
mock_vasp(ref_paths, fake_run_vasp_kwargs)
mock_lobster(ref_paths_lobster, fake_run_lobster_kwargs)

fe_structure = Structure(
lattice=[
[2.33614509e00, 1.11670000e-04, -8.25822930e-01],
[-1.16807798e00, 2.02304724e00, -8.26082200e-01],
[1.17007387e00, 2.02730500e00, 3.31032796e00],
],
species=["Fe", "Fe"],
coords=[
[5.0000002e-01, 5.0000008e-01, 4.9999999e-01],
[9.9999998e-01, 9.9999992e-01, 1.0000000e-08],
],
)

job = MPVaspLobsterMaker(
lobster_maker=LobsterMaker(
task_document_kwargs={
"calc_quality_kwargs": {"potcar_symbols": ["Fe_pv"], "n_bins": 10},
"save_computational_data_jsons": False,
"save_cba_jsons": False,
},
user_lobsterin_settings={
"COHPstartEnergy": -5.0,
"COHPEndEnergy": 5.0,
"cohpGenerator": "from 0.1 to 3.0 orbitalwise",
},
),
).make(fe_structure)

# run the flow or job and ensure that it finished running successfully
responses = run_locally(
job,
create_folders=True,
ensure_success=True,
store=memory_jobstore,
)

task_doc = (
responses[job.jobs[-2].uuid][1]
.replace.output["lobster_task_documents"][0]
.resolve(memory_jobstore)
)

assert isinstance(task_doc, LobsterTaskDocument)

0 comments on commit 4e50400

Please sign in to comment.