Skip to content

Commit

Permalink
Fix incorrect force sign in energy target (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBoothroyd authored Jul 27, 2024
1 parent 6d4b216 commit 7f03241
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion descent/targets/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def predict(
topology = topologies[smiles]

energy_pred = smee.compute_energy(topology, force_field, coords)
forces_pred = torch.autograd.grad(
forces_pred = -torch.autograd.grad(
energy_pred.sum(),
coords,
create_graph=True,
Expand Down
4 changes: 2 additions & 2 deletions descent/tests/targets/test_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_extract_smiles(mock_meoh_entry, mock_hoh_entry):
)
/ math.sqrt(6.0 * 3.0),
torch.tensor([7.899425506591797, -7.89942741394043]) / math.sqrt(2.0),
torch.tensor(
-torch.tensor(
[
[0.0, 83.55978393554688, 0.0],
[-161.40325927734375, -41.77988815307617, 0.0],
Expand All @@ -109,7 +109,7 @@ def test_extract_smiles(mock_meoh_entry, mock_hoh_entry):
]
),
torch.tensor([0.0, -15.798852920532227]),
torch.tensor(
-torch.tensor(
[
[0.0, 83.55978393554688, 0.0],
[-161.40325927734375, -41.77988815307617, 0.0],
Expand Down

0 comments on commit 7f03241

Please sign in to comment.