py21cmfast.AstroOptions

class py21cmfast.AstroOptions

Bases: InputStruct

Options for the ionization routines which enable/disable certain modules.

Parameters:
  • USE_MINI_HALOS (bool, optional) – Set to True if using mini-halos parameterization. If True, USE_TS_FLUCT must be True and RECOMB_MODEL must be not “none”.

  • USE_X_RAY_HEATING (bool, optional) – Whether to include X-ray heating (useful for debugging).

  • USE_CMB_HEATING (bool, optional) – Whether to include CMB heating. (cf Eq.4 of Meiksin 2021, https://arxiv.org/abs/2105.14516)

  • USE_LYA_HEATING (bool, optional) – Whether to use Lyman-alpha heating. (cf Sec. 3 of Reis+2021, https://doi.org/10.1093/mnras/stab2089)

  • INHOMO_RECO (bool, optional) – Whether to perform inhomogeneous recombinations. Increases the computation time. This parameter is deprecated and will be removed in a future version, see RECOMB_MODEL for the new method to control the recombination algorithm.

  • RECOMB_MODEL (str, optional) – The recombination algorithm used in the code. Options are:

    none: Ignoring recombination completely. This is not physical but allows to run the code much faster that way. homogeneous: Assuming a homogeneous recombination rate. This is not physical but could be useful for debugging or testing purposes, and is slightly faster than the inhomogeneous case. inhomogeneous: The most physical option, where the recombination rate is calculated locally at every cell, as described in Sobacchi & Mesinger 2014.

  • USE_TS_FLUCT (bool, optional) – Whether to perform IGM spin temperature fluctuations (i.e. X-ray heating). Dramatically increases the computation time.

  • M_MIN_in_Mass (bool, optional) – Whether the minimum halo mass (for ionization) is defined by mass or virial temperature. Only has an effect when SOURCE_MODEL == 'CONST-ION-EFF'

  • PHOTON_CONS_TYPE (str, optional) – Whether to perform a small correction to account for the inherent photon non-conservation. This can be one of three types of correction:

    • no-photoncons: No photon cosnervation correction,

    • z-photoncons: Photon conservation correction by adjusting the redshift of the N_ion source field (Park+22)

    • alpha-photoncons: Adjustment to the escape fraction power-law slope, based on fiducial results in Park+22, This runs a series of global xH evolutions and one calibration simulation to find the adjustment as a function of xH

    • f-photoncons: Adjustment to the escape fraction normalisation, runs one calibration simulation to find the adjustment as a function of xH where f'/f = xH_global/xH_calibration

  • FIX_VCB_AVG (bool, optional) – Determines whether to use a fixed vcb=VAVG (regardless of USE_RELATIVE_VELOCITIES). It includes the average effect of velocities but not its fluctuations. See Muñoz+21)

  • USE_EXP_FILTER (bool, optional) – Use the exponential filter (MFP-epsilon(r) from Davies & Furlanetto 2021) when calculating ionising emissivity fields.

  • CELL_RECOMB (bool, optional) – An alternate way of counting recombinations based on the local cell rather than the filter region. This is part of the perspective shift (see Davies & Furlanetto 2021) from counting photons/atoms in a sphere and flagging a central pixel to counting photons which we expect to reach the central pixel, and taking the ratio of atoms in the pixel. This flag simply turns off the filtering of N_rec grids, and takes the recombinations in the central cell.

  • LYA_MULTIPLE_SCATTERING (bool, optional) – If True, multiple scattering window function is used for the computation of Lyman alpha photons. If False, the straight-line window function is used (see more info in 2601.14360). This feature can be turned on only when the source model is defined on the Lagrangian grid, otherwise an error is raised.

  • USE_ADIABATIC_FLUCTUATIONS (bool, optional) – Whether to apply adiabatic fluctuations to the initial temperature box, see Munoz 2023. If set to False, the initial temperature box is completely homogeneous. Default is True.

  • USE_UPPER_STELLAR_TURNOVER (bool, optional) – Whether to use an additional powerlaw in stellar mass fraction at high halo mass. The pivot mass scale and power-law index are controlled by two parameters, UPPER_STELLAR_TURNOVER_MASS and UPPER_STELLAR_TURNOVER_INDEX respectively. This is currently only implemented using the discrete halo model, and has no effect otherwise.

  • HALO_SCALING_RELATIONS_MEDIAN (bool, optional) – If True, halo scaling relation parameters (F_STAR10,t_STAR etc…) define the median of their conditional distributions. If False, they describe the mean. This becomes important when using non-symmetric dristributions such as the log-normal.

  • HII_FILTER (str) – Filter for the halo or density field used to generate ionization field Available options are: ‘spherical-tophat’, ‘sharp-k’, and ‘gaussian’

  • HEAT_FILTER (str) – Filter for the halo or density field used to generate the spin-temperature field Available options are: ‘spherical-tophat’, ‘sharp-k’, and ‘gaussian’

  • IONISE_ENTIRE_SPHERE (bool, optional) – If True, ionises the entire sphere on the filter scale when an ionised region is found in the excursion set.

  • INTEGRATION_METHOD_ATOMIC (str, optional) – The integration method to use for conditional MF integrals of atomic halos in the grids:

    • ‘GSL-QAG’: GSL QAG adaptive integration,

    • ‘GAUSS-LEGENDRE’: Gauss-Legendre integration, previously forced in the interpolation tables,

    • ‘GAMMA-APPROX’: Approximate integration, assuming sharp cutoffs and a triple power-law for sigma(M) based on EPS

    Note

    Global integrals will use GSL QAG adaptive integration

  • INTEGRATION_METHOD_MINI (str, optional) – The integration method to use for conditional MF integrals of minihalos in the grids:

    • ‘GSL-QAG’: GSL QAG adaptive integration,

    • ‘GAUSS-LEGENDRE’: Gauss-Legendre integration, previously forced in the interpolation tables,

    • ‘GAMMA-APPROX’: Approximate integration, assuming sharp cutoffs and a triple power-law for sigma(M) based on EPS

asdict() dict

Return a dict representation of the instance.

Examples

This dict should be such that doing the following should work, i.e. it can be used exactly to construct a new instance of the same object:

>>> inp = InputStruct(**params)
>>> newinp =InputStruct(**inp.asdict())
>>> inp == newinp
Return type:

dict

clone(**kwargs)

Make a fresh copy of the instance with arbitrary parameters updated.

classmethod from_subdict(dct: dict[str, Any], safe: bool = True) Self

Construct an instance of this class from a dictionary.

Parameters:
  • dct (dict[str, Any])

  • safe (bool)

Return type:

Self

classmethod new(x: dict | Self | None = None, **kwargs)

Create a new instance of the struct.

Parameters:

x (dict | InputStruct | None) – Initial values for the struct. If x is a dictionary, it should map field names to their corresponding values. If x is an instance of this class, its attributes will be used as initial values. If x is None, the struct will be initialised with default values.

Other Parameters:
  • All other parameters should be passed as if directly to the class constructor

  • (i.e. as parameter names).

Parameters:

x (dict | Self | None)

Examples

>>> params = SimulationOptions.new({'HII_DIM': 250})
>>> params.HII_DIM
250
>>> params = SimulationOptions.new(params)
>>> params.HII_DIM
250
>>> params = SimulationOptions.new()
>>> params.HII_DIM
200
>>> params = SimulationOptions.new(HII_DIM=256)
>>> params.HII_DIM
256
CELL_RECOMB: bool
FIX_VCB_AVG: bool
HALO_SCALING_RELATIONS_MEDIAN: bool
HEAT_FILTER: FilterOptions
HII_FILTER: FilterOptions
property INHOMO_RECO: bool

Whether to perform inhomogeneous recombinations.

This is a deprecated property, and will be removed in a future version. Please use RECOMB_MODEL instead.

Return type:

bool

INTEGRATION_METHOD_ATOMIC: IntegralMethods
INTEGRATION_METHOD_MINI: IntegralMethods
IONISE_ENTIRE_SPHERE: bool
LYA_MULTIPLE_SCATTERING
M_MIN_in_Mass: bool
PHOTON_CONS_TYPE: Literal['no-photoncons', 'z-photoncons', 'alpha-photoncons', 'f-photoncons']
RECOMB_MODEL: Literal['none', 'homogeneous', 'inhomogeneous']
USE_ADIABATIC_FLUCTUATIONS
USE_CMB_HEATING: bool
USE_EXP_FILTER: bool
USE_LYA_HEATING: bool
USE_MINI_HALOS: bool
USE_TS_FLUCT: bool
USE_UPPER_STELLAR_TURNOVER: bool
USE_X_RAY_HEATING: bool
property cdict: dict

A python dictionary containing the properties of the wrapped C-struct.

The memory pointed to by this dictionary is not owned by the wrapped C-struct, but is rather just a python dict. However, in contrast to asdict(), this method transforms the properties to what they should be in C (e.g. linear space vs. log-space) before putting them into the dict.

This dict also contains only the properties of the wrapped C-struct, rather than all properties of the InputStruct instance (some attributes of the python instance are there only to guide setting of defaults, and don’t appear in the C-struct at all).

Return type:

dict