cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cosmology.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseCosmology parse cosmological parameters and options */
4 #include "cddefines.h"
5 #include "physconst.h"
6 #include "cosmology.h"
7 
9 
11 {
12  realnum H_z, H_z_squared;
13 
14  DEBUG_ENTRY( "GetHubbleFactor()" );
15 
16  /* NB - the factor of (1e5/MEGAPARSEC) converts from km/s/Mpc to km/s/km */
17  H_z_squared = POW2(cosmology.H_0 * (realnum)(1e5/MEGAPARSEC)) * (
18  cosmology.omega_lambda +
19  cosmology.omega_matter * POW3( 1.f + z ) +
20  cosmology.omega_rad * POW4( 1.f + z ) +
21  cosmology.omega_k * POW2( 1.f + z ) );
22 
23  H_z = sqrt( H_z_squared );
24 
25  return H_z;
26 }
27 
29 {
31 
32  DEBUG_ENTRY( "GetDensity()" );
33 
34  fixit("Cosmological He fraction should be abund.aprim[1] by default, but controlled by command line option");
35  cosmology.f_He = 0.079f;
36 
37  /* from Switzer & Hirata 2007, equation 2 */
38  density = 1.123e-5f * (cosmology.omega_baryon*cosmology.h*cosmology.h) / (1.f + 3.9715f*cosmology.f_He) *
39  pow3( 1.f + z );
40 
41  return density;
42 }
realnum GetDensity(realnum z)
Definition: cosmology.cpp:28
realnum h
Definition: cosmology.h:38
T pow3(T a)
Definition: cddefines.h:988
realnum H_0
Definition: cosmology.h:38
#define POW2
Definition: cddefines.h:979
realnum f_He
Definition: cosmology.h:42
float realnum
Definition: cddefines.h:124
realnum omega_baryon
Definition: cosmology.h:31
realnum omega_lambda
Definition: cosmology.h:31
realnum omega_k
Definition: cosmology.h:31
double density(const genericState &gs)
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
t_cosmology cosmology
Definition: cosmology.cpp:8
realnum omega_rad
Definition: cosmology.h:31
realnum GetHubbleFactor(realnum z)
Definition: cosmology.cpp:10
#define fixit(a)
Definition: cddefines.h:417
#define POW3
Definition: cddefines.h:986
realnum omega_matter
Definition: cosmology.h:31
#define POW4
Definition: cddefines.h:993