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
7a93b34f
Commit
7a93b34f
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Only compute the external potential energy when running with external potential.
parent
e4af484f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.c
+1
-1
1 addition, 1 deletion
src/engine.c
src/statistics.c
+11
-5
11 additions, 5 deletions
src/statistics.c
with
12 additions
and
6 deletions
src/engine.c
+
1
−
1
View file @
7a93b34f
...
...
@@ -6230,7 +6230,7 @@ void engine_recompute_displacement_constraint(struct engine *e) {
/* Mesh forces smoothing scale */
float
a_smooth
;
if
((
e
->
policy
&
engine_policy_self_gravity
)
&&
e
->
s
->
periodic
==
1
)
if
((
e
->
policy
&
engine_policy_self_gravity
)
&&
e
->
s
->
periodic
==
1
)
a_smooth
=
e
->
gravity_properties
->
a_smooth
*
e
->
s
->
dim
[
0
]
/
e
->
s
->
cdim
[
0
];
else
a_smooth
=
FLT_MAX
;
...
...
This diff is collapsed.
Click to expand it.
src/statistics.c
+
11
−
5
View file @
7a93b34f
...
...
@@ -107,6 +107,8 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
const
struct
space
*
s
=
data
->
s
;
const
struct
engine
*
e
=
s
->
e
;
const
int
with_cosmology
=
(
e
->
policy
&
engine_policy_cosmology
);
const
int
with_ext_grav
=
(
e
->
policy
&
engine_policy_external_gravity
);
const
int
with_self_grav
=
(
e
->
policy
&
engine_policy_self_gravity
);
const
integertime_t
ti_current
=
e
->
ti_current
;
const
double
time_base
=
e
->
time_base
;
const
double
time
=
e
->
time
;
...
...
@@ -190,11 +192,11 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
a_inv2
;
/* 1/2 m a^2 \dot{r}^2 */
stats
.
E_int
+=
m
*
u_inter
;
stats
.
E_rad
+=
cooling_get_radiated_energy
(
xp
);
if
(
gp
!=
NULL
)
{
if
(
gp
!=
NULL
&&
with_self_grav
)
stats
.
E_pot_self
+=
0
.
5
f
*
m
*
gravity_get_physical_potential
(
gp
,
cosmo
);
if
(
gp
!=
NULL
&&
with_ext_grav
)
stats
.
E_pot_ext
+=
m
*
external_gravity_get_potential_energy
(
time
,
potential
,
phys_const
,
gp
);
}
/* Collect entropy */
stats
.
entropy
+=
m
*
entropy
;
...
...
@@ -220,6 +222,8 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
const
struct
space
*
s
=
data
->
s
;
const
struct
engine
*
e
=
s
->
e
;
const
int
with_cosmology
=
(
e
->
policy
&
engine_policy_cosmology
);
const
int
with_ext_grav
=
(
e
->
policy
&
engine_policy_external_gravity
);
const
int
with_self_grav
=
(
e
->
policy
&
engine_policy_self_gravity
);
const
integertime_t
ti_current
=
e
->
ti_current
;
const
double
time_base
=
e
->
time_base
;
const
double
time
=
e
->
time
;
...
...
@@ -292,9 +296,11 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
/* Collect energies. */
stats
.
E_kin
+=
0
.
5
f
*
m
*
(
v
[
0
]
*
v
[
0
]
+
v
[
1
]
*
v
[
1
]
+
v
[
2
]
*
v
[
2
])
*
a_inv2
;
/* 1/2 m a^2 \dot{r}^2 */
stats
.
E_pot_self
+=
0
.
5
f
*
m
*
gravity_get_physical_potential
(
gp
,
cosmo
);
stats
.
E_pot_ext
+=
m
*
external_gravity_get_potential_energy
(
time
,
potential
,
phys_const
,
gp
);
if
(
with_self_grav
)
stats
.
E_pot_self
+=
0
.
5
f
*
m
*
gravity_get_physical_potential
(
gp
,
cosmo
);
if
(
with_ext_grav
)
stats
.
E_pot_ext
+=
m
*
external_gravity_get_potential_energy
(
time
,
potential
,
phys_const
,
gp
);
}
/* Now write back to memory */
...
...
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