It looks like the implementation of the += operator for function_trees leads to precision loss.
The following code (taken from ReMRChem) gives two very different results for rho and n which ideally should be identical.
def setup(self):
rho = vp.FunctionTree(self.mra)
rho.setZero()
rholist = []
for i in range(0, len(self.Psi)):
dens = self.Psi[i].overlap_density(self.Psi[i], self.prec)
print("density i = ", i)
print(dens)
rho += dens.real
rholist.append(dens.real)
#rho.crop(self.prec)
n = rholist[0] + rholist[1]
self.potential = (4.0*np.pi) * self.poisson(n).crop(self.prec)
Commit of ReMRChem showing the issue: 2b6052d94ea4f68715f840b62f9cb7
It looks like the implementation of the
+=operator forfunction_trees leads to precision loss.The following code (taken from ReMRChem) gives two very different results for
rhoandnwhich ideally should be identical.Commit of ReMRChem showing the issue: 2b6052d94ea4f68715f840b62f9cb7