Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ docs/reference/atomate2.*
.vscode/

.DS_Store

env/
3 changes: 2 additions & 1 deletion src/atomate2/vasp/jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
BandStructureSymmLine,
)
from pymatgen.electronic_structure.dos import DOS, CompleteDos, Dos
from pymatgen.io.vasp import Chgcar, Locpot, Wavecar
from pymatgen.io.vasp import Chgcar, Locpot, Wavecar, Waveder

from atomate2.vasp.files import copy_vasp_outputs, write_vasp_input_set
from atomate2.vasp.run import run_vasp, should_stop_children
Expand All @@ -35,6 +35,7 @@
Locpot,
Chgcar,
Wavecar,
Waveder,
Trajectory,
"force_constants",
"normalmode_eigenvecs",
Expand Down
32 changes: 32 additions & 0 deletions src/atomate2/vasp/schemas/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
PotcarSingle,
Vasprun,
VolumetricData,
Waveder,
)

from atomate2 import SETTINGS
Expand Down Expand Up @@ -80,6 +81,7 @@ class VaspObject(ValueEnum):
LOCPOT = "locpot"
OPTIC = "optic"
PROCAR = "procar"
WAVEDER = "waveder"


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

if store_waveder:
wavder = _parse_waveder(dir_name)
if wavder is None:
raise RuntimeError(f"WAVEDER file not found in directory {dir_name}.")
vasp_objects[VaspObject.WAVEDER] = wavder # type: ignore

# MD run
if vasprun.parameters.get("IBRION", -1) == 0:
if vasprun.parameters.get("NSW", 0) == vasprun.nionic_steps:
Expand Down Expand Up @@ -828,6 +840,26 @@ def _get_volumetric_data(
return volumetric_data


def _parse_waveder(dir_name: Path) -> Optional[Waveder]:
"""
Parse the WAVEDER file.

Parameters
----------
dir_name
The directory containing the WAVEDER file.

Returns
-------
Optional[Waveder]
The WAVEDER data.
"""
try:
return Waveder.from_binary(dir_name / "WAVEDER")
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not catch all exceptions?

return None


def _parse_dos(parse_mode: Union[str, bool], vasprun: Vasprun) -> Optional[Dos]:
"""Parse DOS. See Calculation.from_vasp_files for supported arguments."""
nsw = vasprun.incar.get("NSW", 0)
Expand Down