WorksPhysics and Astronomy
rapidsim: A Python interface and cross-platform distribution framework for the RAPID protoplanetary disc simulation code
Abstract
The rapidsim is a Python package for the RAPID (Representative Approach for Particle-Integrated Disks) numerical simulation code, which is a modular one-dimensional hydrodynamic simulation code for modelling the evolution of protoplanetary discs and embedded dust particles written in C language. The package was developed to provide a simple and platform-independent tool for launching RAPID simulation without having to manually compile the native code and its external dependencies. rapidsim is distributed through the Python Package Index (PyPI) using pre-built binary wheels for Linux and macOS on both Intel and Apple Silicon architectures and for multiple Python versions. To ensure that the most recent package version is always available, an automated continuous-integration and release system synchronizes package versioning with RAPID releases, automatically
Motivation and significance
Scientific software plays a key role in investigating astrophysical phenomena, including star and planet formation and stellar evolution. Numerical simulations in astrophysics are often implemented in languages such as C, C++, and Fortran to meet their computational demands. However, installing and running these codes can require additional technical expertise and dependencies. Users typically need to obtain the source code and its dependencies, configure the build environment, and compile the software before it can be used. This process may require platform-specific libraries, and careful configuration of include and library paths. Furthermore, differences between operating systems and computing environments can further complicate installation.
| Nr. | Code metadata description | Please fill in this column |
| C1 | Current code version | v1.0.15 |
| C2 | Permanent GitHub link to code/repository used for this code version | https://github.com/tnehezd/rapidsim |
| C3 | Permanent link to Reproducible Capsule | https://doi.org/10.5281/zenodo.23185394 |
| C4 | Legal Code License | MIT License |
| C5 | Code versioning system used | git |
| C6 | Software code languages, tools, and services used | Python, C, Make, GitHub Actions, cibuildwheel, PyPI |
| C7 | Compilation requirements, operating environments & dependencies | Python , PyYAML. Pre-built binary wheels are provided for Linux x86_64, macOS Intel, and macOS ARM64. |
| C8 | If available Link to developer documentation/manual | https://rapiddocs.readthedocs.io/en/latest/ |
| C9 | Support email for questions | tarczay [email protected] |
Table 1. Metadata of rapidsim.
These challenges also arise, e.g., in the context of protoplanetary disc simulations, for example in the case of the FARGO and FARGO3D hydrodynamic codes [1, 2], or when investigating stellar evolution by, e.g., MESA [Modules for Experiments in Stellar Astrophysics [3, 4] [5, 6, 7, 8]].
RAPID [9, 10] is a modular C simulation code developed to model the evolution of gas and dust in protoplanetary discs. The native executable of RAPID is constructed to run to computationally intensive one-dimensional hydrodynamic simulations. Although using the source code requires users to download the code from the GitHub repository1, compile it and configure its dependencies in their local environment. In order to simplify this process, rapidsim was developed as a Python package providing a higher-level interface to run RAPID. It includes the RAPID executable in the package, allowing users to install and run simulations through the standard Python package manager without manually compiling the C source code.
Another important aspect of rapidsim is the management of software versions and distributions. Each release is linked to a specific version of RAPID, and binary distributions are built automatically for supported operating systems and Python versions. This approach simplifies installation and ensures that the distributed package contains the intended version of the simulation code.
Software description
Software architecture
The rapidsim package consists of a Python wrapper and the compiled RAPID simulation executable. The numerical calculations are performed by the native simulation engine, while the Python wrapper provides the interface between the user and the executable. The wrapper is implemented in Python and uses standard libraries for command-line argument parsing, file and path handling, subprocess management, and version reporting, together with PyYAML [11] for reading the simulation configuration.
The wrapper organizes the simulation process into several steps. First, it reads the YAML [11] configuration file and extracts the parameters specified in its sections. These sections cover the simulation setup, disk properties, boundary conditions, dead-zone parameters, dust properties, output settings, time integration, and logging. A parameter-mapping layer translates the configuration keys into the corresponding parameter names and command-line flags accepted by the RAPID executable. Boolean values are converted into numerical flags where required by the native interface, while logging settings determine the verbosity of the simulation output and whether terminal panels are disabled. This allows the simulation to be configured through a structured YAML file rather than by manually constructing a long command-line invocation.
Before launching the simulation, the wrapper searches for the executable in a predefined sequence of locations, including the binary bundled with the installed Python package and locations used in local development. It then constructs the command from the mapped parameters and launches the executable as a subprocess.
The RAPID simulation code supports parallel execution using OpenMP. To configure the number of threads used during a simulation, rapidsim reads the omp_num_threads parameter from the YAML configuration file and sets the OMP_NUM_THREADS environment variable accordingly before launching the executable. If this parameter is not specified, the wrapper preserves the existing environment setting, defaulting to a single thread if no value is defined.
This allows users to control the degree of parallelism through the configuration file without having to set environment variables manually. rapidsim also handles user interruption and terminates the subprocess when the simulation is cancelled.
The Python wrapper and the native simulation engine are maintained in separate GitHub repositories. The RAPID repository contains the numerical implementation and its native make-based build system, whereas the rapidsim repository contains the wrapper, packaging metadata, and release infrastructure. The repositories are linked through a Git submodule, with the RAPID source tree included in rapidsim. This arrangement keeps the development of the numerical code separate from that of the Python interface while allowing a specific version of the simulation engine to be associated with each package release. When a new RAPID release is published, the automated release workflow builds a corresponding rapidsim package containing the source code of that RAPID release. The native executable is compiled using the RAPID build system and copied into the Python package’s data directory. It is then distributed in the platform-specific binary wheel together with the Python wrapper. Consequently, users can install and run the package without obtaining or compiling the RAPID source code themselves, provided that a compatible pre-built wheel is available for their platform and Python version.
Software functionalities
The rapidsim wrapper simplifies the configuration and execution of RAPID by allowing users to specify simulation parameters in a YAML configuration file instead of providing them individually as command-line arguments. The configuration file uses a nested structure, grouping related parameters into sections covering the simulation setup, disk properties, boundary conditions, dead zone, dust, output, time integration, and logging. Figure A.4 shows an example configuration file illustrating this structure. A complete description of the available parameters and their accepted values is provided in the official online documentation.2
The wrapper provides the following functionalities:
Argument translation. Configuration parameters are translated into the corresponding command-line arguments expected by the native executable. Boolean options are converted to the numerical flags required by the simulation engine, while logging settings are mapped to the appropriate verbosity switches.
Executable resolution. The wrapper first searches for the executable bundled with the installed package. If it is not found, it falls back to checking
bin/simulationrelative to the package and the current working directory, allowing a locally built version of RAPID to be used during development.
Process control. The simulation is launched as a subprocess, with its output streamed to the terminal in real time. The number of OpenMP threads is set according to the configuration, and the wrapper reports the process exit status. Pressing Ctrl+C interrupts the simulation.
Version reporting. The
--versionoption displays the installedrapidsimpackage version.
Precompiled native executables are distributed through platform-specific Python wheels. The release infrastructure builds wheels for Linux (x86_{64}) and macOS, supporting both Intel and Apple Silicon processors and multiple CPython versions. This enables package installers to select a compatible distribution for the user’s platform and Python environment.
Automated build and release system
Binary distribution is automated using GitHub Actions and cibuildwheel. Publishing a new RAPID release triggers the rapidsim release workflow, which proceeds through the following steps:
It identifies the new and previous RAPID release tags.
It computes the next
rapidsimversion. The versioning ofrapidsimis independent of that of RAPID, but follows its changes: an increase in the RAPID major version increments therapidsimmajor version and resets the minor and patch numbers; an increase in the minor version increments therapidsimminor version and resets the patch number; any other release increments the patch number.It checks out the corresponding RAPID release, compiles the native executable, and builds the platform-specific wheels.
It verifies the contents of the generated packages and stores the distributions as release artifacts.
After all target platforms have been built successfully, it commits the updated submodule reference and version metadata to the repository and publishes the wheels to PyPI.
This automation removes manual steps from the release process. Each published package is built from a specific revision of the RAPID source tree, and the resulting binary distributions are generated and published through a common workflow. Figure 1 presents a flowchart of the automated publish process of rapidsim.

