DM21cm - Inhomogeneous Energy Injection in 21cm Cosmology
HERA sensitivity to dark matter monochromatic decays in 21-cm power spectrum
Usage
from dm21cm.injections.decay import DMDecayInjection
from dm21cm.evolve import evolve
import py21cmfast as p21c
return_dict = evolve(
run_name = 'test_injection',
z_start = 45.,
z_end = 5.,
injection = DMDecayInjection(
primary='phot_delta',
m_DM=1e8, # [eV]
lifetime=1e28, # [s]
),
p21c_initial_conditions = p21c.initial_conditions(
user_params = p21c.UserParams(
HII_DIM = 64,
BOX_LEN = 256, # [conformal Mpc]
),
),
p21c_astro_params = p21c.AstroParams(),
)
Installation
Prerequisite: DarkHistory
- Clone the DarkHistory repository here. Checkout branch
DM21cm. - Install the require packages via
pip install -r requirements.txt. - Set environment variable
DH_DIRto point to the project folder (directory containingREADME.md). - Set environment variable
DH_DATA_DIRto point to the DarkHistory data (v1.1) folder (directory containingbinning.p). The data files can be downloaded here.
Prerequisite: 21cmFAST
- Clone the 21cmFAST fork here. Checkout branch
master. - Install 21cmFAST according to README.md
- Install gcc and have environment variable
CCpoint to the binary. - Install gsl (GNU Scientific Library) and have
GSL_LIBpoint to the directory of the library. - Install fftw and have
FFTW_INCpoint to the directory containing fftw header files. - Install
21cmFASTviapip install .in the project directory.
- Install gcc and have environment variable
- Set environment variable
P21C_CACHE_DIRto a directory for storing cached files (requries at least 10G for a 128^3 box 1.01 redshift step run).
DM21cm
- Clone this repository. Checkout branch
main. - Download data files from here.
- Install the require packages via
pip install -r requirements.txt. We recommend installingJAXaccording to your hardware (e.g. GPU) specification. - Set environment variable
DM21CM_DIRto point to the project folder (directory containingREADME.md). - Set environment variable
DM21CM_DATA_DIRto point to the data folder (directory containingabscissas.h5).
Defining your custom injection
import dm21cm.physics as phys
from dm21cm.injections.base import Injection
from darkhistory.spec import pppc
import numpy as np
class CustomInjection (Injection):
def __init__(self):
self.mode = 'Decay implemented again'
self.primary = primary
self.m_DM = m_DM
self.lifetime = lifetime
#===== injections =====
def inj_rate(self, z):
"""Injection event rate density in [injection / pcm^3 s]. [pcm] = [physical cm].
Used in DarkHistory part of the evolution.
"""
rho_DM = phys.rho_DM * (1+z)**3 # [eV / pcm^3]
return float((rho_DM/self.m_DM) / self.lifetime) # [inj / pcm^3 s]
def inj_power(self, z):
"""Injection power density in [eV / pcm^3 s].
Used in DarkHistory.
"""
return self.inj_rate(z) * self.m_DM # [eV / pcm^3 s]
def inj_phot_spec(self, z, **kwargs):
"""Injected photon rate density spectrum assuming a homogeneous universe in [# / pcm^3 s].
Used in DarkHistory.
"""
return self.phot_spec_per_inj * self.inj_rate(z) # [phot / pcm^3 s]
def inj_elec_spec(self, z, **kwargs):
"""Injected electron rate density spectrum assuming a homogeneous universe in [# / pcm^3 s].
Used in DarkHistory.
"""
return self.elec_spec_per_inj * self.inj_rate(z) # [elec / pcm^3 s]
def inj_phot_spec_box(self, z, delta_plus_one_box=..., **kwargs):
"""Injected photon rate density spectrum [# / pcm^3 s] and weight box [dimensionless]."""
return self.inj_phot_spec(z), delta_plus_one_box # [phot / pcm^3 s], [1]
def inj_elec_spec_box(self, z, delta_plus_one_box=..., **kwargs):
"""Injected electron rate density spectrum [# / pcm^3 s] and weight box [dimensionless]."""
return self.inj_elec_spec(z), delta_plus_one_box # [elec / pcm^3 s], [1]
#===== utilities =====
def set_binning(self, abscs):
"""Inherent binning from `evolve` function."""
self.phot_spec_per_inj = pppc.get_pppc_spec(
self.m_DM, abscs['photE'], self.primary, 'phot', decay=True
) # [# / injection event]
self.elec_spec_per_inj = pppc.get_pppc_spec(
self.m_DM, abscs['elecEk'], self.primary, 'elec', decay=True
) # [# / injection event]
def is_injecting_elec(self):
"""Optionally turn off electron injection."""
return not np.allclose(self.elec_spec_per_inj.N, 0.)
def get_config(self):
"""For caching darkhistory runs."""
return {
'mode': self.mode,
'primary': self.primary,
'm_DM': self.m_DM,
'lifetime': self.lifetime
}
Authors
Yitian Sun, Joshua W. Foster, Hongwan Liu, Julian B. Muñoz, and Tracy R. Slatyer
Metadata
Release files for dm21cm 0.0.0.20241004
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dm21cm-0.0.0.20241004.tar.gz | 4.0 MB | Without provenance | Details for dm21cm-0.0.0.20241004.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dm21cm-0.0.0.20241004-py3-none-any.whl | Python 3 | none | any | Details for dm21cm-0.0.0.20241004-py3-none-any.whl |
Total release size: 7.9 MB
Release files / dm21cm-0.0.0.20241004.tar.gz
| Download URL | dm21cm-0.0.0.20241004.tar.gz |
|---|---|
| Size | 4.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f5c9b648a9ad7ca6326bad35e7135ba7c656443a016748ed5219d62eb53e762
|
|
BLAKE2b-256 checksum How to use checksums |
3c9e4b8d86644207662cdc7bc9764c89884024442320bf896dbfab26b1cd340b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Release files / dm21cm-0.0.0.20241004-py3-none-any.whl
| Download URL | dm21cm-0.0.0.20241004-py3-none-any.whl |
|---|---|
| Size | 4.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd58e7777fe47811220d645f64b353c6c174ce5f2fa9f0da9e67f95afabbfdd6
|
|
BLAKE2b-256 checksum How to use checksums |
8af7f89a278899b27782fb566ef1cb09aca0c4ac49561879f519ceb7b5a01ee5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Security for dm21cm 0.0.0.20241004
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.