-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaveFunction.py
46 lines (37 loc) · 1.05 KB
/
waveFunction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import matplotlib.pyplot as plt
import numpy as np
# Constants
h = 6.626e-34
m = 9.11e-31
# Values for L and x
x_list = np.linspace(0, 1, 100)
L = 1
def psi(n, L, x):
return np.sqrt(2 / L) * np.sin(n * np.pi * x / L)
def psi_2(n, L, x):
return np.square(psi(n, L, x))
plt.figure(figsize=(15, 10))
plt.suptitle("Wave Functions", fontsize=18)
for n in range(1, 4):
# Empty lists for energy and psi wave
psi_2_list = []
psi_list = []
for x in x_list:
psi_2_list.append(psi_2(n, L, x))
psi_list.append(psi(n, L, x))
plt.subplot(3, 2, 2 * n - 1)
plt.plot(x_list, psi_list)
plt.xlabel("L", fontsize=13)
plt.ylabel("Ψ", fontsize=13)
plt.xticks(np.arange(0, 1, step=0.5))
plt.title("n=" + str(n), fontsize=16)
plt.grid()
plt.subplot(3, 2, 2 * n)
plt.plot(x_list, psi_2_list)
plt.xlabel("L", fontsize=13)
plt.ylabel("Ψ*Ψ", fontsize=13)
plt.xticks(np.arange(0, 1, step=0.5))
plt.title("n=" + str(n), fontsize=16)
plt.grid()
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()