Figure 1. Flowchart of the GitHub actions automation of publishing rapidsim upon new RAPID version release.
Illustrative examples
Installing rapidsim
The rapidsim package requires at least a Python 3.9 environment. It can be installed using the standard Python package manager:
> pip install rapidsim
The project is hosted on GitHub as an open-source code, for development mode, the package can also be cloned as:
git clone https://github.com/tnehezd/rapidsim.git
The package can then be installed in editable mode, allowing modifications to the Python wrapper. Such modifications can be used to customize the configuration handling or execution workflow. Adding new simulation parameters or command-line switches, however, requires corresponding changes to the native RAPID code.
The package also supports installation on heterogeneous systems: pip automatically selects the appropriate binary wheel for the host platform and Python version. This was tested on Intel-based macOS and Linux systems, including a Linux environment running Python 3.13, demonstrating that the package can be installed and executed outside its original development environment.
Running rapidsim
After installation, a simulation can be launched using the rapidsim command-line interface together with a RAPID configuration file:
rapidsim --config path/to/config.yaml
The configuration file should follow a structured format. Figure A.4 shows an example of a typical configuration file for a simple, pure gas disk. A more detailed description of the available configuration parameters and their accepted values can be found in the package documentation and in the defaults directory of the package’s GitHub repository.
Figure 2 present a typical initialization output on the terminal for a pure gas evolving disk. When enabled, an update panel shows the current status of the simulation (see Figure 3). Upon successful completion, rapidsim reports the end of the simulation. The output files are saved in the user-specified format (HDF5 or ASCII) in the designated output directory. If the default output directory already exists, an incremented four-digit suffix (starting from 0000) is appended to avoid overwriting previous results. The output directory contains the initial-condition files for the disk and dust, while the snapshots are stored in the LOGS directory or a user-defined alternative. Additional log files, including performance logs, are also saved in the output directory.

