Skip to content

Loss of precision with += #101

@ilfreddy

Description

@ilfreddy

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions