- Thank you received: 0
ngsolve.atan and Integrate over a surface
5 years 5 months ago #1647
by sxmeng
ngsolve.atan and Integrate over a surface was created 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.
Best,
Shixu
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.
Best,
Shixu
Attachments:
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 5 months ago #1648
by christopher
Replied by christopher on topic ngsolve.atan and Integrate over a surface
Hi Shixu,
you need to use the arctan2 to have the correct angle for all 4 quadrants (atan is only defined on 2).
Best Christopher
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)
5 years 5 months ago #1649
by sxmeng
Replied by sxmeng on topic ngsolve.atan and Integrate over a surface
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
Traceback (most recent call last):
File "<string>", line 26, in <module>
netgen.libngpy._meshing.NgException: atan2 not available for type N5ngstd4SIMDIdLi4EEE
Best,
Shixu
5 years 5 months ago #1650
by sxmeng
Replied by sxmeng on topic ngsolve.atan and Integrate over a surface
Thanks again Christopher. I guess an alternative way would be
ngsolve.cos(P1*IfPos(y,ngsolve.atan(z/y),ngsolve.atan(z/y)+pi))
ngsolve.cos(P1*IfPos(y,ngsolve.atan(z/y),ngsolve.atan(z/y)+pi))
5 years 5 months ago #1651
by joachim
Replied by joachim on topic ngsolve.atan and Integrate over a surface
this atan2 problem was fixed a few days ago, install the latest nightly version,
Joachim
Joachim
The following user(s) said Thank You: sxmeng
Time to create page: 0.104 seconds