Ejemplo n.º 1
0
def test_spherical_harmonic():
    Nmax = 1
    theta = np.array([np.pi / 2, np.pi / 2, 0], dtype='double')
    phi = np.array([0, np.pi / 2, 0], dtype='double')
    rad = np.ones(3, dtype=np.double)
    coords = Coordinates.from_spherical(rad, theta, phi)

    Y = np.array([[
        2.820947917738781e-01 + 0.000000000000000e+00j, 3.454941494713355e-01 +
        0.000000000000000e+00j, 2.991827511286337e-17 + 0.000000000000000e+00j,
        -3.454941494713355e-01 + 0.000000000000000e+00j
    ],
                  [
                      2.820947917738781e-01 + 0.000000000000000e+00j,
                      2.115541521371041e-17 - 3.454941494713355e-01j,
                      2.991827511286337e-17 + 0.000000000000000e+00j,
                      -2.115541521371041e-17 - 3.454941494713355e-01j
                  ],
                  [
                      2.820947917738781e-01 + 0.000000000000000e+00j,
                      0.000000000000000e+00 + 0.000000000000000e+00j,
                      4.886025119029199e-01 + 0.000000000000000e+00j,
                      0.000000000000000e+00 + 0.000000000000000e+00j
                  ]],
                 dtype=complex)

    basis = sh.spherical_harmonic_basis(Nmax, coords)

    np.testing.assert_allclose(Y, basis, atol=1e-13)
Ejemplo n.º 2
0
def test_spherical_harmonics_real():
    n_max = 10
    theta = np.array([np.pi / 2, np.pi / 2, 0, np.pi / 2], dtype='double')
    phi = np.array([0, np.pi / 2, 0, np.pi / 4], dtype='double')
    rad = np.ones(4)
    coords = Coordinates.from_spherical(rad, theta, phi)

    reference = read_2d_matrix_from_csv('./tests/data/sh_basis_real.csv')
    basis = sh.spherical_harmonic_basis_real(n_max, coords)
    np.testing.assert_allclose(basis, reference, atol=1e-13)