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
e6a7f8be
Commit
e6a7f8be
authored
5 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Update the unit tests using the cosmology module for the new function signature.
parent
c9d3801e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!979
Cosmological integration
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/outputlist.c
+1
-1
1 addition, 1 deletion
src/outputlist.c
tests/testCosmology.c
+22
-8
22 additions, 8 deletions
tests/testCosmology.c
tests/testOutputList.c
+16
-1
16 additions, 1 deletion
tests/testOutputList.c
with
39 additions
and
10 deletions
src/outputlist.c
+
1
−
1
View file @
e6a7f8be
...
@@ -106,7 +106,7 @@ void output_list_read_file(struct output_list *outputlist, const char *filename,
...
@@ -106,7 +106,7 @@ void output_list_read_file(struct output_list *outputlist, const char *filename,
if
(
type
==
OUTPUT_LIST_REDSHIFT
)
*
time
=
1
.
/
(
1
.
+
*
time
);
if
(
type
==
OUTPUT_LIST_REDSHIFT
)
*
time
=
1
.
/
(
1
.
+
*
time
);
if
(
cosmo
&&
type
==
OUTPUT_LIST_AGE
)
if
(
cosmo
&&
type
==
OUTPUT_LIST_AGE
)
*
time
=
cosmology_get_scale_factor
(
cosmo
,
*
time
);
*
time
=
cosmology_get_scale_factor
_from_time
(
cosmo
,
*
time
);
/* Update size */
/* Update size */
ind
+=
1
;
ind
+=
1
;
...
...
This diff is collapsed.
Click to expand it.
tests/testCosmology.c
+
22
−
8
View file @
e6a7f8be
...
@@ -20,11 +20,15 @@
...
@@ -20,11 +20,15 @@
/* Some standard headers. */
/* Some standard headers. */
#include
"../config.h"
#include
"../config.h"
/* Some standard headers */
#include
<fenv.h>
#include
<math.h>
/* Includes. */
/* Includes. */
#include
"swift.h"
#include
"swift.h"
#define N_CHECK 20
#define N_CHECK 20
0
#define TOLERANCE 1e-
7
#define TOLERANCE 1e-
6
void
test_params_init
(
struct
swift_params
*
params
)
{
void
test_params_init
(
struct
swift_params
*
params
)
{
parser_init
(
""
,
params
);
parser_init
(
""
,
params
);
...
@@ -32,12 +36,21 @@ void test_params_init(struct swift_params *params) {
...
@@ -32,12 +36,21 @@ void test_params_init(struct swift_params *params) {
parser_set_param
(
params
,
"Cosmology:Omega_lambda:0.6910"
);
parser_set_param
(
params
,
"Cosmology:Omega_lambda:0.6910"
);
parser_set_param
(
params
,
"Cosmology:Omega_b:0.0486"
);
parser_set_param
(
params
,
"Cosmology:Omega_b:0.0486"
);
parser_set_param
(
params
,
"Cosmology:h:0.6774"
);
parser_set_param
(
params
,
"Cosmology:h:0.6774"
);
parser_set_param
(
params
,
"Cosmology:a_begin:0.1"
);
parser_set_param
(
params
,
"Cosmology:a_begin:0.
0
1"
);
parser_set_param
(
params
,
"Cosmology:a_end:1.0"
);
parser_set_param
(
params
,
"Cosmology:a_end:1.0"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
/* Initialize CPU frequency, this also starts time. */
unsigned
long
long
cpufreq
=
0
;
clocks_set_cpufreq
(
cpufreq
);
/* Choke on FP-exceptions */
#ifdef HAVE_FE_ENABLE_EXCEPT
feenableexcept
(
FE_DIVBYZERO
|
FE_INVALID
|
FE_OVERFLOW
);
#endif
message
(
"Initialization..."
);
message
(
"Initialization..."
);
/* pseudo initialization of params */
/* pseudo initialization of params */
...
@@ -60,14 +73,15 @@ int main(int argc, char *argv[]) {
...
@@ -60,14 +73,15 @@ int main(int argc, char *argv[]) {
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
.);
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
t
mp
=
cosmology_get_time_since_big_bang
(
&
cosmo
,
a
);
double
t
ime
=
cosmology_get_time_since_big_bang
(
&
cosmo
,
a
);
tmp
=
cosmology_get_scale_factor
(
&
cosmo
,
t
mp
);
double
my_a
=
cosmology_get_scale_factor
_from_time
(
&
cosmo
,
t
ime
);
/* check accuracy */
/* check accuracy */
tmp
=
(
tmp
-
a
)
/
a
;
double
rel_err
=
(
my_a
-
a
)
/
a
;
message
(
"Accuracy of %g at a=%g"
,
tmp
,
a
);
message
(
"Accuracy of %g at a=%g"
,
rel_err
,
a
);
assert
(
fabs
(
tmp
)
<
TOLERANCE
);
assert
(
fabs
(
rel_err
)
<
TOLERANCE
);
}
}
message
(
"Everything seems fine with cosmology."
);
message
(
"Everything seems fine with cosmology."
);
...
...
This diff is collapsed.
Click to expand it.
tests/testOutputList.c
+
16
−
1
View file @
e6a7f8be
...
@@ -19,6 +19,10 @@
...
@@ -19,6 +19,10 @@
******************************************************************************/
******************************************************************************/
#include
"../config.h"
#include
"../config.h"
/* Some standard headers */
#include
<fenv.h>
#include
<math.h>
/* Includes. */
/* Includes. */
#include
"swift.h"
#include
"swift.h"
...
@@ -86,7 +90,8 @@ void test_cosmo(struct engine *e, char *name, int with_assert) {
...
@@ -86,7 +90,8 @@ void test_cosmo(struct engine *e, char *name, int with_assert) {
double
output_time
=
0
;
double
output_time
=
0
;
/* Test Time */
/* Test Time */
e
->
time_base
=
log
(
e
->
time_end
/
e
->
cosmology
->
a_begin
)
/
max_nr_timesteps
;
e
->
time_base
=
log
(
e
->
cosmology
->
a_end
/
e
->
cosmology
->
a_begin
)
/
max_nr_timesteps
;
e
->
ti_current
=
0
;
e
->
ti_current
=
0
;
e
->
policy
=
engine_policy_cosmology
;
e
->
policy
=
engine_policy_cosmology
;
...
@@ -115,6 +120,16 @@ void test_cosmo(struct engine *e, char *name, int with_assert) {
...
@@ -115,6 +120,16 @@ void test_cosmo(struct engine *e, char *name, int with_assert) {
};
};
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
/* Initialize CPU frequency, this also starts time. */
unsigned
long
long
cpufreq
=
0
;
clocks_set_cpufreq
(
cpufreq
);
/* Choke on FP-exceptions */
#ifdef HAVE_FE_ENABLE_EXCEPT
feenableexcept
(
FE_DIVBYZERO
|
FE_INVALID
|
FE_OVERFLOW
);
#endif
/* Create a structure to read file into. */
/* Create a structure to read file into. */
struct
swift_params
params
;
struct
swift_params
params
;
...
...
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