Infinite Square Well

Quantum Chemistry

The infinite square well is one of the simplest quantum mechanical systems. A particle is confined to a region of space with infinite potential barriers at the boundaries, creating a potential well.

Problem Setup

Consider a particle of mass confined to a one-dimensional box of length . The potential is:

The wavefunction must vanish at the boundaries: .

Time-Independent Schrödinger Equation

Inside the well, the time-independent Schrödinger equation is:

This is an eigenvalue problem where is the energy eigenvalue and is the corresponding eigenfunction.

Analytical Solution

The analytical solution gives energy eigenvalues:

and normalized wavefunctions:

where is the quantum number.

Finite Difference Method

We discretize the second derivative using finite differences:

This leads to a matrix eigenvalue problem , where is a tridiagonal matrix representing the discretized Hamiltonian.

Implementation

import numpy as np
import matplotlib.pyplot as plt

# Parameters
L = 1.0         # Length of the well (arbitrary units)
N = 1000        # Number of points for discretization
dx = L / (N - 1) # Spatial step size
hbar = 1.0      # Planck's constant (reduced, in arbitrary units)
m = 1.0         # Mass of the particle (arbitrary units)

# Discretized x-axis
x = np.linspace(0, L, N)

# Finite difference matrix for the second derivative
diagonal = np.full(N, -2.0) / dx**2
off_diagonal = np.full(N - 1, 1.0) / dx**2
H = np.diag(diagonal) + np.diag(off_diagonal, 1) + np.diag(off_diagonal, -1)

# Solve the eigenvalue problem
energies, wavefunctions = np.linalg.eigh(-H * hbar**2 / (2 * m))

# Analytical energies for comparison
n_values = np.arange(1, 5)  # Compare first 4 levels
analytical_energies = [(n**2 * np.pi**2 * hbar**2) / (2 * m * L**2) for n in n_values]

# Ensure wavefunctions start positive for consistent plotting
for i in range(len(wavefunctions[0])):
    if wavefunctions[0, i] < 0:
        wavefunctions[:, i] = -wavefunctions[:, i]

# Plot computed wavefunctions and energies
num_levels = 4
plt.figure(figsize=(10, 6))
for i in range(num_levels):
    plt.plot(x, wavefunctions[:, i], label="n={}, Computed E={:.2f}, Analytical E={:.2f}".format(i+1, energies[i], analytical_energies[i]))

plt.title("Wavefunctions in the Infinite Square Well")
plt.xlabel("Position x")
plt.ylabel("Wavefunction ψ(x)")
plt.legend()
plt.show()

# Print both computed and analytical energy levels
print("Computed vs Analytical Energy Levels:")
for i in range(num_levels):
    print("Level {}: Computed E = {:.4f}, Analytical E = {:.4f}".format(i+1, energies[i], analytical_energies[i]))

Results

The finite difference method accurately reproduces the analytical energy eigenvalues and wavefunctions. The computed energies converge to the analytical values as the number of discretization points increases.

Key Features

Physical Interpretation

The infinite square well demonstrates several fundamental quantum mechanical principles: