Skip to content

Commit 4e50400

Browse files
authored
Merge pull request #634 from JaGeo/add_lobster_mp_workflow
Add lobster mp workflow
2 parents c3f126b + 3a83e49 commit 4e50400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+297
-2
lines changed

docs/user/codes/vasp.md

+7

src/atomate2/lobster/schemas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class StrongestBonds(BaseModel):
596596
)
597597

598598

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

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

748748
# Read in lobsterout and lobsterin

src/atomate2/vasp/flows/mp.py

+73
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@
1313

1414
from jobflow import Flow, Maker
1515

16+
from atomate2.lobster.jobs import LobsterMaker
1617
from atomate2.vasp.flows.core import DoubleRelaxMaker
18+
from atomate2.vasp.flows.lobster import VaspLobsterMaker
1719
from atomate2.vasp.jobs.mp import (
1820
MPGGARelaxMaker,
1921
MPGGAStaticMaker,
2022
MPMetaGGARelaxMaker,
2123
MPMetaGGAStaticMaker,
2224
MPPreRelaxMaker,
2325
)
26+
from atomate2.vasp.sets.mp import MPGGAStaticSetGenerator
2427

2528
if TYPE_CHECKING:
2629
from pathlib import Path
2730

2831
from pymatgen.core.structure import Structure
2932

33+
from atomate2.vasp.jobs.base import BaseVaspMaker
34+
3035

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

