Skip to content

Implementation of real_sph_harmonic #3

@vineetbansal

Description

@vineetbansal

Comments in code indicate that the following is possibly a more "textbook" implementation of real_sph_harmonic. Discuss with @janden and either make this the default, or discard altogether:

    @staticmethod
    def real_sph_harmonic2(j, m, theta, phi):
        # TODO: This needs to be made the default implementation of real_sph_harmonic
        # Get the real basis of spherical harmonics in terms of their complex analogues
        # Note that sph_harm reverses the notation of theta/phi
        # 0.707106 = 1/sqrt(2)
        y_m_l = sph_harm(m, j, phi, theta)
        if m == 0:
            result = y_m_l
        else:
            y_minus_m_l = sph_harm(-m, j, phi, theta)
            if m < 0:
                result = 0.707106j * (y_m_l - (-1)**m * y_minus_m_l)
            else:
                result = 0.707106 * (y_minus_m_l + (-1)**m * y_m_l)

        return np.real(result)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions