py21cmfast.drivers.coeval¶
Compute simulations that evolve over redshift.
Attributes¶
Classes¶
A full coeval box with all associated data. |
Functions¶
|
Evolve and perturb halo fields across multiple redshifts. |
|
Perform a full coeval simulation of all fields at given redshifts. |
|
Run a coeval simulation and return the resulting coeval boxes. |
Module Contents¶
- py21cmfast.drivers.coeval.evolve_halos(inputs, all_redshifts, write, initial_conditions, cache, regenerate, free_cosmo_tables, progressbar=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:
all_redshifts (list[float])
initial_conditions (py21cmfast.wrapper.outputs.InitialConditions)
regenerate (bool)
free_cosmo_tables (bool)
progressbar (bool)
- py21cmfast.drivers.coeval.generate_coeval(*, inputs=None, out_redshifts=(), regenerate=None, write=True, cache=None, initial_conditions=None, cleanup=True, progressbar=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_redshiftsparameter. 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 byout_redshifts. If not set,out_redshiftswill be set toinputs.node_redshifts, so that all computed redshifts are returned as coeval boxes.Note
User-supplied
out_redshiftsare not used in the redshift evolution, so that the results depend precisely on thenode_redshiftsdefined in the input parameters.- Parameters:
inputs (
InputParameters) – This object specifies the input parameters for the run, including the random seedout_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 aCacheConfigobject 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 ofOutputCache, 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, theinputsdo not need to be defined (but can be, in order to overwrite thenode_redshifts).cleanup (bool, optional) – A flag to specify whether the C routine cleans up its memory before returning. Typically, if spin_temperature is called directly, you will want this to be true, as if the next box to be calculated has different shape, errors will occur if memory is not cleaned. Note that internally, this is set to False until the last iteration.
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 inout_redshifts.- Parameters:
inputs (py21cmfast.wrapper.inputs.InputParameters | None)
out_redshifts (float | tuple[float])
regenerate (bool | None)
write (py21cmfast.io.caching.CacheConfig | bool)
cache (py21cmfast.io.caching.OutputCache | None)
initial_conditions (py21cmfast.wrapper.outputs.InitialConditions | None)
cleanup (bool)
progressbar (bool)
- py21cmfast.drivers.coeval.run_coeval(**kwargs)[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 togenerate_coeval().- Return type:
list[Coeval]