Skip to content

Commit

Permalink
Add error handling asap parser (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ladinesa committed Jul 3, 2024
1 parent 66ecb53 commit 81682c8
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions atomisticparsers/asap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,19 @@ def index():
)

for step in self.thermodynamics_steps:
traj = self.traj_parser.traj[steps.index(step)]
if (total_energy := traj.get_total_energy()) is not None:
total_energy = total_energy * ureg.eV
if (forces := traj.get_forces()) is not None:
forces = forces * ureg.eV / ureg.angstrom
if (forces_raw := traj.get_forces(apply_constraint=False)) is not None:
forces_raw * ureg.eV / ureg.angstrom
self.parse_thermodynamics_step(
dict(
energy=dict(total=dict(value=total_energy)),
forces=dict(total=dict(value=forces, value_raw=forces_raw)),
try:
traj = self.traj_parser.traj[steps.index(step)]
if (total_energy := traj.get_total_energy()) is not None:
total_energy = total_energy * ureg.eV
if (forces := traj.get_forces()) is not None:
forces = forces * ureg.eV / ureg.angstrom
if (forces_raw := traj.get_forces(apply_constraint=False)) is not None:
forces_raw * ureg.eV / ureg.angstrom
self.parse_thermodynamics_step(
dict(
energy=dict(total=dict(value=total_energy)),
forces=dict(total=dict(value=forces, value_raw=forces_raw)),
)
)
)
except Exception:
pass

0 comments on commit 81682c8

Please sign in to comment.