LutzGross / esys-escript.github.io

Other
29 stars 13 forks source link

0+ComplexScalar(5+8j, Function()) should be a complex data object #68

Closed AndreaCodd closed 1 year ago

AndreaCodd commented 2 years ago

when gEx1 is complex

        print("zero Area before",integrate(whereZero(length(g))))
        g +=  whereZero(length(g))*1e-10
        print("zero Area after",integrate(whereZero(length(g))))

       Does not give a zero area for "zero Area after",

It is necessary to write print("zero Area before",integrate(whereZero(length(g)))) g += (1+1j)whereZero(length(g))1e-10 print("zero Area after",integrate(whereZero(length(g))))

It should be possible to add a complex Scalar function to a real Scalar function to get a complex Scalar function.

LutzGross commented 2 years ago

This is an in-place addition. One can argue that an update of a real data object with complex numbers is not allowed (not necessarily saying it should not be possible) but an exception should be thrown if this is not allowed.

aellery commented 2 years ago

I am having some trouble replicating this bug. With the latest commit, the following code prints "x is complex" to the console.

from esys.escript import * from esys.finley import Rectangle domain=Rectangle(l0=1, l1=1, n0=10, n1=10) x=0+ComplexScalar(5+8j, Function(domain)) if x.isComplex() is True: print("x is complex")

esys-escript commented 1 year ago

Closing the issue as nobody can reproduce the bug.