1. Introduction
Dark matter (DM) is one of the main components of our universe and has played a central role in the structure formation. However, its physical nature is still unknown and has sparked intense investigation in both astrophysical and astronomical research. The inquiry dates back to 1933, when Zwicky [
1] applied the virial theorem to estimate the mass of the Coma Cluster and determined that the velocity dispersion of its galaxies was too high to be sustained by luminous matter alone. Since then, a substantial body of observational evidence [
2,
3,
4,
5] supporting the existence of DM has continued to accumulate. Nevertheless, despite extensive efforts through direct [
6,
7,
8,
9], indirect [
10,
11], and collider-based detection experiments [
12], DM has not been directly detected yet, and its fundamental nature remains elusive and warrants further explorations.
As a novel form of cosmic messenger, gravitational waves (GWs) have recently garnered attention as a potential means of probing DM. Several studies have pointed out the possibility of utilizing GWs for DM detection [
13,
14,
15,
16,
17]. In particular, future space-based gravitational-wave (GW) interferometers [
18,
19,
20,
21] are expected to access the mid-to-low frequency GW band. By observing GW sources over timescales of several years, it may become feasible to detect the phase of GW signals from black holes influenced by environmental effects. Such long-duration observations would furthermore enable detailed studies of the black hole environment through precise analysis of GW signals.
Extreme-mass-ratio inspirals (EMRIs), binary systems comprising a low-mass compact object orbiting a supermassive black hole (SMBH) at a galactic center, constitute one of the primary sources of GW signals. EMRIs provide a valuable window into the dynamical environment of galactic nuclear regions and represent a key target for future GW observations [
22]. Furthermore, compared to comparable-mass binary systems, EMRIs spend significantly longer evolution times within the frequency band of space-based detectors. This extended duration allows environmental perturbations to accumulate measurable imprints in the GW waveform. In addition, the secondary object in an EMRI exerts minimal gravitational influence on the central SMBH’s environment, thereby enabling clearer probes of the environmental properties surrounding the primary black hole.
To probe the properties of DM using GWs, it is essential to understand the distribution of DM around black holes. This knowledge serves as the foundation for constructing accurate theoretical models and generating predictions for GW signals. Various models have historically been developed to describe the distribution of DM halos in galaxies. Commonly adopted profiles include the power-law distribution, the Einasto profile [
23], the Hernquist model [
24], and the Navarro–Frenk–White (NFW) model [
25,
26]. Gondolo and Silk [
27] pioneered a classical Newtonian approach to account for the influence of a central black hole on the DM halo distribution. They derived the redistributed profile of cold DM around a SMBH under a given initial halo model, and coined the term “spike” to describe the steep, post-accretion density peak—distinguishing it from the gentler “cusp” typical of initial halo profiles. Subsequently, Will et al. extended the Newtonian formalism by incorporating relativistic corrections for the DM spike distribution around Schwarzschild and Kerr black holes [
28,
29]. DM spikes have significant effects on indirect detection experiments [
30,
31,
32,
33,
34] and stellar orbits in galactic nuclei [
35,
36,
37].
By considering dynamical friction (DF) within DM spikes [
38], several works proposed using GW signals to probe DM [
15,
39,
40]. It is realized that, unlike gamma-ray observations reliant on annihilation, GWs are sensitive only to the gravitational influence of the DM, thus offering a novel and powerful probe of its distribution. Further extending this line of inquiry, several authors [
41,
42,
43,
44] incorporated the velocity distribution of DM particles, investigating its effect on the orbital eccentricity of binary systems and the corresponding GW waveforms.
The consensus is that cold DM can form a pronounced density spike around a central black hole [
45], with the DF caused by such a DM spike being widely regarded as an important environmental effect. The primary objective of this paper is to develop a computational code capable of calculating both the density and velocity distributions of the DM spike, given initial parameters of the black hole and the DM halo. This tool aims to bridge subsequent GW modeling efforts, thereby facilitating the use of EMRI GW signals to probe the properties of DM surrounding black holes.
This paper is structured as follows. In
Section 2, we provide a detailed introduction to the theoretical framework for calculating the density and velocity distributions of DM around black holes, which is fundamental to understanding our computational approach.
Section 3 presents the core structure and functionalities of the code. In
Section 4, we demonstrate two practical examples of code implementation for calculating DM distribution properties, with step-by-step instructions to facilitate reproducibility. Furthermore, we incorporate the obtained DM density and velocity profiles into GW calculations and provide a preliminary discussion on the influence of DM DF on GW signals. Finally,
Section 5 concludes and summarizes our work.
2. Theoretical Framework
This section provides a brief introduction to the theoretical formalism used to compute the spike distribution properties of DM around a Schwarzschild black hole. The presentation here has been extensively employed in our previous works [
43,
44]. The purpose of this section is to systematically organize the calculation procedure, with the goal of offering a clear and self-contained exposition that elucidates the computational methodology implemented in our code.
2.1. Density Distribution
To characterize the DM spike structure surrounding the black hole, we begin by computing its density distribution. The calculation is initiated from the relativistic mass flow formula:
where
p is the four-momentum,
is the four-velocity,
is the rest mass,
g is the determinant of the metric tensor
and
is the four-momentum volume element. The distribution function
of DM is normalized,
.
We first consider the case of a Schwarzschild black hole with the following metric:
and list the corresponding four constants of motion admitted by timelike geodesics:
where
is the energy per unit mass,
is the angular momentum per unit mass, and
is the square of the conserved total angular momentum per unit mass. Assuming all DM particles in the system share the identical rest mass
, the mass distribution then takes the form of a
-function. Consequently, the distribution function can be simplified to
. The integral over the element
can be carried out. For the sake of simplicity in subsequent discussions, we omit the subscript. When considering the ± signs of
, we observe that only the
t-components of
remain non-vanishing in the Schwarzschild case. Owing to the spherical symmetry of the Schwarzschild metric, we set
to further simplify the calculation. After the Jacobian transformation and simplification, the non-zero component of the mass current four-vector is
where the effective potential is
and the density of the DM spike is
.
The expression for the mass flow given in Equation (
4) corresponds to the form implemented in our code. In the following, we will incrementally introduce the relevant analytical expressions and numerical procedures required to construct the complete mass flow model used in our computations.
2.2. Boundary Conditions
Equation (
4) requires calculation via numerical integration. Before substituting specific models into the integrand, we can first determine the integration boundaries based on physical conditions. Next, we will introduce the integration limit selection method in the integration formula in Equation (
4).
Assuming that only DM particles in bound orbits contribute to the spike density, we refer to the black hole capture conditions in [
29], with
and
Here,
Since the integral in Equation (
4) cannot be solved analytically, we can introduce the following transformation to restrict the integration region to the three-dimensional domain
for the convenience of subsequent numerical computations [
29].
It allows the step size of the numerical integration to be fixed and thus facilitates our integration implementation. Setting
and
in
, we obtain
. For critical orbits,
and
in an unstable orbit
. Meanwhile,
has a double root. These imply that we should solve a system of four polynomial equations of
,
2.3. Distribution Function
After determining the limit of integration, we should specify the distribution function in Equation (
4). Since we consider the adiabatic growth of the DM halo, the distribution function is invariant in form under adiabatic evolution, namely,
. During the growth, the energy
E and angular momenta
L and
of each DM particle evolve, whereas the adiabatic invariants
,
, and
remain constant. For an orbit in the initial non-relativistic DM distribution, these are
For a bound orbit in the Schwarzschild geometry,
Matching , and , we obtain , and , so we can get .
The specific expression of the adiabatic invariant depends on the black hole scenario we consider and the corresponding initial distribution form of DM. Below, we will combine the case of a Schwarzschild black hole to present the calculation expressions corresponding to the two initial distribution forms of DM applied in our code.
2.4. Velocity Distribution
Beyond determining the density distribution of DM, it is also essential to compute its velocity distribution. It is important to note that during the calculation of the DM density profile, the integration is carried out via a point-sampling method. Consequently, the dynamical properties of DM particles accreted into a spike configuration have already been evaluated. Substituting these results into the geodesic equations yields the corresponding velocity values. By integrating over the velocities of all DM particles, the desired velocity distribution of the DM component is obtained.
According to the geodesic equation in the Schwarzschild geometry,
where
, the four-velocity is written as
, where
and
, and where
,
,
.
The isotropic velocity distribution of DM in three-dimensional velocity phase space is parameterized via a normalized variable that accounts for radius-dependent escape velocities. To this end, we introduce the normalized velocity , where denotes the physical speed of an individual DM particle, and represents the escape velocity of circular orbits at radius r, i.e., the maximum speed permitting a particle to remain gravitationally bound to the central black hole. This normalization eliminates the radial dependence of escape velocities, ensuring consistency in velocity distribution analyses across different radial distances.
With this normalized velocity as a basis, we first compute
, defined as the density of DM particles at radius
r with normalized velocity
. This quantity is derived by integrating the phase-space distribution function
—which quantifies mass per unit phase-space volume—over all velocities up to
. The
term in the integral encapsulates the spherical symmetry of velocity phase space, a direct consequence of the isotropic nature of DM (where motion is equally probable in all directions):
Differentiating
with respect to
isolates the density of particles within the infinitesimal velocity interval
. Normalizing this differential density by the total DM density
—the density of all bound DM particles at radius
r, corresponding to
—yields the velocity distribution function. This function describes the fraction of DM particles at radius
r with normalized velocity in the interval
:
2.5. Hernquist Profile
Previously, we have introduced the calculation of the integration limits and the terms related to the integrand in the mass flow expression. Currently, the only undetermined element in the expression is the formula for the initial DM distribution function. Since different initial DM distributions correspond to different distribution function expressions and there is no completely universal formula that can be applied, our code selects two commonly used initial distributions, the Hernquist distribution and the power-law distribution, and provides the corresponding expressions for the adiabatic invariants and the distribution functions used in practical calculations based on these. It should be noted that the calculation formulas for these two forms have been presented in previous studies; we have merely further organized and applied them in our code.
Hernquist profile [
24] has the density function of
with Newtonian gravitational potential
Here,
and
are scale factors related to the total dark matter mass in the halo via
. The ergodic distribution function corresponding to the Hernquist profile admits an analytical expression:
with
The primary numerical challenge associated with this distribution therefore reduces to the evaluation of the radial action. Substituting Equation (
15) into Equation (
9), the radial action for the Hernquist potential can be expressed as
For the Schwarzschild black hole metric, an analogous substitution of the metric into Equation (
10) leads to the corresponding expression for the radial action:
where we adopt the following dimensionless quantities:
2.6. Power-Law Profile
Similarly, we can take the initial DM halo distribution as a single power-law distribution. The power-law profile has the density function of
In contrast to the Hernquist profile, analytical expressions for the ergodic distribution function and radial action are not available. Nevertheless, numerically derived fitting formulae have been established in [
27]; we directly adopt these reference results as follows:
where
is Gamma function,
B is Beta function,
and
. Then, we can use the above expressions to calculate the spike that grows from a power-law dark halo.
2.7. DM Halo Parameters
Once the initial distribution curve of DM is selected, it is necessary to clarify the source of definitions for the parameters in the initial distribution function. For instance, regarding the two parameters
and
in the Hernquist initial distribution (
14), while we can directly define them numerically, which is permitted in our code, we also have an alternative definition method: we can correlate the initial parameters of the DM halo with the mass of the central black hole, and calculate the former through the latter [
46,
47,
48,
49]. The black hole mass
M and the parameters of the initial dark halo (
) are related by the mass–velocity–dispersion relation, namely the one-dimensional velocity dispersion of halo and the virial mass relations:
where
is the one-dimensional velocity dispersion of the halo,
is the virial mass,
is the virial radius,
is the characteristic distance ratio,
is the mass integral function of the halo,
the distance which maximizes the circular velocity
,
is the critical density, and
is the Hubble constant at redshift
. Here, we take
, which is the mass function of the Hernquist profile, and accordingly
. The concentration relation of the virial distance ratio
is given by the following [
50]:
where
is the dimensionless Hubble parameter at redshift
and
. This relation is an empirical polynomial fit describing the DM halo concentration parameter
as a function of virial mass
. It parametrizes the scaling of
c—a key metric for a halo’s density profile steepness, defined as
where
is the virial radius and
the scale radius—with
. This parametrization is critical for specifying parameters of the initial DM halo density profile in our work, which serves as the foundational input for calculating the relativistic DM spike around the central black hole. This ensures consistency with cosmic structure formation predictions within the
CDM paradigm. Then, for a given black hole mass, we can obtain the parameters (
) of the dark halo.
3. Package Overview
Having introduced the underlying theoretical framework, this section proceeds to detail the architecture and configurable parameters of our code. Implemented in Python, the code is organized into eleven distinct modules. The functionality of each module is described in detail below, while
Figure 1 illustrates the dependencies and calling relationships among them.
The params module serves as the central parameter configuration unit. All system parameters defined in the main program are passed to this module, which subsequently distributes them to other computational modules. For detailed parameter definitions and usage, please refer to the core function of the params module in Listing 1.
| Listing 1. Core function of the params module for system parameter configuration. |
![Universe 11 00411 i001a Universe 11 00411 i001a]()
![Universe 11 00411 i001b Universe 11 00411 i001b]() |
The dm_init module, as shown in Listing 2, computes the parameters of the initial DM halo distribution based on the central black hole parameters provided in params. This module is optional, as the code supports two methods for defining the DM halo. The halo mass and scale radius (mhalo and r0) can be set directly in params. Alternatively, if these are not specified, the functions within dm_init can be called to derive them from the central black hole mass using a velocity dispersion relation.
| Listing 2. Function of the dm_init module for calculating initial dark matter halo parameters. |
![Universe 11 00411 i002 Universe 11 00411 i002]() |
The distance module determines the spatial sampling for the calculation by defining the minimum radius of DM particles and the radial grid points at which the density and velocity are evaluated.
As shown in Listing 3, the variable r_cutoff is implemented as an interpolation function. Within this module, a series of minimum orbital radii have been precomputed as functions of the black hole spin and the orbital inclination angle of the DM. For subsequent calculations, this interpolation function can be called directly to obtain the minimum radius for a given set of parameters. It is important to note that this procedure applies to the Kerr black hole scenario. For the Schwarzschild case, the minimum radius is simply set to the innermost stable circular orbit at .
| Listing 3. Functions of the distance module for radial grid generation and minimum radius interpolation. |
![Universe 11 00411 i003a Universe 11 00411 i003a]() ![Universe 11 00411 i003b Universe 11 00411 i003b]() |
The array of radial points used in the computation is constructed starting from this minimum radius. Since the method involves calculating DM density values at discrete radial points and then interpolating to obtain a continuous distribution, the selection of these points is critical. The returned variable r is a one-dimensional array containing these radial sample points. To enhance computational efficiency, this array can be partitioned for parallel processing in subsequent steps.
Notably, the radial points are sampled non-uniformly: a finer step size is used closer to the black hole, yielding a higher density of points, while a coarser sampling is adopted at larger radii. All these sampling parameters are user-configurable based on specific accuracy and performance requirements.
The metric module encapsulates the spacetime metric and associated expressions used in our calculations, including the individual metric components and auxiliary functions introduced to simplify the formalism. Since these metric-related functions are not directly invoked by the main computational workflow, they will not be discussed in further detail here. Interested readers may examine the corresponding source code for a complete implementation.
The velocity modulein Listing 4 defines the velocity component functions for DM particles. As seen in the function definitions, the magnitudes of individual velocity components as well as the resultant total velocity are each recorded.
| Listing 4. Function of the velocity module for calculating dark matter particle velocity components. |
![Universe 11 00411 i004 Universe 11 00411 i004]() |
The
boundary module implements the computation of integration limits in the expression of the mass flow following the Jacobi transformation in Equation (
4). It provides a function that calculates these integration boundaries, which is designed to be called directly by other modules in the package.
The function for solving the integral limits is defined in the initial part of this module, where a set of limits corresponding to various parameter values is precomputed. As illustrated in Listing 5, these precomputed values are used to construct an interpolation function, which is returned as the final implementation of the integral limit function. In subsequent computational steps, this interpolation function can be called directly to obtain the required integration limits.
| Listing 5. Functions of the boundary module for interpolation of integral limits. |
![Universe 11 00411 i005 Universe 11 00411 i005]() |
The invars_funcs module specifies the integration variables and auxiliary component functions appearing in the mass flow expression. It incorporates the integration limit function from the boundary module to supply the required boundary values for numerical evaluation. Several internal functions responsible for remapping integration variables are not directly invoked by the main workflow and are therefore omitted from this documentation.
The
hernquist module implements the initial DM halo model based on the adiabatic invariant formulation corresponding to the Hernquist profile in
Section 2.5. It provides the expression of the specific distribution function utilized in the calculation of the mass flow in Equation (
4).
As these auxiliary functions in Listing 6 are not invoked by the main calculation and are stable, they are not detailed here but are available for inspection.
| Listing 6. Functions of the hernquist module for adiabatic invariants and distribution function. |
![Universe 11 00411 i006a Universe 11 00411 i006a]() ![Universe 11 00411 i006b Universe 11 00411 i006b]() |
The
power_law module, analogous to the
hernquist module, implements the initial DM halo model using a single power-law distribution within the adiabatic invariant framework in
Section 2.6. It supplies the corresponding distribution function expression for evaluation within the mass flow formalism in Equation (
4).
The dm_distr module performs the core numerical computation. It implements a manual point-sampling procedure across different radial distances, applying the mirror-effective potential and angular-effective potential criteria to identify bound-orbit DM particles. The module subsequently calls functions from other modules to compute the corresponding density values at these validated positions.
The dm_distr module, as described in Listing 7, outputs the integrand values for the mass flow expression rather than the final DM density values. To derive the DM density profile, numerical integration of these outputs is required, a step implemented by the data_analyse module. This module generates DM density and velocity values at discrete radial points, and includes visualization examples that correspond to the DM figures presented in this paper.
| Listing 7. Core function of the dm_distr module for dark matter density and velocity calculation. |
![Universe 11 00411 i007 Universe 11 00411 i007]() |
Computational efficiency is enhanced via the implementation of task-level multi-process parallelism, which is realized by directly invoking the core computation function dm_rho_vel through Python’s built-in multiprocessing module. The key implementation steps are detailed as follows: first, the radial grid point array—used for evaluating DM density and particle velocities—is partitioned into non-overlapping subarrays using numpy.array_split, to facilitate task distribution across multiple processes; second, a process pool (multiprocessing.Pool) is initialized to allocate these subarrays to distinct CPU cores; finally, each CPU core executes dm_rho_vel in parallel, computing the DM density and particle velocities for its assigned subset of radial points. This parallelization scheme exploits multi-core hardware resources to enable simultaneous processing of independent radial grid point subsets, thereby shortening the overall computation time. The code snippet in Listing 8 illustrates the core workflow of this calculation:
| Listing 8. Core computational workflow with multiprocessing parallelization. |
![Universe 11 00411 i008 Universe 11 00411 i008]() |
4. Application
In this section, we use two DM profile examples to demonstrate the functionality of the code. We present the distribution characteristics of DM spikes at the center of the Milky Way black hole—using Hernquist and the single power-law profiles as the distribution functions of the initial dark halo, and using the distribution characteristics of DM to plot the GW waveforms corresponding to the extreme mass ratios close to binary stars.
We consider a black hole with a mass similar to M87, i.e., . Since we are considering the Schwarzschild case, and the DM distribution inclination angle is , corresponding to the DM distribution in the equatorial plane (the inclination has no effect in the Schwarzschild case). By invoking the rho_DM package, the initial distribution parameters for both the Hernquist profile and the single power-law profile can be computed from the black hole mass. Using the distance package, we define the radial range from to . By calling the dm_distr package and processing the results with the data_analyse module, we obtain the corresponding density and velocity distributions of DM. For computational efficiency, we employ multiprocessing parallel computing, where the dm_distr function is invoked in parallel. The specific example code can be found in example_test.ipynb.
The results of the density distribution are shown in
Figure 2. The blue dashed curve and red solid curve correspond to the post-accretion spike structures derived from the initial single power-law profile and the Hernquist profile, respectively. As we can see, both curves exhibit a typical spike feature in the logarithmic coordinate system, which is consistent with our expectations.
The density of DM up to a velocity
v,
, and the velocity distributions of the DM particles,
, at different locations around the black hole are shown in
Figure 3. The different curves in the figure correspond to the distributions in different
r. Under the black hole mass considered of
, the corresponding total dark matter halo mass is
, yielding a mass ratio of
. According to the distant weak-field Newtonian analysis presented in [
51], for this mass ratio and an initial Hernquist profile, the distribution function in the presence of a central black hole should exhibit minimal deviation from the black hole-free case, as indicated by Equation (
16).
Figure 3 displays the velocity distribution for an initial single power-law profile. Similarly, the velocity distribution curve can be plotted for dark matter particles with an initial Hernquist profile. Based on the definition of energy per unit mass
in Equation (
3) and the velocity definition in
Section 2.4, the velocity can be expressed in terms of
as
, where
. Applying the Jacobi transformation to the dark matter particle velocity distribution
to
, we can confirm that the distribution function at large distances aligns with the distant weak-field approximation. The impact of the central black hole on the distribution function is primarily concentrated in its immediate vicinity, consistent with conclusions regarding the central black hole’s influence on the dark matter halo density distribution.
Next, we can use the obtained DM halo density and velocity distributions, incorporate the DF of DM in the dynamics of EMRI evolution and calculate the corresponding GW waveform. We consider the secondary object in an EMRI binary both in vacuum and embedded the DM spike around the central primary black hole. We numerically evolve the orbital kinematic quantities of the secondary object using the geodesic Equation (
11). However, considering the extremely high mass of the M87-like black hole, adopted in the preceding example, the evolution time of the corresponding EMRI system is prohibitively long—this property is suboptimal for illustrating the computational efficiency and practical applicability of our framework. We thus select instead a canonical EMRI system with mass parameters
, which aligns with the typical parameter range of EMRIs targeted by future space-based gravitational-wave detectors. For this canonical system, we recompute the dark matter density and velocity distributions around the central SMBH, where
, and further incorporate these updated distribution data into the subsequent gravitational-wave calculation, thereby ensuring the results better represent realistic observational scenarios.
The influences of the DF of DM spike on the evolution of energy
E, angular momentum
L, and GW radiation
Q are given by
The DF effect can be written as [
41]
where
, and
. The density term
in the DF formula is given by interpolation of DM density and velocity output by our code. The gravitational radiation term is given by the post-Newtonian formalism. We take the 3PN term into account [
52]:
where
,
are post-Newton’s formulas.
Subsequently, we can obtain all the temporal kinematic quantities of EMRI system through numerical evolution, and the corresponding GW waveform in time domain can be obtained by substituting the quadrupole–octupole formula [
53]:
where an overdot denotes a time-derivative,
d is the distance from the source to detector, and
are the components of direction vector
, specified by the azimuth
and latitude
of the source in the sky. And the multipole moments are
Herein, we neglect time-dependent mass growth of both the central black hole and the secondary black hole in the EMRI system. This neglect is supported by results from [
54], which demonstrate that the effects induced by such black hole mass growth are negligible for orbital dynamics calculations and GW waveform modeling—specifically, these mass changes do not introduce measurable perturbations to orbital parameters or the evolution of the GW phase.
Figure 4 illustrates the impact of DM-induced DF on the GW waveforms of EMRIs. A key observation from the figure is that the waveform incorporating DM-induced DF exhibits a phase deviation relative to the DF-free counterpart. This phase discrepancy does not remain constant but accumulates gradually as the inspiral progresses, becoming increasingly pronounced in the late evolutionary stage. While we cannot directly observe the rate of this phase deviation accumulation from the waveform itself, we can anticipate that this accumulation rate inevitably slows as the inspiral advances—this is because the DM density drops sharply as the secondary black hole approaches the central SMBH, and the strength of DM-induced DF is closely dependent on the local DM density, leading to a reduced rate of additional phase accumulation in later stages. The amplified views of critical inspiral phases further confirm that the deviation is not a localized artifact but a systematic shift driven by DM-DF effects, which modulates the inspiral trajectory and thus the gravitational-wave phase evolution. This result highlights the non-negligible role of DM spikes in shaping EMRI gravitational-wave signals, providing a potential avenue for constraining DM halo properties through future gravitational-wave detections.