sph_harmonics Module

Spherical Harmonics module written by Son, Sang-Kil in Jun. 2006 the derivatives of the real spherical harmonics have been added by Ludger Inhester Apr. 2017 Notation convention: r : radius theta : polar angle (latitude) phi : azimuthal angle (longitude)

  • This is the same as Arfken's book and same as http://mathworld.wolfram.com/SphericalHarmonic.html but different from http://mathworld.wolfram.com/SphericalCoordinates.html
                       2l+1 (l-m)!
    

    Y_l^m(theta,phi) = sqrt{ ---- ------ } P_l^m( cos theta ) exp( i m phi ) 4pi (l+m)!

Y_l^(-m)(theta,phi) = (-1)^m conjg( Y_l^m(theta,phi) )

Be careful for a phase sign: many texts use a different phase convention.



Interfaces

public interface sph_harmonics_complex

complex spherical harmonics

  • private function sph_harmonics_imag(l, m, theta, phi) result(y)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: l
    integer, intent(in) :: m
    real(kind=long), intent(in) :: theta
    real(kind=long), intent(in) :: phi

    Return Value complex(kind=long)


Functions

public function sph_harmonics_real(l, m, theta, phi) result(y)

calculate real spherical harmonics: this is closely connected to sph_harmonics_prefactor() in molecular_grid.f90 sph_harmonics_real( l, m, theta, phi ) := G%Y_lm_prefactor(lm) * (2l+1) / 4pi * associated_Legendre_P( l, |m|, cos(theta) ) * [ ... ] [ ... ] = 1 for m = 0 = cos( |m| * phi ) for m > 0 = sin( |m| * phi ) for m < 0

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: l
integer, intent(in) :: m
real(kind=long), intent(in) :: theta
real(kind=long), intent(in) :: phi

Return Value real(kind=long)

public function grad_sph_harmonic_y_real(l, m, theta, phi) result(gy)

gradient of real sph harmonic

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: l
integer, intent(in) :: m
real(kind=long), intent(in) :: theta
real(kind=long), intent(in) :: phi

Return Value real(kind=long), (3)

public pure function factorial2(n, n2) result(f)

factorial(n,m) = m! / n! for n < m = 1 otherwise thus, factorial(1,2) = 2; factorial(2,1) = 1

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(in), optional :: n2

Return Value real(kind=long)


Subroutines

public subroutine xyz_to_sph(x, y, z, r, theta, phi)

translates x,y,z into r, theta, phi

Arguments

Type IntentOptional Attributes Name
real(kind=long), intent(in) :: x
real(kind=long), intent(in) :: y
real(kind=long), intent(in) :: z
real(kind=long), intent(out) :: r
real(kind=long), intent(out) :: theta
real(kind=long), intent(out) :: phi