有什么方法可以在Python中的单位球体表面整合球形谐波?

发布于 2025-01-26 01:25:51 字数 933 浏览 2 评论 0原文

我正在尝试将其集成到python中,

f1 = lambda phi, theta: ( np.conj(sph_harm(m1, l1, theta, phi)) \
                           * sph_harm(m2, l2, theta, phi)     #theta--> 0-2pi, phi-->0-pi
                  * np.sin(phi) / np.power(1+epsilon*np.cos(n*phi), l2))

coeff1 = (l1*l2*(l2+1)) /(2*l1*(l1+1))
result = coeff1 * term1
print(result)

其中 m1 l1 m2 l2 具有某些值。例如 m1,m2 = -2, l1,l2 = 2。
我还使用Mathematica检查了我从Python获得的值。它们不匹配不同的值。例如,对于上述 m1,l1,m2,l2 的值,从python i获得了 0.01673 ,而Mathematica给我 1.001433 。对于 l m 的其他较高值,有时差异是巨大的。

然后,我尝试了高斯正交方法来数值计算我的结果。尽管它与Mathematica的结果相匹配的某些值 l m ,但它并不适用于所有值。

很奇怪的是,我发现只有当我考虑np.sin(phi) / np.power(1+epsilon*np.cos(n*phi),l2))< / code> < / code> 。如果我只尝试整合球形谐波,则不会显示任何差异。您是否知道为什么会发生这种情况以及如何解决?

I am trying to integrate this in Python

f1 = lambda phi, theta: ( np.conj(sph_harm(m1, l1, theta, phi)) \
                           * sph_harm(m2, l2, theta, phi)     #theta--> 0-2pi, phi-->0-pi
                  * np.sin(phi) / np.power(1+epsilon*np.cos(n*phi), l2))

coeff1 = (l1*l2*(l2+1)) /(2*l1*(l1+1))
result = coeff1 * term1
print(result)

where m1, l1, m2, l2 have certain values. For example m1,m2=-2, l1,l2=2.
I have also used Mathematica to check the values I get from python. They don't match for different values. For example, for the above mentioned values of m1,l1,m2,l2, from python I obtained 0.01673 while Mathematica gives me 1.001433. For other higher values of l and ms the difference is monumental sometimes.

Then, I have tried Gaussian quadrature method to numerically calculate my result. Though it matches for some values of l and m with the result from Mathematica, It does not hold for all values.

The weird thing is I found the problem occurring only when I consider np.sin(phi) / np.power(1+epsilon*np.cos(n*phi), l2)) in the integration. If I only try to integrate the spherical harmonics, it does not show any difference. Do you have any idea why this is happening and how to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2025-02-02 01:25:51

请注意,在许多关于潜在理论的情况下,我更好地说明了类似的东西,

import numpy as np
from scipy.integrate import simps

xl = np.linspace( a, b, A ) 
yl = np.linspace( c, d, C )
xx, yy = np.meshgrid( xl, yl )
zz = xx.copy()
for i in range( len( yy ) ):
    for j in range( len( xx[0] ) ):
        x0 = xx[ i, j ]
        y0 = yy[ i, j ]
        zz[ i, j ] = f( x0, y0 )
result = simps( simps( zz, xl ), yl )

而不是使用dblquad

Note in many cases on potential theory, I was better of with something like

import numpy as np
from scipy.integrate import simps

xl = np.linspace( a, b, A ) 
yl = np.linspace( c, d, C )
xx, yy = np.meshgrid( xl, yl )
zz = xx.copy()
for i in range( len( yy ) ):
    for j in range( len( xx[0] ) ):
        x0 = xx[ i, j ]
        y0 = yy[ i, j ]
        zz[ i, j ] = f( x0, y0 )
result = simps( simps( zz, xl ), yl )

rather than using dblquad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文