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
a1f4b098
Commit
a1f4b098
authored
6 years ago
by
Folkert Nobels
Browse files
Options
Downloads
Patches
Plain Diff
Add SFR to the xpart of the gas particle for only Gadget 2 SPH as temporary position
parent
6cfefd19
No related branches found
No related tags found
1 merge request
!705
Star formation following Schaye08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hydro/Gadget2/hydro_part.h
+3
-0
3 additions, 0 deletions
src/hydro/Gadget2/hydro_part.h
src/runner.c
+1
-1
1 addition, 1 deletion
src/runner.c
src/starformation/schaye08/starformation.h
+18
-4
18 additions, 4 deletions
src/starformation/schaye08/starformation.h
with
22 additions
and
5 deletions
src/hydro/Gadget2/hydro_part.h
+
3
−
0
View file @
a1f4b098
...
@@ -60,6 +60,9 @@ struct xpart {
...
@@ -60,6 +60,9 @@ struct xpart {
/* Additional data used by the tracers */
/* Additional data used by the tracers */
struct
tracers_xpart_data
tracers_data
;
struct
tracers_xpart_data
tracers_data
;
/* SFR label */
float
SFR
;
#ifdef WITH_LOGGER
#ifdef WITH_LOGGER
/* Additional data for the particle logger */
/* Additional data for the particle logger */
struct
logger_part_data
logger_data
;
struct
logger_part_data
logger_data
;
...
...
This diff is collapsed.
Click to expand it.
src/runner.c
+
1
−
1
View file @
a1f4b098
...
@@ -515,7 +515,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
...
@@ -515,7 +515,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
// const float rho = hydro_get_physical_density(p, cosmo);
// const float rho = hydro_get_physical_density(p, cosmo);
if
(
star_formation_convert_to_star
(
e
,
starform
,
p
,
xp
,
constants
,
cosmo
,
if
(
star_formation_convert_to_star
(
e
,
starform
,
p
,
xp
,
constants
,
cosmo
,
hydro_props
,
us
,
cooling
,
dt_star
))
{
hydro_props
,
us
,
cooling
,
dt_star
,
with_cosmology
))
{
/* Convert your particle to a star */
/* Convert your particle to a star */
struct
spart
*
sp
=
cell_convert_part_to_spart
(
e
,
c
,
p
,
xp
);
struct
spart
*
sp
=
cell_convert_part_to_spart
(
e
,
c
,
p
,
xp
);
...
...
This diff is collapsed.
Click to expand it.
src/starformation/schaye08/starformation.h
+
18
−
4
View file @
a1f4b098
...
@@ -200,12 +200,12 @@ INLINE static int star_formation_potential_to_become_star(
...
@@ -200,12 +200,12 @@ INLINE static int star_formation_potential_to_become_star(
*/
*/
INLINE
static
int
star_formation_convert_to_star
(
INLINE
static
int
star_formation_convert_to_star
(
const
struct
engine
*
e
,
const
struct
star_formation
*
starform
,
const
struct
engine
*
e
,
const
struct
star_formation
*
starform
,
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
phys_const
*
const
phys_const
,
const
struct
cosmology
*
cosmo
,
const
struct
phys_const
*
const
phys_const
,
const
struct
cosmology
*
cosmo
,
const
struct
hydro_props
*
restrict
hydro_props
,
const
struct
hydro_props
*
restrict
hydro_props
,
const
struct
unit_system
*
restrict
us
,
const
struct
unit_system
*
restrict
us
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
double
dt_star
)
{
const
double
dt_star
,
const
int
with_cosmology
)
{
if
(
dt_star
==
0
.
f
)
return
0
;
if
(
dt_star
==
0
.
f
)
return
0
;
...
@@ -219,9 +219,14 @@ INLINE static int star_formation_convert_to_star(
...
@@ -219,9 +219,14 @@ INLINE static int star_formation_convert_to_star(
starform
->
EOS_density_norm
/
phys_const
->
const_proton_mass
,
starform
->
EOS_density_norm
/
phys_const
->
const_proton_mass
,
starform
->
polytropic_index
);
starform
->
polytropic_index
);
/* Calculate the star formation rate */
const
double
SFRpergasmass
=
starform
->
SF_normalization
*
pow
(
pressure
,
starform
->
SF_power_law
);
xp
->
SFR
=
SFRpergasmass
*
p
->
mass
;
/* Calculate the propability of forming a star */
/* Calculate the propability of forming a star */
const
double
prop
=
starform
->
SF_normalization
*
const
double
prop
=
SFRpergasmass
*
dt_star
;
pow
(
pressure
,
starform
->
SF_power_law
)
*
dt_star
;
/* Calculate the seed */
/* Calculate the seed */
unsigned
int
seed
=
(
p
->
id
+
e
->
ti_current
)
%
8191
;
unsigned
int
seed
=
(
p
->
id
+
e
->
ti_current
)
%
8191
;
...
@@ -234,6 +239,15 @@ INLINE static int star_formation_convert_to_star(
...
@@ -234,6 +239,15 @@ INLINE static int star_formation_convert_to_star(
/* Calculate if we form a star */
/* Calculate if we form a star */
return
(
prop
>
randomnumber
);
return
(
prop
>
randomnumber
);
}
/* Check if it is the first time steps after star formation */
if
(
xp
->
SFR
>
0
.
f
)
{
if
(
with_cosmology
)
{
xp
->
SFR
=
-
cosmo
->
a
;
}
else
{
xp
->
SFR
=
-
e
->
time
;
}
}
}
return
0
;
return
0
;
...
...
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