Skip to content

Commit

Permalink
Improve readability of ASE calculator code
Browse files Browse the repository at this point in the history
  • Loading branch information
frostedoyster committed Jul 6, 2024
1 parent ee417ab commit dcca8be
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,16 @@ def calculate(

if do_backward:
with record_function("ASECalculator::run_backward"):
energy.backward(-torch.ones_like(energy))
energy.backward()

with record_function("ASECalculator::convert_outputs"):
if "forces" in properties:
forces_values = system.positions.grad.reshape(-1, 3)
forces_values = -system.positions.grad.reshape(-1, 3)
forces_values = forces_values.to(device="cpu").to(dtype=torch.float64)
self.results["forces"] = forces_values.numpy()

if "stress" in properties:
stress_values = -strain.grad.reshape(3, 3) / atoms.cell.volume
stress_values = strain.grad.reshape(3, 3) / atoms.cell.volume
stress_values = stress_values.to(device="cpu").to(dtype=torch.float64)
self.results["stress"] = _full_3x3_to_voigt_6_stress(
stress_values.numpy()
Expand Down

0 comments on commit dcca8be

Please sign in to comment.