py21cmfast.drivers.coeval

Compute simulations that evolve over redshift.

Attributes

Classes

Coeval

A full coeval box with all associated data.

Functions

evolve_halos(inputs, all_redshifts, write, ...[, ...])

Evolve and perturb halo fields across multiple redshifts.

generate_coeval(*[, inputs, out_redshifts, ...])

Perform a full coeval simulation of all fields at given redshifts.

run_coeval(→ list[Coeval])

Run a coeval simulation and return the resulting coeval boxes.

Module Contents

py21cmfast.drivers.coeval.evolve_halos(inputs: py21cmfast.wrapper.inputs.InputParameters, all_redshifts: list[float], write: py21cmfast.io.caching.CacheConfig, initial_conditions: py21cmfast.wrapper.outputs.InitialConditions, cache: py21cmfast.io.caching.OutputCache, regenerate: bool, progressbar: bool = False)[source]

Evolve and perturb halo fields across multiple redshifts.

This function computes and evolves halo fields for a given set of redshifts, applying perturbations to each halo list. It processes redshifts in reverse order to account for descendant halos.

Parameters:
  • inputs (InputParameters) – Input parameters for the simulation.

  • all_redshifts (list[float]) – List of redshifts to process, in descending order.

  • write (CacheConfig) – Configuration for writing output to cache.

  • initial_conditions (InitialConditions) – Initial conditions for the simulation.

  • cache (OutputCache) – Cache object for storing and retrieving computed results.

  • regenerate (bool) – Flag to indicate whether to regenerate results or use cached values.

  • progressbar (bool, optional) – If True, a progress bar will be displayed throughout the simulation. Defaults to False.

Returns:

list – A list of perturbed halo fields for each redshift, in ascending redshift order. Returns an empty list if halo fields are not used or fixed grids are enabled.

Parameters:
py21cmfast.drivers.coeval.generate_coeval(*, inputs: py21cmfast.wrapper.inputs.InputParameters | None = None, out_redshifts: float | tuple[float, ...] = (), regenerate: bool | None = None, write: py21cmfast.io.caching.CacheConfig | bool = True, cache: py21cmfast.io.caching.OutputCache | None = None, initial_conditions: py21cmfast.wrapper.outputs.InitialConditions | None = None, progressbar: bool = False)[source]

Perform a full coeval simulation of all fields at given redshifts.

This is generally the easiest and most efficient way to generate a set of coeval cubes at a given set of redshifts. It self-consistently deals with situations in which the field needs to be evolved, and does this with the highest memory-efficiency, only returning the desired redshift. All other calculations are by default stored in the on-disk cache so they can be re-used at a later time.

Some calculations of the coeval quantities require redshift evolution, i.e. the calculation of higher-redshift coeval boxes up to some maximum redshift in order to integrate the quantities over cosmic time. The redshifts that define this evolution are set by the inputs.node_redshifts parameter. However, in some simple cases, this evolution is not required, and this parameter can be empty. Thus there is a distinction between the redshifts required for computing the physics (i.e. inputs.node_redshifts) and the redshifts at which the user wants to obtain the resulting coeval cubes. The latter is controlled by out_redshifts. If not set, out_redshifts will be set to inputs.node_redshifts, so that all computed redshifts are returned as coeval boxes.

Note

User-supplied out_redshifts are not used in the redshift evolution, so that the results depend precisely on the node_redshifts defined in the input parameters.

Parameters:
  • inputs (InputParameters) – This object specifies the input parameters for the run, including the random seed

  • out_redshifts (array_like, optional) – A single redshift, or multiple redshifts, at which to return results. By default, use all the inputs.node_redshifts. If neither is specified, an error will be raised.

  • regenerate (bool) – If True, regenerate all fields, even if they are in the cache.

  • write (CacheConfig, optional) – Either a bool specifying whether to write _all_ the boxes to cache (or none of them), or a CacheConfig object specifying which boxes to write.

  • cache (OutputCache, optional) – The cache object to use for reading and writing data from the cache. This should be an instance of OutputCache, which depends solely on specifying a directory to host the cache.

  • initial_conditions (InitialConditions, optional) – If given, use these intial conditions as a basis for computing the other fields, instead of re-computing the ICs. If this is defined, the inputs do not need to be defined (but can be, in order to overwrite the node_redshifts).

  • progressbar (bool, optional) – If True, a progress bar will be displayed throughout the simulation. Defaults to False.

Returns:

coevals (list of Coeval) – The full data for the Coeval class, with init boxes, perturbed fields, ionized boxes, brightness temperature, and potential data from the conservation of photons. A list of such objects, one for each redshift in out_redshifts.

Parameters:
py21cmfast.drivers.coeval.run_coeval(**kwargs) → list[Coeval][source]

Run a coeval simulation and return the resulting coeval boxes.

This simply wraps generate_coeval() and returns a list of coeval objects at the requested output redshifts after the generator has been exhausted. All parameters are passed directly to generate_coeval().

Return type:

list[Coeval]

py21cmfast.drivers.coeval.logger[source]