187192
return Flow(jobs=jobs, output=output, name=self.name)
193+
194+
195+
# update potcars to 54, use correct W potcar
196+
# use staticmaker for compatibility
197+
198+
199+
@dataclass
200+
class MPVaspLobsterMaker(VaspLobsterMaker):
201+
"""
202+
Maker to perform a Lobster computation.
203+
204+
The calculations performed are:
205+
206+
1. Optional optimization.
207+
2. Static calculation with ISYM=0.
208+
3. Several Lobster computations testing several basis sets are performed.
209+
210+
.. Note::
211+
212+
The basis sets can only be changed with yaml files.
213+
214+
Parameters
215+
----------
216+
name : str
217+
Name of the flows produced by this maker.
218+
relax_maker : .BaseVaspMaker or None
219+
A maker to perform a relaxation on the bulk. Set to ``None`` to skip the
220+
bulk relaxation.
221+
lobster_static_maker : .BaseVaspMaker
222+
A maker to perform the computation of the wavefunction before the static run.
223+
Cannot be skipped. It can be LOBSTERUNIFORM or LobsterStaticMaker()
224+
lobster_maker : .LobsterMaker
225+
A maker to perform the Lobster run.
226+
delete_wavecars : bool
227+
If true, all WAVECARs will be deleted after the run.
228+
address_min_basis : str
229+
A path to a yaml file including basis set information.
230+
address_max_basis : str
231+
A path to a yaml file including basis set information.
232+
"""
233+
234+
name: str = "lobster"
235+
relax_maker: BaseVaspMaker | None = field(
236+
default_factory=lambda: MPGGADoubleRelaxMaker()
237+
)
238+
lobster_static_maker: BaseVaspMaker = field(
239+
default_factory=lambda: MPGGAStaticMaker(
240+
input_set_generator=MPGGAStaticSetGenerator(
241+
user_potcar_functional="PBE_54",
242+
user_potcar_settings={"W": "W_sv"},
243+
user_kpoints_settings={"reciprocal_density": 310},
244+
user_incar_settings={
245+
"EDIFF": 1e-6,
246+
"NSW": 0,
247+
"LWAVE": True,
248+
"ISYM": 0,
249+
"IBRION": -1,
250+
"ISMEAR": -5,
251+
"LORBIT": 11,
252+
"ALGO": "Normal",
253+
},
254+
)
255+
)
256+
)
257+
lobster_maker: LobsterMaker | None = field(default_factory=lambda: LobsterMaker())
258+
delete_wavecars: bool = True
259+
address_min_basis: str | None = None
260+
address_max_basis: str | None = None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ALGO = Normal
2+
EDIFF = 1e-06
3+
ENCUT = 520
4+
IBRION = -1
5+
ISMEAR = -5
6+
ISPIN = 2
7+
ISYM = 0
8+
LASPH = True
9+
LCHARG = True
10+
LMAXMIX = 4
11+
LORBIT = 11
12+
LREAL = False
13+
LWAVE = True
14+
MAGMOM = 2*2.758
15+
NBANDS = 18
16+
NELM = 100
17+
NSW = 0
18+
PREC = Accurate
19+
SIGMA = 0.05
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
COHPstartEnergy -5.0
2+
COHPendEnergy 5.0
3+
basisSet pbeVaspFit2015
4+
cohpGenerator from 0.1 to 3.0 orbitalwise
5+
saveProjectionToFile
6+
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ALGO = Fast
2+
EDIFF = 0.0001
3+
ENCUT = 520
4+
IBRION = 2
5+
ISIF = 3
6+
ISMEAR = -5
7+
ISPIN = 2
8+
LASPH = True
9+
LCHARG = False
10+
LMAXMIX = 4
11+
LORBIT = 11
12+
LREAL = Auto
13+
LWAVE = False
14+
MAGMOM = 2*2.758
15+
NELM = 100
16+
NSW = 99
17+
PREC = Accurate
18+
SIGMA = 0.05
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pymatgen with grid density = 211 / number of atoms
2+
0
3+
Gamma
4+
5 5 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Fe2
2+
1.0
3+
2.3361450900000000 0.0001116700000000 -0.8258229300000000
4+
-1.1680779800000001 2.0230472399999999 -0.8260822000000000
5+
1.1700738700000000 2.0273050000000001 3.3103279600000000
6+
Fe
7+
2
8+
direct
9+
0.5000000200000000 0.5000000800000000 0.4999999900000000 Fe
10+
0.9999999800000000 0.9999999200000000 0.0000000100000000 Fe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fe_pv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ALGO = Fast
2+
EDIFF = 0.0001
3+
ENCUT = 520
4+
IBRION = 2
5+
ISIF = 3
6+
ISMEAR = -5
7+
ISPIN = 2
8+
LASPH = True
9+
LCHARG = False
10+
LMAXMIX = 4
11+
LORBIT = 11
12+
LREAL = Auto
13+
LWAVE = False
14+
MAGMOM = 1*2.106 1*2.107
15+
NELM = 100
16+
NSW = 99
17+
PREC = Accurate
18+
SIGMA = 0.05
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pymatgen with grid density = 220 / number of atoms
2+
0
3+
Gamma
4+
5 5 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Fe2
2+
1.0
3+
2.3247697431142709 0.0011158394059855 -0.8224083286119700
4+
-1.1615226345878924 2.0137000999124477 -0.8226732920954348
5+
1.1372826593766157 1.9704788611038830 3.2175225091681869
6+
Fe
7+
2
8+
direct
9+
0.4999999975681003 0.5000000220874210 0.5000000028567035 Fe
10+
0.0000000024318998 0.9999999779125790 -0.0000000028567036 Fe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fe_pv
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ALGO = Normal
2+
EDIFF = 1e-06
3+
ENCUT = 520
4+
IBRION = -1
5+
ISMEAR = -5
6+
ISPIN = 2
7+
ISYM = 0
8+
LASPH = True
9+
LCHARG = True
10+
LMAXMIX = 4
11+
LORBIT = 11
12+
LREAL = False
13+
LWAVE = True
14+
MAGMOM = 2*2.105
15+
NBANDS = 18
16+
NELM = 100
17+
NSW = 0
18+
PREC = Accurate
19+
SIGMA = 0.05
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pymatgen with grid density = 221 / number of atoms
2+
0
3+
Gamma
4+
5 5 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Fe2
2+
1.0
3+
2.3191222174320663 0.0022375575036685 -0.8210990887096972
4+
-1.1577271585521238 2.0093705129625041 -0.8213633337288552
5+
1.1366928212633334 1.9694568925378289 3.2158537811988110
6+
Fe
7+
2
8+
direct
9+
0.4999999975681035 0.5000000220874199 0.5000000028567015 Fe
10+
0.0000000024318965 0.9999999779125801 0.9999999971432985 Fe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fe_pv
Binary file not shown.
Binary file not shown.

tests/vasp/lobster/flows/test_lobster.py

