ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_cosmology::setVolComDiffNormed Interface Reference

Generate and return the cosmological Comoving Volume Differential (Element) per unit solid angle of the sky (i.e., 1 Steradian normalized to Hubble Volume, given the user-specified cosmological parameters. More...

Detailed Description

Generate and return the cosmological Comoving Volume Differential (Element) per unit solid angle of the sky (i.e., 1 Steradian normalized to Hubble Volume, given the user-specified cosmological parameters.

Assuming \((\Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)\) represent the normalized densities of Dark Matter, Dark Energy, Radiation Energy, and Curvature in a Universe with negligible neutrino mass such that \(\Omega_M + \Omega_\Lambda + \Omega_R + \Omega_K = 1\), the Comoving Volume Element \(dV_C\) at a given cosmological redshift \(z\) is defined as (e.g., Peebles, 1993),

\begin{eqnarray} \large dV_C(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K) &=& D_H \frac{\big[D_M(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)\big]^2}{E(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)} ~ dz ~ d\Omega ~, \\ &=& D_H \frac{\big[D_A(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)\big]^2}{E(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)} (1+z)^2 ~ dz ~ d\Omega ~, \\ &=& D_H \frac{\big[D_L(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)\big]^2}{E(z; \Omega_M, \Omega_\Lambda, \Omega_R, \Omega_K)} \frac{1}{(1+z)^2} ~ dz ~ d\Omega ~, \end{eqnarray}

where

  1. \(dV_C(z; \cdots)\) is the cosmological Comoving Volume Element at redshift \(z\),,
  2. \(D_M(z; \cdots)\) is the cosmological Transverse Comoving Distance as a subroutine of redshift,
  3. \(D_A(z; \cdots)\) is the cosmological Angular Diameter Distance as a subroutine of redshift,
  4. \(D_L(z; \cdots)\) is the cosmological Luminosity Distance as a subroutine of redshift,
  5. \(E(z; \cdots)\) is the dimensionless Hubble Parameter,
  6. \(D_H = \frac{C}{H_0}\) is the Hubble Distance,
  7. \(H_0\) is the Hubble Constant.
  8. \(C\) is the speed of light,
  9. \(z\) is the redshift,

The value returned by the procedures under this generic interface is \(\frac{dV_C}{V_H}\), that is, normalized to the Hubble Volume.
To obtain the full-sky (normalized) Comoving Volume Element, multiply the output of the procedures under this generic interface by \(4\pi\), that is, 4 * acos(-1.).

Parameters
[out]volComDiffNormed: The output scalar or array of the same rank as other array-like arguments, of the same type and kind as the input argument zplus1 containing the cosmological Comoving Volume Element per Steradian at the desired redshift normalized to the Hubble Distance.
[in]disComTransNormedSq: The input scalar or array of the same rank as other array-like arguments, of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128) representing the the square of the Dimensionless (Normalized) Transverse Comoving Distance at the desired redshift for which the Comoving Volume Element must be computed.
This argument can be readily obtained by taking the square of the output of getDisComTransNormed, or if the cosmology is the Concordance model, one can use the approximation provided by getDisComTransNormedWU10.
See the examples below for usage.
[in]hubbleParamNormed: The input scalar or array of the same rank as other array-like arguments, of the same type and kind as disComTransNormedSq representing the Dimensionless Hubble Parameter at the desired redshift for which the Comoving Volume Element must be computed.
This argument can be readily obtained by taking the square-root of the output of getHubbleParamNormedSq.
See the examples below for usage.


Possible calling interfaces

call setVolComDiffNormed(volComDiffNormed, disComTransNormedSq, hubbleParamNormed)
Generate and return the cosmological Comoving Volume Differential (Element) per unit solid angle of t...
This module contains procedures and generic interfaces and constants for cosmological calculations.
Warning
The input arguments must be computed for the same redshift and cosmological parameters.
The equivalence and consistencies of the input arguments are not verified within the algorithm because such validations require extra information that is not provided as input.
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
The reason for requesting the rather awkward input arguments above instead of the redshift and other primitive cosmological parameters is to ensure the computation efficiency of the algorithms at the highest level by taking out the potentially unnecessary computations out of the algorithms.
See getVolComDiffNormed for an equivalent, more flexible, but potentially less performant interface.
Developer Remark:
There is no performance benefit in passing the inverse of hubbleParamNormed instead of the what is passed in the current interface.
Do not attempt to change the interface.
See also
getVolComNormed
getHubbleParamNormedSq
getDisComTransNormed
getDisLumNormed
getDisAngNormed
getDisComNormed
LOG_HUBBLE_CONST
HUBBLE_DISTANCE_MPC
HUBBLE_CONST
OMEGA_M
OMEGA_L
OMEGA_R
OMEGA_K


Example usage

1program example
2
3 use pm_kind, only: SK, IK
7 use pm_io, only: display_type
8
9 implicit none
10
11 real :: VolComDiffNormed(3)
12 type(display_type) :: disp
13
14 disp = display_type(file = "main.out.F90")
15
16 call disp%skip()
17 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show("!Compute the Comoving Volume Element in units of Hubble Volume.")
19 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
20 call disp%skip()
21
22 call disp%skip()
23 call disp%show("call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1., reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.)))")
24 call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1., reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.)))
25 call disp%show("VolComDiffNormed(1)")
26 call disp%show( VolComDiffNormed(1) )
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1.1, reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.1)))")
31 call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1.1, reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.1)))
32 call disp%show("VolComDiffNormed(1)")
33 call disp%show( VolComDiffNormed(1) )
34 call disp%skip()
35
36 call disp%skip()
37 call disp%show("call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6)))")
38 call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6)))
39 call disp%show("VolComDiffNormed(1:2)")
40 call disp%show( VolComDiffNormed(1:2) )
41 call disp%skip()
42
43 call disp%skip()
44 call disp%show("call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2)))")
45 call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2)))
46 call disp%show("VolComDiffNormed(1:2)")
47 call disp%show( VolComDiffNormed(1:2) )
48 call disp%skip()
49
50 call disp%skip()
51 call disp%show("call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2, sqrtAbsOmegaK = sqrt(0.2), reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2)))")
52 call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2, sqrtAbsOmegaK = sqrt(0.2), reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2)))
53 call disp%show("VolComDiffNormed(1:2)")
54 call disp%show( VolComDiffNormed(1:2) )
55 call disp%skip()
56
57 ! Generate both the cosmic rate and the rate density.
58
59 block
60
61 use pm_val2str, only: getStr
62 use pm_arraySpace, only: getLinSpace
63 use pm_arraySpace, only: getLogSpace
64
65 real, allocatable :: zplus1(:), OmegaM(:), OmegaL(:), VolComDiffNormed(:)
66 integer :: fileUnit, i
67
68 OmegaM = [1., 0.3, .05]
69 OmegaL = 1. - OmegaM
70 allocate(VolComDiffNormed, mold = OmegaM)
71 zplus1 = 1. + getLogSpace(log(0.0001), log(10000.), 500_IK)
72
73 open(newunit = fileUnit, file = "setVolComDiffNormed.RK.txt")
74 write(fileUnit, "(*(g0,:,','))") "z", ("DisLum_"//getStr(OmegaM(i),"(g0.1)")//"_"//getStr(OmegaL(i),"(g0.1)"), i = 1, size(OmegaM))
75 do i = 1, size(zplus1)
76 call setVolComDiffNormed(VolComDiffNormed, getDisComTransNormed(zplus1(i), OmegaM, OmegaL, 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1(i), OmegaM, OmegaL)))
77 write(fileUnit, "(*(g0,:,','))") zplus1(i) - 1., VolComDiffNormed
78 end do
79 close(fileUnit)
80
81 end block
82
83end program example
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
Generate count evenly-logarithmically-spaced points over the interval [base**logx1,...
Generate and return the cosmological Transverse Comoving Distance normalized to Hubble Distance,...
Generate and return the square of the dimensionless Hubble Parameter for the default or the specifie...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Generate and return the conversion of the input value to an output Fortran string,...
Definition: pm_val2str.F90:167
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!Compute the Comoving Volume Element in units of Hubble Volume.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1., reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.)))
8VolComDiffNormed(1)
9+0.00000000
10
11
12call setVolComDiffNormed(VolComDiffNormed(1), getDisComTransNormed(zplus1 = 1.1, reltol = sqrt(epsilon(0.)))**2, sqrt(getHubbleParamNormedSq(zplus1 = 1.1)))
13VolComDiffNormed(1)
14+0.907804910E-2
15
16
17call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.4, omegaL = 0.6)))
18VolComDiffNormed(1:2)
19+0.273632020, +0.371431828
20
21
22call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2, reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.2)))
23VolComDiffNormed(1:2)
24+0.199308142, +0.205419630
25
26
27call setVolComDiffNormed(VolComDiffNormed(1:2), getDisComTransNormed(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2, sqrtAbsOmegaK = sqrt(0.2), reltol = 0.0001)**2, sqrt(getHubbleParamNormedSq(zplus1 = [ 2., 3.], omegaM = 0.2, omegaL = 0.6, omegaR = 0.4, omegaK = -0.2)))
28VolComDiffNormed(1:2)
29+0.135484368, +0.118126549
30
31

