Skip to content

Commit

Permalink
Fixed device mismatch in energy_spectrum computation
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseoe authored and danielkelshaw committed Sep 4, 2023
1 parent 21d7c7b commit 2338b25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kolsol/torch/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def energy_spectrum(self, u_hat: torch.Tensor, agg: bool = False) -> torch.Tenso
uu = 0.5 * oe.contract('...u -> ...', u_hat * torch.conj(u_hat)).real
intk = torch.sqrt(self.kk).to(torch.int)

ek = torch.zeros((tuple([*leading_dims]) + tuple([torch.max(intk) + 1])))
ek = torch.zeros((tuple([*leading_dims]) + tuple([torch.max(intk) + 1])), device=self.device)
for combo in it.product(*map(range, intk.shape)):
ek[tuple([...]) + tuple([intk[combo]])] += uu[tuple([...]) + tuple(combo)] / self.nk_grid ** self.ndim

Expand Down

0 comments on commit 2338b25

Please sign in to comment.