Figure 2. Typical initialization terminal output of the RAPID simulation core for a pure gas accreting model.The [PY-WRAPPER: RAPIDSIM] label indicates that the simulation is launched via rapidsim.

=========================================================================
|| STARTING MAIN SIMULATION LOOP... ||
=========================================================================
[SAVE AT STEP: 1] Time: 0.00e+00 yr | dt: 1.91e+00 yr | HDF5 SNAPSHOT SAVED
=========================================================================
| STEP: 30010 | Mode: GAS-ONLY EVOLUTION
| TIME: 9.9993e+03 / 1.0000e+04 yr [###################.] 100.0%
| DT: 1.9091e+00 yr
| DISK MASS: 1.0020e-02 / 1.0020e-05 M_Sun (Remaining: 100.00%)
=========================================================================
...
[SAVE AT STEP: 300200] Time: 9.00e+04 yr | dt: 1.91e+00 yr | HDF5 SNAPSHOT SAVED
=========================================================================
| STEP: 300200 | Mode: GAS-ONLY EVOLUTION
| TIME: 9.9999e+04 / 1.0000e+05 yr [###################.] 100.0%
| DT: 1.9091e+00 yr
| DISK MASS: 1.0020e-02 / 1.0020e-05 M_Sun (Remaining: 100.00%)
=========================================================================
=========================================================================
|| Simulation finished in 00:01:32. Summary written to logs. ||
=========================================================================
[PY-WRAPPER: RAPIDSIM] Main Simulation Program completed successfully.Figure 3. Example progress and finishing panels for a pure gas simulation initialized in Figure 2.
Impact
The primary impact of rapidsim is the reduction of the technical barrier between a computational astrophysics code and its end users. Without the package, users of RAPID must obtain the source code, satisfy the compiler
and native library requirements, and build the executable locally. rapidsim transfers this complexity to an automated build infrastructure and presents the resulting software through a standard Python distribution mechanism. By retaining the computational core in C, rapidsim combines the performance advantages of compiled native code with the ease of installation and execution provided by a Python interface. This approach is widely used in the scientific Python ecosystem, where packages such as NumPy [12] expose computationally intensive native implementations through a high-level Python interface.
Furthermore, the separation between RAPID and rapidsim establishes a reusable distribution model for future development. RAPID can be developed as a native numerical code while rapidsim maintains a stable user-facing interface and provides reproducible binary distributions. Conversely, modifications to the Python interface and packaging infrastructure do not require changes to the numerical implementation, unless new command-line options or simulation parameters need to be introduced. The automated release system further improves the traceability of the distributed software. Each package release is constructed from a specific RAPID release, with the source revision recorded automatically and the corresponding binary packages published to PyPI.
Although rapidsim has not yet been the subject of a dedicated scientific publication, the underlying RAPID code has already been used in published research papers [10, 9]. Additionally, Tarczay-Nehéz & Császár [13] presents a dedicated methods paper describing the code design, numerical methods, and implementation of RAPID in detail. Furthermore, an extension of [9] is in preparation to explore additional aspects of protoplanetary disk evolution, including photoevaporation. The availability of rapidsim facilitates these follow-up investigations by simplifying software installation and simulation execution while retaining the existing computational capabilities of RAPID.
Conclusions
rapidsim provides a Python interface and cross-platform distribution for RAPID, an established C-based code for simulating gas and dust evolution in protoplanetary discs. The main contribution of rapidsim is to make the existing numerical capabilities of RAPID accessible through a standard Python package, without requiring users to compile the native code or manage its build dependencies themselves. The functionality provided by rapidsim includes YAML-based control of simulation parameters, pre-built binary wheels for supported Linux and macOS platforms, and an automated release pipeline that links each distribution to a specific version of the underlying simulation code. This separation of the native C code RAPID and the wrapper rapidsim allows the numerical implementation and the user-facing interface to evolve independently, while maintaining traceability between source code and distributed executables. The resulting package provides a practical foundation for using RAPID in a wider range of research environments and for incorporating its simulations into Python-based scientific workflows.
Acknowledgements
This paper was supported by the János Bolyai Scholarship of the Hungarian Academy of Sciences, by the ‘SeismoLab’ KKP-137523 Élvonal grant of the Hungarian Research, Development and Innovation Office (NKFIH), and by the LP2025-14/2025 Lendület grant of the Hungarian Academy of Sciences. This paper is written by the assistance of a large language model (ChatGPT-5.6 Luna by OpenAI) for linguistic refinement. All content and any errors remain the sole responsibility of the first author.
An example of a YAML configuration file

# example YAML config file
simulation_parameters:
# Simulation Control Options
enable_dust_drift: false
enable_dust_growth: false
enable_gas_evolution: true
enable_two_dust_populations: false
enable_photoevaporation: false
disk_parameters:
# Grid and Disk Initial Parameters
number_of_grid_points: 500
inner_radius_au: 1
outer_radius_au: 50.0
disk_mass: 0.01
sigma_profile_exponent: -1.0
alpha_viscosity: 0.01
aspect_ratio_at_1au: 0.05
output_parameters:
# File I/O Parameters
output_directory_name: "output"
output_format: "ascii"
time_parameters:
# Time Parameters
total_simulation_time: 1e5
output_write_frequency: 10000Figure A.4. An example of a YAML configuration file for running simulation with rapidsim.
Current executable software version
The current version of rapidsim is v1.0.15.
References
- [1]F. Masset, FARGO: A fast eulerian transport algorithm for differentially rotating disks, Astronomy and Astrophysics Supplement Series 141 (2000) 165–173. arXiv:astro-ph/9910390, doi:10.1051/aas:2000116.DOI
- [2]P. Benítez-Llambay, F. S. Masset, Fargo3d: A new gpu-oriented mhd code, The Astrophysical Journal Supplement Series 223 (1) (2016) 11. URL http://stacks.iop.org/0067-0049/223/i=1/a=11
- [3]B. Paxton, L. Bildsten, A. Dotter, F. Herwig, P. Lesaffre, F. Timmes, Modules for Experiments in Stellar Astrophysics (MESA), Astrophys J Supp 192 (1) (2011) 3. arXiv:1009.1622, doi:10.1088/0067-0049/192/1/3.DOI
- [4]B. Paxton, M. Cantiello, P. Arras, L. Bildsten, E. F. Brown, A. Dotter, C. Mankovich, M. H. Montgomery, D. Stello, F. X. Timmes, R. Townsend, Modules for Experiments in Stellar Astrophysics (MESA): Planets, Oscillations, Rotation, and Massive Stars, Astrophys J Supp 208 (1) (2013) 4. arXiv:1301.0319, doi:10.1088/0067-0049/208/1/4.DOI