To simulate the evolution of a wave function in an infinite potential well according to the Schrödinger equation, we expand the wave function in terms of energy eigenstates (stationary states) and evolve each component with its specific phase factor. The solution involves numerical integration to compute expansion coefficients and dynamic visualization of the wave function's evolution.
Approach
- Problem Setup: Define the infinite well boundaries (0 to L) and physical constants (ℏ = m = 1).
- Initial Wave Function: Use a Gaussian wave packet centered at L/2 with a specified width and initial momentum.
- Eigenstate Expansion: Compute coefficients ( c_n ) by projecting the initial wave function onto the energy eigenstates ( \psi_n(x) ).
- Time Evolution: Evolve each eigenstate with the phase factor ( e^{-i E_n t / \hbar} ).
- Animation: Continuously update the wave function's probability density and real part over time.
Solution Code
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from scipy.integrate import simps
# Constants
L = 1.0 # Width of the well
hbar = 1.0 # Reduced Planck constant
m = 1.0 # Particle mass
n_max = 100 # Number of eigenstates to use
N = 1000 # Number of spatial points
t_max = 0.1 # Total simulation time
dt = 0.001 # Time step
frames = 100 # Number of animation frames
# Spatial grid
x = np.linspace(0, L, N)
dx = x[1] - x[0]
# Initial wave function: Gaussian wave packet
x0 = L / 2.0 # Center
sigma = 0.05 # Width
k0 = 30.0 # Initial wave number
psi0 = np.exp(-(x - x0)**2 / (2 * sigma**2)) * np.exp(1j * k0 * x)
# Normalize the initial wave function
norm = np.sqrt(simps(np.abs(psi0)**2, x))
psi0 /= norm
# Energy eigenstates and eigenvalues
def eigenstate(n, x):
return np.sqrt(2 / L) * np.sin(n * np.pi * x / L)
def eigenvalue(n):
return (n**2 * np.pi**2 * hbar**2) / (2 * m * L**2)
# Compute expansion coefficients c_n
c_n = np.zeros(n_max, dtype=np.complex128)
for n in range(1, n_max + 1):
psi_n = eigenstate(n, x)
integrand = psi_n * psi0
c_n[n-1] = simps(integrand, x)
# Time evolution function
def wave_function(t):
psi_t = np.zeros_like(x, dtype=np.complex128)
for n in range(1, n_max + 1):
E_n = eigenvalue(n)
phase = np.exp(-1j * E_n * t / hbar)
psi_t += c_n[n-1] * eigenstate(n, x) * phase
return psi_t
# Set up the figure
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8))
fig.suptitle('Wave Function Evolution in an Infinite Potential Well')
# Plot initial state
t0 = 0.0
psi_t0 = wave_function(t0)
prob_density = np.abs(psi_t0)**2
real_part = np.real(psi_t0)
line1, = ax1.plot(x, prob_density, 'b-', lw=2, label=r'$|\psi(x,t)|^2$')
line2, = ax2.plot(x, real_part, 'r-', lw=2, label=r'Re$(\psi(x,t))$')
# Format plots
ax1.set_ylabel('Probability Density')
ax1.set_ylim(0, max(prob_density)*1.1)
ax1.grid(alpha=0.6)
ax1.legend(loc='upper right')
ax2.set_xlabel('Position (x)')
ax2.set_ylabel('Real Part')
ax2.set_ylim(min(real_part)*1.1, max(real_part)*1.1)
ax2.grid(alpha=0.6)
ax2.legend(loc='upper right')
# Animation update function
def update(frame):
t = frame * dt
psi_t = wave_function(t)
prob_density = np.abs(psi_t)**2
real_part = np.real(psi_t)
line1.set_ydata(prob_density)
line2.set_ydata(real_part)
ax1.set_title(f'Time = {t:.4f}')
return line1, line2
# Create animation
ani = FuncAnimation(fig, update, frames=frames, interval=50, blit=True)
plt.tight_layout(rect=[0, 0, 1, 0.96])
plt.show()
Explanation
- Initial Setup: The infinite well spans from 0 to ( L ). Physical constants are normalized (ℏ = m = 1).
- Gaussian Wave Packet: The initial state is a Gaussian centered at ( L/2 ) with width ( \sigma ), modulated by a plane wave ( e^{i k_0 x} ) to impart momentum.
- Eigenstate Expansion: The initial wave function is decomposed into energy eigenstates ( \psi_n(x) = \sqrt{2/L} \sin(n \pi x / L) ). Coefficients ( c_n ) are computed via numerical integration (Simpson's rule).
- Time Evolution: Each eigenstate evolves with a phase factor ( e^{-i E_n t / \hbar} ), where ( E_n = (n^2 \pi^2 \hbar^2)/(2 m L^2) ). The total wave function at time ( t ) is reconstructed by summing these evolved states.
- Animation: The probability density ( |\psi(x,t)|^2 ) and the real part of ( \psi(x,t) ) are dynamically plotted over time using
FuncAnimation, updating every 50 milliseconds for smooth visualization.
This approach efficiently captures the quantum dynamics by leveraging the analytical solutions for the infinite well, ensuring accurate and visually intuitive simulations.