-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00000000.py
More file actions
29 lines (22 loc) · 773 Bytes
/
Copy path00000000.py
File metadata and controls
29 lines (22 loc) · 773 Bytes
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
import numpy as np
import matplotlib.pyplot as plt
# Parameters
L = 1.0 # Length of the box
n_levels = 3 # Number of energy levels to plot
x = np.linspace(0, L, 1000) # Positions inside the box
plt.figure(figsize=(10, 6))
for n in range(1, n_levels + 1):
# Wavefunction Ψ_n(x)
psi_n = np.sqrt(2/L) * np.sin(n * np.pi * x / L)
# Probability density |Ψ_n(x)|^2
prob_density = psi_n**2
# Plot wavefunction
plt.plot(x, psi_n, label=f'Ψ_{n}(x)')
# Optionally, plot probability density (uncomment below)
# plt.plot(x, prob_density, linestyle='--', label=f'|Ψ_{n}(x)|^2')
plt.title("Wavefunctions of a Particle in a 1D Box")
plt.xlabel("Position x")
plt.ylabel("Ψ_n(x)")
plt.legend()
plt.grid(True)
plt.show()