Skip to content

Commit c57f9c1

Browse files
authored
Feat: GW workflow with VASP (#808)
* Added the Materials Virtual Lab GW Set to the repo and implemented the MVLGWSetGenerator * add a Materials Virtual Lab GW band structure maker * fix bug * rename MVLGWMaker * created a Flow that does all three stages (static, diag, gw) for a GW band structure calculation * fixed bug * update the mvl gw yaml file and explicity copy the magmon in it * update the gw workflow * Revert line 37 to original state and fixed a typo * update the class doc of MVLGWSetGenerator * rewrite job name * rewrite job name * make job and flow names short * update job name * change the method names to adjust for recent updates on the main branch * explicitly specify files to copy * copied all data files for gw test case * add testcase for running MVL GW workflow * modified the files needed to copy between jobs * fixed wrong assertation * added missing data files to run the tests * add a warning in the GW workflow * removed MVL GW set yaml file, instead, import from pymatgen * reorganize the mvl jobs * reorganize the mvl gw workflow * update test case for mvl gw workflow and update the test data * update the mvl gw workflow * update test case for mvl gw workflow and corresponding test data * Bump emmet-core from 0.84.2 to 0.84.3rc3 * updated test data for mvl g0w0 * removed MVLGWSetGenerator class; use MVLGWSet directly instead * removed deprecate comments * remove CONTCAR.gz, use CONTCAR instead
1 parent 237dcdc commit c57f9c1

Some content is hidden

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

53 files changed

+400
-2
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
"PyYAML",
2929
"click",
3030
"custodian>=2024.4.18",
31-
"emmet-core>=0.82.2",
31+
"emmet-core>=0.84.3rc3",
3232
"jobflow>=0.1.11",
3333
"monty>=2024.7.30",
3434
"numpy",
@@ -98,7 +98,7 @@ strict = [
9898
"click==8.1.7",
9999
"custodian==2024.10.16",
100100
"dscribe==2.1.1",
101-
"emmet-core==0.84.2",
101+
"emmet-core==0.84.3rc3",
102102
"ijson==3.3.0",
103103
"jobflow==0.1.18",
104104
"lobsterpy==0.4.9",

src/atomate2/vasp/flows/mvl.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""Materials Virtual Lab (MVL) VASP flows."""
2+
3+
from __future__ import annotations
4+
5+
from dataclasses import dataclass, field
6+
from typing import TYPE_CHECKING
7+
8+
from jobflow import Flow, Maker
9+
10+
from atomate2.vasp.jobs.mvl import MVLGWMaker, MVLNonSCFMaker, MVLStaticMaker
11+
12+
if TYPE_CHECKING:
13+
from pathlib import Path
14+
15+
from pymatgen.core.structure import Structure
16+
17+
from atomate2.vasp.jobs.base import BaseVaspMaker
18+
19+
20+
@dataclass
21+
class MVLGWBandStructureMaker(Maker):
22+
"""
23+
Maker to generate VASP band structures with Materials Virtual Lab GW setup.
24+
25+
.. warning::
26+
This workflow is only compatible with the Materials Virtual Lab GW setup,
27+
and it may require additional benchmarks. Please use with caution.
28+
29+
Parameters
30+
----------
31+
name : str
32+
Name of the flows produced by this maker.
33+
gw_maker : .BaseVaspMaker
34+
The maker to use for the GW calculation.
35+
"""
36+
37+
name: str = "MVL G0W0 band structure"
38+
static_maker: BaseVaspMaker = field(default_factory=MVLStaticMaker)
39+
nscf_maker: BaseVaspMaker = field(default_factory=MVLNonSCFMaker)
40+
gw_maker: BaseVaspMaker = field(default_factory=MVLGWMaker)
41+
42+
def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow:
43+
"""
44+
Create a band structure flow.
45+
46+
Parameters
47+
----------
48+
structure : Structure
49+
A pymatgen structure object.
50+
prev_dir : str or Path or None
51+
A previous VASP calculation directory to copy output files from.
52+
53+
Returns
54+
-------
55+
Flow
56+
A band structure flow.
57+
"""
58+
static_job = self.static_maker.make(structure, prev_dir=prev_dir)
59+
nscf_job = self.nscf_maker.make(
60+
static_job.output.structure, prev_dir=static_job.output.dir_name
61+
)
62+
gw_job = self.gw_maker.make(
63+
nscf_job.output.structure, prev_dir=nscf_job.output.dir_name
64+
)
65+
jobs = [static_job, nscf_job, gw_job]
66+
67+
outputs = {
68+
"static": static_job.output,
69+
"nscf": nscf_job.output,
70+
"gw": gw_job.output,
71+
}
72+
73+
return Flow(jobs, outputs, name=self.name)

src/atomate2/vasp/jobs/mvl.py

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
"""Core jobs for running VASP calculations."""
2+
3+
from __future__ import annotations
4+
5+
import logging
6+
from dataclasses import dataclass, field
7+
from typing import TYPE_CHECKING
8+
9+
from pymatgen.io.vasp.sets import MVLGWSet
10+
11+
from atomate2.vasp.jobs.base import BaseVaspMaker, vasp_job
12+
13+
if TYPE_CHECKING:
14+
from pathlib import Path
15+
16+
from jobflow import Response
17+
from pymatgen.core.structure import Structure
18+
19+
from atomate2.vasp.sets.base import VaspInputGenerator
20+
21+
22+
logger = logging.getLogger(__name__)
23+
24+
25+
@dataclass
26+
class MVLStaticMaker(BaseVaspMaker):
27+
"""
28+
Maker to create a static calculation compatible with Materials Virtual Lab GW jobs.
29+
30+
Parameters
31+
----------
32+
name : str
33+
The job name.
34+
input_set_generator : .VaspInputGenerator
35+
A generator used to make the input set.
36+
write_input_set_kwargs : dict
37+
Keyword arguments that will get passed to :obj:`.write_vasp_input_set`.
38+
copy_vasp_kwargs : dict
39+
Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`.
40+
run_vasp_kwargs : dict
41+
Keyword arguments that will get passed to :obj:`.run_vasp`.
42+
task_document_kwargs : dict
43+
Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`.
44+
stop_children_kwargs : dict
45+
Keyword arguments that will get passed to :obj:`.should_stop_children`.
46+
write_additional_data : dict
47+
Additional data to write to the current directory. Given as a dict of
48+
{filename: data}. Note that if using FireWorks, dictionary keys cannot contain
49+
the "." character which is typically used to denote file extensions. To avoid
50+
this, use the ":" character, which will automatically be converted to ".". E.g.
51+
``{"my_file:txt": "contents of the file"}``.
52+
"""
53+
54+
name: str = "MVL static"
55+
input_set_generator: VaspInputGenerator = field(
56+
default_factory=lambda: MVLGWSet(mode="STATIC")
57+
)
58+
59+
@vasp_job
60+
def make(
61+
self,
62+
structure: Structure,
63+
prev_dir: str | Path | None = None,
64+
) -> Response:
65+
"""
66+
Run a static calculation compatible with later Materials Virtual Lab GW jobs.
67+
68+
Parameters
69+
----------
70+
structure : .Structure
71+
A pymatgen structure object.
72+
prev_dir : str or Path or None
73+
A previous VASP calculation directory to copy output files from.
74+
"""
75+
return super().make.original(self, structure, prev_dir)
76+
77+
78+
@dataclass
79+
class MVLNonSCFMaker(BaseVaspMaker):
80+
"""
81+
Maker to create a non-scf calculation compatible with Materials Virtual Lab GW jobs.
82+
83+
Parameters
84+
----------
85+
name : str
86+
The job name.
87+
input_set_generator : .VaspInputGenerator
88+
A generator used to make the input set.
89+
write_input_set_kwargs : dict
90+
Keyword arguments that will get passed to :obj:`.write_vasp_input_set`.
91+
copy_vasp_kwargs : dict
92+
Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`.
93+
run_vasp_kwargs : dict
94+
Keyword arguments that will get passed to :obj:`.run_vasp`.
95+
task_document_kwargs : dict
96+
Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`.
97+
stop_children_kwargs : dict
98+
Keyword arguments that will get passed to :obj:`.should_stop_children`.
99+
write_additional_data : dict
100+
Additional data to write to the current directory. Given as a dict of
101+
{filename: data}. Note that if using FireWorks, dictionary keys cannot contain
102+
the "." character which is typically used to denote file extensions. To avoid
103+
this, use the ":" character, which will automatically be converted to ".". E.g.
104+
``{"my_file:txt": "contents of the file"}``.
105+
"""
106+
107+
name: str = "MVL nscf"
108+
input_set_generator: VaspInputGenerator = field(
109+
default_factory=lambda: MVLGWSet(mode="DIAG")
110+
)
111+
112+
@vasp_job
113+
def make(
114+
self,
115+
structure: Structure,
116+
prev_dir: str | Path | None = None,
117+
) -> Response:
118+
"""
119+
Run a static calculation compatible with later Materials Virtual Lab GW jobs.
120+
121+
Parameters
122+
----------
123+
structure : .Structure
124+
A pymatgen structure object.
125+
prev_dir : str or Path or None
126+
A previous VASP calculation directory to copy output files from.
127+
"""
128+
self.copy_vasp_kwargs.setdefault("additional_vasp_files", ("CHGCAR",))
129+
130+
return super().make.original(self, structure, prev_dir)
131+
132+
133+
@dataclass
134+
class MVLGWMaker(BaseVaspMaker):
135+
"""
136+
Maker to create Materials Virtual Lab GW jobs.
137+
138+
This class can make the jobs for the typical three stapes of the GW calculation.
139+
140+
Parameters
141+
----------
142+
name : str
143+
The job name.
144+
input_set_generator : .VaspInputGenerator
145+
A generator used to make the input set.
146+
write_input_set_kwargs : dict
147+
Keyword arguments that will get passed to :obj:`.write_vasp_input_set`.
148+
copy_vasp_kwargs : dict
149+
Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`.
150+
run_vasp_kwargs : dict
151+
Keyword arguments that will get passed to :obj:`.run_vasp`.
152+
task_document_kwargs : dict
153+
Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`.
154+
stop_children_kwargs : dict
155+
Keyword arguments that will get passed to :obj:`.should_stop_children`.
156+
write_additional_data : dict
157+
Additional data to write to the current directory. Given as a dict of
158+
{filename: data}. Note that if using FireWorks, dictionary keys cannot contain
159+
the "." character which is typically used to denote file extensions. To avoid
160+
this, use the ":" character, which will automatically be converted to ".". E.g.
161+
``{"my_file:txt": "contents of the file"}``.
162+
"""
163+
164+
name: str = "MVL G0W0"
165+
input_set_generator: VaspInputGenerator = field(
166+
default_factory=lambda: MVLGWSet(mode="GW")
167+
)
168+
169+
@vasp_job
170+
def make(
171+
self,
172+
structure: Structure,
173+
prev_dir: str | Path | None = None,
174+
) -> Response:
175+
"""
176+
Run a Materials Virtual Lab GW band structure VASP job.
177+
178+
Parameters
179+
----------
180+
structure : .Structure
181+
A pymatgen structure object.
182+
prev_dir : str or Path or None
183+
A previous VASP calculation directory to copy output files from.
184+
"""
185+
self.copy_vasp_kwargs.setdefault(
186+
"additional_vasp_files", ("CHGCAR", "WAVECAR", "WAVEDER")
187+
)
188+
189+
return super().make.original(self, structure, prev_dir)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ALGO = Gw0
2+
ENCUTGW = 250
3+
ICHARG = 1
4+
ISMEAR = 0
5+
ISPIN = 1
6+
LORBIT = 11
7+
LREAL = Auto
8+
LWAVE = True
9+
NBANDS = 48
10+
NELM = 1
11+
NOMEGA = 80
12+
PREC = Accurate
13+
SIGMA = 0.01
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pymatgen with grid density = 61 / number of atoms
2+
0
3+
Gamma
4+
3 3 3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Si2
2+
1.0
3+
0.0000000000000000 2.7300000000000000 2.7300000000000000
4+
2.7300000000000000 0.0000000000000000 2.7300000000000000
5+
2.7300000000000000 2.7300000000000000 0.0000000000000000
6+
Si
7+
2
8+
direct
9+
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
10+
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Si_GW

tests/test_data/vasp/Si_G0W0/MVL_G0W0/outputs/CONTCAR

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)