Skip to content

Commit

Permalink
deploy: 697ce40
Browse files Browse the repository at this point in the history
  • Loading branch information
jmd-dk committed Apr 8, 2024
1 parent f33a69d commit 2ca738e
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 160 deletions.
29 changes: 4 additions & 25 deletions _sources/parameters/input_output.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ CO\ *N*\ CEPT run.
.. caution::
Leaving out certain data when reading in snapshots
will result in components not being fully
initialized, e.g. in this example all particles
initialised, e.g. in this example all particles
loaded from disk will not have any momenta assigned
(not even :math:`0`). Running a simulation with such
a partially initialised component will result in a
Expand Down Expand Up @@ -1487,26 +1487,6 @@ CO\ *N*\ CEPT run.

* ``τ`` or ``tau``: The conformal time :math:`\tau` (in
CLASS called ``conf. time [Mpc]``).
* ``D``: The linear growth factor :math:`D` (in CLASS
called ``gr.fac. D``).
* ``f``: The linear growth rate
:math:`f \equiv \mathrm{d}\ln D / \mathrm{d}\ln a`
(in CLASS called ``gr.fac. f``).
* ``D2``: The second-order growth factor :math:`D^{(2)}`
(in CLASS called ``gr.fac. D2``).
* ``f2``: The second-order growth rate
:math:`f^{(2)} \equiv \mathrm{d}\ln D^{(2)} / \mathrm{d}\ln a`
(in CLASS called ``gr.fac. f2``).

.. note::
When running the
:doc:`class utility </utilities/class>`, the
``class_extra_background`` parameter is by default
set to

.. code-block:: python3
{'tau', 'D', 'f', 'D2', 'f2'}
-- --------------- -- -
\ **Example 0** \ Include the conformal time :math:`\tau` among the
CLASS background quantities when dumping these to disk,
Expand All @@ -1523,15 +1503,14 @@ CO\ *N*\ CEPT run.
class_extra_background = 'conf. time [Mpc]'
-- --------------- -- -
\ **Example 1** \ Include the linear growth factor :math:`D` and rate
:math:`f` among the background quantities when dumping
\ **Example 1** \ Include the luminosity distance and the angular diameter
distance among the background quantities when dumping
these to disk, e.g. when running the CO\ *N*\ CEPT
:doc:`class utility </utilities/class>`:

.. code-block:: python3
class_extra_background = {'D', 'f'}
class_extra_background = {'lum. dist.', 'ang.diam.dist.'}
== =============== == =


Expand Down
34 changes: 27 additions & 7 deletions _sources/parameters/physics.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ physical models and schemes to be used.
'LPT': {
'default': 1,
},
'dealias': {
'default': False,
},
'non-Gaussianity': {
'default': 0.0,
},
Expand Down Expand Up @@ -313,12 +316,15 @@ physical models and schemes to be used.

* ``'LPT'``: Specifies the order of Lagrangian
perturbation theory to use when realising particle
components. Orders :math:`1` and :math:`2` are
available. While the first order (1LPT) is carried out
relativistically (if not using back-scaling), the
second-order (2LPT) contributions are always
constructed in a Newtonian fashion (though they are
build from the (relativistic) 1LPT results).
components. Orders :math:`1`, :math:`2` and :math:`3`
are available. While the first order (1LPT) is carried
out relativistically (if not using back-scaling), the
higher order corrections are always constructed in a
Newtonian fashion (though they are built out of the
relativistic 1LPT results).

* ``'dealias'``: Specifies whether aliasing defects
should be removed during 2LPT and 3LPT computations.

* ``'non-Gaussianity'``: Sets the amount of local
non-Gaussianity to include in realisations. This is
Expand Down Expand Up @@ -445,7 +451,21 @@ physical models and schemes to be used.
'LPT': 2,
}
-- --------------- -- -
\ **Example 2** \ Always perform realisations using the primordial noise
\ **Example 2** \ Make use of dealiased third-order Lagrangian
perturbation theory (3LPT) when realising
particle components:

.. code-block:: python3
realization_options = {
'LPT': 3,
'dealias': True,
}
This is the most expensive but also most accurate
particle realisation scheme implemented.
-- --------------- -- -
\ **Example 3** \ Always perform realisations using the primordial noise
as the underlying source of structure, regardless of the
time of realisation:

