Commit 3ad25972 authored by Francesco Montanari's avatar Francesco Montanari

Test comoving volume

* test_cosmo.el, cosmo_compare.py: Add tests for the comoving volumne.

* cosmo.el: Minor docs updates.

* README.org: Update docs.
parent 672a9e5a
......@@ -116,6 +116,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<...>
#+END_EXAMPLE
- cosmo-comoving-volume :: Display comoving volume in
mini-buffer.
- cosmo-hubble :: Display Hubble parameter in mini-buffer.
- cosmo-hubble-distance :: Display Hubble distance c/H0 [Mpc]
......@@ -130,6 +133,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
- cosmo-luminosity-distance :: Display luminosity distance in
mini-buffer.
- cosmo-parallax-distance :: Display parallax distance in mini-buffer.
- cosmo-pedia :: Display a reference to basic cosmological
definitions.
......
......@@ -60,18 +60,9 @@
;;; Todo:
;; In priority order:
;;
;; - Refactor tests, now they are too cumbersome and repetitive.
;;
;; - Add all quantities from Hogg 1999.
;;
;; - Suggest default parameters when reading them with the related
;; command; set the to default values if none is entered.
;;
;; - Allow users to load a customized file with the cosmo-pedia
;; command (or describe how to do it from ~/.emacs).
;;
;; - (Consider the following only if performance becomes critical.) At
;; a fixed redshift, only cosmo-get-los-comoving-distance perform
;; the integral. Other distances are defined in terms of this
......@@ -372,8 +363,8 @@ Optional argument JMAX maximum number of steps."
(defun cosmo--get-comoving-volume-nonflat (DM DH ocurvature)
"Return the comoving volume for non-vanishing curvature.
Argument DM comoving distance (transverse).
Argument DH Hubble distance
Argument OCURVATURE curvature density parameter"
Argument DH Hubble distance.
Argument OCURVATURE curvature density parameter."
(let* ((DM-over-DH (/ DM DH))
(sqrt-ok (sqrt (abs (cosmo-get-ocurvature))))
(pref (* 2.0 float-pi (/ (expt DH 3.0) ocurvature)))
......@@ -385,8 +376,7 @@ Argument OCURVATURE curvature density parameter"
(setq term1 (* DM-over-DH
(sqrt (1+ (* ocurvature (expt DM-over-DH 2.0))))))
(setq term2 (/ (funcall func (* sqrt-ok DM-over-DH)) sqrt-ok))
(* pref (- term1 term2))
))
(* pref (- term1 term2))))
(defun cosmo-get-comoving-volume (redshift)
"Comoving volume [Mpc^3] for Lambda-CDM at a given REDSHIFT."
......
......@@ -50,6 +50,8 @@ def print_curves(reds, cosmo):
name='luminosity-distance [Mpc]')
sexp_print(reds, cosmo.angular_diameter_distance(reds).value,
name='angular-diameter-distance [Mpc]')
sexp_print(reds, cosmo.comoving_volume(reds).value,
name='comoving-volume [Mpc^3]')
def print_open_cosmo():
......@@ -59,7 +61,9 @@ def print_open_cosmo():
Ode0 = 0.7
cosmo = LambdaCDM(H0=H0, Om0=Om0, Ode0=Ode0)
print('* Open cosmology:')
print('===============')
print('Open cosmology:')
print('===============')
print('H0={} [km/s/Mpc], Om0={}, Ode0={}, Orel0={}, Ok0={}\n'
.format(H0, Om0, Ode0, cosmo.Ogamma(0.)+cosmo.Onu(0.),
cosmo.Ok(0.)))
......@@ -75,7 +79,9 @@ def print_close_cosmo():
Ode0 = 0.7
cosmo = LambdaCDM(H0=H0, Om0=Om0, Ode0=Ode0)
print('* Close cosmology:')
print('================')
print('Close cosmology:')
print('================')
print('H0={} [km/s/Mpc], Om0={}, Ode0={}, Orel0={}, Ok0={}\n'
.format(H0, Om0, Ode0, cosmo.Ogamma(0.)+cosmo.Onu(0.),
cosmo.Ok(0.)))
......@@ -90,7 +96,9 @@ def print_flat_cosmo():
Om0 = 0.3
cosmo = FlatLambdaCDM(H0=H0, Om0=Om0, Tcmb0=0.)
print('* Flat cosmology:')
print('===============')
print('Flat cosmology:')
print('===============')
print('H0={} [km/s/Mpc], Om0={}, Ode0={}, Orel0={}, Ok0={}\n'
.format(H0, Om0, cosmo.Ode(0.), cosmo.Ogamma(0.)+cosmo.Onu(0.),
cosmo.Ok(0.)))
......
......@@ -28,6 +28,10 @@
;; This package provides an unit test for cosmo.el, a cosmological
;; calculator.
;;; Todo:
;; - Refactor tests, now they are too cumbersome and repetitive.
;;; Code:
......@@ -119,6 +123,10 @@ Argument OREL relativistic density parameter today."
(assert (cosmo-almost-eq
(cosmo-get-angular-diameter-distance 1000.0) 13.2194016018 1e-3)))
(defun cosmo-test-comoving-volume ()
(assert (cosmo-almost-eq
(cosmo-get-comoving-volume 1000.0) 1.00014515316e+13 3e-3)))
(cosmo-test-efunc)
(cosmo-test-inv-efunc)
(cosmo-test-hubble)
......@@ -128,6 +136,7 @@ Argument OREL relativistic density parameter today."
(cosmo-test-transverse-comoving-distance-open)
(cosmo-test-luminosity-distance)
(cosmo-test-angular-diameter-distance)
(cosmo-test-comoving-volume)
;;; Close cosmology.
......@@ -144,7 +153,12 @@ Argument OREL relativistic density parameter today."
(cosmo-get-transverse-comoving-distance 1000.0)
14832.933576 1e-3)))
(defun cosmo-test-comoving-volume ()
(assert (cosmo-almost-eq
(cosmo-get-comoving-volume 1000.0) 1.24288502093e+13 3e-3)))
(cosmo-test-transverse-comoving-distance-close)
(cosmo-test-comoving-volume)
;;; Flat cosmology.
......@@ -158,10 +172,15 @@ Argument OREL relativistic density parameter today."
(defun cosmo-test-transverse-comoving-distance-flat ()
(assert (cosmo-almost-eq
(cosmo-get-transverse-comoving-distance 1000.0)
13660.5292969 1e-3)))
(cosmo-get-transverse-comoving-distance 1000.0) 13660.5292969 1e-3)))
(defun cosmo-test-comoving-volume ()
(assert (cosmo-almost-eq
(cosmo-get-comoving-volume 1000.0) 1.06780313213e+13 3e-3)))
(cosmo-test-transverse-comoving-distance-flat)
(cosmo-test-comoving-volume)
;;; Benchmarks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment