Skip to content

Commit 36bdad8

Browse files
committed
Test comoving distance functions in testCosmology
1 parent 22112d6 commit 36bdad8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/testCosmology.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
5656
struct cosmology cosmo;
5757
cosmology_init(&params, &us, &phys_const, &cosmo);
5858

59-
message("Start checking computation...");
59+
message("Start checking time since big bang computation...");
6060

6161
for (int i = 0; i < N_CHECK; i++) {
6262
double a = 0.1 + 0.9 * i / (N_CHECK - 1.);
@@ -70,6 +70,20 @@ int main(int argc, char *argv[]) {
7070
assert(fabs(tmp) < TOLERANCE);
7171
}
7272

73+
message("Start checking comoving distance computation...");
74+
75+
for (int i = 0; i < N_CHECK; i++) {
76+
double a = 0.1 + 0.9 * i / (N_CHECK - 1.);
77+
/* Compute a(comoving_distance(a)) and check if same results */
78+
double tmp = cosmology_get_comoving_distance(&cosmo, a);
79+
tmp = cosmology_scale_factor_at_comoving_distance(&cosmo, tmp);
80+
81+
/* check accuracy */
82+
tmp = (tmp - a) / a;
83+
message("Accuracy of %g at a=%g", tmp, a);
84+
assert(fabs(tmp) < TOLERANCE);
85+
}
86+
7387
message("Everything seems fine with cosmology.");
7488

7589
cosmology_clean(&cosmo);

0 commit comments

Comments
 (0)