Spaces:
Sleeping
Sleeping
Download wavefunctions.py from j25aiml013/physics-simulation: direct link, hf CLI and curl.
- Browser
- Download file 698 Bytes
-
https://huggingface.co/spaces/j25aiml013/physics-simulation/resolve/main/wavefunctions.py
- Command line
-
hf download hf://spaces/j25aiml013/physics-simulation/wavefunctions.py
-
curl -L -o wavefunctions.py https://huggingface.co/spaces/j25aiml013/physics-simulation/resolve/main/wavefunctions.py
698 Bytes
| import numpy as np | |
| from .constants import BOHR_RADIUS | |
| # ------------------------------------------------------ | |
| # Particle in a Box: ψ_n(x) | |
| # ------------------------------------------------------ | |
| def pib_wavefunction(n: int, x: np.ndarray, L: float) -> np.ndarray: | |
| return np.sqrt(2 / L) * np.sin(n * np.pi * x / L) | |
| # ------------------------------------------------------ | |
| # Hydrogen ground state approximation (1D radial) | |
| # ψ(r) = (1/√π a₀³) exp(-r / a₀) | |
| # ------------------------------------------------------ | |
| def hydrogen_ground_state(r: np.ndarray) -> np.ndarray: | |
| r = np.abs(r) | |
| return (1 / np.sqrt(np.pi * BOHR_RADIUS**3)) * np.exp(-r / BOHR_RADIUS) | |