diff --git a/matscipy/calculators/ewald/calculator.py b/matscipy/calculators/ewald/calculator.py index f4db90b3b..9d06d4bf6 100644 --- a/matscipy/calculators/ewald/calculator.py +++ b/matscipy/calculators/ewald/calculator.py @@ -211,9 +211,9 @@ def determine_nk(charge, cell, acc, a, natoms): [nxmax / cell[0, 0], nymax / cell[1, 1], nzmax / cell[2, 2]] ) scaled_nbk = np.dot(np.array(np.abs(cell)), vector) - nxmax = max(1, np.int(scaled_nbk[0])) - nymax = max(1, np.int(scaled_nbk[1])) - nzmax = max(1, np.int(scaled_nbk[2])) + nxmax = max(1, np.int32(scaled_nbk[0])) + nymax = max(1, np.int32(scaled_nbk[1])) + nzmax = max(1, np.int32(scaled_nbk[2])) return kmax, np.array([nxmax, nymax, nzmax]) @@ -451,7 +451,8 @@ def calculate(self, atoms, properties, system_changes): self.reset_kspace(atoms) super().calculate(atoms, properties, system_changes) - + self.results["real_ewald_en"] = self.results["energy"] + self.results["real_ewald_f"] = self.results["forces"] nb_atoms = len(atoms) charge_n = atoms.get_array("charge") @@ -460,16 +461,17 @@ def calculate(self, atoms, properties, system_changes): alpha = self.alpha # Energy + e_self = self.self_energy(charge_n, alpha) e_long = self.kspace_energy( charge_n, atoms.get_positions(), atoms.get_volume(), I_l, k_lc ) + self.results["self_ewald_en"] = e_self + self.results["kspace_ewald_en"] = e_long self.results["energy"] += e_self + e_long self.results["free_energy"] += e_self + e_long - - # Forces - self.results["forces"] += self.first_derivative_kspace( + kspace_f = self.first_derivative_kspace( charge_n, nb_atoms, atoms.get_volume(), @@ -477,6 +479,10 @@ def calculate(self, atoms, properties, system_changes): I_l, k_lc, ) + # Forces + self.results["forces"] += kspace_f + + self.results["kspace_ewald_f"] = kspace_f # Virial self.results["stress"] += (