Skip to content

Commit

Permalink
👌 allow early-time Δa limiter to be 0 (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmd-dk authored Feb 8, 2024
1 parent d3bcc86 commit 41f5665
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
24 changes: 20 additions & 4 deletions doc/parameters/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,22 @@ random numbers used for the primordial noise.
Δa_max_early = 0.0008
-- --------------- -- -
\ **Example 1** \ Effectively disregard this limiter completely by setting
\ **Example 1** \ Ignore this limiter by setting it equal to :math:`0`:

.. code-block:: python3
Δa_max_early = 0
.. note::
As the instantaneous Hubble time :math:`H^{-1}` is
part of the same limiter as the early-time
:math:`\Delta a` (see the paper on
':ref:`The cosmological simulation code CO𝘕CEPT 1.0<the_cosmological_simulation_code_concept_10>`'),
doing this means that :math:`H^{-1}` will be used to
set the global time step size at early times,
leading to finer time-stepping at such times.
-- --------------- -- -
\ **Example 2** \ Effectively disregard this limiter completely by setting
it equal to its
:ref:`late-time version <Deltaa_max_late>`:

Expand All @@ -210,10 +225,11 @@ random numbers used for the primordial noise.
.. note::
As the instantaneous Hubble time :math:`H^{-1}` is
part of the same limiter as the early-time
:math:`\Delta a` (again, see the paper on
:math:`\Delta a` (see the paper on
':ref:`The cosmological simulation code CO𝘕CEPT 1.0<the_cosmological_simulation_code_concept_10>`'),
this also removes any explicit limitation of the
global time step size due to :math:`H^{-1}`.
doing this effectively also removes any explicit
limitation of the global time step size due
to :math:`H^{-1}`.
== =============== == =


Expand Down
4 changes: 2 additions & 2 deletions src/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5891,8 +5891,8 @@ def open_hdf5(filename, raise_exception=False, **kwargs):
# The maximum allowed Δa at late times is supposed to be bigger than the
# maximum allowed value of Δa at early times,
# and they must both be positive.
if Δa_max_early <= 0:
abort('You must have Δa_max_early > 0')
if Δa_max_early < 0:
abort('You must have Δa_max_early 0')
if Δa_max_late <= 0:
abort('You must have Δa_max_late > 0')
if Δa_max_early > Δa_max_late:
Expand Down
13 changes: 7 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,13 @@ def get_base_timestep_size(components, static_timestepping_func=None):
Δt_hubble = fac_hubble/H
bottleneck_hubble = 'the Hubble time'
# Constant Δa overrule Hubble at early times
a_next = a + Δa_max_early
if a_next < 1:
Δt_Δa_early = Δt_base_background_factor*(cosmic_time(a_next) - t)
if Δt_Δa_early > Δt_hubble:
Δt_hubble = Δt_Δa_early
bottleneck_hubble = 'the maximum allowed Δa (early)'
if Δa_max_early > 0:
a_next = a + Δa_max_early
if a_next < 1:
Δt_Δa_early = Δt_base_background_factor*(cosmic_time(a_next) - t)
if Δt_Δa_early > Δt_hubble:
Δt_hubble = Δt_Δa_early
bottleneck_hubble = 'the maximum allowed Δa (early)'
if Δt_hubble < Δt_max:
Δt_max = Δt_hubble
bottleneck = bottleneck_hubble
Expand Down

0 comments on commit 41f5665

Please sign in to comment.