Exemple #1
0
def sph_synthesis(flm_it, r, th, phi, lmax=17):
    ylm_it = spherical_harmonics_it(th, phi)
    f = 0.0
    for (flm, l1, m1), (ylm, l, m) in zip(flm_it, ylm_it):
        assert l == l1 and m == m1
        f += flm * ylm
    return f
Exemple #2
0
def check_lebedev_quadrature(order, tolerance=1e-9):
    th, phi, w = array(LebedevGridPoints[Lebedev_Npts[order]]).transpose()
    sph_it1 = spherical_harmonics_it(th, phi)
    for Ylm1, l1, m1 in sph_it1:
        if l1 > Lebedev_L2max[order]:
            break
        sph_it2 = spherical_harmonics_it(th, phi)
        for Ylm2, l2, m2 in sph_it2:
            if l2 > Lebedev_L2max[order]:
                break
            I = 4.0 * pi * sum(w * Ylm1 * Ylm2.conjugate())
            print("<%s %s|%s %s> = %s" % (l1, m1, l2, m2, I))
            if l1 == l2 and m1 == m2:
                print("|I-1.0| = %s" % abs(I - 1.0))
                assert abs(I - 1.0) < tolerance
            else:
                assert abs(I) < tolerance
Exemple #3
0
def spherical_wave_expansion_it(f, r, order):
    """find grid closest to requested order"""
    n = abs(array(Lebedev_L2max) - order).argmin()
    if order != Lebedev_L2max[n]:
        print("No grid for order %s, using grid which integrates up to L2max = %s exactly instead." \
            % (order, Lebedev_L2max[n]))
    th, phi, w = array(LebedevGridPoints[Lebedev_Npts[n]]).transpose()
    x = outerN(r, sin(th) * cos(phi))
    y = outerN(r, sin(th) * sin(phi))
    z = outerN(r, cos(th))
    fxyz = f(x, y, z)
    sph_it = spherical_harmonics_it(th, phi)
    for Ylm, l, m in sph_it:
        flm = 4.0 * pi * sum(w * fxyz * Ylm.conjugate(), axis=-1)
        yield flm, l, m
        if m == -Lebedev_L2max[n]:
            raise StopIteration