Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: GW workflow with VASP #808

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
830e2d6
Added the Materials Virtual Lab GW Set to the repo and implemented th…
yanghan234 Apr 17, 2024
66083fb
add a Materials Virtual Lab GW band structure maker
yanghan234 Apr 17, 2024
e5b0ae1
fix bug
yanghan234 Apr 17, 2024
ebf6354
rename MVLGWMaker
yanghan234 Apr 17, 2024
9324567
created a Flow that does all three stages (static, diag, gw) for a GW…
yanghan234 Apr 17, 2024
3c3e06a
fixed bug
yanghan234 Apr 19, 2024
f00bcc5
update the mvl gw yaml file and explicity copy the magmon in it
yanghan234 Apr 21, 2024
4bfd28a
update the gw workflow
yanghan234 Apr 21, 2024
d853aee
Revert line 37 to original state and fixed a typo
yanghan234 Apr 22, 2024
eb286c3
update the class doc of MVLGWSetGenerator
yanghan234 Jun 12, 2024
139b181
rewrite job name
yanghan234 Jun 12, 2024
2bb6037
rewrite job name
yanghan234 Jun 13, 2024
b91184f
Merge branch 'main' into hanyang/gw_with_vasp
yanghan234 Sep 7, 2024
0880262
make job and flow names short
yanghan234 Sep 8, 2024
bcca85f
update job name
yanghan234 Sep 8, 2024
db0b7a6
change the method names to adjust for recent updates on the main branch
yanghan234 Sep 15, 2024
f94f691
explicitly specify files to copy
yanghan234 Sep 15, 2024
7d33f83
copied all data files for gw test case
yanghan234 Sep 15, 2024
975fe78
add testcase for running MVL GW workflow
yanghan234 Sep 15, 2024
982ccd4
Merge branch 'materialsproject:main' into hanyang/gw_with_vasp
yanghan234 Sep 16, 2024
b5c50c8
modified the files needed to copy between jobs
yanghan234 Sep 16, 2024
fb9dba7
fixed wrong assertation
yanghan234 Sep 16, 2024
0a456f8
added missing data files to run the tests
yanghan234 Sep 16, 2024
7cce683
add a warning in the GW workflow
yanghan234 Sep 16, 2024
8f3bc83
removed MVL GW set yaml file, instead, import from pymatgen
yanghan234 Sep 17, 2024
181463e
reorganize the mvl jobs
yanghan234 Sep 17, 2024
31e9f1d
reorganize the mvl gw workflow
yanghan234 Sep 17, 2024
41e0f7f
update test case for mvl gw workflow and update the test data
yanghan234 Sep 17, 2024
dccbf1a
Merge branch 'main' into hanyang/gw_with_vasp
yanghan234 Sep 17, 2024
e9b1408
update the mvl gw workflow
yanghan234 Sep 17, 2024
b88eb4d
update test case for mvl gw workflow and corresponding test data
yanghan234 Sep 17, 2024
c7b1521
Merge branch 'main' into hanyang/gw_with_vasp
yanghan234 Oct 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
186 changes: 186 additions & 0 deletions src/atomate2/vasp/jobs/mvl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
"""Core jobs for running VASP calculations."""

from __future__ import annotations

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

from atomate2.vasp.jobs.base import BaseVaspMaker, vasp_job
from atomate2.vasp.sets.mvl import MVLGWSetGenerator

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=MVLGWSetGenerator)

@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.input_set_generator.mode = "STATIC"

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=MVLGWSetGenerator)

@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.input_set_generator.mode = "DIAG"
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=MVLGWSetGenerator)

@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.input_set_generator.mode = "GW"
self.copy_vasp_kwargs.setdefault(
"additional_vasp_files", ("CHGCAR", "WAVECAR", "WAVEDER")
)

return super().make.original(self, structure, prev_dir)
45 changes: 45 additions & 0 deletions src/atomate2/vasp/sets/mvl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Module defining Materials Virtual Lab (MVL) VASP input set generators."""

from __future__ import annotations

import logging
from dataclasses import dataclass

from pymatgen.io.vasp.sets import MVLGWSet

logger = logging.getLogger(__name__)


@dataclass
class MVLGWSetGenerator(MVLGWSet):
"""
Materials Virtual Lab GW input set generator.

To generate Materials Virtual Lab input sets for static,
diag and GW calculations.

Parameters
----------
mode
The mode of the calculation. Options are "STATIC", "DIAG", and "GW".
nbands_factor
Multiplicative factor for NBANDS when starting from a previous calculation.
Choose a higher number if you are doing an LOPTICS calculation.
**kwargs
Other keyword arguments that will be passed to :obj:`VaspInputGenerator`
"""

reciprocal_density: float = 100
mode: str = "STATIC"
copy_wavecar: bool = True

@property
def incar_updates(self) -> dict:
"""Get updates to the INCAR for a Materials Virtual Lab GW calculation.

Returns
-------
dict
A dictionary of updates to apply.
"""
return super().incar_updates
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
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_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
Loading