AstroNbodySim.jl
A general-purpose, GPU-accelerated astrophysical N-body simulation library, released under the GPL-3.0 license.
AstroNbodySim.jl builds on the broader JuliaAstroSim ecosystem (PhysicalParticles, PhysicalTrees, PhysicalMeshes, AstroIC, AstroIO, AstroPlot, ParallelOperations) to provide a modular, fully unit-aware, hybrid-parallel simulation toolkit.
Installation
]add AstroNbodySimor, to install from the latest main branch:
]add https://github.com/JuliaAstroSim/AstroNbodySim.jlYou might need to install NVIDIA CUDA toolkit
Package Features
- Compute with units
- User-friendly
- Well documented
- Readable programming
- Vectorized array operations
- Dispatch on types for various simulation settings
Float16,Float32,Float64,Int128,BigFloat,Measurement, etc.
- Cross-platform:
Linux,Windows,MacOS. Easy to deploy - Hybrid Parallelism: multi-threading, distributed parallelism, GPU acceleration
- Modularity and Versatility: 10+ packages, designed for general purposes, highly extentable
- Realtime visualzation (interactive)
- Auto-test workflow
Development Guide
- It is highly recommended to use latest
masterbranch of related packages (in JuliaAstroSim), first clone: dev --local [absolute path]to install packages mentioned above, for examplepkg> dev --local /home/user/work/AstroNbodySimVS Codeas well as itsJulia Extensionis convenient to use, andRevise.jlwill update changes on the run.
First Time User Guide
Read documentation of
Julia: https://docs.julialang.org/en/v1/Read documentations and READMEs of related packages
Try examples in
AstroNbodySim/examples. First install packages used in examples byAstroNbodySim/examples/install_pkgs.jl. The default output directory of all examples is./output. The programme would make a directory if the user-defined output path does not exist to avoid unnecessary errors.To interrupt a running simulation, create a file named
stopin the output directory (same with Gadget2):echo > output/stopIt's convenient to check out supported function arguments and keywords by
help?inREPL, for example,help?> run search: run run(sim::Simulation) This function does all the work for you: 1. `prepare` sim environment and preprocess data 2. evaluate force, initialize timesteps, output 3. `mainloop`
Gravity solvers at a glance
| Solver | Method | Complexity | Typical use |
|---|---|---|---|
DirectSum | softened pairwise summation | $\mathcal{O}(N^2)$ | reference solutions, $N \lesssim 10^5$ |
Tree | Barnes–Hut octree (Gadget-2 framework) | $\mathcal{O}(N \log N)$ | large particle counts, $N \gtrsim 10^5$ |
FFT | spectral Poisson solver on a mesh | $\mathcal{O}(N_g^3 \log N_g)$ | periodic boxes, 3D galaxy simulations |
FDM | finite-difference Poisson solver | sparse/dense linear solve | 1D/2D verification, non-periodic boundaries |
ML | neural-network Poisson solver (experimental) | network inference | research prototype only |
The particle solvers use the Gadget-2 cubic-spline softening kernel and the Gadget-2 leapfrog (kick–drift–kick) integrator, with fixed or adaptive timesteps. See the Manual for the formulas, defaults and parallel execution modes.
Relation to WaveDM.jl
AstroNbodySim.jl also provides the N-body engine used by WaveDM.jl. There the DirectSum and Tree solvers are used for collisionless baryons (bulge and stellar disk particles). In the static (:particles_static) mode the particle set is frozen and only supplies a background potential; in the dynamic (:particles_dynamic) mode the particles contribute their potential to the grid at every SPE step and the wave-DM acceleration is interpolated back to the particle positions. The baryon_mode keyword itself belongs to WaveDM.jl, not to this package. Orbit lookback and tidal-force workflows built on these solvers are demonstrated in examples/08-TrajectoryLookback.
Supporting and Citing
This software was developed as part of academic research. If you use it in research, teaching, or other activities, please follow the instructions on the CITING page.
AstroNbodySim.jl is the N-body engine of WaveDM.jl and should be cited together with the following papers:
- Meng, R. & Dong, X. 2026, WaveDM.jl: An Adaptable Simulation Framework for Dynamics of Baryonic and Wave Dark Matter on Galaxy Scales, Research in Astronomy and Astrophysics — journal article · arXiv:2606.25026 · DOI 10.1088/1674-4527/ae9042
@article{meng2026wavedmjladaptablea,
title = {{{WaveDM}}.Jl: {{An Adaptable Simulation Framework}} for {{Dynamics}} of {{Baryonic}} and {{Wave Dark Matter}} on {{Galaxy Scales}}},
shorttitle = {{{WaveDM}}.Jl},
author = {Meng, Runyu and Dong, Xiaobo},
year = 2026,
journal = {Research in Astronomy and Astrophysics},
issn = {1674-4527},
doi = {10.1088/1674-4527/ae9042},
url = {http://iopscience.iop.org/article/10.1088/1674-4527/ae9042},
eprint = {2606.25026},
archiveprefix = {arXiv},
primaryclass = {astro-ph.GA},
urldate = {2026-07-26}
}Publications built on this code base:
- Meng, R. & Dong, X. 2026, Wave Cold Dark Matter Can Reproduce the Radial Acceleration Relation in X-ray Elliptical Galaxies, Research in Astronomy and Astrophysics — journal article · arXiv:2610.18969 · DOI 10.1088/1674-4527/aeac08
@article{meng2026wavecold,
title = {Wave {{Cold Dark Matter Can Reproduce}} the {{Radial Acceleration Relation}} in {{X}}-Ray {{Elliptical Galaxies}}},
author = {Meng, Runyu and Dong, Xiaobo},
year = 2026,
journal = {Research in Astronomy and Astrophysics},
issn = {1674-4527},
doi = {10.1088/1674-4527/aeac08},
url = {http://iopscience.iop.org/article/10.1088/1674-4527/aeac08},
eprint = {2610.18969},
archiveprefix = {arXiv},
primaryclass = {astro-ph.GA},
urldate = {2026-09-24}
}Manual Outline
- Basic
- Tutorial: MOND and QUMOND
- Tutorial: pseudo-Newtonian potentials
- DirectSum gravity solver
- Tree gravity solver
- FFT Poisson solver
- FDM Poisson solver
- ML Poisson solver (experimental)
- Types
- Methods
Contributing and citing
Issues and pull requests are always welcome — see Contributing for guidelines. If you use AstroNbodySim.jl in research, please cite the package via CITATION.bib; the same BibTeX entries are also bundled in these docs on the Citing page.