ngsolve.atan and Integrate over a surface

More
5 years 5 months ago #1647 by sxmeng
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(P2*ngsolve.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.

File Attachment:

File Name: test4.py
File Size:1 KB


Best,
Shixu
Attachments:
More
5 years 5 months ago #1648 by christopher
Hi Shixu,
you need to use the arctan2 to have the correct angle for all 4 quadrants (atan is only defined on 2).
Code:
ngsolve.atan2(y,z)
Best Christopher
More
5 years 5 months ago #1649 by sxmeng
Thank you Christopher. The use of atan2 gives the following:

Traceback (most recent call last):
File "<string>", line 26, in <module>
netgen.libngpy._meshing.NgException: atan2 not available for type N5ngstd4SIMDIdLi4EEE

Best,
Shixu
More
5 years 5 months ago #1650 by sxmeng
Thanks again Christopher. I guess an alternative way would be

ngsolve.cos(P1*IfPos(y,ngsolve.atan(z/y),ngsolve.atan(z/y)+pi))
More
5 years 5 months ago #1651 by joachim
this atan2 problem was fixed a few days ago, install the latest nightly version,
Joachim
The following user(s) said Thank You: sxmeng
Time to create page: 0.104 seconds