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: Module

Helium recombination model implementation.

Computes helium ionization fraction evolution through multiple phases: HeII+III equilibrium, post-Saha HeII expansion, and full HeII recombination.

Attributes:

  • integration_spacing float

    Step size in log scale factor for integration

  • lna_axis_4Heequil array

    Log scale factor grid for HeII+III equilibrium phase

  • concrete_axis_size array

    Pre-allocated array for HeII full recombination phase

  • concrete_axis_size_postSahaHe array

    Pre-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:

  • h float

    Hubble parameter

  • omega_b float

    The baryon density Omega_b h^2

  • omega_cdm float

    The density of Cold Dark Matter Omega_cdm h^2

  • Neff float

    Effective number of neutrinos

  • YHe float

    Helium fraction

  • rtol float, optional

    Relative tolerance for ODE solver (default: 1e-6)

  • atol float, optional

    Absolute tolerance for ODE solver (default: 1e-9)

  • solver diffrax.Solver, optional

    ODE solver instance (default: Kvaerno3())

  • max_steps int, optional

    Maximum 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:

  • xe float

    Current total ionization fraction

  • lna float

    Log scale factor

  • h float

    Hubble parameter

  • omega_b float

    The baryon density Omega_b h^2

  • omega_cdm float

    The density of Cold Dark Matter Omega_cdm h^2

  • Neff float

    Effective number of neutrinos

  • YHe float

    Helium 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_lna float

    Initial log scale factor

  • h float

    Hubble parameter

  • omega_b float

    The baryon density Omega_b h^2

  • omega_cdm float

    The density of Cold Dark Matter Omega_cdm h^2

  • Neff float

    Effective number of neutrinos

  • YHe float

    Helium fraction

  • threshold float, optional

    Threshold 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_lna float

    Initial log scale factor

  • xe0 float

    Initial ionization fraction

  • h float

    Hubble parameter

  • omega_b float

    The baryon density Omega_b h^2

  • omega_cdm float

    The density of Cold Dark Matter Omega_cdm h^2

  • Neff float

    Effective number of neutrinos

  • YHe float

    Helium fraction

  • rtol float, optional

    Relative tolerance (default: 1e-6)

  • atol float, optional

    Absolute tolerance (default: 1e-9)

  • solver diffrax.Solver, optional

    ODE solver (default: Kvaerno3())

  • max_steps int, optional

    Maximum 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:

  • lna float

    Log scale factor

  • omega_b float

    The baryon density Omega_b h^2

  • YHe float

    Helium 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:

  • lna float

    Log scale factor

  • h float

    Hubble parameter

  • omega_b float

    The baryon density Omega_b h^2

  • omega_cdm float

    The density of Cold Dark Matter Omega_cdm h^2

  • Neff float

    Effective number of neutrinos

  • YHe float

    Helium 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:

  • lna float

    Log scale factor

  • state float

    Current HeII ionization state

  • args tuple

    h, 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_axis array

    Log scale factor grid

  • omega_b float

    The baryon density Omega_b h^2

  • YHe float

    Helium fraction

  • threshold float, optional

    Threshold for HeIII fraction to stop calculation (default: 1e-9)

Returns:

tuple

(xe_output, lna_output) - ionization fraction and log scale factor arrays