Projects / Fornax A
Fornax A: exploring writing galaxy simulations in C
Hobby project, 2026 · an excuse to learn C and parallel programming · set-up and analysis in Python
I wanted to learn C properly, and writing an N-body code seemed a lot more fun than working through exercises. Once it ran, it needed something to simulate, and NGC 1316 was the obvious choice: the brightest galaxy in the Fornax cluster, host of the radio source Fornax A, and clearly the wreckage of a merger. Its outskirts are full of debris, with stellar loops and shells out to about 160 kpc (Iodice et al. 2017) and neutral-hydrogen tails 70–150 kpc long (Serra et al. 2019). Serra et al. argue it came from a roughly 10:1 merger 1–3 Gyr ago, between a gas-poor lenticular galaxy and a gas-rich spiral like the Milky Way. So I tried to crash two galaxies together and see what came out.
To be clear about what this is: a hobby project, not research. It's gravity and nothing else, so there's no gas physics, no star formation, no dust, no feedback and no AGN, which for a galaxy famous for its radio lobes is quite a lot to leave out. What I did do is take the starting conditions seriously, setting the masses, sizes and orbit from published measurements so the thing I'm playing with at least resembles the real galaxy. Everything below is me exploring, not a result.
Setting up the two galaxies
| Primary (lenticular) | Satellite (Milky Way-like spiral) | |
|---|---|---|
| Dark halo | 4.5×10¹² M☉ | 6.1×10¹¹ M☉ |
| Bulge | 4.8×10¹¹ M☉, rotating | 10¹⁰ M☉ |
| Stellar disk | 1.2×10¹¹ M☉ | 5×10¹⁰ M☉ |
| Cold gas | none | 10¹⁰ M☉ (tracer) |
| Particles | 660 000 | 475 000 |
The stellar mass ratio is 10.3:1. This is the part I tried hardest to get right: I picked the big galaxy's masses by fitting the measured velocity-dispersion profile of NGC 1316 (McNeil-Moylan et al. 2012) and kept its stellar mass inside the range the photometry allows (Iodice et al. 2017), so the galaxy I start with is at least the right size and weight. Then I let each galaxy sit on its own for 0.6–1 Gyr to check it didn't fall apart before the collision even started, which is a good way to catch mistakes: over 1 Gyr alone, the big galaxy's structure drifted by at most 3.7% and its energy held to 3 parts in 10⁴.
The code, which was the actual point
The simulation runs on a collisionless N-body code I wrote from scratch as a single C11 file, which is where most of the learning happened. Gravity uses a Barnes–Hut octree with quadrupole moments and the Barnes (1994) offset opening criterion, softened on 100 pc scales. Particles advance with a kick–drift–kick leapfrog on individual block timesteps, and the force calculation is parallelised with OpenMP. The code comes with a validation suite that checks it against problems with known answers, such as the equilibrium of a Plummer sphere and cold collapse. The production run followed 1.135 million particles for 3 Gyr and wrote a snapshot every 5 Myr. Python scripts build the initial conditions and handle the analysis and rendering.
Choosing the orbit
Before the production run, three low-resolution scout mergers (91 000 particles, 2.2 Gyr) tested a prograde passage at 15 kpc (A), the same orbit retrograde (B) and a wider 40 kpc pericentre (C). I chose A because the prograde passage tears out the long, thin tidal tails that the HI shows. B spreads the debris into a broad fan instead, and C needs more passages before it merges.
What happens
| Time | |
|---|---|
| 0.36 Gyr | First pericentre at 11 kpc: a tidal tail and the first shells are thrown out |
| 0.75 Gyr | Apocentre at 116 kpc |
| 1.20 Gyr | Second pericentre, 0.5 kpc |
| 1.4–1.9 Gyr | The orbit decays through apocentres of 30, 18 and 15 kpc |
| 1.67 Gyr | The satellite's bound core falls below 10% of its bulge mass |
| ≈ 2.0 Gyr | The two nuclei coalesce |
| 3.00 Gyr | End of the run: a remnant about 1 Gyr past the merger |
How close did it get?
The final remnant is about 1 Gyr past the merger, at the young end of the 1–3 Gyr age that Serra et al. infer. To compare it with the real galaxy, I rendered it from the direction that best matches the observed kinematics, at the same physical scale, orientation and surface-brightness scale as an image of NGC 1316 from the DESI Legacy Imaging Surveys, taking a distance of 20.8 Mpc.
At matched depth it's about the right size, which was more than I expected. It is also rounder and smoother than the real thing, which has dust lanes (no dust here) and loops of debris visible even in this survey image. Comparing the profiles: the velocity dispersion comes out close (χ²/N = 1.2), rotation less so (χ²/N = 3.0), and the brightness is a bit high inside 10 kpc and too low beyond 20 kpc, so my galaxy is missing part of the real one's outer envelope. For gravity alone, starting from numbers in papers, that feels like a fair outcome.
Stripped stars pile up into shells, strongest around 1.8 Gyr, at radii close to NGC 1316's loops (about 91 and 160 kpc). That's satisfying, but it only means the orbit carries roughly the right energy. It certainly doesn't predict where any particular loop sits on the sky.
One moment, six quantities
Every quantity is rendered as its own frame series. These show the central 250 kpc at 1.8 Gyr, when the shells are strongest.






Everything it leaves out
- No gas physics at all. The "gas" is just particles that feel gravity. Real HI gets stripped, ionised and turned into stars, so my tails never fade: they sail past the observed 70–150 kpc by about 2 Gyr and reach 206 kpc by 3 Gyr, and far too much cold gas survives (8.4×10⁹ M☉ beyond 20 kpc, against roughly 7×10⁸ M☉ of real HI).
- No star formation, dust, feedback or AGN. Which, for the galaxy behind one of the brightest radio sources in the sky, is a glaring omission. Nothing here says anything about the radio lobes.
- One merger, in isolation. There is no Fornax cluster potential, no neighbouring NGC 1317 and no later minor accretion.
- The orbit was chosen by eye. I tried three and picked the one that looked most like the real tails. A real study would search the orbital parameters properly.
- Limited resolution. Nothing smaller than about 0.3 kpc is real, and the heavy dark-matter particles slowly puff up thin structures over time.
Code
The N-body code and the analysis scripts will be on GitHub soon.
References
- Barnes, J. E. 1994, in Computational Astrophysics: offset opening criterion
- Dey, A. et al. 2019, AJ, 157, 168: the DESI Legacy Imaging Surveys, source of the NGC 1316 images (legacysurvey.org)
- Hernquist, L. 1993, ApJS, 86, 389: N-body realisations of disk galaxies
- Iodice, E. et al. 2017, ApJ, 839, 21: deep VST imaging of the loops and envelope
- McNeil-Moylan, E. K. et al. 2012, A&A, 539, A11: planetary-nebula and integrated-light kinematics
- Power, C. et al. 2003, MNRAS, 338, 14: timestep criterion
- Serra, P. et al. 2019, A&A, 628, A122: MeerKAT HI tails and the merger scenario