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
0ef836d1
Commit
0ef836d1
authored
8 years ago
by
Stefan Arridge
Browse files
Options
Downloads
Patches
Plain Diff
Added cooling to runner.c
parent
f06e74fa
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!242
Add the cooling infrastructure and the const_du and const_lambda
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cooling.c
+2
-2
2 additions, 2 deletions
src/cooling.c
src/cooling.h
+1
-1
1 addition, 1 deletion
src/cooling.h
src/runner.c
+50
-0
50 additions, 0 deletions
src/runner.c
with
53 additions
and
3 deletions
src/cooling.c
+
2
−
2
View file @
0ef836d1
...
...
@@ -64,7 +64,7 @@ void cooling_print(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
){
double
dt
){
/*updates the entropy of a particle after integrating the cooling equation*/
float
u_old
;
...
...
@@ -80,7 +80,7 @@ void update_entropy(const struct cooling_data* cooling,
}
float
calculate_new_thermal_energy
(
float
u_old
,
float
dt
,
const
struct
cooling_data
*
cooling
){
float
calculate_new_thermal_energy
(
float
u_old
,
double
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
...
...
This diff is collapsed.
Click to expand it.
src/cooling.h
+
1
−
1
View file @
0ef836d1
...
...
@@ -97,5 +97,5 @@ 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
);
double
dt
);
#endif
/* SWIFT_COOLING_H */
This diff is collapsed.
Click to expand it.
src/runner.c
+
50
−
0
View file @
0ef836d1
...
...
@@ -135,6 +135,53 @@ void runner_do_grav_external(struct runner *r, struct cell *c, int timer) {
if
(
timer
)
TIMER_TOC
(
timer_dograv_external
);
}
/**
* @brief Calculate change in entropy from cooling
*
* @param r runner task
* @param c cell
* @param timer 1 if the time is to be recorded.
*/
void
runner_do_cooling
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
)
{
struct
part
*
restrict
parts
=
c
->
parts
;
const
int
count
=
c
->
count
;
const
int
ti_current
=
r
->
e
->
ti_current
;
const
struct
cooling_data
*
cooling
=
r
->
e
->
cooling
;
const
struct
phys_const
*
constants
=
r
->
e
->
physical_constants
;
const
double
timeBase
=
r
->
e
->
timeBase
;
double
dt
;
TIMER_TIC
;
/* Recurse? */
if
(
c
->
split
)
{
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
runner_do_cooling
(
r
,
c
->
progeny
[
k
],
0
);
return
;
}
#ifdef TASK_VERBOSE
OUT
;
#endif
/* Loop over the gparts in this cell. */
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
/* Get a direct pointer on the part. */
struct
part
*
restrict
p
=
&
parts
[
i
];
/* Is this part within the time step? */
if
(
p
->
ti_end
<=
ti_current
)
{
dt
=
(
p
->
ti_end
-
p
->
ti_begin
)
*
timeBase
;
update_entropy
(
cooling
,
constants
,
p
,
dt
);
}
}
if
(
timer
)
TIMER_TOC
(
timer_do_cooling
);
}
/**
* @brief Sort the entries in ascending order using QuickSort.
*
...
...
@@ -1158,6 +1205,9 @@ void *runner_main(void *data) {
case
task_type_grav_external
:
runner_do_grav_external
(
r
,
t
->
ci
,
1
);
break
;
case
task_type_cooling
:
runner_do_cooling
(
r
,
t
->
ci
,
1
);
break
;
case
task_type_part_sort
:
space_do_parts_sort
();
break
;
...
...
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