py21cmfast.wrapper.inputs.CosmoParams

class py21cmfast.wrapper.inputs.CosmoParams

Bases: InputStruct

Cosmological parameters.

Default parameters are based on Plank18, Table 2, last column [TT,TE,EE+lowE+lensing+BAO].

Variables:
  • hlittle (float) – The hubble parameter, \(H_0/100\).

  • OMm (float) – The fractional matter density, \(\Omega_m\). This is the sum of the baryon and CDM densities.

  • OMb (float) – The fraction baryon density, \(\Omega_b\).

  • POWER_INDEX (float) – Spectral index of the power spectrum, \(n_s\)

  • SIGMA_8 (float) – RMS mass variance of the matter field in spheres of 8 Mpc/h (power spectrum normalisation). If not given explicitly but A_s is given, it is auto-calculated via A_s and the other cosmological parameters. Only one of SIGMA_8 and A_s can be given, otherwise an error is raised. If neither is given, it is set to the default value of 0.8102.

  • A_s (float) – Amplitude of primordial curvature power spectrum, at \(k_{pivot} = 0.05 {\rm Mpc}^{-1}\). If not given explicitly and SIGMA_8 is given, it is auto-calculated via SIGMA_8 and the other cosmological parameters, using CLASS. Only one of SIGMA_8 and A_s can be given, otherwise an error is raised. If neither is given, it is set to the default value of 2.105e-9.

  • base_cosmo (astropy.cosmology.FLRW, optional) – The base astropy cosmology object to use for this cosmology. You can set this to something other than LambdaCDM if you want to use a different cosmology. Note that the cosmological parameters in base_cosmo are not used at all—only the cosmography. You almost certainly should not set this to anything other than the default, unless you know what you are doing.

  • OMn (float) – Omega neutrino, the neutrino component. Note that this is not used in any of the calculations in the code, but is just provided for completeness.

  • OMk (float) – Omega curvature, the curvature component. Note that this is not used in any of the calculations in the code, but is just provided for completeness.

  • OMr (float) – Omega radiation, the radiation component. Note that this is not used in any of the calculations in the code, but is just provided for completeness.

  • OMtot (float) – Omega total, the total density. Note that this is not used in any of the calculations and is assumed to be unity (i.e. a flat universe), but is just provided for completeness.

  • Y_He (float) – Helium mass fraction.

  • wl (float) – Dark energy equation of state parameter.

asdict() dict

Return a dict representation of the instance.

Examples

This dict is 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_astropy(cosmo: astropy.cosmology.FLRW, **kwargs)

Create a CosmoParams object from an astropy cosmology object.

Pass SIGMA_8 and POWER_INDEX as kwargs if you want to override the default values.

Parameters:

cosmo (astropy.cosmology.FLRW)

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
property A_s: float

Amplitude of primordial curvature power spectrum, at k_pivot = 0.05 Mpc^-1.

If not given explicitly, it is auto-calculated via sigma_8 and the other cosmological parameters.

Return type:

float

OMb: float
OMk: float
property OMl

Omega lambda, dark energy density.

OMm: float
OMn: float
OMr: float
OMtot: float
POWER_INDEX: float
property SIGMA_8: float

RMS mass variance (power spectrum normalisation).

If not given explicitly, it is auto-calculated via A_s and the other cosmological parameters.

Return type:

float

Y_He: float
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 cosmo

An astropy cosmology object for this cosmology.

hlittle: float
wl: float