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
1cbf5caf
Commit
1cbf5caf
authored
6 years ago
by
Folkert Nobels
Browse files
Options
Downloads
Patches
Plain Diff
Make the seed external and explicit in the runner
parent
0aa907f8
No related branches found
No related tags found
1 merge request
!705
Star formation following Schaye08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/runner.c
+4
-2
4 additions, 2 deletions
src/runner.c
src/starformation/schaye08/starformation.h
+12
-3
12 additions, 3 deletions
src/starformation/schaye08/starformation.h
with
16 additions
and
5 deletions
src/runner.c
+
4
−
2
View file @
1cbf5caf
...
...
@@ -470,6 +470,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
const
int
count
=
c
->
hydro
.
count
;
struct
part
*
restrict
parts
=
c
->
hydro
.
parts
;
struct
xpart
*
restrict
xparts
=
c
->
hydro
.
xparts
;
unsigned
int
testseed
;
TIMER_TIC
;
...
...
@@ -492,9 +493,10 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
if
(
part_is_active
(
p
,
e
))
{
//const float rho = hydro_get_physical_density(p, cosmo);
// THIS IS A VERY WEAK SEED, WE NEED TO IMPROVE THIS
testseed
=
p
->
id
+
timer
;
if
(
starformation_potential_to_become_star
(
starform
,
p
,
xp
,
constants
,
cosmo
)
)
{
starformation_convert_to_gas
(
starform
,
p
,
xp
,
cosmo
);
starformation_convert_to_gas
(
starform
,
p
,
xp
,
cosmo
,
testseed
);
}
// MATTHIEU: Temporary star-formation law
// Do not use this at home.
...
...
This diff is collapsed.
Click to expand it.
src/starformation/schaye08/starformation.h
+
12
−
3
View file @
1cbf5caf
...
...
@@ -80,6 +80,9 @@ struct star_formation {
/*! Critical density to form stars */
double
den_crit
;
/*! Maximum critical density to form stars */
double
den_crit_max
;
/*! Scaling metallicity */
double
Z0
;
...
...
@@ -164,10 +167,11 @@ INLINE static int starformation_potential_to_become_star(
* */
INLINE
static
void
starformation_convert_to_gas
(
const
struct
star_formation
*
starform
,
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
const
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
,
unsigned
int
seed
){
/* Set a dummy seed for testing */
unsigned
int
globalseed
=
42
;
//
unsigned int globalseed = 42;
/* Get the pressure */
const
double
pressure
=
hydro_get_physical_pressure
(
p
,
cosmo
);
...
...
@@ -177,7 +181,7 @@ INLINE static void starformation_convert_to_gas(
starform
->
SF_power_law
)
*
p
->
time_bin
;
/* Generate a random number between 0 and 1. */
const
double
randomnumber
=
rand_r
(
&
global
seed
)
*
starform
->
inv_RAND_MAX
;
const
double
randomnumber
=
rand_r
(
&
seed
)
*
starform
->
inv_RAND_MAX
;
/* Calculate if we form a star */
if
(
prop
>
randomnumber
)
{
...
...
@@ -358,6 +362,11 @@ INLINE static void starformation_init_backend(
/* Read the power law of the critical density scaling */
starform
->
n_Z0
=
parser_get_opt_param_double
(
parameter_file
,
"SchayeSF:MetDep_SFthresh_Slope"
,
powerlawZ_default
);
/* Read the maximum allowed density for star formation */
starform
->
den_crit_max
=
parser_get_opt_param_double
(
parameter_file
,
"SchayeSF:thresh_max_norm_HpCM3"
,
norm_ncrit_no04_default
);
}
/* Conversion of number density from cgs */
static
const
float
dimension_numb_den
[
5
]
=
{
0
,
-
3
,
0
,
0
,
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