Skip to content

Commit

Permalink
Detach tensors.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Jul 31, 2024
1 parent c1f6fbf commit c2ecaa3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions emle/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ def run(self, path=None):
)

# Compute the total energy and gradients.
E_tot = E_vac + E.cpu().numpy()
E_tot = E_vac + E.detach().cpu().numpy()
grad_qm = dE_dxyz_qm_bohr + grad_vac
grad_mm = dE_dxyz_mm_bohr.cpu().numpy()

Expand Down Expand Up @@ -1505,7 +1505,7 @@ def run(self, path=None):
self._method = method

# Store the the MM and EMLE energies. The MM energy is an approximation.
E_mm = E_mm_qm_vac + E.cpu().numpy()
E_mm = E_mm_qm_vac + E.detach().cpu().numpy()
E_emle = E_tot

# Work out the current value of lambda.
Expand Down Expand Up @@ -1873,7 +1873,7 @@ def _sire_callback(self, atomic_numbers, charges_mm, xyz_qm, xyz_mm):
)

# Compute the total energy and gradients.
E_tot = E_vac + E.cpu().numpy()
E_tot = E_vac + E.detach().cpu().numpy()
grad_qm = dE_dxyz_qm_bohr + grad_vac
grad_mm = dE_dxyz_mm_bohr.cpu().numpy()

Expand Down Expand Up @@ -1915,7 +1915,7 @@ def _sire_callback(self, atomic_numbers, charges_mm, xyz_qm, xyz_mm):
self._method = method

# Store the the MM and EMLE energies. The MM energy is an approximation.
E_mm = E_mm_qm_vac + E.cpu().numpy()
E_mm = E_mm_qm_vac + E.detach().cpu().numpy()
E_emle = E_tot

# Work out the current value of lambda.
Expand Down

0 comments on commit c2ecaa3

Please sign in to comment.