+86
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from atomate2.lobster.jobs import LobsterMaker
55
from atomate2.lobster.schemas import LobsterTaskDocument
66
from atomate2.vasp.flows.lobster import VaspLobsterMaker
7+
from atomate2.vasp.flows.mp import MPVaspLobsterMaker
78
from atomate2.vasp.jobs.lobster import LobsterStaticMaker
89
from atomate2.vasp.powerups import update_user_incar_settings
910

@@ -246,3 +247,88 @@ def test_lobstermaker_delete(mock_vasp, mock_lobster, clean_dir, memory_jobstore
246247
.resolve(memory_jobstore),
247248
LobsterTaskDocument,
248249
)
250+
251+
252+
def test_mp_vasp_lobstermaker(
253+
mock_vasp, mock_lobster, clean_dir, memory_jobstore, vasp_test_dir
254+
):
255+
# mapping from job name to directory containing test files
256+
ref_paths = {
257+
"MP GGA relax 1": "Fe_lobster_mp/GGA_relax_1",
258+
"MP GGA relax 2": "Fe_lobster_mp/GGA_relax_2",
259+
"MP GGA static": "Fe_lobster_mp/GGA_static",
260+
}
261+
262+
# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings
263+
fake_run_vasp_kwargs = {
264+
"MP GGA relax 1": {
265+
"incar_settings": ["NSW", "ISMEAR"],
266+
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
267+
},
268+
"MP GGA relax 2": {
269+
"incar_settings": ["NSW", "ISMEAR"],
270+
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
271+
},
272+
"MP GGA static": {
273+
"incar_settings": ["NSW", "LWAVE", "ISMEAR", "ISYM", "NBANDS", "ISPIN"],
274+
"check_inputs": ["poscar", "potcar", "kpoints", "incar"],
275+
},
276+
}
277+
278+
ref_paths_lobster = {
279+
"lobster_run_0": "Fe_lobster/lobster_0",
280+
"delete_lobster_wavecar": "Fe_lobster/lobster_0",
281+
}
282+
283+
# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings
284+
fake_run_lobster_kwargs = {
285+
"lobster_run_0": {"lobsterin_settings": ["basisfunctions"]},
286+
}
287+
288+
# automatically use fake VASP and write POTCAR.spec during the test
289+
mock_vasp(ref_paths, fake_run_vasp_kwargs)
290+
mock_lobster(ref_paths_lobster, fake_run_lobster_kwargs)
291+
292+
fe_structure = Structure(
293+
lattice=[
294+
[2.33614509e00, 1.11670000e-04, -8.25822930e-01],
295+
[-1.16807798e00, 2.02304724e00, -8.26082200e-01],
296+
[1.17007387e00, 2.02730500e00, 3.31032796e00],
297+
],
298+
species=["Fe", "Fe"],
299+
coords=[
300+
[5.0000002e-01, 5.0000008e-01, 4.9999999e-01],
301+
[9.9999998e-01, 9.9999992e-01, 1.0000000e-08],
302+
],
303+
)
304+
305+
job = MPVaspLobsterMaker(
306+
lobster_maker=LobsterMaker(
307+
task_document_kwargs={
308+
"calc_quality_kwargs": {"potcar_symbols": ["Fe_pv"], "n_bins": 10},
309+
"save_computational_data_jsons": False,
310+
"save_cba_jsons": False,
311+
},
312+
user_lobsterin_settings={
313+
"COHPstartEnergy": -5.0,
314+
"COHPEndEnergy": 5.0,
315+
"cohpGenerator": "from 0.1 to 3.0 orbitalwise",
316+
},
317+
),
318+
).make(fe_structure)
319+
320+
# run the flow or job and ensure that it finished running successfully
321+
responses = run_locally(
322+
job,
323+
create_folders=True,
324+
ensure_success=True,
325+
store=memory_jobstore,
326+
)
327+
328+
task_doc = (
329+
responses[job.jobs[-2].uuid][1]
330+
.replace.output["lobster_task_documents"][0]
331+
.resolve(memory_jobstore)
332+
)
333+
334+
assert isinstance(task_doc, LobsterTaskDocument)

0 commit comments

Comments
 (0)