HyRex.helium module
- class HyRex.helium.helium_model(lna_axis_4Heequil, integration_spacing=0.0005, Nsteps=800, Nsteps_postSahaHe=4000, z0=8000.0, z1=20.0)[source]
Bases:
ModuleHelium recombination model implementation.
Computes helium ionization fraction evolution through multiple phases: HeII+III equilibrium, post-Saha HeII expansion, and full HeII recombination.
Attributes:
integration_spacingfloatStep size in log scale factor for integration
lna_axis_4HeequilarrayLog scale factor grid for HeII+III equilibrium phase
concrete_axis_sizearrayPre-allocated array for HeII full recombination phase
concrete_axis_size_postSahaHearrayPre-allocated array for post-Saha HeII expansion phase
Methods:
get_helium_history:Compute full helium recombination history (units: dimensionless)
xesaha_HeII_III:Compute HeII+III equilibrium phase (units: dimensionless)
post_saha_xHeII:Compute post-Saha HeII expansion (units: dimensionless)
solve_HeII_full:Solve full HeII recombination (units: dimensionless)
xHeII_post_Saha:Compute HeII fraction in post-Saha regime (units: dimensionless)
xH1_Saha:Compute neutral hydrogen fraction in Saha equilibrium (units: dimensionless)
helium_dxHeIIdlna:Compute HeII recombination rate (units: dimensionless)
xe_derivative_HeII:Compute HeII derivative for ODE integration (units: dimensionless)
- get_helium_history(h, omega_b, omega_cdm, Neff, YHe, rtol=1e-06, atol=1e-09, solver=Kvaerno3(), max_steps=1024)[source]
Compute complete helium recombination history through all phases.
Sequentially computes helium ionization fraction through HeII+III equilibrium, post-Saha HeII expansion, and full HeII recombination phases.
Parameters:
hfloatHubble parameter
omega_bfloatThe baryon density Omega_b h^2
omega_cdmfloatThe density of Cold Dark Matter Omega_cdm h^2
NefffloatEffective number of neutrinos
YHefloatHelium fraction
rtolfloat, optionalRelative tolerance for ODE solver (default: 1e-6)
atolfloat, optionalAbsolute tolerance for ODE solver (default: 1e-9)
solverdiffrax.Solver, optionalODE solver instance (default: Kvaerno3())
max_stepsint, optionalMaximum solver steps (default: 1024)
Returns:
- tuple
(xe_4He, lna_4He) containing helium ionization fraction evolution and log scale factor grid
- helium_dxHeIIdlna(xe, lna, h, omega_b, omega_cdm, Neff, YHe)[source]
Compute HeII recombination rate.
Calculates rate of change of HeII ionization fraction including detailed atomic physics and escape probabilities.
Parameters:
xefloatCurrent total ionization fraction
lnafloatLog scale factor
hfloatHubble parameter
omega_bfloatThe baryon density Omega_b h^2
omega_cdmfloatThe density of Cold Dark Matter Omega_cdm h^2
NefffloatEffective number of neutrinos
YHefloatHelium fraction
Returns:
- float
HeII recombination rate dxHeII/dlna (units: dimensionless)
- post_saha_xHeII(starting_lna, h, omega_b, omega_cdm, Neff, YHe, threshold=1e-05)[source]
Compute post-Saha HeII expansion phase.
Calculates ionization fraction including corrections to Saha equilibrium until deviations exceed threshold.
Parameters:
starting_lnafloatInitial log scale factor
hfloatHubble parameter
omega_bfloatThe baryon density Omega_b h^2
omega_cdmfloatThe density of Cold Dark Matter Omega_cdm h^2
NefffloatEffective number of neutrinos
YHefloatHelium fraction
thresholdfloat, optionalThreshold for deviation from Saha (default: 1e-5)
Returns:
- tuple
(xe_output, lna_output) - ionization fraction and log scale factor arrays
- solve_HeII_full(starting_lna, xe0, h, omega_b, omega_cdm, Neff, YHe, rtol=1e-06, atol=1e-09, solver=Kvaerno3(), max_steps=1024)[source]
Solve full HeII recombination evolution.
Integrates HeII recombination including detailed atomic physics until HeII fraction becomes negligible.
Parameters:
starting_lnafloatInitial log scale factor
xe0floatInitial ionization fraction
hfloatHubble parameter
omega_bfloatThe baryon density Omega_b h^2
omega_cdmfloatThe density of Cold Dark Matter Omega_cdm h^2
NefffloatEffective number of neutrinos
YHefloatHelium fraction
rtolfloat, optionalRelative tolerance (default: 1e-6)
atolfloat, optionalAbsolute tolerance (default: 1e-9)
solverdiffrax.Solver, optionalODE solver (default: Kvaerno3())
max_stepsint, optionalMaximum steps (default: 1024)
Returns:
- tuple
(xe_output, lna_output) - ionization fraction and log scale factor arrays
- xH1_Saha(lna, omega_b, YHe)[source]
Compute neutral hydrogen fraction in Saha equilibrium.
Calculates neutral hydrogen fraction assuming Saha equilibrium between hydrogen ionization and recombination.
Parameters:
lnafloatLog scale factor
omega_bfloatThe baryon density Omega_b h^2
YHefloatHelium fraction
Returns:
- float
Neutral hydrogen fraction (units: dimensionless)
- xHeII_post_Saha(lna, omega_b, YHe)[source]
Compute HeII fraction in post-Saha regime.
Calculates HeII fraction using Saha equilibrium between HeI and HeII.
Parameters:
lnafloatLog scale factor
hfloatHubble parameter
omega_bfloatThe baryon density Omega_b h^2
omega_cdmfloatThe density of Cold Dark Matter Omega_cdm h^2
NefffloatEffective number of neutrinos
YHefloatHelium fraction
Returns:
- float
HeII fraction (units: dimensionless)
- xe_derivative_HeII(lna, state, args)[source]
Compute HeII derivative for ODE integration.
Derivative function for HeII ionization fraction evolution used in ODE integration with diffrax.
Parameters:
lnafloatLog scale factor
statefloatCurrent HeII ionization state
argstupleh, omega_b, omega_cdm, Neff, YHe, omega_rad; the Hubble parameter, the baryon denisty Omega_b h^2, the CDM density Omega_cdm h^2, the effecgive number of neutrinos, the helium fraction, and the radiation energy density (determined by Neff and can be computed by cosmology.omega_rad0(Neff))
Returns:
- float
Time derivative of HeII fraction (units: dimensionless)
- xesaha_HeII_III(lna_axis, omega_b, YHe, threshold=1e-09)[source]
Compute xe in HeII+III equilibrium phase.
Calculates ionization fraction assuming equilibrium between HeII and HeIII until HeIII fraction drops below threshold.
Parameters:
lna_axisarrayLog scale factor grid
omega_bfloatThe baryon density Omega_b h^2
YHefloatHelium fraction
thresholdfloat, optionalThreshold for HeIII fraction to stop calculation (default: 1e-9)
Returns:
- tuple
(xe_output, lna_output) - ionization fraction and log scale factor arrays