numerics
Loading...
Searching...
No Matches
Numerics Library

A C++ numerical computing library with interactive physics simulations.


Library Modules

core — Vectors, matrices, and backend dispatch

factorization — Direct linear solvers

solvers — Iterative solvers

eigen — Eigenvalue methods

svd — Singular value decomposition

spectral — Fourier transforms

analysis — Quadrature and root finding

stats — Simulation observables

markov — Markov chain Monte Carlo

sparse and banded — Structured sparse formats

spatial — Spatial data structures and grid


Physics Applications

Monte Carlo

2D Ising Model

page_app_ising

Metropolis dynamics and umbrella-sampled nucleation on a 300×300 lattice. Reproduces Brendel et al. (2005) nucleation experiments.

Library feature Role
num::markov::metropolis_sweep_prob Sweep hot path with precomputed Boltzmann table
num::markov::umbrella_sweep_prob Per-sweep rejection / save-restore for window sampling
num::SparseMatrix + sparse_matvec Neighbour-sum matrix for energy observable (SIMD path)
num::RunningStats, num::Histogram Online mean, variance, nucleus-size distribution per window
num::newton Mean-field self-consistency equation solver

Fluid Dynamics

2D SPH Fluid Simulation

page_app_fluid

Weakly compressible SPH with heat transport, rigid bodies, and particle injection. Tait EOS, cubic-spline kernel, Morris viscosity Laplacian.

Library feature Role
num::CellList2D O(1) neighbour queries; Newton-3rd-law pair traversal
num::Backend dispatch seq (pair loop) ↔ omp (per-particle) selectable at runtime
num::Vector Flat particle attribute arrays

3D SPH Fluid Simulation

page_app_fluid3d

3D WCSPH with opposing hose jets, heat transport, and a free-orbit camera whose orientation rotates the gravity vector.

Library feature Role
num::CellList3D 3D counting-sort spatial hash; 13-stencil Newton-3rd-law pairs
num::Backend dispatch seq (pair traversal) ↔ omp (per-particle)
num::Vector Flat particle attribute arrays

2D Incompressible Navier-Stokes

page_app_ns

Chorin projection on a staggered MAC grid; semi-Lagrangian advection; matrix-free CG pressure solve. Kelvin–Helmholtz double shear layer initial condition.

Library feature Role
num::cg_matfree Matrix-free CG for -∇²p = r; warm-start from previous pressure field
num::dot Inner products inside CG (dispatched to best available backend)
num::Vector Velocity faces u, v; pressure p; intermediates u*, v*, rhs

Quantum Mechanics

2D Time-Dependent Schrödinger Equation

page_app_tdse

Strang operator splitting with Crank–Nicolson kinetic sweeps; Thomas algorithm for O(N) tridiagonal solves; Lanczos eigendecomposition; five interchangeable potentials.

Library feature Role
num::thomas O(N) complex tridiagonal solve per row/column (kinetic sweeps)
num::lanczos Krylov subspace for lowest eigenmodes
num::brent Bessel zero-finding for exact circular-well energies
num::gauss_legendre Norm and energy quadrature

Electromagnetism

Electromagnetic Field Demo

page_app_em

DC current flow + magnetostatics on a 32³ voxel grid. Four Poisson problems (one electric, three magnetic) solved with matrix-free CG; interactive magnetic dipole.

Library feature Role
num::cg_matfree All four Poisson solves (variable-coefficient electric + 3× magnetic)
num::Grid3D 3D scalar field storage for φ, A, J, B components
num::Vector Flattened field arrays passed to the solver

Status Report

Run cmake --build build --target report to generate output/REPORT.md — a full snapshot of the current build:

  • Build environment — compiler, flags, detected backends (BLAS, FFTW3, OpenMP, CUDA, MPI)
  • Test summary — pass/fail counts per suite
  • Benchmark tables — throughput and timing for every module (linalg, FFT, banded, analysis)
  • Plots — PNG throughput curves (seq vs fftw, size scaling) in output/plots/

Sections whose backend was not found at configure time are left as placeholders, so the report always reflects exactly what is installed.


Lecture Notes