Pysic-rs Documentation¶
High-performance mathematical physics engine in Rust with Python bindings
Pysic-rs provides CPU-only, textbook-validated implementations of standard mathematical physics, built entirely in Rust and exposed to Python through PyO3. Every algorithm is a canonical result from the established literature â nothing experimental, nothing research-pending. This is the physics companion to Optimiz-rs, which supplies the probabilistic and statistical machinery (MCMC, HMM, SDE, Kalman filtering). Where you need physics and statistics, the two libraries interoperate.
đ Module Map â Pysic-rs covers thirteen foundational areas:
Getting Started
Examples
- Example Notebooks
- 00 · Fundamental Constants and API Scope
- 01 · ODE Integration: rk4_solve, backward_euler, leapfrog, rk45_solve
- 02 · Heat Equation: Crank-Nicolson 1D and ADI 2D
- 03 · Wave Equation: FDTD 1D and 2D
- 04 · Poisson Equation: poisson_fft_2d
- 05 · Schrödinger & Dirac 1D: Split-Step Evolution
- 06 · Fourier Analysis: fft/ifft, spectral_derivative, welch_psd
- 07 · Quantum States: Pauli Matrices/Structures, Fock & Coherent States
- 08 · Quantum Propagators: Feynman and Free
- 09 · Gauge Theory: su(3) Structure Constants and Instanton Action
- 10 · Quantum Topology: Berry Phase, Chern Number, Winding Number
- 11 · General Relativity: Schwarzschild Metric, Christoffel, ADM Constraints
- 12 · Classical Mechanics: Rotations, Euler Equations, Inertia
- 13 · Electromagnetism: Radiation, Compton, Casimir Effect
- Catalogue
- Real-World Applications
- Statistical Validation
Algorithms
- Special Functions
- 1. The Gamma Function
- 2. The Beta Function
- 3. Bessel Functions
- 4. Legendre Polynomials & Spherical Harmonics
- 5. Chebyshev Polynomials
- 6. Error Function
- 7. Riemann Zeta Function
- 8. Airy Functions
- 9. Exponential Integral
- 10. Available Functions
- 11. Usage Examples
- 12. Numerical Accuracy
- 13. Advantages & Limitations
- 14. References
- 15. Related Topics
- Linear Algebra
- Numerical Calculus
- ODE Solvers
- PDE Solvers
- 1. Classification of Linear PDEs
- 2. Schrödinger Equation (Split-Step Fourier)
- 3. Dirac Equation (Split-Step)
- 4. Heat Equation (CrankâNicolson)
- 5. Wave Equation (FDTD)
- 6. Poisson Equation
- 7. Maxwell 3D (Yee FDTD)
- 8. Routines
- 9. Usage Examples
- 10. Stability Guidelines (von Neumann analysis, proven)
- 11. Advantages & Limitations
- 12. References
- 13. Related Topics
- Fourier Analysis
- Quantum Mechanics
- General Relativity
- Gauge Theory
- Classical Mechanics
- Topology
- Electromagnetism
- Casimir Effect
API Reference
- API Reference: Special Functions
- API Reference: Linear Algebra
- API Reference: Numerical Calculus
- API Reference: ODE
- API Reference: PDE
- API Reference: Fourier Analysis
- API Reference: Quantum Mechanics
- API Reference: General Relativity
- API Reference: Gauge Theory
- API Reference: Classical Mechanics
- API Reference: Topology
- API Reference: Electromagnetism
- API Reference: Casimir Effect
Theory
Advanced
Features¶
Modules Included:
Special Functions: Gamma (Lanczos), Beta, Bessel J/Y, Legendre P/P_â^m, spherical harmonics, Chebyshev T/U, Airy, erf/erfc, exponential integral, Riemann zeta
Linear Algebra: Cholesky, LU with pivoting, GaussâJordan inverse, determinant, tensor raise/lower, metric signature, Lie bracket
Numerical Calculus: gradient, Hessian, Jacobian, trapezoid/Simpson/GaussâLegendre/Romberg integration, linear & cubic-spline interpolation
ODE Solvers: RK4, RK45 (DormandâPrince), backward Euler, CrankâNicolson, leapfrog, velocity Verlet, Yoshida symplectic, Hamiltonian integration
PDE Solvers: Schrödinger (split-step Fourier), Dirac, heat (CrankâNicolson + ADI), wave (FDTD 1D/2D), Poisson (FFT + SOR), Maxwell (3D Yee)
Fourier Analysis: FFT/IFFT, power spectral density, Welch PSD, spectral derivatives
Quantum Mechanics: Pauli matrices, spin operators, density matrices, partial trace, coherent/number/squeeze states, RayleighâSchrödinger perturbation, path integrals, Feynman propagators
General Relativity: Schwarzschild, Kerr, KerrâNewman, FLRW, Minkowski; Christoffel, Riemann, Ricci, Einstein tensors; geodesics; ADM 3+1; stressâenergy
Gauge Theory: SU(2)/SU(3) structure constants, Gell-Mann matrices, connections, covariant derivative, YangâMills action/EOM, instantons (ât Hooft)
Classical Mechanics: Hamiltonian, Lagrange/EulerâLagrange, Poisson bracket, rigid-body (Euler equations, quaternions, Euler angles)
Topology: Berry phase & curvature, Chern/TKNN numbers, winding numbers, skyrmion number
Electromagnetism: Greenâs functions (static, retarded, Helmholtz, dyadic), radiation formulas (Larmor, dipole, cyclotron, synchrotron, Thomson, Compton)
Casimir Effect: parallel plates, sphere, cylinders, ζ-regularization, finite-T, Lifshitz, Polder, van der Waals
Performance:
Pure Rust core with zero-cost abstractions
Python bindings via PyO3 (abi3) â no NumPy dependency at the boundary
Optional Rayon parallelism
50â100Ă faster than pure Python physics code
Quick Example¶
from pysicrs import constants, schwarzschild_metric, rk4_solve
# Physical constants
print(constants()["c"]) # 2.997925e+08
# Schwarzschild metric at r = 10M
g = schwarzschild_metric(10.0, 1.0)
print(g[0, 0]) # -(1 - 2/10) = -0.8
# Integrate the harmonic oscillator with RK4
def osc(t, y):
return [y[1], -y[0]]
times, traj = rk4_solve(osc, [1.0, 0.0], 0.0, 10.0, 10000)
print(traj[-1][0]) # cos(10) â -0.8391
Installation¶
From source:
# Clone repository
git clone https://github.com/ThotDjehuty/pysic-rs.git
cd pysic-rs
# Build and install
pip install maturin
maturin develop --release