Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
CosmologicalDistances.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2021 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
24#include <cmath>
25
27#include "ElementsKernel/Real.h"
28
33
35
36namespace Euclid {
37namespace PhysicsUtils {
38
40 return Elements::Units::c_light * 1.0E3 / parameters.getHubbleConstant(); // in [pc]
41}
42
43double CosmologicalDistances::hubbleParameter(double z, const CosmologicalParameters& parameters) const {
44 double square = (1. + z) * (1. + z);
45 double cube = square * (1. + z);
46 return std::sqrt(parameters.getOmegaM() * cube + parameters.getOmegaK() * square + parameters.getOmegaLambda());
47}
48
50 double relative_precision) const {
51 if (z == 0) {
52 return 0.;
53 }
54
58
59 MathUtils::FunctionAdapter adpater([&parameters, this](double x) { return 1. / hubbleParameter(x, parameters); });
60
61 return hubbleDistance(parameters) * integrate(adpater, 0., z, std::move(integrationScheme));
62}
63
65 double comoving = comovingDistance(z, parameters);
66 if (parameters.getOmegaK() == 0.) {
67 return comoving;
68 }
69
70 double dHOverSqrtOmegaK = hubbleDistance(parameters) / std::sqrt(std::abs(parameters.getOmegaK()));
71
72 if (parameters.getOmegaK() > 0) {
73 return dHOverSqrtOmegaK * std::sinh(comoving / dHOverSqrtOmegaK);
74 } else {
75 return dHOverSqrtOmegaK * std::sin(comoving / dHOverSqrtOmegaK);
76 }
77}
78
79double CosmologicalDistances::luminousDistance(double z, const CosmologicalParameters& parameters) const {
80 if (z == 0.) {
81 return 10.;
82 } else {
83 return (1. + z) * transverseComovingDistance(z, parameters);
84 }
85}
86
87double CosmologicalDistances::distanceModulus(double z, const CosmologicalParameters& parameters) const {
88 return 5. * std::log10(luminousDistance(z, parameters) / 10.);
89}
90
92 const CosmologicalParameters& parameters) const {
93 double D_H = hubbleDistance(parameters);
94 double E = hubbleParameter(z, parameters);
95 double D_M = transverseComovingDistance(z, parameters);
96 return D_M * D_M / (E * D_H * D_H);
97}
98
99} // namespace PhysicsUtils
100} // namespace Euclid
Adapt a std::function<double(double)> to the Function Interface.
double hubbleParameter(double z, const CosmologicalParameters &parameters) const
Returns the (unit-less) Hubble parameter E(z)
double hubbleDistance(const CosmologicalParameters &parameters) const
Get the computed Hubble distance for the cosmology.
double transverseComovingDistance(double z, const CosmologicalParameters &parameters) const
return the transverse comoving distance in [pc]
double comovingDistance(double z, const CosmologicalParameters &parameters, double relative_precision=0.0000001) const
return the comoving distance in [pc]. This value is obtained through a numerical integration....
double distanceModulus(double z, const CosmologicalParameters &parameters) const
return the correction for the Magnitude due to the distance: DM =5*log_10(DL/10pc)
double luminousDistance(double z, const CosmologicalParameters &parameters) const
return the luminous distance in [pc]. For z=0 the returned value is 10pc.
double dimensionlessComovingVolumeElement(double z, const CosmologicalParameters &parameters) const
return the dimensionless comoving volume element.
Model the cosmological parameters. Omega_m, Omega_lambda, Omega_k and hubble_constant....
double getOmegaLambda() const
Get Omega Lambda for the cosmology.
double getHubbleConstant() const
Get the Hubble constant H_0 in (km/s)/Mpc.
double getOmegaM() const
Get Omega matter for the cosmology.
double getOmegaK() const
Get the Omega curvature (computed as 1 - Omega_m - Omega_L) for the cosmology.
T log10(T... args)
T move(T... args)
std::array< std::vector< double >, N > Coordinates
Used to pass the grid coordinates to interpn. Internally will make a copy of the required values.
T sin(T... args)
T sinh(T... args)
T sqrt(T... args)