Rapster
Rapid population synthesis code for binary black hole mergers in dynamical environments.
Install / Use
/learn @Kkritos/RapsterREADME
Rapster
Rapid population synthesis code for compact binary coalescences in dense stellar clusters.
$\tt Rapster$ stands for $\rm RAPid\ cluSTER$ evolution. (Thanks to Mark Cheung for coming up with the short-hand version!)
Author: Konstantinos Kritos kkritos1@jhu.edu
Version: March 18, 2026. (Thanks to Tousif Islam for helping modularize this repository!)
(Thanks to Hector Cruz for digitizing my hand-drawn logo!)
Contents:
- Overview
- Requirements
- Units
- Input parameters
- Running a simulation
- Output files
- Applications of the code
- Citing this work
- Reporting bugs
- Thank you
<a name="overview"></a>
1. Overview
The repository provides the source code files for the current version in rapster/ and all necessary data files in the Data/ folder, for the rapid evolution of dense star cluster environments and the dynamical assembly of compact-object coalescences and tidal disruption events.
The modeling accounts for the necessary physical processes for forming compact-object binaries and cluster evolution employing semi-analytic prescriptions described in Sec. 2 of K. Kritos et al. PRD (2024). This is our code paper, which we wrote together with Vladirim Strokov, Vishal Baibhav, and Emanuele Berti.
Note:
For computational efficiency, the folder Data/MzamsMrem/ contains 12 files with pre-calculated look-up tables of stellar remnants masses on a grid of zero-age main sequence values up to $340M_\odot$ and 12 values of absolute metallicity in the range from $10^{-4}$ to $1.7\times10^{-2}$ as calculated with the $\tt SEVN$ code M. Spera & M. Mapelli (2017).
In the current version, we have also included look-up tables for the Mandel-Muller and Fryer et al. (2012) delayed and rapid remnant-mass prescription models in files Mueller_Mandel.txt, MzamsMrem_F12d.txt, and MzamsMrem_F12r.txt, respectively.
Moreover, Data/Planck18_lookup_table.npz is a look-up table for the redshift-lookback time and lookback time-redshift relations assuming the Planck 2018 cosmology.
Finally, Data/x_mb_vec.pkl is a precomputed look-up table generated by Data/.marginally_bound.py for the marginally bound radius normalized to the gravitational radius in the dimensionless spin-inclination parameter space grid.
Abbreviations:
- BH: black hole
- NS: neutron star
- WD: white dwarf
- BBH: binary black hole
- CBC: compact binary coalescence
- GW: gravitational wave
- TDE: tidal disruption event
<a name="requirements"></a>
2. Requirements
The following Python packages are required to run the code:
- $\tt numpy$ (=2.2.4)
- $\tt scipy$ (=1.15.2)
- $\tt pandas$ (=2.2.3)
The code is tested with packages in the versions shown in parentheses above; however, likely, other versions work too.
It is recommended that the user create and work in a local Python environment, installing all the dependencies above.
The following packages are recommended for running the tutorial notebook in Examples/, but are not necessary to run cluster simulations:
- $\tt matplotlib$
- $\tt jupyterlab$
- $\tt ipykernel$
First, create an environment called .rapsterenv in the root directory of the repository Rapster/, and hidden from view:
python3 -m venv .rapsterenv
If you use a different name, please add the environment name as a new row in .gitignore, since the environment folder should never be pushed to the repository.
To activate this environment:
source .rapsterenv/bin/activate
To install rapster and all requirements, run:
pip install -e .
Verify the installation (along with dependencies) and package version:
pip list
Finally, include the virtual environment in the kernel:
python -m ipykernel install --user --name=rapsterenv --display-name "Python (.rapsterenv)"
<a name="units"></a>
3. Units
The current version of the code uses astrophysical units; see, e.g., Heggie & Hut (2003):
- Mass: solar mass ($M_\odot$)
- Distance: parsec ($\rm pc$)
- Time: million years ($\rm Myr$)
- Velocity: $\rm km\ s^{-1}$
- Gravitational constant: $G=1/232$
- Speed of light: $c=3\times10^5$
<a name="inputparameters"></a>
4. Input parameters
The code accepts parameters with flag options.
For a description of all input parameters, run the following command in the command line interface:
python -m rapster.run_cluster --help
For the user’s convenience, we paste the list of optional arguments in the form of a Table here as well:
| Flag | Description | Type | Default |
|:--- |:--- |:--- |:--- |
| -N, --number | Initial number of stars | int | 1000000 |
| -r, --half_mass_radius | Initial half-mass radius [pc] | float | 1 |
| -mm, --minimum_star_mass | Smallest ZAMS mass [Msun] | float | 0.08 |
| -mM, --maximum_star_mass | Largest ZAMS mass [Msun] | float | 150 |
| -Z, --metallicity | Absolute metallicity | float | 0.001 |
| -z, --cluster_formation_redshift | Redshift of cluster formation | float | 3.0 |
| -n, --central_stellar_density | Initial central stellar number density [pc^-3] | float | 5.3e5 |
| -fb, --binary_fraction | Initial binary star fraction | float | 0.1 |
| -S, --seed | Seed number | int | 1234567890 |
| -dtm, --minimum_time_step | Minimum simulation time-step [Myr] | float | 0.1 |
| -dtM, --maximum_time_step | Maximum simulation time-step [Myr] | float | 50.0 |
| -tM, --maximum_time | Maximum simulation time [Myr] | float | 140000.0 |
| -wK, --supernova_kick_parameter | One-dimensional supernova kick parameter [km/s] | float | 265.0 |
| -K, --natal_kick_prescription | Natal kick prescription (0 for fallback, 1 for momentum conservation) | int | 0 |
| -R, --galactocentric_radius | Initial galactocentric radius [pc] | float | 8000.0 |
| -vg, --galactocentric_velocity | Galactocentric circular velocity [km/s] | float | 220.0 |
| -s, --spin_parameter | Natal spin parameter of first generation (1g) BHs | float | 0.0 |
| -SD, --spin_distribution | Natal spin distribution model (0 for uniform, 1 for monochromatic) | int | 0 |
| -P, --print_information | Print runtime information (0 for no, 1 for yes) | int | 1 |
| -Mi, --mergers_file_indicator | Export mergers file (0 for no, 1 for yes) | int | 1 |
| -MF, --mergers_file_name | Name of .txt output file with BBH merger source parameters | str | mergers |
| -Ei, --evolution_file_indicator | Export evolution file (0 for no, 1 for yes) | int | 1 |
| -EF, --evolution_file_name | Name of .txt output file with time-dependent quantities | str | evolution |
| -Hi, --hardening_file_indicator | Export hardening file (0 for no, 1 for yes) | int | 1 |
| -HF, --hardening_file_name | Name of .txt output file with BBH time evolution information | str | hardening |
| -BIi, --blackholes_in_file_indicator | Use external BH file (0 for no, 1 for yes) | int | 0 |
| -BIF, --blackholes_in_file_name | Name of .npz input file with initial BH masses | str | input_BHs.npz |
| -BOi, --blackholes_out_file_indicator | Export BH masses file (0 for no, 1 for yes) | int | 1 |
| -BOF, --blackholes_out_file_name | Name of .npz file with the masses of all BHs in solar masses | str | output_BHs.npz |
| -RP, --remnant_mass_prescription | Remnant mass prescription (0 for SEVN delayed, 1 for Fryer+2012 delayed, 2 for SEVN rapid, 3 for Fryer+2012 rapid) | int | 1 |
| -NS, --with_neutron_stars | Include neutron stars (if =1) else no (if =0) | int | 1 |
| -WT, --with_tdes | Include tdes (if =1) else no (if =0) | int | 1 |
| -Ti, --tdes_file_indicator | Export tdes file (0 for no, 1 for yes) | 1 | 1 |
| -TF, --tdes_file_name | Name of .txt file containing tde parameters | str | tdes |
| -MBH, --massive_black_hole_mass | Mass of the seed massive BH (if >0) | float | 0 |
| -sBH, --massive_black_hole_spin | Spin of the seed massive BH (from 0 to 1) | float | 0 |
| -RF, --results_folder_name | Name of the folder where output files will be exported | str | Results |
Note:
The initial value of the central stellar density is set by default to 5.3e5 (pc^-3), which assumes a Plummer density profile: $n=3(1.3)^3N/(4\pi)\simeq0.53N$, where $N$ is the number of stars and $r=1,\rm pc$. The cluster then evolves homologically, by assumption. Under the Plummer profile, if the input values for the initial number of stars or initial half-mass radius $r$ are updated, then the central density should be set accordingly, $n=0.53 N/r^3$. If the user prefers an alternative density stellar profile, then a different relation may hold between $N$ and $r$.
<a name="runningasimulation"></a>
5. Running a simulation
usage: -m [-h] [-N] [-r] [-mm] [-mM] [-Z] [-z] [-n] [-fb] [-S] [-dtm] [-dtM] [-tM] [-wK] [-K] [-R] [-vg] [-s] [-SD] [-P] [-Mi] [-MF] [-Ei] [-EF] [-Hi] [-HF] [-BIi] [-BIF] [-BOi] [-BOF] [-RP] [-NS] [-WT] [-Ti] [-TF] [-MBH] [-sBH] [-RF]
Testing:
To test the code, execute the program with all defaults:
python -m rapster.run_cluster
from any directory, with the virtual environment (.rapsterenv) enabled.
This should create five files: Results/mergers.txt, Results/evolution.txt, Results/hardening.txt, Results/tdes.txt, and Results/outputBHs.pkl inside the newly created folder Results/ within your current directory. To check and verify whether you have produced these files correctly, we include the corresponding files /Rapster/Example/Results_Test/mergers.txt, /Rapster/Example/Results_Test/evolution.txt, /Rapster/Example/Results_Test/hardening.txt, /Rapster/Example/Results_Test/tdes.txt,
