Unverified Commit 00dd8cba authored by Farhad Ramezanghorbani's avatar Farhad Ramezanghorbani Committed by GitHub
Browse files

Add retain_graph (force and stress) case in ASE (#417)

This PR resolves #415
Thanks @mhellstr for pointing it out
parent 79470486
......@@ -72,7 +72,7 @@ class Calculator(ase.calculators.calculator.Calculator):
self.results['free_energy'] = energy.item()
if 'forces' in properties:
forces = -torch.autograd.grad(energy.squeeze(), coordinates)[0]
forces = -torch.autograd.grad(energy.squeeze(), coordinates, retain_graph='stress' in properties)[0]
self.results['forces'] = forces.squeeze(0).to('cpu').numpy()
if 'stress' in properties:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment