Parameters

Contents

Parameters#

Note

This module contains various parameter classes used throughout Beorn to configure simulations, cosmological settings, source properties, and solver options.

Global parameters for this simulation. They encompass the astrophysical parameters of the source, the cosmological parameters, the simulation parameters, the solver parameters, the excursion set parameters, and the halo mass function parameters. Slots are used to prevent the creation of new attributes. This is useful to avoid typos and to have a clear overview of the parameters.

class beorn.structs.parameters.CosmologyParameters(Om: float = 0.31, Ob: float = 0.045, Ol: float = 0.68, rho_c: float = 277500000000.0, h0: float = 0.68, sigma_8: float = 0.83, ns: float = 0.96)[source]#

Cosmological parameters for the simulation.

Om#

Matter density parameter.

Type:

float

Ob#

Baryon density parameter.

Type:

float

Ol#

Dark energy density parameter.

Type:

float

rho_c#

Critical density of the universe.

Type:

float

h0#

Dimensionless Hubble parameter.

Type:

float

sigma_8#

Amplitude of the matter power spectrum on 8 Mpc/h scales.

Type:

float

ns#

Scalar spectral index.

Type:

float

class beorn.structs.parameters.Parameters(source: SourceParameters = <factory>, solver: SolverParameters = <factory>, cosmology: CosmologyParameters = <factory>, simulation: SimulationParameters = <factory>, cosmo_sim: CosmoSimParameters = <factory>)[source]#

Group all the parameters for the simulation.

classmethod from_dict(params_dict: dict) Parameters[source]#

Create a Parameters object from a dictionary. This is useful for loading parameters from a file.

classmethod from_group(group: h5py.Group) Parameters[source]#

Create a Parameters object from an hdf5 group. This is useful for loading parameters from an hdf5 file.

classmethod from_yaml(yaml_path: Path) Parameters[source]#

Create a Parameters object from a YAML file.

beorn_hash() str[source]#

Short MD5 hash of BEoRN-specific parameters (source, solver, simulation).

Cosmology is intentionally excluded — it is already encoded in the input data directory name (e.g. the py21cmfast subdirectory). This hash therefore differentiates astrophysical models applied to the same underlying density/halo data.

cosmo_sim is also excluded: it controls which input data is used but does not affect the underlying physics model — it is already encoded in the input_tag.

profiles_hash() str[source]#

Short MD5 hash of parameters that affect the 1D radiation profiles.

Covers source parameters, cosmology, solver redshifts, and the halo mass / accretion-rate bins. Intentionally excludes random seed, grid dimensions (Ncell, Lbox, py21cmfast_high_res_factor), and other simulation parameters that do not influence the 1D profile shapes. This allows profiles to be reused when re-running BEoRN with a different py21cmfast seed or a different grid resolution.

summary_str() str[source]#

Return a concise human-readable summary of the key model parameters.

to_yaml(path: Path, exclude_keys: set[str] | None = None) None[source]#

Write parameters to a human-readable YAML file at path.

Parameters:
  • path – Destination file path.

  • exclude_keys

    Optional set of strings to omit. Two forms are supported:

    • "section" — remove the entire top-level section, e.g. {"simulation", "cosmo_sim"}.

    • "section.field" — remove a single field within a section, e.g. {"solver.redshifts"}.

unique_hash() str[source]#

Generates a unique hash for the current set of parameters. This can be used as a unique key when caching the computations.

cosmo_sim: CosmoSimParameters#

cosmo-sim input parameters (py21cmfast, Thesan, PKDGrav, etc.)

cosmology: CosmologyParameters#

cosmological parameters

simulation: SimulationParameters#

simulation parameters

solver: SolverParameters#

solver parameters

source: SourceParameters#

source parameters

class beorn.structs.parameters.SimulationParameters(Ncell: int = 128, Lbox: float = 100, store_grids: list = ('delta_b', 'Grid_Temp', 'Grid_xHII', 'Grid_xal'), cores: int = 1, spreading_pixel_threshold: int = -1, spreading_subgrid_approximation: bool = True, minimum_grid_size_heat: int = 4, minimum_grid_size_lyal: int = 16, compute_s_alpha_fluctuations: bool = True, compute_x_coll_fluctuations: bool = True, degrade_resolution: int = 1)[source]#

Parameters that are used to run the simulation. These are used in the generation of the halo profiles and when converting the halo profiles to a grid.

Lbox: float#

Box length, in [Mpc/h]. This is the length of the box in each dimension. The total volume will be Lbox^3.

Ncell: int#

Number of pixels of the final grid. This is the number of pixels in each dimension. The total number of pixels will be Ncell^3.

compute_s_alpha_fluctuations: bool#

Whether or not to include the fluctuations in the suppression factor S_alpha when computing the x_al fraction.

compute_x_coll_fluctuations: bool#

Whether or not to include the fluctuations in the collisional coupling coefficient x_coll when computing the x_tot fraction.

cores: int#

Number of cores used in parallelization. The computation for each redshift can be parallelized with a shared memory approach. This is the number of cores used for this. Keeping the number at 1 disables parallelization.

degrade_resolution: int#

Downsample density grids read from N-body files by this integer factor before painting. A value of 1 (default) applies no degradation. A value of N block-averages each N³ voxel into one, e.g. degrade_resolution=4 turns a 256³ grid into 64³. Set Ncell to the native grid size divided by degrade_resolution.

property kbins: numpy.ndarray#

Returns the k bins for the power spectrum. The bins are logarithmically spaced between k_min and k_max. The number of bins is determined by the size of the simulation box and the number of cells.

minimum_grid_size_heat: int#

Minimum grid size used when computing the heat kernel from its associated profile.

minimum_grid_size_lyal: int#

Minimum grid size used when computing the lyal kernel from its associated profile.

spreading_pixel_threshold: int#

When spreading the excess ionization fraction, treat all the connected regions with less than “thresh_pixel” as a single connected region (to speed up). If set to a negative value, a default nonzero value will be used

spreading_subgrid_approximation: bool#

When spreading the excess ionization fraction and running distance_transform_edt, whether or not to do the subgrid approximation.

store_grids: list#

Base grids to write to the HDF5 output file. These four fields are the independent outputs of the painting stage. Derived quantities such as ‘Grid_dTb’ are not stored by default because they can be recomputed on the fly as cached properties from the base fields (Grid_dTb = f(delta_b, Grid_Temp, Grid_xHII, Grid_xal, z)). Add ‘Grid_dTb’ here only if you need pre-computed access to it for very large grids where recomputation is expensive.

class beorn.structs.parameters.SolverParameters(redshifts: numpy.ndarray = <factory>, fXh: Literal['constant', 'variable']='constant', halo_mass_accretion_alpha: numpy.ndarray = <factory>, halo_mass_bin_min: float = 100000.0, halo_mass_bin_max: float = 100000000000000.0, halo_mass_nbin: int = 100, HI_frac: float = 0.92, clumping: int = 1, z_decoupling: int = 135, z_source_start: float = 35.0)[source]#

Solver parameters for the simulation.

HI_frac: float#

HI number fraction. Only used when running H_He_Final.

clumping: int#

Rescale the background density. Set to 1 to get the normal 2h profile term.

fXh: Literal['constant', 'variable']#

if fXh is constant here, it will take the value 0.11. Otherwise, we will compute the free e- fraction in neutral medium and take the fit fXh = xe**0.225

halo_mass_accretion_alpha: numpy.ndarray#

Coefficient for exponential mass accretion. Since beorn distinguishes between accretion rates a range should be specified

halo_mass_bin_max: float#

Maximum halo mass bin in solar masses.

halo_mass_bin_min: float#

Minimum halo mass bin in solar masses.

halo_mass_nbin: int#

Number of mass bins.

redshifts: numpy.ndarray#

High-resolution redshift grid used by the 1D RT profile solver. Should span the full redshift range of interest at fine enough resolution for accurate profile integration. Stored inside the RadiationProfiles cache — does not need to be written to igm_data/igm_params.yaml.

z_decoupling: int#

Redshift at which the gas decouples from CMB and starts cooling adiabatically.

z_source_start: float#

Maximum lookback redshift for X-ray and ionisation integrals. Sources are assumed to have started emitting no earlier than this redshift. When source.source_age is None (default), the integral extends all the way back to z_source_start. When source_age is set, the window is further capped by the finite age — whichever limit is reached first applies.

