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
f06e74fa
Commit
f06e74fa
authored
8 years ago
by
Stefan Arridge
Browse files
Options
Downloads
Patches
Plain Diff
Improved cooling functions
parent
4bef84ae
No related branches found
No related tags found
1 merge request
!242
Add the cooling infrastructure and the const_du and const_lambda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cooling.c
+20
-21
20 additions, 21 deletions
src/cooling.c
src/cooling.h
+6
-2
6 additions, 2 deletions
src/cooling.h
with
26 additions
and
23 deletions
src/cooling.c
+
20
−
21
View file @
f06e74fa
...
...
@@ -61,11 +61,12 @@ void cooling_print(const struct cooling_data* cooling) {
cooling
->
const_cooling
.
cooling_tstep_mult
);
#endif
/* CONST_COOLING */
}
int
update_entropy
(
const
struct
cooling_data
*
cooling
,
const
struct
phys_const
*
const
phys_const
,
struct
part
*
p
,
float
dt
){
void
update_entropy
(
const
struct
cooling_data
*
cooling
,
const
struct
phys_const
*
const
phys_const
,
struct
part
*
p
,
float
dt
){
/*updates the entropy of a particle after integrating the cooling equation*/
int
status
==
0
;
float
u_old
;
float
u_new
;
float
new_entropy
;
...
...
@@ -73,34 +74,32 @@ int update_entropy(const struct cooling_data* cooling,
float
rho
=
p
->
rho
;
u_old
=
old_entropy
/
(
GAMMA_MINUS1
)
*
pow
(
rho
,
GAMMA_MINUS1
);
status
=
calculate_new_thermal_energy
(
u_old
,
&
u_new
,
dt
,
cooling
)
:
if
(
status
==
0
){
new_entropy
=
u_new
/
pow
(
rho
,
GAMMA_MINUS1
)
*
GAMMA_MINUS1
;
p
->
entropy
=
new_entropy
}
else
message
(
"Error with cooling, particle's entropy has not been updated"
);
return
status
;
u_new
=
calculate_new_thermal_energy
(
u_old
,
dt
,
cooling
)
:
new_entropy
=
u_new
/
pow
(
rho
,
GAMMA_MINUS1
)
*
GAMMA_MINUS1
;
p
->
entropy
=
new_entropy
}
#ifdef CONST_COOLING
int
calculate_new_thermal_energy
(
float
u_old
,
float
*
u_new
,
float
dt
,
const
struct
cooling_data
*
cooling
){
float
calculate_new_thermal_energy
(
float
u_old
,
float
dt
,
const
struct
cooling_data
*
cooling
){
#ifdef CONST_COOLING
//This function integrates the cooling equation, given the initial thermal energy and the timestep dt.
//Returns 0 if successful and 1 if not
int
status
=
0
;
float
du_dt
=
cooling
->
const_cooling
.
lambda
;
float
u_floor
=
cooling
->
const_cooling
.
min_energy
;
if
(
u_old
-
du_dt
*
dt
>
min_energy
)
:
*
u_new
=
u_old
-
du_dt
*
dt
;
else:
*
u_new
=
min_energy
float
u_new
;
if
(
u_old
-
du_dt
*
dt
>
min_energy
){
u_new
=
u_old
-
du_dt
*
dt
;
}
else
{
u_new
=
min_energy
;
}
return
u_new
;
#endif
/*CONST_COOLING*/
}
return
status
}
#endif /*CONST_COOLING
This diff is collapsed.
Click to expand it.
src/cooling.h
+
6
−
2
View file @
f06e74fa
...
...
@@ -61,7 +61,8 @@ struct cooling_data {
*/
__attribute__
((
always_inline
))
INLINE
static
float
cooling_timestep
(
const
struct
cooling_data
*
cooling
,
const
struct
phys_const
*
const
phys_const
,
const
struct
part
*
const
p
)
{
const
struct
phys_const
*
const
phys_const
,
const
struct
part
*
const
p
)
{
const
float
cooling_rate
=
get_cooling_rate
(
p
->
density
,
p
->
internal_energy
,
cooling
);
return
cooling
->
const_cooling
.
cooling_tstep_mult
*
p
->
internal_energy
/
cooling_rate
;
...
...
@@ -93,5 +94,8 @@ void cooling_init(const struct swift_params* parameter_file,
struct
cooling_data
*
cooling
);
void
cooling_print
(
const
struct
cooling_data
*
cooling
);
float
calculate_new_thermal_energy
(
float
u_old
,
float
dt
,
const
struct
cooling_data
*
cooling
);
void
update_entropy
(
const
struct
cooling_data
*
cooling
,
const
struct
phys_const
*
const
phys_const
,
struct
part
*
p
,
float
dt
);
#endif
/* SWIFT_COOLING_H */
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