ngsolve.atan and Integrate over a surface

Hi,

I am trying to integrate a coefficient function over a surface (labeled as “observationplane”):

P1=0
P2=1
Integrate(cos(P1*ngsolve.atan(y/z))cos(P2ngsolve.atan(y/z)),mesh,BND,definedon=mesh.Boundaries(“observationplane”))

It should be zero, however it returns a non-zero value 2.0002296550916974.

The attached code produces this result.
https://ngsolve.org/media/kunena/attachments/921/test4.py

Best,
Shixu

Attachment: test4.py

Hi Shixu,
you need to use the arctan2 to have the correct angle for all 4 quadrants (atan is only defined on 2).

ngsolve.atan2(y,z)

Best Christopher

Thank you Christopher. The use of atan2 gives the following:

Traceback (most recent call last):
File “”, line 26, in
netgen.libngpy._meshing.NgException: atan2 not available for type N5ngstd4SIMDIdLi4EEE

Best,
Shixu

Thanks again Christopher. I guess an alternative way would be

ngsolve.cos(P1*IfPos(y,ngsolve.atan(z/y),ngsolve.atan(z/y)+pi))

this atan2 problem was fixed a few days ago, install the latest nightly version,
Joachim