Skip to content

Commit

Permalink
Fix force shape when only 1 atom (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasdfgbnm authored and farhadrgh committed Jan 27, 2020
1 parent 987711c commit ca47b22
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchani/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def calculate(self, atoms=None, properties=['energy'],

if 'forces' in properties:
forces = -torch.autograd.grad(energy.squeeze(), coordinates)[0]
self.results['forces'] = forces.squeeze().to('cpu').numpy()
self.results['forces'] = forces.squeeze(0).to('cpu').numpy()

if 'stress' in properties:
volume = self.atoms.get_volume()
Expand Down

0 comments on commit ca47b22

Please sign in to comment.