Figure: Demonstration of rotating a spherical harmonic by means of the
Wigner D-matrix. In the above image, a 3dz2 and a 4fz3 atomic orbital are rotated
by an angle
Rotation of spherical harmonics using Wigner-D matrices
The canonical spherical harmonics
wherein
In the script below, a dz2 spherical harmonic is rotated over an axis with
coordinates
from sphecerix import tesseral_wigner_D
from scipy.spatial.transform import Rotation as R
import numpy as np
def main():
# build rotation axis and set angle
axis = np.ones(3) / np.sqrt(3)
angle = np.pi
Robj = R.from_rotvec(axis * angle)
# construct tesseral Wigner D matrix
D = tesseral_wigner_D(2, Robj)
Y = np.zeros(5)
Y[2] = 1
# calculate linear combination of the spherical harmonics after rotation
Yp = D @ Y
print(Yp)
if __name__ == '__main__':
main()