Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

ngsolve.atan and Integrate over a surface

More
4 years 10 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
4 years 10 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
4 years 10 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
4 years 10 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
4 years 10 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.157 seconds