Skip to content

Commit 21b236c

Browse files
committed
allow waveder to be stored
1 parent 2b6cf03 commit 21b236c

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ docs/reference/atomate2.*
6363
.vscode/
6464

6565
.DS_Store
66+
67+
env/

src/atomate2/vasp/jobs/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
BandStructureSymmLine,
1717
)
1818
from pymatgen.electronic_structure.dos import DOS, CompleteDos, Dos
19-
from pymatgen.io.vasp import Chgcar, Locpot, Wavecar
19+
from pymatgen.io.vasp import Chgcar, Locpot, Wavecar, Waveder
2020

2121
from atomate2.vasp.files import copy_vasp_outputs, write_vasp_input_set
2222
from atomate2.vasp.run import run_vasp, should_stop_children
@@ -35,6 +35,7 @@
3535
Locpot,
3636
Chgcar,
3737
Wavecar,
38+
Waveder,
3839
Trajectory,
3940
"force_constants",
4041
"normalmode_eigenvecs",

src/atomate2/vasp/schemas/calculation.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
PotcarSingle,
2626
Vasprun,
2727
VolumetricData,
28+
Waveder,
2829
)
2930

3031
from atomate2 import SETTINGS
@@ -80,6 +81,7 @@ class VaspObject(ValueEnum):
8081
LOCPOT = "locpot"
8182
OPTIC = "optic"
8283
PROCAR = "procar"
84+
WAVEDER = "waveder"
8385

8486

8587
class PotcarSpec(BaseModel):
@@ -601,6 +603,7 @@ def from_vasp_files(
601603
Tuple[str]
602604
] = SETTINGS.VASP_STORE_VOLUMETRIC_DATA,
603605
store_trajectory: bool = False,
606+
store_waveder: bool = False,
604607
vasprun_kwargs: Optional[Dict] = None,
605608
) -> Tuple["Calculation", Dict[VaspObject, Dict]]:
606609
"""
@@ -656,6 +659,9 @@ def from_vasp_files(
656659
This can help reduce the size of DOS objects in systems with many atoms.
657660
store_volumetric_data
658661
Which volumetric files to store.
662+
store_waveder
663+
Whether to store the contents of the binary WAVEDER file.
664+
Which is used to compute frequency dependent dielectric functions.
659665
store_trajectory
660666
Whether to store the ionic steps in a pymatgen Trajectory object. if `True`,
661667
:obj:'.CalculationOutput.ionic_steps' is set to None to reduce duplicating
@@ -728,6 +734,12 @@ def from_vasp_files(
728734
)
729735
vasp_objects[VaspObject.TRAJECTORY] = traj # type: ignore
730736

737+
if store_waveder:
738+
wavder = _parse_waveder(dir_name)
739+
if wavder is None:
740+
raise RuntimeError(f"WAVEDER file not found in directory {dir_name}.")
741+
vasp_objects[VaspObject.WAVEDER] = wavder # type: ignore
742+
731743
# MD run
732744
if vasprun.parameters.get("IBRION", -1) == 0:
733745
if vasprun.parameters.get("NSW", 0) == vasprun.nionic_steps:
@@ -828,6 +840,26 @@ def _get_volumetric_data(
828840
return volumetric_data
829841

830842

843+
def _parse_waveder(dir_name: Path) -> Optional[Waveder]:
844+
"""
845+
Parse the WAVEDER file.
846+
847+
Parameters
848+
----------
849+
dir_name
850+
The directory containing the WAVEDER file.
851+
852+
Returns
853+
-------
854+
Optional[Waveder]
855+
The WAVEDER data.
856+
"""
857+
try:
858+
return Waveder.from_binary(dir_name / "WAVEDER")
859+
except Exception:
860+
return None
861+
862+
831863
def _parse_dos(parse_mode: Union[str, bool], vasprun: Vasprun) -> Optional[Dos]:
832864
"""Parse DOS. See Calculation.from_vasp_files for supported arguments."""
833865
nsw = vasprun.incar.get("NSW", 0)

0 commit comments

Comments
 (0)