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
0aeeff5a
Commit
0aeeff5a
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added some sanity checks in the cosmology module.
parent
20cc7089
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cosmology.c
+28
-1
28 additions, 1 deletion
src/cosmology.c
with
28 additions
and
1 deletion
src/cosmology.c
+
28
−
1
View file @
0aeeff5a
...
...
@@ -119,6 +119,10 @@ static INLINE double E(double Or, double Om, double Ok, double Ol, double w0,
*/
double
cosmology_get_time_since_big_bang
(
const
struct
cosmology
*
c
,
double
a
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
a
<
a_begin
)
error
(
"Error a can't be smaller than a_begin"
);
#endif
/* Time between a_begin and a */
const
double
delta_t
=
interp_table
(
c
->
time_interp_table
,
log
(
a
),
c
->
log_a_begin
,
c
->
log_a_end
);
...
...
@@ -506,6 +510,10 @@ double cosmology_get_drift_factor(const struct cosmology *c,
integertime_t
ti_start
,
integertime_t
ti_end
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
ti_end
<
ti_start
)
error
(
"ti_end must be >= ti_start"
);
#endif
const
double
a_start
=
c
->
log_a_begin
+
ti_start
*
c
->
time_base
;
const
double
a_end
=
c
->
log_a_begin
+
ti_end
*
c
->
time_base
;
...
...
@@ -530,6 +538,10 @@ double cosmology_get_grav_kick_factor(const struct cosmology *c,
integertime_t
ti_start
,
integertime_t
ti_end
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
ti_end
<
ti_start
)
error
(
"ti_end must be >= ti_start"
);
#endif
const
double
a_start
=
c
->
log_a_begin
+
ti_start
*
c
->
time_base
;
const
double
a_end
=
c
->
log_a_begin
+
ti_end
*
c
->
time_base
;
...
...
@@ -554,6 +566,10 @@ double cosmology_get_hydro_kick_factor(const struct cosmology *c,
integertime_t
ti_start
,
integertime_t
ti_end
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
ti_end
<
ti_start
)
error
(
"ti_end must be >= ti_start"
);
#endif
const
double
a_start
=
c
->
log_a_begin
+
ti_start
*
c
->
time_base
;
const
double
a_end
=
c
->
log_a_begin
+
ti_end
*
c
->
time_base
;
...
...
@@ -579,6 +595,10 @@ double cosmology_get_therm_kick_factor(const struct cosmology *c,
integertime_t
ti_start
,
integertime_t
ti_end
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
ti_end
<
ti_start
)
error
(
"ti_end must be >= ti_start"
);
#endif
const
double
a_start
=
c
->
log_a_begin
+
ti_start
*
c
->
time_base
;
const
double
a_end
=
c
->
log_a_begin
+
ti_end
*
c
->
time_base
;
...
...
@@ -600,11 +620,18 @@ double cosmology_get_therm_kick_factor(const struct cosmology *c,
double
cosmology_get_delta_time
(
const
struct
cosmology
*
c
,
double
a1
,
double
a2
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
a2
<
a1
)
error
(
"Incorrect arguments. a2 must be >= a1"
);
if
(
a1
<
c
->
a_begin
)
error
(
"Value of a1 smaller than a_begin(%e)"
,
c
->
a_begin
);
if
(
a2
>
c
->
a_end
)
error
(
"Value of a2 larger than a_end(%e)"
,
c
->
a_end
);
#endif
/* Time between a_begin and a1 */
const
double
t1
=
interp_table
(
c
->
time_interp_table
,
log
(
a1
),
c
->
log_a_begin
,
c
->
log_a_end
);
/* Time between a_begin and a
1
*/
/* Time between a_begin and a
2
*/
const
double
t2
=
interp_table
(
c
->
time_interp_table
,
log
(
a2
),
c
->
log_a_begin
,
c
->
log_a_end
);
...
...
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