Postprocessing of the example output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6import glob
7import sys
8
9fontsize = 17
10
11marker ={ "CK" : "-"
12 , "IK" : "."
13 , "RK" : "-"
14 }
15xlab = { "CK" : "redshift: Z ( real/imaginary components )"
16 , "IK" : "redshift: Z ( integer-valued )"
17 , "RK" : "redshift: Z ( real-valued )"
18 }
19legends = [ "$\Omega_M = 1.0, \Omega_\Lambda = 0.0$"
20 , "$\Omega_M = 0.3, \Omega_\Lambda = 0.7$"
21 , "$\Omega_M = .05, \Omega_\Lambda = .95$"
22 ]
23
24for kind in ["IK", "CK", "RK"]:
25
26 pattern = "*." + kind + ".txt"
27 fileList = glob.glob(pattern)
28 if len(fileList) == 1:
29
30 df = pd.read_csv(fileList[0], delimiter = ",")
31
32 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
33 ax = plt.subplot()
34
35 if kind == "CK":
36 plt.plot( df.values[:, 0]
37 , df.values[:,1:len(legends)+1]
38 , marker[kind]
39 #, color = "r"
40 )
41 plt.plot( df.values[:,1]
42 , df.values[:,1:len(legends)+1]
43 , marker[kind]
44 #, color = "blue"
45 )
46 else:
47 plt.plot( df.values[:, 0]
48 , df.values[:,1:len(legends)+1]
49 , marker[kind]
50 #, color = "r"
51 )
52 ax.legend ( legends
53 , fontsize = fontsize
54 )
55
56 plt.xticks(fontsize = fontsize - 2)
57 plt.yticks(fontsize = fontsize - 2)
58 ax.set_xlabel(xlab[kind], fontsize = 17)
59 ax.set_ylabel("Comoving Volume Element / Hubble Volume", fontsize = 17)
60 plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
61 ax.tick_params(axis = "y", which = "minor")
62 ax.tick_params(axis = "x", which = "minor")
63 ax.set_xscale("log")
64 ax.set_yscale("log")
65
66 plt.savefig(fileList[0].replace(".txt",".png"))
67
68 elif len(fileList) > 1:
69
70 sys.exit("Ambiguous file list exists.")

Visualization of the example output
Test:
test_pm_cosmology


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2012, 12:00 AM, National Institute for Fusion Studies, The University of Texas at Austin

Definition at line 3723 of file pm_cosmology.F90.


The documentation for this interface was generated from the following file: