py21cmfast.MatterOptions

class py21cmfast.MatterOptions

Bases: InputStruct

Structure containing options which affect the matter field (ICs, perturbedfield, halos).

Variables:
  • HMF – Determines which halo mass function to be used for the normalisation of the collapsed fraction (default Sheth-Tormen). Should be one of the following codes: PS (Press-Schechter) ST (Sheth-Tormen) Watson (Watson FOF) Watson-z (Watson FOF-z) Delos (Delos+23) Reed07 (Reed+07; arXiv:0607150) Yung24 (Yung+24; arXiv:2304.04348)

  • USE_RELATIVE_VELOCITIES (int, optional) – Flag to decide whether to use relative velocities. If True, POWER_SPECTRUM is automatically set to 5. Default False.

  • POWER_SPECTRUM

    Determines which power spectrum to use, default EH (unless USE_RELATIVE_VELOCITIES is True). Use the following codes:

    • EH : Eisenstein & Hu 1999

    • BBKS: Bardeen et al. 1986

    • EFSTATHIOU: Efstathiou et al. 1992

    • PEEBLES: Peebles 1980

    • WHITE: White 1985

    • CLASS: Uses fits from the CLASS code

  • PERTURB_ON_HIGH_RES – Whether to perform the Zel’Dovich or 2LPT perturbation on the low or high resolution grid.

  • USE_FFTW_WISDOM – Whether or not to use stored FFTW_WISDOMs for improving performance of FFTs

  • USE_INTERPOLATION_TABLES

    Defines the interpolation tables used in the code. Default is ‘hmf-interpolation’. There are three levels available:

    • ’no-interpolation’: No interpolation tables are used.

    • ’sigma-interpolation’: Interpolation tables are used for sigma(M) only.

    • ’hmf-interpolation’: Interpolation tables are used for sigma(M) the halo mass

    function.

  • PERTURB_ALGORITHM – Whether to use second-order Lagrangian perturbation theory (2LPT), Zel’dovich (ZELDOVICH), or linear evolution (LINEAR). Set this to 2LPT if the density field or the halo positions are extrapolated to low redshifts. The current implementation is very naive and adds a factor ~6 to the memory requirements. Reference: Scoccimarro R., 1998, MNRAS, 299, 1097-1118 Appendix D.

  • MINIMIZE_MEMORY – If set, the code will run in a mode that minimizes memory usage, at the expense of some CPU/disk-IO. Good for large boxes / small computers.

  • SAMPLE_METHOD

    The sampling method to use in the halo sampler when calculating progenitor populations:

    • MASS-LIMITED : Mass-limited CMF sampling, where samples are drawn until the expected mass is reached

    • NUMBER-LIMITED : Number-limited CMF sampling, where we select a number of halos from the Poisson distribution and then sample the CMF that many times

    • PARTITION : Sheth et al 1999 Partition sampling, where the EPS collapsed fraction is sampled (gaussian tail) and then the condition is updated using the conservation of mass.

    • BINARY-SPLIT : Parkinson et al 2008 Binary split model as in DarkForest (Qiu et al 2021) where the EPS merger rate is sampled on small internal timesteps such that only binary splits can occur.

    Note

    The initial sampling from the density grid will ALWAYS use NUMBER-LIMITED sampling (method 1)

  • FILTER – Filter to use for sigma (matter field variance) and radius to mass conversions. available options are: spherical-tophat and gaussian

  • HALO_FILTER – Filter to use for the DexM halo finder. available options are: spherical-tophat, sharp-k and gaussian

  • SMOOTH_EVOLVED_DENSITY_FIELD – Smooth the evolved density field after perturbation.

  • DEXM_OPTMIZE – Use a faster version of the DexM halo finder which excludes halos from forming within a certain distance of larger halos.

  • KEEP_3D_VELOCITIES – Whether to keep the 3D velocities in the ICs. If False, only the z velocity is kept.

  • SOURCE_MODEL

    The source model to use in the simulation. Options are:

    • E-INTEGRAL: The traditional excursion-set formalism, where source properties are defined on the Eulerian grid after 2LPT in regions of filter scale R (see the X_FILTER options for filter shapes). This integrates over the CHMF using the smoothed density grids, then multiplies the result by (1 + delta) to get the source properties in each cell.

    • CONST-ION-EFF: Similar to E-INTEGRAL, but ionizing efficiency is constant and does not depend on the halo mass (see Mesinger+ 2010).

    • L-INTEGRAL: Analagous to the ‘ESF-L’ model described in Trac+22, where source properties are defined on the Lagrangian (IC) grid by integrating the CHMF prior to the IGM physics and then mapping properties to the Eulerian grid using 2LPT.

    • DEXM-ESF: The DexM excursion-set formalism, where discrete halo catalogues are generated on the Lagrangian (IC) grid using an excursion-set halo finder. Source properties are defined on the Lagrangian grid and then mapped to the Eulerian grid using 2LPT. This model utilised the ‘L-INTEGRAL’ method for halos below the DexM mass resolution, which is the mass of the high-resolution (DIM^3) cells.

    • CHMF-SAMPLER: The CHMF sampler, where discrete halo catalogues are generated by sampling the CHMF on the IC grid, between the low-resolution (HII_DIM^3) cell mass and a minimum mass defined by the user (SAMPLER_MIN_MASS). This model uses the ‘L-INTEGRAL’ method for halos below the SAMPLER_MIN_MASS, and the ‘DEXM-ESF’ method for halos above the HII_DIM cell mass.

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
DEXM_OPTIMIZE: bool
FILTER: FilterOptions
HALO_FILTER: FilterOptions
HMF: Literal['PS', 'ST', 'WATSON', 'WATSON-Z', 'DELOS', 'REED07', 'YUNG24']
KEEP_3D_VELOCITIES: bool
MINIMIZE_MEMORY: bool
PERTURB_ALGORITHM: Literal['LINEAR', 'ZELDOVICH', '2LPT']
PERTURB_ON_HIGH_RES: bool
POWER_SPECTRUM: Literal['EH', 'BBKS', 'EFSTATHIOU', 'PEEBLES', 'WHITE', 'CLASS']
SAMPLE_METHOD: Literal['MASS-LIMITED', 'NUMBER-LIMITED', 'PARTITION', 'BINARY-SPLIT']
SMOOTH_EVOLVED_DENSITY_FIELD: bool
SOURCE_MODEL: Literal['CONST-ION-EFF', 'E-INTEGRAL', 'L-INTEGRAL', 'DEXM-ESF', 'CHMF-SAMPLER']
USE_FFTW_WISDOM: bool
USE_INTERPOLATION_TABLES: Literal['no-interpolation', 'sigma-interpolation', 'hmf-interpolation']
USE_RELATIVE_VELOCITIES: 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

property has_discrete_halos: bool

Whether the current options will produce discrete halo catalogues.

Return type:

bool

property lagrangian_source_grid: bool

Whether the current source model is Lagrangian.

Return type:

bool

property mass_dependent_zeta: bool

Whether the current source model uses mass-dependent zeta.

Return type:

bool