py21cmfast.wrapper.photoncons ============================= .. py:module:: py21cmfast.wrapper.photoncons .. autoapi-nested-parse:: Module for the photon conservation models. The excursion set reionisation model applied in ionize_box does not conserve photons. As a result there is an offset between the expected global ionized fraction and the value calculated from the ionized bubble maps. These models apply approximate corrections in order to bring the bubble maps more in line with the expected global values. The application of the model is controlled by the flag option PHOTON_CONS_TYPE, which can take 4 values: 0. No correction is applied 1. We use the ionizing emissivity grids from a different redshift when calculating ionized bubble maps, this mapping from one redshift to another is obtained by performing a calibration simulation and measuring its redshift difference with the expected global evolution. 2. The power-law slope of the ionizing escape fraction is adjusted, using a fit ALPHA_ESC -> X + Y*Q(z), where Q is the expected global ionized fraction. This relation is fit by performing a calibration simulation as in (1), and comparing it to a range of expected global histories with different power-law slopes. 3. The normalisation of the ionizing escape fraction is adjusted, using a fit F_ESC10 -> X + Y*Q(z), where Q is the expected global ionized fraction. This relation is fit by performing a calibration simulation as in (1), and taking its ratio with the expected global evolution. .. rubric:: Notes The function map for the photon conservation model looks like:: wrapper.run_lightcone/coeval() setup_photon_cons_correction() calibrate_photon_cons_correction() _init_photon_conservation_correction() --> computes and stores global evolution -->perfoms calibration simulation _calibrate_photon_conservation_correction() --> stores calibration evolution IF PHOTON_CONS_TYPE=='z-photoncons': lib.ComputeIonizedBox() lib.adjust_redshifts_for_photoncons() lib.determine_deltaz_for_photoncons() (first time only) --> calculates the deltaz array with some smoothing --> does more smoothing and returns the adjusted redshift ELIF PHOTON_CONS_TYPE=='alpha-photoncons': photoncons_alpha() --> computes and stores ALPHA_ESC shift vs global neutral fraction lib.ComputeIonizedBox() get_fesc_fit() --> applies the fit to the current redshift ELIF PHOTON_CONS_TYPE=='f-photoncons': photoncons_fesc() --> computes and stores F_ESC10 shift vs global neutral fraction lib.ComputeIonizedBox() get_fesc_fit() --> applies the fit to the current redshift .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: py21cmfast.wrapper.photoncons.logger Functions --------- .. autoapisummary:: py21cmfast.wrapper.photoncons.alpha_func py21cmfast.wrapper.photoncons.calibrate_photon_cons py21cmfast.wrapper.photoncons.get_photoncons_dz py21cmfast.wrapper.photoncons.photoncons_alpha py21cmfast.wrapper.photoncons.photoncons_fesc py21cmfast.wrapper.photoncons.setup_photon_cons Module Contents --------------- .. py:function:: alpha_func(Q, a_const, a_slope) Linear Function to fit in the simpler photon conservation model. .. !! processed by numpydoc !! .. py:function:: calibrate_photon_cons(inputs, initial_conditions, **kwargs) Perform a photon conservation calibration simulation. :Parameters: * **initial_conditions** (:class:`~InitialConditions`,) -- The InitialConditions instance to use for the photonconservation calculation * **inputs** (:class:`~InputParameters`,) -- An InputParameters instance. :Other Parameters: **See docs of :func:`compute_initial_conditions` for more information.** .. !! processed by numpydoc !! .. py:function:: get_photoncons_dz(inputs, redshift, **kwargs) Access the delta z arrays from the photon conservation model in C. .. !! processed by numpydoc !! .. py:function:: photoncons_alpha(inputs, **kwargs) Run the Simpler photons conservation model using ALPHA_ESC. This adjusts the slope of the escape fraction instead of redshifts to match a global evolution. .. !! processed by numpydoc !! .. py:function:: photoncons_fesc(inputs) Run the Even Simpler photon conservation model using F_ESC10. Adjusts the normalisation of the escape fraction to match a global evolution. .. !! processed by numpydoc !! .. py:function:: setup_photon_cons(initial_conditions, inputs = None, **kwargs) Set up the photon non-conservation correction. First performs a simplified calibration simulation and saves its neutral fraction history, to be matched to the analytic expression from solving the filling factor ODE. This matching can happen via a redshift adjustment, or an adjustment to the escape fraction power-law parameters :Parameters: * **initial_conditions** (:class:`~InitialConditions`,) -- The InitialConditions instance to use for the photonconservation calculation * **inputs** (:class:`~InputParameters`, optional) -- An InputParameters instance. If not given will taken from initial_conditions. :Other Parameters: **Any other parameters able to be passed to :func:`compute_initial_conditions`.** .. !! processed by numpydoc !! .. py:data:: logger