Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mace/calculators/mace_torchsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def compute_forces(self) -> bool:
def compute_stress(self) -> bool:
return self._compute_stress

def forward(self, state: Any) -> Dict[str, torch.Tensor]:
def forward(self, state: Any, **_kwargs: Any) -> Dict[str, torch.Tensor]:
if ts is None:
raise RuntimeError(
"torch-sim is required to call MaceTorchSimModel.forward"
Expand Down Expand Up @@ -601,7 +601,15 @@ def forward(self, state: Any) -> Dict[str, torch.Tensor]:
data_dict["total_spin"] = total_spin

if self._is_polar:
if total_spin is not None and (total_spin == 0).all():
if "total_charge" not in data_dict:
data_dict["total_charge"] = torch.zeros(
self.n_systems, device=self._device, dtype=self._dtype
)
if "total_spin" not in data_dict:
data_dict["total_spin"] = torch.ones(
self.n_systems, device=self._device, dtype=self._dtype
)
elif (data_dict["total_spin"] == 0).all():
log.warning(
"PolarMACE detected with total_spin=0 for all systems. "
"MACE's default total_spin is 1.0; if this is unintentional, "
Expand Down
Loading
Loading