Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
3a43c49c
Commit
3a43c49c
authored
7 years ago
by
lhausamm
Committed by
Loic Hausammann
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Change output testCosmology and add warning message about accuracy in cosmology.c
parent
867f606a
No related branches found
No related tags found
1 merge request
!560
Output time from a file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cosmology.c
+3
-0
3 additions, 0 deletions
src/cosmology.c
tests/testCosmology.c
+5
-7
5 additions, 7 deletions
tests/testCosmology.c
with
8 additions
and
7 deletions
src/cosmology.c
+
3
−
0
View file @
3a43c49c
...
@@ -679,6 +679,9 @@ double cosmology_get_a_from_z(const struct cosmology *c, double redshift) {
...
@@ -679,6 +679,9 @@ double cosmology_get_a_from_z(const struct cosmology *c, double redshift) {
/**
/**
* @brief Compute scale factor from time since big bang.
* @brief Compute scale factor from time since big bang.
*
*
* WARNING: This method has a low accuracy at high redshift.
* The relative error is around 1e-3 (testCosmology.c is measuring it).
*
* @param c The current #cosmology.
* @param c The current #cosmology.
* @param t time since the big bang
* @param t time since the big bang
* @return The scale factor.
* @return The scale factor.
...
...
This diff is collapsed.
Click to expand it.
tests/testCosmology.c
+
5
−
7
View file @
3a43c49c
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/* Includes. */
/* Includes. */
#include
"swift.h"
#include
"swift.h"
#define N_CHECK
1
0
#define N_CHECK
2
0
#define TOLERANCE 1e-3
#define TOLERANCE 1e-3
void
test_params_init
(
struct
swift_params
*
params
)
{
void
test_params_init
(
struct
swift_params
*
params
)
{
...
@@ -58,17 +58,15 @@ int main(int argc, char *argv[]) {
...
@@ -58,17 +58,15 @@ int main(int argc, char *argv[]) {
message
(
"Start checking computation..."
);
message
(
"Start checking computation..."
);
double
a
[
N_CHECK
]
=
{
0
.
1
,
0
.
2
,
0
.
3
,
0
.
4
,
0
.
5
,
0
.
6
,
0
.
7
,
0
.
8
,
0
.
9
,
1
.
0
};
for
(
int
i
=
0
;
i
<
N_CHECK
;
i
++
)
{
for
(
int
i
=
0
;
i
<
N_CHECK
;
i
++
)
{
double
a
=
0
.
1
+
0
.
9
*
i
/
(
N_CHECK
-
1
.);
/* Compute a(t(a)) and check if same results */
/* Compute a(t(a)) and check if same results */
double
tmp
=
cosmology_get_time_since_big_bang
(
&
cosmo
,
a
[
i
]
);
double
tmp
=
cosmology_get_time_since_big_bang
(
&
cosmo
,
a
);
tmp
=
cosmology_get_scale_factor
(
&
cosmo
,
tmp
);
tmp
=
cosmology_get_scale_factor
(
&
cosmo
,
tmp
);
/* check accuracy */
/* check accuracy */
tmp
=
(
tmp
-
a
[
i
]
)
/
a
[
i
]
;
tmp
=
(
tmp
-
a
)
/
a
;
message
(
"Accuracy of %
f
at a=%
f
"
,
tmp
,
a
[
i
]
);
message
(
"Accuracy of %
g
at a=%
g
"
,
tmp
,
a
);
assert
(
fabs
(
tmp
)
<
TOLERANCE
);
assert
(
fabs
(
tmp
)
<
TOLERANCE
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment