Skip to content

Commit

Permalink
Merge pull request #55 from wcwitt/torchscript_merge
Browse files Browse the repository at this point in the history
Update lammps_mace
  • Loading branch information
ilyes319 authored Nov 29, 2022
2 parents f49b10a + 7be5c75 commit 921dcf1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mace/calculators/lammps_mace.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def forward(
virials: Optional[torch.Tensor] = torch.zeros_like(data["cell"])
stress: Optional[torch.Tensor] = torch.zeros_like(data["cell"])
if mask_ghost is not None and displacement is not None:
displacement.requires_grad_(True) # For some reason torchscript needs that.
#displacement.requires_grad_(True) # For some reason torchscript needs that.
node_energy_ghost = node_energy * mask_ghost
total_energy_ghost = scatter_sum(
src=node_energy_ghost, index=data["batch"], dim=-1, dim_size=num_graphs
Expand All @@ -70,6 +70,8 @@ def forward(
torch.cross(cell[:, 1, :], cell[:, 2, :], dim=1),
).unsqueeze(-1)
stress = virials / volume.view(-1, 1, 1)
else:
virials = torch.zeros_like(displacement)

total_energy = scatter_sum(
src=node_energy, index=data["batch"], dim=-1, dim_size=num_graphs
Expand Down

0 comments on commit 921dcf1

Please sign in to comment.