Last active
May 30, 2017 14:22
-
-
Save kumpeishiraishi/c39baecc07bf6f51670d1fefc8e54aa1 to your computer and use it in GitHub Desktop.
Draw spherical harmonics with your preferred quantum numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.special import sph_harm | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
# Designate quantum numbers here! | |
m = 1 | |
l = 3 | |
point_size = 100 | |
theta = np.linspace(0,np.pi,num=point_size) | |
phi = np.linspace(0,2*np.pi,num=point_size) | |
r = 2 | |
x = r*np.outer(np.sin(theta),np.cos(phi)) | |
y = r*np.outer(np.sin(theta),np.sin(phi)) | |
z = r*np.outer(np.cos(theta),np.ones(point_size)) | |
T = np.outer(theta,np.ones(point_size)) | |
P = np.outer(np.ones(point_size),phi) | |
R = np.abs(np.real(sph_harm(m,l,P,T))) | |
fig = plt.figure() | |
ax = fig.add_subplot(111,projection="3d") | |
ax.plot_wireframe(R*x,R*y,R*z) | |
plt.savefig("20170530_sph_harm_3_1.png",dpi=300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment