Skip to content
Closed
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
30 changes: 24 additions & 6 deletions emmet-core/emmet/core/vasp/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import logging
import os
import copy
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING, Any
Expand Down Expand Up @@ -835,27 +836,44 @@ def from_vasp_files(
exclude_from_trajectory = ["structure"]
if store_trajectory == StoreTrajectoryOption.PARTIAL:
exclude_from_trajectory.append("electronic_steps")
frame_properties = [
IonicStep(**x).model_dump(exclude=exclude_from_trajectory)
for x in vasprun.ionic_steps
]


# In the case of MLMD, not every ionic step is captured.
# We should instead use md_data instead
if vasprun.incar.get("ML_LMLFF"):
# Note that md_data includes the structures, but
# to avoid redundance, we'll copy then remove them
frame_properties = copy.deepcopy(vasprun.md_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to avoid the deepcopy here? Could take up a lot of memory / CPU

structures = [d["structure"] for d in vasprun.md_data]
for fp in frame_properties:
del fp['structure']
else:
structures = [d["structure"] for d in vasprun.ionic_steps]
frame_properties = [
IonicStep(**x).model_dump(exclude=exclude_from_trajectory)
for x in vasprun.ionic_steps
]

if oszicar_file:
try:
oszicar_file = dir_name / oszicar_file
oszicar = Oszicar(oszicar_file)
if "T" in oszicar.ionic_steps[0]:
for frame_property, oszicar_is in zip(
frame_properties, oszicar.ionic_steps
):
frame_property["temperature"] = oszicar_is.get("T")
except ValueError:
except ValueError as e:
# there can be errors in parsing the floats from OSZICAR
print("Error parsing OSZICAR file, skipping temperature assignment.", e.message)
pass

traj = Trajectory.from_structures(
[d["structure"] for d in vasprun.ionic_steps],
structures,
frame_properties=frame_properties,
constant_lattice=False,
)

vasp_objects[VaspObject.TRAJECTORY] = traj # type: ignore

# MD run
Expand Down
1 change: 1 addition & 0 deletions emmet-core/emmet/core/vasp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def discover_and_sort_vasp_files(
"vasprun",
"contcar",
"outcar",
"oszicar"
):
if k in f:
by_type[f"{k}_file"].append(_f)
Expand Down
Loading