test_sphere.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:quadpy 作者: nschloe 项目源码 文件源码
def test_spherical_harmonic(scheme):
    '''Assert the norm of the spherical harmonic

    Y_1^1(phi, theta) = -1/2 sqrt(3/2/pi) * exp(i*phi) * sin(theta)

    is indeed 1, i.e.,

    int_0^2pi int_0^pi
        Y_1^1(phi, theta) * conj(Y_1^1(phi, theta)) * sin(theta)
        dphi dtheta = 1.
    '''
    def spherical_harmonic_11(azimuthal, polar):
        # y00 = 1.0 / numpy.sqrt(4*numpy.pi)
        y11 = -0.5 * numpy.sqrt(3.0/2.0/numpy.pi) \
            * numpy.exp(1j*azimuthal) * numpy.sin(polar)
        return y11 * numpy.conjugate(y11)

    val = quadpy.sphere.integrate_spherical(
        spherical_harmonic_11,
        rule=scheme
        )

    assert abs(val - 1.0) < 1.0e-15
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号