Alexandria  2.19
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
36 namespace Euclid {
37 namespace PhysicsUtils {
38 
40  return Elements::Units::c_light * 1.0E3 / parameters.getHubbleConstant(); // in [pc]
41 }
42 
43 double 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 (Elements::isEqual(0., z)) {
52  return 0.;
53  }
54 
57 
58  MathUtils::FunctionAdapter adpater([&parameters, this](double x) { return 1. / hubbleParameter(x, parameters); });
59 
60  return hubbleDistance(parameters) * integrate(adpater, 0., z, std::move(integrationScheme));
61 }
62 
64  double comoving = comovingDistance(z, parameters);
65  if (Elements::isEqual(0., parameters.getOmegaK())) {
66  return comoving;
67  }
68 
69  double dHOverSqrtOmegaK = hubbleDistance(parameters) / std::sqrt(std::abs(parameters.getOmegaK()));
70 
71  if (parameters.getOmegaK() > 0) {
72  return dHOverSqrtOmegaK * std::sinh(comoving / dHOverSqrtOmegaK);
73  } else {
74  return dHOverSqrtOmegaK * std::sin(comoving / dHOverSqrtOmegaK);
75  }
76 }
77 
78 double CosmologicalDistances::luminousDistance(double z, const CosmologicalParameters& parameters) const {
79  if (Elements::isEqual(0., z)) {
80  return 10.;
81  } else {
82  return (1. + z) * transverseComovingDistance(z, parameters);
83  }
84 }
85 
86 double CosmologicalDistances::distanceModulus(double z, const CosmologicalParameters& parameters) const {
87  return 5. * std::log10(luminousDistance(z, parameters) / 10.);
88 }
89 
91  double D_H = hubbleDistance(parameters);
92  double E = hubbleParameter(z, parameters);
93  double D_M = transverseComovingDistance(z, parameters);
94  return D_M * D_M / (E * D_H * D_H);
95 }
96 
97 } // namespace PhysicsUtils
98 } // namespace Euclid
double getOmegaK() const
Get the Omega curvature (computed as 1 - Omega_m - Omega_L) for the cosmology.
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. The relative precision of the integration can be specified and is defaulted to 0.00001%.
double getOmegaM() const
Get Omega matter for the cosmology.
double transverseComovingDistance(double z, const CosmologicalParameters &parameters) const
return the transverse comoving distance in [pc]
T sinh(T...args)
double getHubbleConstant() const
Get the Hubble constant H_0 in (km/s)/Mpc.
double hubbleParameter(double z, const CosmologicalParameters &parameters) const
Returns the (unit-less) Hubble parameter E(z)
Class implementing the NumericalIntegrationScheme interface.
T log10(T...args)
double getOmegaLambda() const
Get Omega Lambda for the cosmology.
Adapt a std::function&lt;double(double)&gt; to the Function Interface.
T sin(T...args)
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.
double hubbleDistance(const CosmologicalParameters &parameters) const
Get the computed Hubble distance for the cosmology.
T move(T...args)
ELEMENTS_API double integrate(const Function &function, const double min, const double max, std::unique_ptr< NumericalIntegrationScheme > numericalIntegrationScheme=nullptr)
STL class.
double distanceModulus(double z, const CosmologicalParameters &parameters) const
return the correction for the Magnitude due to the distance: DM =5*log_10(DL/10pc) ...
bool isEqual(const RawType &left, const RawType &right)
T sqrt(T...args)
static const int minimal_order
Definition: SimpsonsRule.h:51
Model the cosmological parameters. Omega_m, Omega_lambda, Omega_k and hubble_constant. Guarantee that the sum of the Omegas is 1.
constexpr double c_light