Fun fact about the video above
This simulation (see credits below) compares images of the Helix Nebula from three observatories: Hubble’s image in visible light, Spitzer’s infrared view, and Webb’s high-resolution near-infrared look.
A simulation that takes forty minutes on a tiny grid is not a tool you can explore with. The thesis is about fixing that.
The pion description of large-scale structure needs a field evolved on a 3D grid, and at every step it needs a Poisson-type equation solved. In the first versions, that step used Green's functions and cost O(N⁶) for N points per side. A 25³ grid in Python took about forty minutes. Higher resolution was out of reach.
What I changed
Swapped the algorithm
Spectral inversion with FFTs replaces the Green's function sum: O(N⁶) becomes O(N³ log N).
Moved from Python to C++
A C++17 implementation with a flat, cache-friendly array layout. A run from about 17 Myr to 1.63 Gyr took about twenty minutes.
Wrote my own FFT
A mixed-radix Cooley–Tukey transform for sizes built from the factors 2, 3 and 5, so grids are not forced to be powers of two. It works on 3D arrays directly.
Parallelized with OpenMP
The 1D transforms along each axis are independent, so slices are divided between threads.
How much faster
Overall, the C++ solver is about 400 times faster than the first Mathematica prototype: roughly 20 times from the algorithm and Python move, and roughly 20 times from C++. The bars use a log scale, because a linear one would flatten the first two.
Checking it against FFTW3
I validated the custom FFT against FFTW3, the standard library for this job. The results agree to about 1e-12.
| Accuracy against FFTW3 | Agrees to about 1e-12 |
|---|---|
| Single-core speed | FFTW3 is about 50 times faster |
| OpenMP, 8 threads | 2.6 to 3.3 times faster on grids of 64³ and larger |
| On local machines | About 3 times faster |
FFTW3 is much faster, and I say so plainly. What the custom FFT gave me is flexibility: control over layout, grid sizes and parallelization inside the simulation, and a result I can fully explain.
Thesis, code and talks
- Honors_Thesis_2025 on GitHubCode, benchmarks and the thesis
- Read the thesis (PDF)Science Honors Program, Manhattan University, 2025
- The research it supportsThe paper and the physics
Defended in April 2025 at the Science Seminar, Manhattan University. Advised by Dr. Bart Horn.
The poster