EoR ionization diffusion calculations and power spectrum analysis with GPU acceleration
Project description
EoRCaLC - Epoch of Reionization Calculator
EoRCaLC is a Python package for calculating ionization diffusion and power spectrum analysis during the Epoch of Reionization (EoR). It features GPU acceleration support for high-performance cosmological simulations.
Features
- 🚀 GPU Acceleration: High-performance calculations using CuPy (CUDA 12.x)
- 📊 Power Spectrum Analysis: Matter power spectrum calculations via CAMB
- 🌌 Mass Functions: Halo mass function computations with custom transfer functions
- 🔬 Ionization Physics: Ionization diffusion and recombination modeling
- ⚡ Optimized Algorithms: Efficient numerical integration and interpolation
Installation
Prerequisites
- Python 3.8 or higher
- CUDA 12.x compatible GPU (for GPU acceleration)
- CUDA Toolkit 12.x installed
Basic Installation
pip install -e .
GPU Support (CUDA 12.x)
For GPU acceleration with CUDA 12.x:
pip install -e ".[gpu]"
Or install CuPy separately:
pip install cupy-cuda12x
Development Installation
pip install -e ".[dev]"
Dependencies
Core Dependencies
- numpy (≥1.20.0): Numerical computing
- scipy (≥1.6.0): Scientific computing and integration
- astropy (≥4.0): Astronomical calculations and units
- camb (≥1.3.0): Cosmological matter power spectrum
- massfunc (≥0.0.10): Halo mass function calculations
- cupy-cuda12x (≥12.0.0): GPU acceleration (optional)
- filelock (≥3.0.0): File locking for concurrent access
- cosfunc: Cosmological functions (local dependency)
Usage
Basic Example - CPU Version
from eorcalc.ioninti import Ion
# Initialize ionization calculator
z = 7.0 # Redshift
ion_calc = Ion(
z=z,
fesc=0.2, # Escape fraction
A2byA1=0.1, # Transfer function parameter
ktrans=200, # Transition scale [Mpc^-1]
alpha=2.0, # Power law index
beta=0.0 # Secondary index
)
# Calculate ionization properties
# ... your calculations here ...
GPU-Accelerated Version
from eorcalc.ioninti_gpu import Ion
# Same interface but with GPU acceleration
ion_calc = Ion(
z=7.0,
fesc=0.2,
A2byA1=0.1,
ktrans=200,
alpha=2.0,
beta=0.0
)
# GPU-accelerated computations
# ... your calculations here ...
Ionization Diffusion
from eorcalc.iondiff import Ion
# Full ionization diffusion calculations
ion_diff = Ion(
z=7.0,
fesc=0.2,
kakaka=0.7e-28, # Recombination coefficient
xi_ion=10**25.6, # Ionizing efficiency
A2byA1=0.1,
ktrans=200,
alpha=2.0,
beta=0.0
)
# Perform diffusion calculations
# ... your calculations here ...
Power Spectrum Analysis
from eorcalc.powerspec import MassFunctions
# Initialize cosmological calculator
cosmo = MassFunctions(
A2byA1=0.1,
kMpc_trans=200,
alpha=2.0,
beta=0.0
)
# Calculate mass functions and power spectra
z = 7.0
M = 1e10 # Solar masses
sigma = cosmo.sigma_M(M, z)
mass_func = cosmo.massfunc(M, z)
Module Overview
eorcalc.ioninti
CPU-based ionization calculations with standard numerical methods.
eorcalc.ioninti_gpu
GPU-accelerated ionization calculations using CuPy for enhanced performance.
eorcalc.iondiff
Ionization diffusion modeling including recombination effects.
eorcalc.powerspec
CAMB-based matter power spectrum and halo mass function calculations.
eorcalc.special
Special functions and utilities:
qion_sb99: Ionizing photon production from Starburst99 modelsinterp1d_gpu: GPU-accelerated interpolationxim: Ionization fraction calculationsfstar: Star formation efficiency
Project Structure
EoRCaLC/
├── eorcalc/
│ ├── __init__.py
│ ├── iondiff.py # Ionization diffusion (CPU)
│ ├── ioninti.py # Ionization initial (CPU)
│ ├── ioninti_gpu.py # Ionization (GPU accelerated)
│ ├── powerspec.py # Power spectrum & mass functions
│ └── special.py # Special functions & utilities
├── pyproject.toml # Project configuration
├── LICENSE # MIT License
└── README.md # This file
Performance Tips
- GPU Memory: Ensure sufficient GPU memory for large-scale simulations
- Batch Processing: Process multiple redshifts in batches for efficiency
- Caching: Enable CAMB result caching for repeated calculations
- Precision: Use
float32on GPU for memory-intensive tasks if precision allows
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this code in your research, please cite:
@software{eorcalc2025,
author = {Hajime Hinata},
title = {EoRCaLC: Epoch of Reionization Calculator},
year = {2025},
url = {https://github.com/SOYONAOC/IonDiff}
}
Contact
- Author: Hajime Hinata
- Email: onmyojiflow@gmail.com
- Repository: https://github.com/SOYONAOC/IonDiff
- Issues: https://github.com/SOYONAOC/IonDiff/issues
Acknowledgments
This package builds upon:
- CAMB: Cosmological Boltzmann code
- CuPy: NumPy-compatible array library for GPU
- Astropy: Community Python library for Astronomy
- massfunc: Halo mass function library
Version History
v0.1.0 (2025-10-02)
- Initial release
- CPU and GPU implementations
- Power spectrum analysis
- Ionization diffusion modeling
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eorcalc-0.1.0.tar.gz.
File metadata
- Download URL: eorcalc-0.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d12cbd01313bffa3e5836ca959c44ea11d564c2d2e5a189d5f4a4e23b4432370
|
|
| MD5 |
f5ca4b9972e81dbd92b08fcf3669e882
|
|
| BLAKE2b-256 |
a549ebe9dafeb8979a960d68fb8932eeb7e0712e9d06603c32d9841729d52d93
|
File details
Details for the file eorcalc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eorcalc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09e12d72e4dd3492297acfce0570e12227229023811bb18a99f5a5064be7e584
|
|
| MD5 |
bdf4643112620e39cac79cdf56b408f8
|
|
| BLAKE2b-256 |
a8d047658695798b64e3817f2228017da206df4a55bb33d47a606de5d5d0d846
|