Welcome to NSphere’s Documentation!

Overview

NSphere simulates the evolution of spherical self-gravitating systems, primarily targeting collisionless dark matter halos in astrophysics. It leverages the inherent spherical symmetry to simplify the complex 𝑁-body problem. By reducing the six-dimensional phase space (position and velocity) to three dimensions (radius r, radial velocity 𝑣ᵣ, and angular momentum or velocity angle), the computational cost is significantly lowered. The core principle is self-consistency: the gravitational potential is generated by the mass distribution of all particles, and particles orbit within that potential. In equilibrium, such systems, described by a phase-space Distribution Function (DF) often dependent on energy (ε) and angular momentum (), are generally stable. NSphere provides a tool to efficiently explore how these systems evolve when perturbed or subjected to new physical processes (e.g., dark matter interactions, central black hole growth, external tidal forces) where analytical solutions are intractable.

Numerical Implementation

The simulation evolves a system of 𝑁 particles, often representing concentric mass shells. The algorithm proceeds in discrete time steps. At each step: 1. Sorting: Particles are efficiently sorted by their radial coordinate r. This allows for rapid calculation of the mass enclosed within any radius, M(r), which determines the gravitational force. The implementation utilizes optimized sorting algorithms like Quadsort, achieving nearly 𝑁 log 𝑁 or even linear scaling for the nearly-ordered data typical between steps. 2. Force Calculation: The gravitational force on each particle is calculated based solely on the mass M(r) enclosed within its current radius (Newton’s Shell Theorem). Centrifugal force due to angular momentum (ℓ²/r³) is added. 3. Integration: Particle states (radius r and radial velocity 𝑣ᵣ) are updated using a numerical integrator. NSphere employs adaptive leapfrog methods, automatically refining the time step for accuracy. For orbits with very low angular momentum approaching the center (r -> 0), where standard integration becomes stiff, a Levi-Civita coordinate transformation (ϱ = √(r)) and fictitious time ( = dt/r) are used to regularize the equations of motion and improved stability and accuracy.

This approach significantly reduces computational cost compared to traditional 𝑁² 𝑁-body methods and mitigates issues like two-body relaxation effects, making it suitable for high-precision studies of spherical systems on standard hardware.

(For more technical details, see the sections below)

Indices and tables