Spaces:
Sleeping
Sleeping
File size: 1,087 Bytes
05354e5 | 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 | import numpy as np
from .constants import E_CHARGE, COULOMB_CONSTANT
# ------------------------------------------------------
# Infinite Square Well (Particle in a Box)
# ------------------------------------------------------
def potential_infinite_well(x: np.ndarray, L: float) -> np.ndarray:
V = np.zeros_like(x)
V[x < 0] = np.inf
V[x > L] = np.inf
return V
# ------------------------------------------------------
# Harmonic Oscillator: V(x) = 1/2 m ω² x²
# ------------------------------------------------------
def potential_harmonic(x: np.ndarray, mass: float, omega: float) -> np.ndarray:
return 0.5 * mass * omega**2 * x**2
# ------------------------------------------------------
# Coulomb Potential for Hydrogen Atom
# ------------------------------------------------------
def potential_hydrogen_1d(x: np.ndarray) -> np.ndarray:
"""
1D radial approximation:
V(r) = - (k e²) / r
"""
x = np.where(x == 0, 1e-12, x) # avoid singularity
return -(COULOMB_CONSTANT * E_CHARGE**2) / np.abs(x)
|