class beorn.structs.parameters.SourceParameters(source_type: Literal['SED', 'Ghara', 'Ross', 'constant'] = 'SED', energy_min_sed_xray: int = 500, energy_max_sed_xray: int = 2000, energy_cutoff_min_xray: int = 500, energy_cutoff_max_xray: int = 2000, alS_xray: float = 1.00001, xray_normalisation: float = 3.4e+40, n_lyman_alpha_photons: int = 9690, lyman_alpha_power_law: float = 0.0, halo_mass_min: float = 100000000.0, halo_mass_max: float = 1e+16, f_st: float = 0.05, f_st_grid_min: float = 0.01, f_st_grid_max: float = 0.2, f_st_grid_n: int = 30, f_st_paint_distribution: Literal['lognormal', 'normal', 'uniform'] = 'lognormal', f_st_paint_sigma: float = 0.5, f_st_paint_min: float = 0.01, f_st_paint_max: float = 0.2, f_st_paint_seed: int | None = None, Mp: float = 190400000000.0, g1: float = 0.49, g2: float = -0.61, Mt: float = 100000000.0, g3: float = 4, g4: float = -1, Nion: int = 5000, f0_esc: float = 0.2, Mp_esc: float = 10000000000.0, pl_esc: float = 0.0, min_xHII_value: int = 0, mass_accretion_lookback: int = 10, alpha_fallback: float | str = 'mean', t_source_age: float = None)[source]#

Parameters for the sources of radiation. Sensible defaults are provided.

Mp: float#

pivot mass of the double power law describing the star formation rate

Mp_esc: float#

pivot mass for the escape fraction

Mt: float#

turnover mass of the low mass suppression term of the star formation rate

Nion: int#

number of ionizing photons per baryon in stars

alS_xray: float#

TODO

alpha_fallback: float | str#

Fallback alpha value for halos not found in the merger tree, or whose mass history is too short to fit reliably. Options: - float : fixed value (e.g. 0.6, the typical mean from THESAN-DARK 2 at z~8) - ‘mean’ : mean of the fitted alphas at that snapshot (default — adapts with redshift) - ‘median’: median of the fitted alphas at that snapshot

energy_cutoff_max_xray: int#

upper energy cutoff for the xray band

energy_cutoff_min_xray: int#

lower energy cutoff for the xray band

energy_max_sed_xray: int#

maximum energy of normalization of xrays in eV

energy_min_sed_xray: int#

minimum energy of normalization of xrays in eV

f0_esc: float#

photon escape fraction f_esc = f0_esc * (M/Mp)^pl_esc

f_st: float#

the prefactor of the star formation efficiency f_star which is a function of halo mass

f_st_grid_max: float#

Maximum f_st value for precomputing (mass, alpha, f_st, z) radiation profiles.

f_st_grid_min: float#

Minimum f_st value for precomputing (mass, alpha, f_st, z) radiation profiles.

f_st_grid_n: int#

Number of f_st grid points for precomputing (mass, alpha, f_st, z) radiation profiles.

f_st_paint_distribution: Literal['lognormal', 'normal', 'uniform']#

Distribution used to sample per-halo f_st during painting.

f_st_paint_max: float#

Upper clipping bound for sampled f_st during painting.

f_st_paint_min: float#

Lower clipping bound for sampled f_st during painting.

f_st_paint_seed: int | None#

Optional RNG seed for reproducible per-snapshot f_st sampling.

f_st_paint_sigma: float#

Width parameter for the f_st sampling distribution (log-space sigma for lognormal).

g1: float#

power law index of the star formation rate

g2: float#

power law index of the star formation rate

g3: float#

power law index of the low mass suppression term of the star formation rate

g4: float#

power law index of the low mass suppression term of the star formation rate

halo_mass_max: float#

Maximum mass of star forming halo. Objects above this mass are not considered during the painting process

halo_mass_min: float#

Minimum mass of star forming halo. Mdark in HM. Objects below this mass are not considered during the painting process

lyman_alpha_power_law: float#

power law index for lyal. 0.0 for constant, 1.0 for linear, 2.0 for quadratic

mass_accretion_lookback: int#

Number of snapshots to look back when fitting the per-halo accretion rate alpha from merger trees. The thesis by Moll (2025) shows that the mean alpha stabilises at n=10 lookback snapshots, corresponding to a causal timescale of ~300 Myr (Δz≈4 from z=8). Values below 5 give unstable fits; going beyond 10 only marginally reduces scatter.

min_xHII_value: int#

lower limit for the ionization fraction. All pixels with xHII < min_xHII_value will be set to this value.

n_lyman_alpha_photons: int#

number of lyal photons per baryons in stars

pl_esc: float#

power law index for the escape fraction

source_type: Literal['SED', 'Ghara', 'Ross', 'constant']#

source type. SED, Ghara, Ross, constant

t_source_age: float#

Maximum source age in Myr. When set, the X-ray and ionisation integrals are limited to a lookback window of this duration rather than integrating all the way back to solver.z_source_start. This prevents unphysically old emission histories for halos that formed recently. None (default) preserves the original behaviour (integrate back to solver.z_source_start).

xray_normalisation: float#

Xray normalization [(erg/s) * (yr/Msun)] (astro-ph/0607234 eq22)