py21cmfast.MatterOptions

class py21cmfast.MatterOptions

Bases: InputStruct

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

Parameters:
  • HMF (str, optional) – 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)

  • 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 (str, optional) – 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 (bool, optional) – Whether to perform the Zel’Dovich or 2LPT perturbation on the low or high resolution grid.

  • USE_FFTW_WISDOM (bool, optional) – Whether or not to use stored FFTW_WISDOMs for improving performance of FFTs

  • USE_INTERPOLATION_TABLES (str, optional) – 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 (str, optional) – 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 (bool, optional) – 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 (str, optional) – 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 : Parkinsson 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 (string, optional) – Filter to use for sigma (matter field variance) and radius to mass conversions. available options are: spherical-tophat and gaussian

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

  • SMOOTH_EVOLVED_DENSITY_FIELD (bool, optional) – Smooth the evolved density field after perturbation.

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

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

  • SOURCE_MODEL (str, optional) – 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.

    • 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.

classmethod __init_subclass__()

Store each subclass for easy access.

Return type:

None

__str__()

Human-readable string representation of the object.

Return type:

str

asdict()

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, safe=True)

Construct an instance of a parameter structure from a dictionary.

classmethod new(x=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

>>> up = SimulationOptions({'HII_DIM': 250})
>>> up.HII_DIM
250
>>> up = SimulationOptions(up)
>>> up.HII_DIM
250
>>> up = SimulationOptions()
>>> up.HII_DIM
200
>>> up = SimulationOptions(HII_DIM=256)
>>> up.HII_DIM
256
DEXM_OPTIMIZE: bool
FILTER: FilterOptions
HALO_FILTER: FilterOptions
HMF: Literal['PS', 'ST', 'WATSON', 'WATSON-Z', 'DELOS']
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 cstruct: py21cmfast.wrapper.structs.StructWrapper

The object pointing to the memory accessed by C-code for this struct.

Return type:

py21cmfast.wrapper.structs.StructWrapper

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

property struct: py21cmfast.wrapper.structs.StructWrapper

The python-wrapped struct associated with this input object.

Return type:

py21cmfast.wrapper.structs.StructWrapper