Skip to content

Commit

Permalink
Merge pull request #1105 from yanghan234/hanyang/gw-runtypes
Browse files Browse the repository at this point in the history
Feat: Add run types for GW calculations
  • Loading branch information
esoteric-ephemera authored Oct 11, 2024
2 parents 2a12298 + 6fe3a88 commit 42606d4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
fi
test:
needs: check-enums
# to-do: add check-enums req after finding solution for pushing to external forks
#needs: check-enums
strategy:
matrix:
os: ["ubuntu-latest"] # TODO openbabel for windows and mac
Expand Down
1 change: 0 additions & 1 deletion emmet-core/emmet/core/qchem/calc_types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
and/or
emmet/core/qchem/calc_types/calc_types.yaml
"""

from emmet.core.utils import ValueEnum


Expand Down
3 changes: 3 additions & 0 deletions emmet-core/emmet/core/vasp/calc_types/calc_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ RUN_TYPES:
LASPH: true
LUSE_VDW: true
Zab_vdW: -1.8867
GW:
G0W0:
ALGO: Gw0
TASK_TYPES:
- NSCF Line
- NSCF Uniform
Expand Down
29 changes: 28 additions & 1 deletion emmet-core/emmet/core/vasp/calc_types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
and/or
emmet/core/vasp/calc_types/calc_types.yaml
"""

from emmet.core.utils import ValueEnum, IgnoreCaseEnum


Expand All @@ -18,6 +17,8 @@ class RunType(IgnoreCaseEnum):
AM05_U = "AM05+U"
B3LYP = "B3LYP"
B3LYP_U = "B3LYP+U"
G0W0 = "G0W0"
G0W0_U = "G0W0+U"
GGA = "GGA"
GGA_U = "GGA+U"
HF = "HF"
Expand Down Expand Up @@ -155,6 +156,32 @@ class CalcType(IgnoreCaseEnum):
B3LYP_U_Structure_Optimization = "B3LYP+U Structure Optimization"
B3LYP_U_Unrecognized = "B3LYP+U Unrecognized"
B3LYP_Unrecognized = "B3LYP Unrecognized"
G0W0_DFPT = "G0W0 DFPT"
G0W0_DFPT_Dielectric = "G0W0 DFPT Dielectric"
G0W0_Deformation = "G0W0 Deformation"
G0W0_Dielectric = "G0W0 Dielectric"
G0W0_Molecular_Dynamics = "G0W0 Molecular Dynamics"
G0W0_NMR_Electric_Field_Gradient = "G0W0 NMR Electric Field Gradient"
G0W0_NMR_Nuclear_Shielding = "G0W0 NMR Nuclear Shielding"
G0W0_NSCF_Line = "G0W0 NSCF Line"
G0W0_NSCF_Uniform = "G0W0 NSCF Uniform"
G0W0_Optic = "G0W0 Optic"
G0W0_Static = "G0W0 Static"
G0W0_Structure_Optimization = "G0W0 Structure Optimization"
G0W0_U_DFPT = "G0W0+U DFPT"
G0W0_U_DFPT_Dielectric = "G0W0+U DFPT Dielectric"
G0W0_U_Deformation = "G0W0+U Deformation"
G0W0_U_Dielectric = "G0W0+U Dielectric"
G0W0_U_Molecular_Dynamics = "G0W0+U Molecular Dynamics"
G0W0_U_NMR_Electric_Field_Gradient = "G0W0+U NMR Electric Field Gradient"
G0W0_U_NMR_Nuclear_Shielding = "G0W0+U NMR Nuclear Shielding"
G0W0_U_NSCF_Line = "G0W0+U NSCF Line"
G0W0_U_NSCF_Uniform = "G0W0+U NSCF Uniform"
G0W0_U_Optic = "G0W0+U Optic"
G0W0_U_Static = "G0W0+U Static"
G0W0_U_Structure_Optimization = "G0W0+U Structure Optimization"
G0W0_U_Unrecognized = "G0W0+U Unrecognized"
G0W0_Unrecognized = "G0W0 Unrecognized"
GGA_DFPT = "GGA DFPT"
GGA_DFPT_Dielectric = "GGA DFPT Dielectric"
GGA_Deformation = "GGA Deformation"
Expand Down
5 changes: 4 additions & 1 deletion emmet-core/emmet/core/vasp/calc_types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _variant_equal(v1, v2) -> bool:
return v1 == v2

# This is to force an order of evaluation
for functional_class in ["HF", "VDW", "METAGGA", "GGA"]:
for functional_class in ["GW", "HF", "VDW", "METAGGA", "GGA"]:
for special_type, params in _RUN_TYPE_DATA[functional_class].items():
if all(
_variant_equal(parameters.get(param, None), value)
Expand Down Expand Up @@ -122,6 +122,9 @@ def task_type(
elif incar.get("IBRION", 1) == 0:
calc_type.append("Molecular Dynamics")

elif incar.get("ALGO", "Normal").lower() == "gw0":
calc_type.append("NSCF Uniform")

if len(calc_type) == 0:
return TaskType("Unrecognized")

Expand Down
9 changes: 8 additions & 1 deletion emmet-core/emmet/core/vasp/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# mypy: ignore-errors

import os
import logging
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -754,7 +755,13 @@ def from_vasp_files(
volumetric_files = [] if volumetric_files is None else volumetric_files
vasprun = Vasprun(vasprun_file, **vasprun_kwargs)
outcar = Outcar(outcar_file)
contcar = Poscar.from_file(contcar_file)
if (
os.path.getsize(contcar_file) == 0
and vasprun.parameters.get("NELM", 60) == 1
):
contcar = Poscar(vasprun.final_structure)
else:
contcar = Poscar.from_file(contcar_file)
completed_at = str(datetime.fromtimestamp(vasprun_file.stat().st_mtime))

output_file_paths = _get_output_file_paths(volumetric_files)
Expand Down

0 comments on commit 42606d4

Please sign in to comment.