Skip to content

Commit

Permalink
Feat: GW workflow with VASP (#808)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yanghan234 authored Nov 12, 2024
1 parent 237dcdc commit c57f9c1
Show file tree
Hide file tree
Showing 53 changed files with 400 additions and 2 deletions.
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>=2024.4.18",
"emmet-core>=0.82.2",
"emmet-core>=0.84.3rc3",
"jobflow>=0.1.11",
"monty>=2024.7.30",
"numpy",
Expand Down Expand Up @@ -98,7 +98,7 @@ strict = [
"click==8.1.7",
"custodian==2024.10.16",
"dscribe==2.1.1",
"emmet-core==0.84.2",
"emmet-core==0.84.3rc3",
"ijson==3.3.0",
"jobflow==0.1.18",
"lobsterpy==0.4.9",
Expand Down
73 changes: 73 additions & 0 deletions src/atomate2/vasp/flows/mvl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""Materials Virtual Lab (MVL) VASP flows."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from jobflow import Flow, Maker

from atomate2.vasp.jobs.mvl import MVLGWMaker, MVLNonSCFMaker, MVLStaticMaker

if TYPE_CHECKING:
from pathlib import Path

from pymatgen.core.structure import Structure

from atomate2.vasp.jobs.base import BaseVaspMaker


@dataclass
class MVLGWBandStructureMaker(Maker):
"""
Maker to generate VASP band structures with Materials Virtual Lab GW setup.
.. warning::
This workflow is only compatible with the Materials Virtual Lab GW setup,
and it may require additional benchmarks. Please use with caution.
Parameters
----------
name : str
Name of the flows produced by this maker.
gw_maker : .BaseVaspMaker
The maker to use for the GW calculation.
"""

name: str = "MVL G0W0 band structure"
static_maker: BaseVaspMaker = field(default_factory=MVLStaticMaker)
nscf_maker: BaseVaspMaker = field(default_factory=MVLNonSCFMaker)
gw_maker: BaseVaspMaker = field(default_factory=MVLGWMaker)

def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow:
"""
Create a band structure flow.
Parameters
----------
structure : Structure
A pymatgen structure object.
prev_dir : str or Path or None
A previous VASP calculation directory to copy output files from.
Returns
-------
Flow
A band structure flow.
"""
static_job = self.static_maker.make(structure, prev_dir=prev_dir)
nscf_job = self.nscf_maker.make(
static_job.output.structure, prev_dir=static_job.output.dir_name
)
gw_job = self.gw_maker.make(
nscf_job.output.structure, prev_dir=nscf_job.output.dir_name
)
jobs = [static_job, nscf_job, gw_job]

outputs = {
"static": static_job.output,
"nscf": nscf_job.output,
"gw": gw_job.output,
}

return Flow(jobs, outputs, name=self.name)
189 changes: 189 additions & 0 deletions src/atomate2/vasp/jobs/mvl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
"""Core jobs for running VASP calculations."""

from __future__ import annotations

import logging
from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from pymatgen.io.vasp.sets import MVLGWSet

from atomate2.vasp.jobs.base import BaseVaspMaker, vasp_job

if TYPE_CHECKING:
from pathlib import Path

from jobflow import Response
from pymatgen.core.structure import Structure

from atomate2.vasp.sets.base import VaspInputGenerator


logger = logging.getLogger(__name__)


@dataclass
class MVLStaticMaker(BaseVaspMaker):
"""
Maker to create a static calculation compatible with Materials Virtual Lab GW jobs.
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 = "MVL static"
input_set_generator: VaspInputGenerator = field(
default_factory=lambda: MVLGWSet(mode="STATIC")
)

@vasp_job
def make(
self,
structure: Structure,
prev_dir: str | Path | None = None,
) -> Response:
"""
Run a static calculation compatible with later Materials Virtual Lab GW jobs.
Parameters
----------
structure : .Structure
A pymatgen structure object.
prev_dir : str or Path or None
A previous VASP calculation directory to copy output files from.
"""
return super().make.original(self, structure, prev_dir)


@dataclass
class MVLNonSCFMaker(BaseVaspMaker):
"""
Maker to create a non-scf calculation compatible with Materials Virtual Lab GW jobs.
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 = "MVL nscf"
input_set_generator: VaspInputGenerator = field(
default_factory=lambda: MVLGWSet(mode="DIAG")
)

@vasp_job
def make(
self,
structure: Structure,
prev_dir: str | Path | None = None,
) -> Response:
"""
Run a static calculation compatible with later Materials Virtual Lab GW jobs.
Parameters
----------
structure : .Structure
A pymatgen structure object.
prev_dir : str or Path or None
A previous VASP calculation directory to copy output files from.
"""
self.copy_vasp_kwargs.setdefault("additional_vasp_files", ("CHGCAR",))

return super().make.original(self, structure, prev_dir)


@dataclass
class MVLGWMaker(BaseVaspMaker):
"""
Maker to create Materials Virtual Lab GW jobs.
This class can make the jobs for the typical three stapes of the GW calculation.
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 = "MVL G0W0"
input_set_generator: VaspInputGenerator = field(
default_factory=lambda: MVLGWSet(mode="GW")
)

@vasp_job
def make(
self,
structure: Structure,
prev_dir: str | Path | None = None,
) -> Response:
"""
Run a Materials Virtual Lab GW band structure VASP job.
Parameters
----------
structure : .Structure
A pymatgen structure object.
prev_dir : str or Path or None
A previous VASP calculation directory to copy output files from.
"""
self.copy_vasp_kwargs.setdefault(
"additional_vasp_files", ("CHGCAR", "WAVECAR", "WAVEDER")
)

return super().make.original(self, structure, prev_dir)
13 changes: 13 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_G0W0/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALGO = Gw0
ENCUTGW = 250
ICHARG = 1
ISMEAR = 0
ISPIN = 1
LORBIT = 11
LREAL = Auto
LWAVE = True
NBANDS = 48
NELM = 1
NOMEGA = 80
PREC = Accurate
SIGMA = 0.01
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_G0W0/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 61 / number of atoms
0
Gamma
3 3 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_G0W0/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Si2
1.0
0.0000000000000000 2.7300000000000000 2.7300000000000000
2.7300000000000000 0.0000000000000000 2.7300000000000000
2.7300000000000000 2.7300000000000000 0.0000000000000000
Si
2
direct
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
1 change: 1 addition & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_G0W0/inputs/POTCAR.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si_GW
Empty file.
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.
1 change: 1 addition & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_G0W0/outputs/POTCAR.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si_GW
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_nscf/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ALGO = Exact
EDIFF = 1e-08
ICHARG = 1
ISMEAR = 0
ISPIN = 1
LOPTICS = True
LORBIT = 11
LPEAD = True
LREAL = Auto
LWAVE = True
NBANDS = 48
NELM = 1
PREC = Accurate
SIGMA = 0.01
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_nscf/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 61 / number of atoms
0
Gamma
3 3 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_nscf/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Si2
1.0
0.0000000000000000 2.7300000000000000 2.7300000000000000
2.7300000000000000 0.0000000000000000 2.7300000000000000
2.7300000000000000 2.7300000000000000 0.0000000000000000
Si
2
direct
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
1 change: 1 addition & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_nscf/inputs/POTCAR.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si_GW
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.
1 change: 1 addition & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_nscf/outputs/POTCAR.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si_GW
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_static/inputs/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALGO = Normal
EDIFF = 1e-08
ICHARG = 1
ISMEAR = 0
ISPIN = 1
LORBIT = 11
LREAL = Auto
LWAVE = True
NELM = 100
PREC = Accurate
SIGMA = 0.01
4 changes: 4 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_static/inputs/KPOINTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pymatgen with grid density = 61 / number of atoms
0
Gamma
3 3 3
10 changes: 10 additions & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_static/inputs/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Si2
1.0
0.0000000000000000 2.7300000000000000 2.7300000000000000
2.7300000000000000 0.0000000000000000 2.7300000000000000
2.7300000000000000 2.7300000000000000 0.0000000000000000
Si
2
direct
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
0.2500000000000000 0.2500000000000000 0.2500000000000000 Si
1 change: 1 addition & 0 deletions tests/test_data/vasp/Si_G0W0/MVL_static/inputs/POTCAR.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Si_GW
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 @@
Si_GW
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c57f9c1

Please sign in to comment.