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
7894d3b5
Commit
7894d3b5
authored
8 years ago
by
Stefan Arridge
Browse files
Options
Downloads
Patches
Plain Diff
Fixed enforcement of energy floor. entropy_dt is limited in hydro_kick_extra
parent
e66c2328
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!307
Fix cooling bug
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/CoolingHaloWithSpin/cooling_halo.yml
+1
-1
1 addition, 1 deletion
examples/CoolingHaloWithSpin/cooling_halo.yml
src/cooling/const_lambda/cooling.h
+2
-4
2 additions, 4 deletions
src/cooling/const_lambda/cooling.h
src/hydro/Gadget2/hydro.h
+4
-3
4 additions, 3 deletions
src/hydro/Gadget2/hydro.h
with
7 additions
and
8 deletions
examples/CoolingHaloWithSpin/cooling_halo.yml
+
1
−
1
View file @
7894d3b5
...
@@ -10,7 +10,7 @@ InternalUnitSystem:
...
@@ -10,7 +10,7 @@ InternalUnitSystem:
TimeIntegration
:
TimeIntegration
:
time_begin
:
0.
# The starting time of the simulation (in internal units).
time_begin
:
0.
# The starting time of the simulation (in internal units).
time_end
:
10.
# The end time of the simulation (in internal units).
time_end
:
10.
# The end time of the simulation (in internal units).
dt_min
:
1e-
10
# The minimal time-step size of the simulation (in internal units).
dt_min
:
1e-
8
# The minimal time-step size of the simulation (in internal units).
dt_max
:
1e-1
# The maximal time-step size of the simulation (in internal units).
dt_max
:
1e-1
# The maximal time-step size of the simulation (in internal units).
# Parameters governing the conserved quantities statistics
# Parameters governing the conserved quantities statistics
...
...
This diff is collapsed.
Click to expand it.
src/cooling/const_lambda/cooling.h
+
2
−
4
View file @
7894d3b5
...
@@ -89,10 +89,8 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
...
@@ -89,10 +89,8 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
float
cooling_du_dt
=
cooling_rate
(
phys_const
,
us
,
cooling
,
p
);
float
cooling_du_dt
=
cooling_rate
(
phys_const
,
us
,
cooling
,
p
);
/* Integrate cooling equation to enforce energy floor */
/* Integrate cooling equation to enforce energy floor */
if
(
u_old
+
hydro_du_dt
*
dt
<
u_floor
)
{
if
(
u_old
+
(
hydro_du_dt
+
cooling_du_dt
)
*
dt
<
u_floor
)
{
cooling_du_dt
=
0
.
f
;
cooling_du_dt
=
-
(
u_old
+
dt
*
hydro_du_dt
-
u_floor
)
/
dt
;
}
else
if
(
u_old
+
(
hydro_du_dt
+
cooling_du_dt
)
*
dt
<
u_floor
)
{
cooling_du_dt
=
(
u_old
+
dt
*
hydro_du_dt
-
u_floor
)
/
dt
;
}
}
/* Update the internal energy time derivative */
/* Update the internal energy time derivative */
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Gadget2/hydro.h
+
4
−
3
View file @
7894d3b5
...
@@ -332,6 +332,8 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
...
@@ -332,6 +332,8 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
else
else
p
->
rho
*=
expf
(
w2
);
p
->
rho
*=
expf
(
w2
);
if
(
p
->
entropy
+
p
->
entropy_dt
*
dt
<
0
.
0
)
printf
(
"Negative entropy: Old entropy = %g, New entropy = %g "
,
p
->
entropy
,
p
->
entropy
+
p
->
entropy_dt
*
dt
);
/* Predict the entropy */
/* Predict the entropy */
p
->
entropy
+=
p
->
entropy_dt
*
dt
;
p
->
entropy
+=
p
->
entropy_dt
*
dt
;
...
@@ -377,9 +379,8 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
...
@@ -377,9 +379,8 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
float
dt
)
{
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
float
dt
)
{
/* Do not decrease the entropy by more than a factor of 2 */
/* Do not decrease the entropy by more than a factor of 2 */
const
float
entropy_change
=
p
->
entropy_dt
*
dt
;
p
->
entropy_dt
=
max
(
-
0
.
5
f
*
xp
->
entropy_full
/
dt
,
p
->
entropy_dt
);
xp
->
entropy_full
=
xp
->
entropy_full
+=
p
->
entropy_dt
*
dt
;
max
(
xp
->
entropy_full
+
entropy_change
,
0
.
5
f
*
xp
->
entropy_full
);
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
xp
->
entropy_full
);
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
xp
->
entropy_full
);
...
...
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