|
25 | 25 | PotcarSingle, |
26 | 26 | Vasprun, |
27 | 27 | VolumetricData, |
| 28 | + Waveder, |
28 | 29 | ) |
29 | 30 |
|
30 | 31 | from atomate2 import SETTINGS |
@@ -80,6 +81,7 @@ class VaspObject(ValueEnum): |
80 | 81 | LOCPOT = "locpot" |
81 | 82 | OPTIC = "optic" |
82 | 83 | PROCAR = "procar" |
| 84 | + WAVEDER = "waveder" |
83 | 85 |
|
84 | 86 |
|
85 | 87 | class PotcarSpec(BaseModel): |
@@ -601,6 +603,7 @@ def from_vasp_files( |
601 | 603 | Tuple[str] |
602 | 604 | ] = SETTINGS.VASP_STORE_VOLUMETRIC_DATA, |
603 | 605 | store_trajectory: bool = False, |
| 606 | + store_waveder: bool = False, |
604 | 607 | vasprun_kwargs: Optional[Dict] = None, |
605 | 608 | ) -> Tuple["Calculation", Dict[VaspObject, Dict]]: |
606 | 609 | """ |
@@ -656,6 +659,9 @@ def from_vasp_files( |
656 | 659 | This can help reduce the size of DOS objects in systems with many atoms. |
657 | 660 | store_volumetric_data |
658 | 661 | 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. |
659 | 665 | store_trajectory |
660 | 666 | Whether to store the ionic steps in a pymatgen Trajectory object. if `True`, |
661 | 667 | :obj:'.CalculationOutput.ionic_steps' is set to None to reduce duplicating |
@@ -728,6 +734,12 @@ def from_vasp_files( |
728 | 734 | ) |
729 | 735 | vasp_objects[VaspObject.TRAJECTORY] = traj # type: ignore |
730 | 736 |
|
| 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 | + |
731 | 743 | # MD run |
732 | 744 | if vasprun.parameters.get("IBRION", -1) == 0: |
733 | 745 | if vasprun.parameters.get("NSW", 0) == vasprun.nionic_steps: |
@@ -828,6 +840,26 @@ def _get_volumetric_data( |
828 | 840 | return volumetric_data |
829 | 841 |
|
830 | 842 |
|
| 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 | + |
831 | 863 | def _parse_dos(parse_mode: Union[str, bool], vasprun: Vasprun) -> Optional[Dos]: |
832 | 864 | """Parse DOS. See Calculation.from_vasp_files for supported arguments.""" |
833 | 865 | nsw = vasprun.incar.get("NSW", 0) |
|
0 commit comments