Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
a9b4fb91
Commit
a9b4fb91
authored
Nov 20, 2017
by
lhausamm
Browse files
cooling_rate was not returning du_dt, but u
parent
af92d4c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cooling/grackle/cooling.h
View file @
a9b4fb91
...
...
@@ -50,6 +50,8 @@
* @param cooling The #cooling_function_data used in the run.
* @param p Pointer to the particle data.
* @param dt The time-step of this particle.
*
* @return du / dt
*/
__attribute__
((
always_inline
))
INLINE
static
double
cooling_rate
(
const
struct
phys_const
*
restrict
phys_const
,
...
...
@@ -61,6 +63,7 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
/* Get current internal energy (dt=0) */
double
u_old
=
hydro_get_internal_energy
(
p
);
double
u_new
=
u_old
;
/* Get current density */
const
float
rho
=
hydro_get_density
(
p
);
/* Actual scaling fractor */
...
...
@@ -71,12 +74,12 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
double
Z
=
0
.
02041
;
if
(
wrap_do_cooling
(
rho
,
&
u_
old
,
dt
,
Z
,
a_now
)
==
0
)
{
if
(
wrap_do_cooling
(
rho
,
&
u_
new
,
dt
,
Z
,
a_now
)
==
0
)
{
error
(
"Error in do_cooling.
\n
"
);
return
0
;
}
return
u_old
;
return
(
u_new
-
u_old
)
/
dt
;
}
/**
...
...
@@ -99,23 +102,21 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
if
(
dt
==
0
.)
return
;
/* Get current internal energy (dt=0) */
const
float
u_old
=
hydro_get_internal_energy
(
p
);
/* Current du_dt */
const
float
hydro_du_dt
=
hydro_get_internal_energy_dt
(
p
);
float
u_
new
;
float
d
u_
dt
;
float
delta_u
;
u_
new
=
cooling_rate
(
phys_const
,
us
,
cooling
,
p
,
dt
);
d
u_
dt
=
cooling_rate
(
phys_const
,
us
,
cooling
,
p
,
dt
);
delta_u
=
u_
new
-
u_old
;
delta_u
=
d
u_
dt
*
dt
;
/* record energy lost */
xp
->
cooling_data
.
radiated_energy
+=
-
delta_u
*
hydro_get_mass
(
p
);
/* Update the internal energy */
hydro_set_internal_energy_dt
(
p
,
hydro_du_dt
+
d
elta_u
/
dt
);
hydro_set_internal_energy_dt
(
p
,
hydro_du_dt
+
d
u_
dt
);
}
/**
...
...
src/cooling/grackle/grackle_wrapper.c
View file @
a9b4fb91
...
...
@@ -157,7 +157,6 @@ int wrap_do_cooling(double rho, double *u, double dt, double Z, double a_now) {
error
(
"Error in solve_chemistry."
);
return
0
;
}
// return updated chemistry and energy
for
(
int
i
=
0
;
i
<
FIELD_SIZE
;
i
++
)
{
u
[
i
]
=
energy
[
i
]
/
u_factor
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment