Commit 86bbca98 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Add the first draft for the inactive SFR in the logger

parent 39c9fb13
......@@ -592,7 +592,11 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
star_formation_init_SFH(&c->stars.sfh);
/* Anything to do here? */
if (!cell_is_active_hydro(c, e)) return;
if (!cell_is_active_hydro(c, e)) {
star_formation_init_SFH_inactive(&c->stars.sfh);
return;
}
star_formation_init_SFH_active(&c->stars.sfh);
/* Recurse? */
if (c->split) {
......@@ -642,7 +646,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
star_formation_compute_SFR(p, xp, sf_props, phys_const, cosmo,
dt_star);
/* Add the SFR to the SFH struct of this cell */
/* Add the SFR and SFR*dt to the SFH struct of this cell */
star_formation_log_for_active_particles(p, xp, &c->stars.sfh, dt_star);
/* Are we forming a star particle from this SF rate? */
......
......@@ -56,6 +56,33 @@ INLINE static void star_formation_init_SFH(struct star_formation_history *sf) {
/* Initialize the counter at zero */
sf->N_stars = 0;
}
/**
* @brief Initialize the star formation history struct
*
* @param sf the star_formation_history struct we want to initialize
*/
INLINE static void star_formation_init_SFH_active(struct star_formation_history *sf) {
/* Initialize the active SFR */
sf->SFR_active = 0.f;
/* Initialize the SFR*dt active */
sf->SFRdt_active = 0.f;
/* Initialize the inactive SFR */
sf->SFR_inactive = 0.f;
}
/**
* @brief Initialize the star formation history struct
*
* @param sf the star_formation_history struct we want to initialize
*/
INLINE static void star_formation_init_SFH_inactive(struct star_formation_history *sf) {
/* The active SFR becomes the inactive SFR */
sf->SFR_inactive += sf->SFR_active;
/* Initialize the active SFR */
sf->SFR_active = 0.f;
......@@ -84,6 +111,9 @@ INLINE static void star_formation_add_progeny_SFH(
/* Add the SFR * dt of the progeny */
sf->SFRdt_active += sfprogeny->SFRdt_active;
/* Add the Inactive SFR of the progeny */
sf->SFR_inactive += sfprogeny->SFR_inactive;
}
/**
......@@ -105,6 +135,10 @@ INLINE static void star_formation_get_total_cell(
sf->N_stars += sfcell->new_stellar_mass;
sf->SFR_active += sfcell->SFR_active;
sf->SFRdt_active += sfcell->SFRdt_active;
sf->SFR_inactive += sfcell->SFR_inactive;
}
/**
......@@ -120,6 +154,10 @@ INLINE static void star_formation_clear_total_cell(struct cell *c) {
sfcell->N_stars = 0;
sfcell->SFR_active = 0.f;
sfcell->SFRdt_active = 0.f;
sfcell->SFR_inactive = 0.f;
}
/**
......@@ -137,6 +175,10 @@ INLINE static void star_formation_add_to_parent_cell(
sfcell->N_stars += sf->N_stars;
sfcell->SFR_active += sf->SFR_active;
sfcell->SFRdt_active += sf->SFR_active;
sfcell->SFR_inactive += sf->SFR_inactive;
}
/**
......@@ -151,6 +193,10 @@ INLINE static void star_formation_init_SFH_engine(
sfh->N_stars = 0;
sfh->SFR_active = 0.f;
sfh->SFRdt_active = 0.f;
sfh->SFR_inactive = 0.f;
}
/**
......@@ -164,10 +210,14 @@ INLINE static void star_formation_init_SFH_engine(
INLINE static void star_formation_write_to_file(
const double time, const double a, const double z,
struct star_formation_history sf) {
/* Open the file */
FILE *fp;
fp = fopen("./SFH.txt", "a");
fprintf(fp, "%16e %12.7f %12.7f %10lld %14e %14e\n", time, a, z, sf.N_stars,
sf.new_stellar_mass, sf.SFR_active);
/* Calculate the total SFR */
const float totalSFR = sf.SFR_active + sf.SFR_inactive;
fprintf(fp, "%16e %12.7f %12.7f %10lld %14e %14e %14e %14e\n", time, a, z, sf.N_stars,
sf.new_stellar_mass, sf.SFR_active, sf.SFRdt_active, totalSFR);
fclose(fp);
}
......
......@@ -28,7 +28,7 @@ struct star_formation_history {
float new_stellar_mass;
/*! SFR of all particles */
float SFR;
float SFR_inactive;
/*! SFR of active particles */
float SFR_active;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment