Skip to content
Snippets Groups Projects
Commit d2862cd8 authored by Alexei Borissov's avatar Alexei Borissov Committed by Alexei Borissov
Browse files

Added Simba star formation subdirectory

parent 3dd7920e
Branches
No related tags found
No related merge requests found
Showing with 1127 additions and 1 deletion
......@@ -2247,6 +2247,9 @@ case "$with_star_formation" in
GEAR)
AC_DEFINE([STAR_FORMATION_GEAR], [1], [GEAR star formation model (Revaz and Jablonka (2018))])
;;
SIMBA)
AC_DEFINE([STAR_FORMATION_SIMBA], [1], [SIMBA stellar feedback incorporated into EAGLE star formation model (Dave et al (2019))])
;;
*)
AC_MSG_ERROR([Unknown star formation model])
;;
......
......@@ -37,6 +37,7 @@
inline void compute_kick_speed(struct spart *sp, const struct feedback_props *feedback_props, const struct cosmology *cosmo) {
/* Calculate circular velocity based on Baryonic Tully-Fisher relation*/
// ALEXEI: check whether this formula is correct wrt comoving coordinates
const float v_circ = pow(sp->feedback_data.host_galaxy_mass/feedback_props->simba_host_galaxy_mass_norm, feedback_props->simba_v_circ_exp);
/* checkout what this random number does and how to generate it */
......@@ -64,7 +65,7 @@ inline void compute_kick_speed(struct spart *sp, const struct feedback_props *fe
* @param feedback_props The properties of the feedback model
*/
inline void compute_mass_loading(struct spart *sp, const struct feedback_props *feedback_props) {
// ALEXEI: check units of host_galaxy_mass with Romeel: is this a mass or mass/msun?
// ALEXEI: Think this should be star particle mass, not host galaxy mass. Check with Romeel
if (sp->mass < feedback_props->simba_mass_spectrum_break_msun) {
sp->feedback_data.to_distribute.wind_mass = feedback_props->simba_wind_mass_eta
* sp->feedback_data.host_galaxy_mass * pow(sp->mass/feedback_props->simba_mass_spectrum_break_msun,feedback_props->simba_low_mass_power);
......@@ -89,6 +90,7 @@ inline void compute_heating(struct spart *sp, const struct feedback_props *feedb
float u_wind = 0.5*sp->feedback_data.to_distribute.v_kick*sp->feedback_data.to_distribute.v_kick;
/* Calculate internal energy contribution from SN */
// ALEXEI: Think this should be star particle mass, not host galaxy mass. Check with Romeel
float u_SN = feedback_props->SN_energy * sp->feedback_data.host_galaxy_mass
/ sp->feedback_data.to_distribute.wind_mass;
......@@ -213,6 +215,10 @@ __attribute__((always_inline)) INLINE static void feedback_evolve_spart(
}
__attribute__((always_inline)) INLINE static void star_formation_launch_wind(
struct part* restrict p, struct xpart* restrict xp,
const struct cosmology* cosmo){}
/**
* @brief Write a feedback struct to the given FILE as a stream of bytes.
*
......
......@@ -43,6 +43,8 @@
#elif defined(STAR_FORMATION_GEAR)
#define swift_star_formation_model_creates_stars 1
#include "./star_formation/GEAR/star_formation.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation.h"
#else
#error "Invalid choice of star formation law"
#endif
......
This diff is collapsed.
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_EAGLE_STAR_FORMATION_IACT_H
#define SWIFT_EAGLE_STAR_FORMATION_IACT_H
/**
* @file EAGLE/star_formation_iact.h
* @brief Density computation
*/
/**
* @brief do star_formation computation after the runner_iact_density (symmetric
* version)
*
* @param r2 Comoving square distance between the two particles.
* @param dx Comoving vector separating both particles (pi - pj).
* @param hi Comoving smoothing-length of particle i.
* @param hj Comoving smoothing-length of particle j.
* @param pi First particle.
* @param pj Second particle.
* @param a Current scale factor.
* @param H Current Hubble parameter.
*/
__attribute__((always_inline)) INLINE static void runner_iact_star_formation(
float r2, const float *dx, float hi, float hj, struct part *restrict pi,
struct part *restrict pj, float a, float H) {
/* Nothing to do here. We do not need to compute any quantity in the hydro
density loop for the EAGLE star formation model. */
}
/**
* @brief do star_formation computation after the runner_iact_density (non
* symmetric version)
*
* @param r2 Comoving square distance between the two particles.
* @param dx Comoving vector separating both particles (pi - pj).
* @param hi Comoving smoothing-length of particle i.
* @param hj Comoving smoothing-length of particle j.
* @param pi First particle.
* @param pj Second particle (not updated).
* @param a Current scale factor.
* @param H Current Hubble parameter.
*/
__attribute__((always_inline)) INLINE static void
runner_iact_nonsym_star_formation(float r2, const float *dx, float hi, float hj,
struct part *restrict pi,
const struct part *restrict pj, float a,
float H) {
/* Nothing to do here. We do not need to compute any quantity in the hydro
density loop for the EAGLE star formation model. */
}
#endif /* SWIFT_EAGLE_STAR_FORMATION_IACT_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_STAR_FORMATION_EAGLE_IO_H
#define SWIFT_STAR_FORMATION_EAGLE_IO_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "io_properties.h"
/**
* @brief Specifies which particle fields to write to a dataset
*
* @param parts The particle array.
* @param xparts The extended data particle array.
* @param list The list of i/o properties to write.
*
* @return Returns the number of fields to write.
*/
__attribute__((always_inline)) INLINE static int star_formation_write_particles(
const struct part* parts, const struct xpart* xparts,
struct io_props* list) {
list[0] =
io_make_output_field("SFR", FLOAT, 1, UNIT_CONV_SFR, xparts, sf_data.SFR);
return 1;
}
#endif /* SWIFT_STAR_FORMATION_EAGLE_IO_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2019 Folkert Nobels (nobels@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/
#ifndef SWIFT_EAGLE_STARFORMATION_LOGGER_H
#define SWIFT_EAGLE_STARFORMATION_LOGGER_H
/* Some standard headers */
#include <stdlib.h>
/* Local includes */
#include "cell.h"
#include "hydro.h"
#include "part.h"
#include "star_formation_logger_struct.h"
#include "units.h"
/**
* @brief Update the stellar mass in the current cell after creating
* the new star particle spart sp
*
* @param sp new created star particle
* @param sf the star_formation_history struct of the current cell
*/
INLINE static void star_formation_logger_log_new_spart(
const struct spart *sp, struct star_formation_history *sf) {
/* Add mass of created sparticle to the total stellar mass in this cell*/
sf->new_stellar_mass += sp->mass;
}
/**
* @brief Initialize the star formation history struct in the case the cell is
* inactive
*
* @param sf the star_formation_history struct we want to initialize
*/
INLINE static void star_formation_logger_log_inactive_cell(
struct star_formation_history *sf) {
/* Initialize the stellar mass to zero*/
sf->new_stellar_mass = 0.f;
/* The active SFR becomes the inactive SFR */
sf->SFR_inactive += sf->SFR_active;
/* Initialize the active SFR */
sf->SFR_active = 0.f;
/* Initialize the SFR*dt active */
sf->SFRdt_active = 0.f;
}
/**
* @brief add a star formation history struct to an other star formation history
* struct
*
* @param sf_add the star formation struct which we want to add to the star
* formation history
* @param sf_update the star formation structure which we want to update
*/
INLINE static void star_formation_logger_add(
struct star_formation_history *sf_update,
const struct star_formation_history *sf_add) {
/* Update the SFH structure */
sf_update->new_stellar_mass += sf_add->new_stellar_mass;
sf_update->SFR_active += sf_add->SFR_active;
sf_update->SFRdt_active += sf_add->SFRdt_active;
sf_update->SFR_inactive += sf_add->SFR_inactive;
}
/**
* @brief Initialize the star formation history structure in the #engine
*
* @param sfh The pointer to the star formation history structure
*/
INLINE static void star_formation_logger_init(
struct star_formation_history *sfh) {
/* Initialize the collecting SFH structure to zero */
sfh->new_stellar_mass = 0.f;
sfh->SFR_active = 0.f;
sfh->SFRdt_active = 0.f;
sfh->SFR_inactive = 0.f;
}
/**
* @brief Write the final SFH to a file
*
* @param fp The file to write to.
* @param time the simulation time (time since Big Bang) in internal units.
* @param a the scale factor.
* @param z the redshift.
* @param sf the #star_formation_history struct.
* @param step The time-step of the simulation.
*/
INLINE static void star_formation_logger_write_to_log_file(
FILE *fp, const double time, const double a, const double z,
const struct star_formation_history sf, const int step) {
/* Calculate the total SFR */
const float totalSFR = sf.SFR_active + sf.SFR_inactive;
fprintf(fp, "%6d %16e %12.7f %12.7f %14e %14e %14e %14e\n", step, time, a, z,
sf.new_stellar_mass, sf.SFR_active, sf.SFRdt_active, totalSFR);
}
/**
* @brief Initialize the SFH logger file
*
* @param fp the file pointer
* @param us The current internal system of units.
* @param phys_const Physical constants in internal units
*/
INLINE static void star_formation_logger_init_log_file(
FILE *fp, const struct unit_system *restrict us,
const struct phys_const *phys_const) {
/* Write some general text to the logger file */
fprintf(fp, "# Star Formation History Logger file\n");
fprintf(fp, "######################################################\n");
fprintf(fp, "# The quantities are all given in internal physical units!\n");
fprintf(fp, "#\n");
fprintf(fp, "# (0) Simulation step\n");
fprintf(fp,
"# (1) Time since Big Bang (cosmological run), Time since start of "
"the simulation (non-cosmological run).\n");
fprintf(fp, "# Unit = %e seconds\n", us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e yr or %e Myr\n", 1.f / phys_const->const_year,
1.f / phys_const->const_year / 1e6);
fprintf(fp, "# (2) Scale factor (no unit)\n");
fprintf(fp, "# (3) Redshift (no unit)\n");
fprintf(fp, "# (4) Total mass stars formed in the current time-step.\n");
fprintf(fp, "# Unit = %e gram\n", us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",
1.f / phys_const->const_solar_mass);
fprintf(fp, "# (5) The total SFR of all the active particles.\n");
fprintf(fp, "# Unit = %e gram/s\n",
us->UnitMass_in_cgs / us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",
phys_const->const_year / phys_const->const_solar_mass);
fprintf(fp,
"# (6) The star formation rate (SFR) of active particles multiplied "
"by their time-step size.\n");
fprintf(fp, "# Unit = %e gram\n", us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",
1.f / phys_const->const_solar_mass);
fprintf(fp, "# (7) The total SFR of all the particles in the simulation.\n");
fprintf(fp, "# Unit = %e gram/s\n",
us->UnitMass_in_cgs / us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",
phys_const->const_year / phys_const->const_solar_mass);
fprintf(fp, "#\n");
fprintf(
fp,
"# (0) (1) (2) (3) (4) "
" (5) (6) (7)\n");
fprintf(
fp,
"# Time a z total M_stars SFR "
"(active) SFR*dt (active) SFR (total)\n");
}
/**
* @brief Add the SFR tracer to the total active SFR of this cell
*
* @param p the #part
* @param xp the #xpart
* @param sf the SFH logger struct
* @param dt_star The length of the time-step in physical internal units.
*/
INLINE static void star_formation_logger_log_active_part(
const struct part *p, const struct xpart *xp,
struct star_formation_history *sf, const double dt_star) {
/* Add the SFR to the logger file */
sf->SFR_active += xp->sf_data.SFR;
/* Update the active SFR*dt */
sf->SFRdt_active += xp->sf_data.SFR * dt_star;
}
/**
* @brief Add the SFR tracer to the total inactive SFR of this cell as long as
* the SFR tracer is larger than 0
*
* @param p the #part
* @param xp the #xpart
* @param sf the SFH logger struct
*/
INLINE static void star_formation_logger_log_inactive_part(
const struct part *p, const struct xpart *xp,
struct star_formation_history *sf) {
/* Add the SFR to the logger file */
sf->SFR_inactive += max(xp->sf_data.SFR, 0.f);
}
#endif /* SWIFT_EAGLE_STARFORMATION_LOGGER_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2019 Folkert Nobels (nobels@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_EAGLE_STAR_FORMATION_LOGGER_STRUCT_H
#define SWIFT_EAGLE_STAR_FORMATION_LOGGER_STRUCT_H
/* Starformation history struct */
struct star_formation_history {
/*! Total new stellar mass */
float new_stellar_mass;
/*! SFR of all particles */
float SFR_inactive;
/*! SFR of active particles */
float SFR_active;
/*! SFR*dt of active particles */
float SFRdt_active;
};
#endif /* SWIFT_EAGLE_STAR_FORMATION_LOGGER_STRUCT_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_EAGLE_STAR_FORMATION_STRUCT_H
#define SWIFT_EAGLE_STAR_FORMATION_STRUCT_H
/**
* @brief Star-formation-related properties stored in the extended particle
* data.
*/
struct star_formation_xpart_data {
/*! Star formation rate */
float SFR;
};
#endif /* SWIFT_EAGLE_STAR_FORMATION_STRUCT_H */
......@@ -37,6 +37,8 @@
#include "./star_formation/EAGLE/star_formation_iact.h"
#elif defined(STAR_FORMATION_GEAR)
#include "./star_formation/GEAR/star_formation_iact.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation_iact.h"
#else
#error "Invalid choice of star formation law"
#endif
......
......@@ -36,6 +36,8 @@
#include "./star_formation/EAGLE/star_formation_io.h"
#elif defined(STAR_FORMATION_GEAR)
#include "./star_formation/GEAR/star_formation_io.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation_io.h"
#else
#error "Invalid choice of star formation model."
#endif
......
......@@ -36,6 +36,8 @@
#include "./star_formation/EAGLE/star_formation_logger.h"
#elif defined(STAR_FORMATION_GEAR)
#include "./star_formation/GEAR/star_formation_logger.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation_logger.h"
#else
#error "Invalid choice of star formation model."
#endif
......
......@@ -36,6 +36,8 @@
#include "./star_formation/EAGLE/star_formation_logger_struct.h"
#elif defined(STAR_FORMATION_GEAR)
#include "./star_formation/GEAR/star_formation_logger_struct.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation_logger_struct.h"
#else
#error "Invalid choice of star formation structure."
#endif
......
......@@ -36,6 +36,8 @@
#include "./star_formation/EAGLE/star_formation_struct.h"
#elif defined(STAR_FORMATION_GEAR)
#include "./star_formation/GEAR/star_formation_struct.h"
#elif defined(STAR_FORMATION_SIMBA)
#include "./star_formation/SIMBA/star_formation_struct.h"
#else
#error "Invalid choice of star formation structure."
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment