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
3399665b
Commit
3399665b
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Post-merge fixes and code formatting.
parent
9f2e83a5
No related branches found
No related tags found
1 merge request
!509
Cosmological time integration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/main.c
+41
-27
41 additions, 27 deletions
examples/main.c
src/cosmology.c
+2
-2
2 additions, 2 deletions
src/cosmology.c
with
43 additions
and
29 deletions
examples/main.c
+
41
−
27
View file @
3399665b
...
...
@@ -599,28 +599,30 @@ int main(int argc, char *argv[]) {
phys_const_print
(
&
prog_const
);
}
/* Initialise the cosmology */
struct
cosmology
cosmo
;
if
(
with_cosmology
)
cosmology_init
(
params
,
&
us
,
&
prog_const
,
&
cosmo
);
if
(
with_cosmology
)
cosmology_print
(
&
cosmo
);
struct
engine
ee
;
ee
.
ti_current
=
0
;
ee
.
timeBase
=
(
log
(
cosmo
.
a_end
)
-
log
(
cosmo
.
a_begin
))
/
max_nr_timesteps
;
cosmology_update
(
&
cosmo
,
&
ee
);
/* Initialise the cosmology */
struct
cosmology
cosmo
;
if
(
with_cosmology
)
cosmology_init
(
params
,
&
us
,
&
prog_const
,
&
cosmo
);
if
(
with_cosmology
)
cosmology_print
(
&
cosmo
);
// MATTHIEU START
struct
engine
ee
;
ee
.
ti_current
=
0
;
ee
.
timeBase
=
(
log
(
cosmo
.
a_end
)
-
log
(
cosmo
.
a_begin
))
/
max_nr_timesteps
;
cosmology_update
(
&
cosmo
,
&
ee
);
for
(
int
i
=
0
;
i
<=
16
;
++
i
)
{
for
(
int
i
=
0
;
i
<=
16
;
++
i
)
{
ee
.
ti_current
=
(
max_nr_timesteps
/
16
)
*
i
;
ee
.
ti_current
=
(
max_nr_timesteps
/
16
)
*
i
;
cosmology_update
(
&
cosmo
,
&
ee
);
cosmology_update
(
&
cosmo
,
&
ee
);
message
(
"z=%e H(z)=%e w=%f t=%e [yrs] t_l=%e [yrs]"
,
cosmo
.
z
,
cosmo
.
H
,
cosmo
.
w
,
cosmo
.
time
/
prog_const
.
const_year
,
cosmo
.
lookback_time
/
prog_const
.
const_year
);
}
message
(
"z=%e H(z)=%e w=%f t=%e [yrs] t_l=%e [yrs]"
,
cosmo
.
z
,
cosmo
.
H
,
cosmo
.
w
,
cosmo
.
time
/
prog_const
.
const_year
,
cosmo
.
lookback_time
/
prog_const
.
const_year
);
}
return
0
;
return
0
;
// MATTHIEU END
/* Initialise the hydro properties */
if
(
with_hydro
)
hydro_props_init
(
&
hydro_properties
,
params
);
...
...
@@ -702,13 +704,25 @@ int main(int argc, char *argv[]) {
"ICs."
,
N_total
[
0
],
N_total
[
2
],
N_total
[
1
]);
/* Also update the total counts (in case of changes due to replication) */
/* Initialize the space with these data. */
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
space_init
(
&
s
,
params
,
dim
,
parts
,
gparts
,
sparts
,
Ngas
,
Ngpart
,
Nspart
,
periodic
,
replicate
,
with_self_gravity
,
talking
,
dry_run
);
if
(
myrank
==
0
)
{
clocks_gettime
(
&
toc
);
message
(
"space_init took %.3f %s."
,
clocks_diff
(
&
tic
,
&
toc
),
clocks_getunit
());
fflush
(
stdout
);
}
/* Also update the total counts (in case of changes due to replication) */
#if defined(WITH_MPI)
N_long
[
0
]
=
s
.
nr_parts
;
N_long
[
1
]
=
s
.
nr_gparts
;
N_long
[
2
]
=
s
.
nr_sparts
;
MPI_Allreduce
(
&
N_long
,
&
N_total
,
3
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
N_long
[
0
]
=
s
.
nr_parts
;
N_long
[
1
]
=
s
.
nr_gparts
;
N_long
[
2
]
=
s
.
nr_sparts
;
MPI_Allreduce
(
&
N_long
,
&
N_total
,
3
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
#else
N_total
[
0
]
=
s
.
nr_parts
;
N_total
[
1
]
=
s
.
nr_gparts
;
...
...
@@ -743,10 +757,10 @@ int main(int argc, char *argv[]) {
message
(
"nr of cells at depth %i is %i."
,
data
[
0
],
data
[
1
]);
}
/* Initialise the
table of Ewald corrections for the gravity check
s */
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
if
(
periodic
)
gravity_exact_force_ew
al
d
_init
(
dim
[
0
]
);
#endif
/* Initialise the
external potential propertie
s */
if
(
with_external_gravity
)
potenti
al_init
(
params
,
&
prog_const
,
&
us
,
&
s
,
&
potential
);
if
(
myrank
==
0
)
potential_print
(
&
potential
);
/* Initialise the cooling function properties */
if
(
with_cooling
)
cooling_init
(
params
,
&
us
,
&
prog_const
,
&
cooling_func
);
...
...
This diff is collapsed.
Click to expand it.
src/cosmology.c
+
2
−
2
View file @
3399665b
...
...
@@ -82,7 +82,7 @@ static INLINE double cosmology_dark_energy_EoS(double a, double w_0,
}
/**
* @brief Computes the integral of the dark-energy equation of state
* @brief Computes the integral of the dark-energy equation of state
* up to a scale-factor a.
*
* We follow the convention of Linder & Jenkins, MNRAS, 346, 573, 2003
...
...
@@ -100,7 +100,7 @@ static INLINE double w_tilde(double a, double w0, double wa) {
* @brief Compute \f$ E(z) \f$.
*/
static
INLINE
double
E
(
double
Or
,
double
Om
,
double
Ok
,
double
Ol
,
double
w0
,
double
wa
,
double
a
)
{
double
wa
,
double
a
)
{
const
double
a_inv
=
1
.
/
a
;
return
sqrt
(
Or
*
a_inv
*
a_inv
*
a_inv
*
a_inv
+
Om
*
a_inv
*
a_inv
*
a_inv
+
Ok
*
a_inv
*
a_inv
+
Ol
*
exp
(
3
.
*
w_tilde
(
a
,
w0
,
wa
)));
...
...
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