Expand Down
52 changes: 35 additions & 17 deletions _sources/tutorial/bispectra.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,24 @@ together in a single plot, for which we make use of the plotting script below:
# Plotting functions
def plot1D(conf):
def get_color(a, lpt=1):
color = np.asarray(
matplotlib.colors.ColorConverter().to_rgb(f'C{a_values.index(a)%10}')
)
color /= (1 + 2/3*(lpt - 1))
def get_color(a, lpt=1, color=None):
if color is None:
color = f'C{a_values.index(a)%10}'
color = np.asarray(matplotlib.colors.ColorConverter().to_rgb(color))
color /= (1 + 0.4*(lpt - 1))
return color
def get_linestyle(lpt):
return {1: '-', 2: '--', 3: ':'}.get(lpt, '-.')
fig, axes = plt.subplots(2, sharex=True)
for lpt in lpts:
linestyle = get_linestyle(lpt)
for a in a_values:
subdata = data.get((conf, lpt, a))
if subdata is None:
continue
k = subdata['k']
axes[0].loglog (k, subdata['B'], '-', color=get_color(a, lpt))
axes[1].semilogx(k, subdata['Q'], '-', color=get_color(a, lpt))
axes[0].loglog (k, subdata['B'], linestyle, color=get_color(a, lpt))
axes[1].semilogx(k, subdata['Q'], linestyle, color=get_color(a, lpt))
axes[0].loglog (k, subdata['B_tree'], 'k--', linewidth=1)
axes[1].semilogx(k, subdata['Q_tree'], 'k--', linewidth=1)
axes[0].set_xlim(k[0], k[-1])
Expand All @@ -183,9 +186,10 @@ together in a single plot, for which we make use of the plotting script below:
)
for lpt in lpts:
axes[1].plot(
0.5, 0.5, '-',
0.5, 0.5, get_linestyle(lpt),
color=get_color(1, lpt, 'grey'),
transform=axes[1].transAxes,
color=get_color(a_values[0], lpt), label=f'simulation: {lpt}LPT',
label=f'simulation: {lpt}LPT',
)
axes[1].plot(
0.5, 0.5, 'k--',
Expand Down Expand Up @@ -453,11 +457,11 @@ prediction.
The reason for the mismatch between the simulation initial conditions and the
perturbative tree-level prediction is that the former makes use of first-order
(Lagrangian) perturbation theory while the latter is a second-order result.
While CO\ *N*\ CEPT uses first-order Lagrangian perturbation theory (1LPT) to
assign initial particle positions and momenta (through what is often referred
to as the Zel'dovich approximation), a second-order (2LPT) correction can
optionally be applied on top. The order of LPT to use is specified by the
``'LPT'`` sub-parameter of the ``realization_options``
By default, CO\ *N*\ CEPT uses first-order Lagrangian perturbation theory
(1LPT) to assign initial particle positions and momenta (through what is often
referred to as the Zel'dovich approximation), though second-order (2LPT)
corrections can optionally be applied on top. The order of LPT to use is
specified by the ``'LPT'`` sub-parameter of the ``realization_options``
:ref:`parameter <realization_options>`, which defaults to ``1``. In
:ref:`our parameter file <param-bispec>`, this is controlled through the
``_lpt`` helper variable.
Expand All @@ -481,7 +485,7 @@ this time with ``_lpt = 2``:
Once again, these new results will not overwrite any of the old. While you can
in fact update the plot continually while the above simulations are busy being
carried out, you should suspend any judgement until they are all complete. The
2LPT results will be shown as darkened versions of the colours used for 1LP.
2LPT results will appear as dashed lines.

With the plot updated following the completion of every simulation, we see that
opting for 2LPT indeed leads to excellent agreement with the tree-level
Expand All @@ -506,6 +510,20 @@ If you would like to see still better convergence of the bispectrum, feel free
to run even more paired simulations with different seeds (using 2LPT, 1LPT,
or both).

.. note::
CO\ *N*\ CEPT further implements 3LPT, which given our
:ref:`parameter file <param-bispec>` you can enable via ``_lpt = 3``.
The changes to the bispectrum when upgrading from 2LPT to 3LPT are however
much less dramatic than the changes from 1LPT to 2LPT. In fact, given the
parameters set in our :ref:`parameter file <param-bispec>`, the difference
will be virtually impossible to see from the plots generated by our
:ref:`plotting script <plot-bispec>`. For 3LPT to be a significant
improvement upon 2LPT, we need to initialise later and/or simulate
smaller scales than what we have just done. For example, changing to
``a_begin = 0.08`` and ``boxsize = 128*Mpc`` and then rerunning everything
using ``_lpt = 1``, ``_lpt = 2`` and ``_lpt = 3``, differences between 2LPT
and 3LPT will show up in the generated plot at high :math:`k`.



.. raw:: html
Expand All @@ -514,7 +532,7 @@ or both).

Let us now consider bispectrum configurations different from the equilateral
case. Another commonly studied case is that of the "squeezed" bispectrum,
where one of the triangle legs (one of the three :math:`k` values) are much
where one of the triangle legs (one of the three :math:`k` values) is much
smaller than the other two. The configuration to use is controlled by the
``'configuration'`` sub-parameter of the ``bispec_options``
:ref:`parameter <bispec_options>`, which in the
Expand Down Expand Up @@ -569,7 +587,7 @@ showing only the 2LPT (as we did not compute the squeezed bispectra for the
at the lower :math:`Q` panel, the agreement between the simulation measurements
and the tree-level predictions does not appear to be as good as for the
equilateral configurations. From this it is clear that we cannot generally
expect our simulations to be initialized with a bispectrum matching the
expect our simulations to be initialised with a bispectrum matching the
tree-level prediction for a general triangle configuration, even when
using 2LPT. The striking agreement we found for the equilateral configurations
then appears even more incredible. Looking at the upper :math:`B` panel of
Expand Down
84 changes: 44 additions & 40 deletions _sources/utilities/class.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,43 @@ Data layout
~~~~~~~~~~~
The data layout within ``class_processed.hdf5`` is as follows:

* ``background``: Group containing various background quantities, tabulated
at a common 1D time grid:

* ``a``: Data set of scale factor :math:`a` values at which all background
quantities are tabulated.
* ``z``: Data set of redshift :math:`z` values at which all background
quantities are tabulated.
* ``t``: Data set of cosmic time :math:`t` values at which all background
quantities are tabulated.
* ``background``: Group containing data sets for various background
quantities, tabulated at a common 1D time grid:

* ``a``: Scale factor :math:`a` values at which all background quantities
are tabulated.
* ``z``: Redshift :math:`z` values at which all background quantities
are tabulated.
* ``t``: Cosmic time :math:`t` values at which all background quantities
are tabulated.
* ``tau``: Conformal time :math:`\tau`. values at which all background quantities
are tabulated.
* ``H``: The Hubble parameter :math:`H`.
* ``rho_<species>`` with ``<species>`` some CLASS species: The background
energy density :math:`\bar{\rho}` of the given species. The critical
'``crit``' and total '``tot``' energy densities are present as well.
* ``p_<species>`` with ``<species>`` some CLASS species: The background
pressure :math:`\bar{P}` of the given species.

When running the CO\ *N*\ CEPT class utility, the ``class_extra_background``
:ref:`parameter <class_extra_background>` is by default populated with the
following values:

.. code-block:: python3
class_extra_background = {'tau', 'D', 'f', 'D2', 'f2'}
which then further adds the following background quantities:

* ``tau``: The conformal time :math:`\tau`.
* ``D``: First-order (linear) growth factor :math:`D = D^{(1)}`.
* ``D``: First-order (linear) growth factor :math:`D = D^{(1)}`, with the
convention :math:`D^{(1)}(a=1) = 1`.
* ``f``: First-order (linear) growth rate
:math:`f = f^{(1)} \equiv \mathrm{d}\ln D / \mathrm{d}\ln a`.
* ``D2``: Second-order growth factor :math:`D^{(2)}`.
:math:`f = f^{(1)} \equiv \mathrm{d}\ln D^{(1)} / \mathrm{d}\ln a`.
* ``D2``: Second-order growth factor :math:`D^{(2)}`, with the
convention :math:`D^{(2)} > 0`.
* ``f2``: Second-order growth rate
:math:`f^{(2)} \equiv \mathrm{d}\ln D^{(2)} / \mathrm{d}\ln a`.
* ``D3a``: Third-order growth factor :math:`D^{(3\text{a})}`, with the
convention :math:`D^{(3\text{a})} > 0`.
* ``f3a``: Third-order growth rate
:math:`f^{(3\text{a})} \equiv \mathrm{d}\ln D^{(3\text{a})} / \mathrm{d}\ln a`.
* ``D3b``: Third-order growth factor :math:`D^{(3\text{b})}`, with the
convention :math:`D^{(3\text{b})} > 0`.
* ``f3a``: Third-order growth rate
:math:`f^{(3\text{b})} \equiv \mathrm{d}\ln D^{(3\text{b})} / \mathrm{d}\ln a`.
* ``D3c``: Third-order growth factor :math:`D^{(3\text{c})}`, with the
convention :math:`D^{(3\text{c})} > 0`.
* ``f3c``: Third-order growth rate
:math:`f^{(3\text{c})} \equiv \mathrm{d}\ln D^{(3\text{c})} / \mathrm{d}\ln a`.

In addition to the above datasets, this group also stores some attributes,
namely the reduced Hubble constant ``h`` (given by
Expand Down Expand Up @@ -450,22 +454,22 @@ various data sets are expressed:
.. table::
:align: center

====================================================================== ============================
.. centered:: Quantity .. centered:: Unit (default)
====================================================================== ============================
Scale factor ``a`` and redshift ``z`` .. centered:: :math:`[1]`
Cosmic time ``t`` and conformal time ``tau`` .. centered:: :math:`[\text{Gyr}]`
Fourier mode ``k`` .. centered:: :math:`[\text{Mpc}^{-1}]`
Hubble parameter ``H`` .. centered:: :math:`[\text{Gyr}^{-1}]`
Growth factors ``D``, ``D2`` and rates ``f``, ``f2`` .. centered:: :math:`[1]`
Background energy density ``rho`` .. centered:: :math:`[10^{10}\, m_{\odot}\, \text{Mpc}^{-3}]`
Energy density contrast ``delta`` .. centered:: :math:`[1]`
Velocity divergence ``theta`` .. centered:: :math:`[\text{Gyr}^{-1}]`
Pressure background ``p`` and perturbation ``deltaP`` .. centered:: :math:`[10^{10}\, m_{\odot}\, \text{Mpc}^{-1}\,\text{Gyr}^{-2}]`
Shear stress ``sigma`` .. centered:: :math:`[\text{Mpc}^2\,\text{Gyr}^{-2}]`
Metric perturbations ``phi`` and ``psi`` .. centered:: :math:`[\text{Mpc}^2\,\text{Gyr}^{-2}]`
Time derivatives of metric perturbations ``h_prime`` and ``H_T_prime`` .. centered:: :math:`[\text{Gyr}^{-1}]`
====================================================================== ============================
========================================================================================================== ============================
.. centered:: Quantity .. centered:: Unit (default)
========================================================================================================== ============================
Scale factor ``a`` and redshift ``z`` .. centered:: :math:`[1]`
Cosmic time ``t`` and conformal time ``tau`` .. centered:: :math:`[\text{Gyr}]`
Fourier mode ``k`` .. centered:: :math:`[\text{Mpc}^{-1}]`
Hubble parameter ``H`` .. centered:: :math:`[\text{Gyr}^{-1}]`
Growth factors ``D``, ``D2``, ``D3a``, ``D3b``, ``D3c`` and rates ``f``, ``f2``, ``f3a``, ``f3b``, ``f3c`` .. centered:: :math:`[1]`
Background energy density ``rho`` .. centered:: :math:`[10^{10}\, m_{\odot}\, \text{Mpc}^{-3}]`
Energy density contrast ``delta`` .. centered:: :math:`[1]`
Velocity divergence ``theta`` .. centered:: :math:`[\text{Gyr}^{-1}]`
Pressure background ``p`` and perturbation ``deltaP`` .. centered:: :math:`[10^{10}\, m_{\odot}\, \text{Mpc}^{-1}\,\text{Gyr}^{-2}]`
Shear stress ``sigma`` .. centered:: :math:`[\text{Mpc}^2\,\text{Gyr}^{-2}]`
Metric perturbations ``phi`` and ``psi`` .. centered:: :math:`[\text{Mpc}^2\,\text{Gyr}^{-2}]`
Time derivatives of metric perturbations ``h_prime`` and ``H_T_prime`` .. centered:: :math:`[\text{Gyr}^{-1}]`
========================================================================================================== ============================

.. tip::
If you need the Hubble parameter ``H`` in its canonial units of
Expand Down
Loading

0 comments on commit 2ca738e

Please sign in to comment.