MP-Gadget
5.0.1.dev1-76bc7d4726-dirty
|
Compute the mass return rate of metals from stellar evolution. More...
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_roots.h>
#include <gsl/gsl_errno.h>
#include <omp.h>
#include "physconst.h"
#include "walltime.h"
#include "slotsmanager.h"
#include "treewalk.h"
#include "metal_return.h"
#include "densitykernel.h"
#include "density.h"
#include "cosmology.h"
#include "winds.h"
#include "utils/spinlocks.h"
#include "metal_tables.h"
Go to the source code of this file.
Classes | |
struct | metal_return_params |
struct | TreeWalkQueryMetals |
struct | TreeWalkResultMetals |
struct | TreeWalkNgbIterMetals |
struct | massbin_find_params |
struct | imf_integ_params |
struct | TreeWalkNgbIterStellarDensity |
struct | TreeWalkQueryStellarDensity |
struct | TreeWalkResultStellarDensity |
struct | StellarDensityPriv |
Macros | |
#define | METALS_GET_PRIV(tw) ((struct MetalReturnPriv*) ((tw)->priv)) |
#define | NHSML 10 |
#define | STELLAR_DENSITY_GET_PRIV(tw) ((struct StellarDensityPriv*) ((tw)->priv)) |
Functions | |
void | set_metal_params (double Sn1aN0) |
void | set_metal_return_params (ParameterSet *ps) |
void | setup_metal_table_interp (struct interps *interp) |
static int | metal_return_haswork (int n, TreeWalk *tw) |
static void | metal_return_ngbiter (TreeWalkQueryMetals *I, TreeWalkResultMetals *O, TreeWalkNgbIterMetals *iter, LocalTreeWalk *lv) |
static void | metal_return_copy (int place, TreeWalkQueryMetals *input, TreeWalk *tw) |
static void | metal_return_postprocess (int place, TreeWalk *tw) |
static double | chabrier_imf (double mass) |
double | atime_integ (double atime, void *params) |
static double | atime_to_myr (Cosmology *CP, double atime1, double atime2, gsl_integration_workspace *gsl_work) |
double | massendlife (double mass, void *params) |
double | do_rootfinding (struct massbin_find_params *p, double mass_low, double mass_high) |
void | find_mass_bin_limits (double *masslow, double *masshigh, const double dtstart, const double dtend, double stellarmetal, gsl_interp2d *lifetime_tables) |
double | chabrier_imf_integ (double mass, void *params) |
double | chabrier_mass (double mass, void *params) |
double | compute_imf_norm (gsl_integration_workspace *gsl_work) |
double | sn1a_number (double dtmyrstart, double dtmyrend, double hub) |
double | compute_agb_yield (gsl_interp2d *agb_interp, const double *agb_weights, double stellarmetal, double masslow, double masshigh, gsl_integration_workspace *gsl_work) |
double | compute_snii_yield (gsl_interp2d *snii_interp, const double *snii_weights, double stellarmetal, double masslow, double masshigh, gsl_integration_workspace *gsl_work) |
static double | mass_yield (double dtmyrstart, double dtmyrend, double stellarmetal, double hub, struct interps *interp, double imf_norm, gsl_integration_workspace *gsl_work, double masslow, double masshigh) |
static double | metal_yield (double dtmyrstart, double dtmyrend, double stellarmetal, double hub, struct interps *interp, MyFloat *MetalYields, double imf_norm, gsl_integration_workspace *gsl_work, double masslow, double masshigh) |
int64_t | metal_return_init (const ActiveParticles *act, Cosmology *CP, struct MetalReturnPriv *priv, const double atime) |
void | metal_return_priv_free (struct MetalReturnPriv *priv) |
void | metal_return (const ActiveParticles *act, DomainDecomp *const ddecomp, Cosmology *CP, const double atime, const double AvgGasMass) |
int | metals_haswork (int i, MyFloat *MassReturn) |
static int | stellar_density_haswork (int i, TreeWalk *tw) |
static double | effhsml (int place, int i, TreeWalk *tw) |
static void | stellar_density_copy (int place, TreeWalkQueryStellarDensity *I, TreeWalk *tw) |
static void | stellar_density_reduce (int place, TreeWalkResultStellarDensity *remote, enum TreeWalkReduceMode mode, TreeWalk *tw) |
void | stellar_density_check_neighbours (int i, TreeWalk *tw) |
static void | stellar_density_ngbiter (TreeWalkQueryStellarDensity *I, TreeWalkResultStellarDensity *O, TreeWalkNgbIterStellarDensity *iter, LocalTreeWalk *lv) |
void | stellar_density (const ActiveParticles *act, MyFloat *StarVolumeSPH, MyFloat *MassReturn, const ForceTree *const tree) |
Variables | |
static struct metal_return_params | MetalParams |
Compute the mass return rate of metals from stellar evolution.
This file returns metals from stars with some delay. Delayed sources followed are AGB stars, SNII and Sn1a. 9 Species specific yields are stored in the stars and the gas particles. Gas enrichment is not run every timestep, but only for stars that have significant enrichment, or are young. The model closely follows Illustris-TNG, https://arxiv.org/abs/1703.02970 However the tables used are slightly different: we consider SNII between 8 and 40 Msun following Kobayashi 2006, where they use a hybrid of Kobayashi and Portinari. AGB yields are from Karakas 2010, like TNG, but stars with mass > 6.5 are from Doherty 2014, not Fishlock 2014. More details of the model can be found in the Illustris model Vogelsberger 2013: https://arxiv.org/abs/1305.2913 As the Kobayashi table only goes to 13 Msun, stars with masses 8-13 Msun are assumed to yield like a 13 Msun star, but scaled by a factor of (M/13).
Definition in file metal_return.c.
#define METALS_GET_PRIV | ( | tw | ) | ((struct MetalReturnPriv*) ((tw)->priv)) |
Definition at line 99 of file metal_return.c.
#define NHSML 10 |
Definition at line 726 of file metal_return.c.
#define STELLAR_DENSITY_GET_PRIV | ( | tw | ) | ((struct StellarDensityPriv*) ((tw)->priv)) |
Definition at line 762 of file metal_return.c.
double atime_integ | ( | double | atime, |
void * | params | ||
) |
Definition at line 154 of file metal_return.c.
References CP, and hubble_function().
Referenced by atime_to_myr().
|
static |
Definition at line 161 of file metal_return.c.
References atime_integ(), CP, GSL_WORKSPACE, SEC_PER_MEGAYEAR, and Cosmology::UnitTime_in_s.
Referenced by metal_return_init().
|
static |
Definition at line 144 of file metal_return.c.
Referenced by chabrier_imf_integ(), and chabrier_mass().
double chabrier_imf_integ | ( | double | mass, |
void * | params | ||
) |
Definition at line 289 of file metal_return.c.
References chabrier_imf(), imf_integ_params::interp, imf_integ_params::masses, imf_integ_params::metallicities, imf_integ_params::metallicity, and imf_integ_params::weights.
Referenced by compute_agb_yield(), and compute_snii_yield().
double chabrier_mass | ( | double | mass, |
void * | params | ||
) |
Definition at line 308 of file metal_return.c.
References chabrier_imf().
Referenced by compute_imf_norm(), and test_yields().
double compute_agb_yield | ( | gsl_interp2d * | agb_interp, |
const double * | agb_weights, | ||
double | stellarmetal, | ||
double | masslow, | ||
double | masshigh, | ||
gsl_integration_workspace * | gsl_work | ||
) |
Definition at line 342 of file metal_return.c.
References agb_masses, agb_metallicities, AGB_NMET, chabrier_imf_integ(), GSL_WORKSPACE, imf_integ_params::interp, imf_integ_params::masses, imf_integ_params::metallicities, imf_integ_params::metallicity, SNAGBSWITCH, and imf_integ_params::weights.
Referenced by mass_yield(), metal_yield(), and test_yields().
double compute_imf_norm | ( | gsl_integration_workspace * | gsl_work | ) |
Definition at line 314 of file metal_return.c.
References chabrier_mass(), GSL_WORKSPACE, MAXMASS, and MINMASS.
Referenced by metal_return_init(), and test_yields().
double compute_snii_yield | ( | gsl_interp2d * | snii_interp, |
const double * | snii_weights, | ||
double | stellarmetal, | ||
double | masslow, | ||
double | masshigh, | ||
gsl_integration_workspace * | gsl_work | ||
) |
Definition at line 368 of file metal_return.c.
References chabrier_imf_integ(), GSL_WORKSPACE, imf_integ_params::interp, imf_integ_params::masses, imf_integ_params::metallicities, imf_integ_params::metallicity, SNAGBSWITCH, snii_masses, snii_metallicities, SNII_NMASS, SNII_NMET, and imf_integ_params::weights.
Referenced by mass_yield(), metal_yield(), and test_yields().
double do_rootfinding | ( | struct massbin_find_params * | p, |
double | mass_low, | ||
double | mass_high | ||
) |
Definition at line 194 of file metal_return.c.
References massendlife(), and MAXITER.
Referenced by find_mass_bin_limits().
|
inlinestatic |
Definition at line 772 of file metal_return.c.
References ForceTree::BoxSize, force_get_father(), NODE::len, NHSML, ForceTree::Nodes, part_manager_type::NumPart, P, PartManager, STELLAR_DENSITY_GET_PRIV, and TreeWalk::tree.
Referenced by stellar_density_check_neighbours(), and stellar_density_copy().
void find_mass_bin_limits | ( | double * | masslow, |
double * | masshigh, | ||
const double | dtstart, | ||
const double | dtend, | ||
double | stellarmetal, | ||
gsl_interp2d * | lifetime_tables | ||
) |
Definition at line 230 of file metal_return.c.
References agb_masses, do_rootfinding(), massbin_find_params::dtfind, LIFE_NMET, lifetime_masses, lifetime_metallicity, massbin_find_params::lifetime_tables, massbin_find_params::massacc, massendlife(), MAXMASS, massbin_find_params::metalacc, and massbin_find_params::stellarmetal.
Referenced by metal_return_init(), and test_yields().
|
static |
Definition at line 395 of file metal_return.c.
References agb_total_mass, compute_agb_yield(), compute_snii_yield(), interp, sn1a_number(), sn1a_total_metals, and snii_total_mass.
Referenced by metal_return_init().
double massendlife | ( | double | mass, |
void * | params | ||
) |
Definition at line 185 of file metal_return.c.
References massbin_find_params::dtfind, lifetime, lifetime_masses, lifetime_metallicity, massbin_find_params::lifetime_tables, massbin_find_params::massacc, massbin_find_params::metalacc, and massbin_find_params::stellarmetal.
Referenced by do_rootfinding(), and find_mass_bin_limits().
void metal_return | ( | const ActiveParticles * | act, |
DomainDecomp *const | ddecomp, | ||
Cosmology * | CP, | ||
const double | atime, | ||
const double | AvgGasMass | ||
) |
This function is the driver routine for the calculation of metal return.
Definition at line 517 of file metal_return.c.
References ActiveParticles::ActiveParticle, CP, TreeWalk::ev_label, TreeWalk::fill, force_tree_free(), force_tree_rebuild_mask(), free_spinlocks(), GASMASK, TreeWalk::haswork, slots_manager_type::info, init_spinlocks(), MetalReturnPriv::MassReturn, MetalReturnPriv::MaxGasMass, metal_return_copy(), metal_return_haswork(), metal_return_init(), metal_return_ngbiter(), metal_return_postprocess(), metal_return_priv_free(), MPI_INT64, TreeWalk::ngbiter, TreeWalk::ngbiter_type_elsize, ActiveParticles::NumActiveParticle, TreeWalk::postprocess, TreeWalk::priv, TreeWalk::query_type_elsize, TreeWalk::reduce, TreeWalk::repeatdisallowed, TreeWalk::result_type_elsize, slot_info::size, SlotsManager, MetalReturnPriv::spin, MetalReturnPriv::StarVolumeSPH, stellar_density(), TreeWalk::tree, treewalk_run(), treewalk_visit_ngbiter(), TreeWalk::visit, and walltime_measure.
Referenced by run().
|
static |
Definition at line 583 of file metal_return.c.
References MetalReturnPriv::gsl_work, MetalReturnPriv::HighDyingMass, TreeWalkQueryMetals::Hsml, MetalReturnPriv::hub, MetalReturnPriv::imf_norm, interp, MetalReturnPriv::LowDyingMass, TreeWalkQueryMetals::Mass, TreeWalkQueryMetals::MassGenerated, metal_yield(), TreeWalkQueryMetals::MetalGenerated, TreeWalkQueryMetals::Metallicity, METALS_GET_PRIV, TreeWalkQueryMetals::MetalSpeciesGenerated, NMETALS, P, STARP, and TreeWalkQueryMetals::StarVolumeSPH.
Referenced by metal_return().
|
static |
Definition at line 720 of file metal_return.c.
References MetalReturnPriv::MassReturn, METALS_GET_PRIV, and metals_haswork().
Referenced by metal_return().
int64_t metal_return_init | ( | const ActiveParticles * | act, |
Cosmology * | CP, | ||
struct MetalReturnPriv * | priv, | ||
const double | atime | ||
) |
Definition at line 437 of file metal_return.c.
References ActiveParticles::ActiveParticle, agb_masses, atime_to_myr(), compute_imf_norm(), CP, find_mass_bin_limits(), MetalReturnPriv::gsl_work, GSL_WORKSPACE, MetalReturnPriv::HighDyingMass, MetalReturnPriv::hub, HUBBLE, Cosmology::HubbleParam, MetalReturnPriv::imf_norm, slots_manager_type::info, MetalReturnPriv::interp, interps::lifetime_interp, MetalReturnPriv::LowDyingMass, mass_yield(), MetalReturnPriv::MassReturn, MAXMASS, message(), metals_haswork(), mymalloc, ActiveParticles::NumActiveParticle, P, SEC_PER_MEGAYEAR, setup_metal_table_interp(), slot_info::size, SlotsManager, snii_metallicities, SNII_NMET, STARP, MetalReturnPriv::StarVolumeSPH, MetalReturnPriv::StellarAges, and ta_malloc.
Referenced by metal_return().
|
static |
For all gas particles within the density radius of this star, add a fraction of the total mass and metals generated, weighted by the SPH kernel distance from the star.
Definition at line 633 of file metal_return.c.
References TreeWalkNgbIterMetals::base, density_kernel_init(), density_kernel_wk(), endrun(), GetDensityKernelType(), DensityKernel::Hinv, TreeWalkQueryMetals::Hsml, TreeWalkNgbIterBase::Hsml, kernel(), TreeWalkNgbIterMetals::kernel, lock_spinlock(), TreeWalkNgbIterBase::mask, TreeWalkQueryMetals::Mass, TreeWalkQueryMetals::MassGenerated, TreeWalkResultMetals::MassReturn, TreeWalkQueryMetals::MetalGenerated, TreeWalkQueryMetals::Metallicity, MetalParams, METALS_GET_PRIV, TreeWalkQueryMetals::MetalSpeciesGenerated, NGB_TREEFIND_ASYMMETRIC, NMETALS, TreeWalkNgbIterBase::other, P, TreeWalkNgbIterBase::r, TreeWalkNgbIterBase::r2, SPHP, metal_return_params::SPHWeighting, TreeWalkQueryMetals::StarVolumeSPH, TreeWalkNgbIterBase::symmetric, LocalTreeWalk::tw, unlock_spinlock(), and wk.
Referenced by metal_return().
|
static |
Definition at line 619 of file metal_return.c.
References METALS_GET_PRIV, P, and STARP.
Referenced by metal_return().
void metal_return_priv_free | ( | struct MetalReturnPriv * | priv | ) |
Definition at line 500 of file metal_return.c.
References MetalReturnPriv::gsl_work, MetalReturnPriv::HighDyingMass, MetalReturnPriv::LowDyingMass, MetalReturnPriv::MassReturn, myfree, MetalReturnPriv::StarVolumeSPH, MetalReturnPriv::StellarAges, and ta_free.
Referenced by metal_return().
|
static |
Definition at line 411 of file metal_return.c.
References agb_total_metals, agb_yield, compute_agb_yield(), compute_snii_yield(), interp, NMETALS, sn1a_number(), sn1a_total_metals, sn1a_yields, snii_total_metals, and snii_yield.
Referenced by metal_return_copy().
int metals_haswork | ( | int | i, |
MyFloat * | MassReturn | ||
) |
Definition at line 708 of file metal_return.c.
References MetalReturnPriv::MassReturn, P, and STARP.
Referenced by metal_return_haswork(), metal_return_init(), and stellar_density_haswork().
void set_metal_params | ( | double | Sn1aN0 | ) |
Definition at line 55 of file metal_return.c.
References MetalParams, and metal_return_params::Sn1aN0.
Referenced by test_yields().
void set_metal_return_params | ( | ParameterSet * | ps | ) |
Definition at line 62 of file metal_return.c.
References metal_return_params::MaxNgbDeviation, MetalParams, param_get_double(), param_get_int(), metal_return_params::Sn1aN0, metal_return_params::SPHWeighting, and ThisTask.
Referenced by read_parameter_file().
void setup_metal_table_interp | ( | struct interps * | interp | ) |
Definition at line 76 of file metal_return.c.
References agb_masses, agb_metallicities, AGB_NMASS, AGB_NMET, agb_total_mass, agb_total_metals, agb_yield, interp, LIFE_NMASS, LIFE_NMET, lifetime, lifetime_masses, lifetime_metallicity, NMETALS, snii_masses, snii_metallicities, SNII_NMASS, SNII_NMET, snii_total_mass, snii_total_metals, and snii_yield.
Referenced by metal_return_init(), and test_yields().
double sn1a_number | ( | double | dtmyrstart, |
double | dtmyrend, | ||
double | hub | ||
) |
Definition at line 324 of file metal_return.c.
References HUBBLE, MetalParams, SEC_PER_MEGAYEAR, and metal_return_params::Sn1aN0.
Referenced by mass_yield(), metal_yield(), and test_yields().
void stellar_density | ( | const ActiveParticles * | act, |
MyFloat * | StarVolumeSPH, | ||
MyFloat * | MassReturn, | ||
const ForceTree *const | tree | ||
) |
Definition at line 923 of file metal_return.c.
References ActiveParticles::ActiveParticle, ForceTree::BoxSize, StellarDensityPriv::DesNumNgb, endrun(), TreeWalk::ev_label, TreeWalk::fill, GetDensityKernelType(), GetNumNgb(), TreeWalk::haswork, slots_manager_type::info, StellarDensityPriv::Left, StellarDensityPriv::MassReturn, StellarDensityPriv::maxcmpte, myfree, mymalloc, TreeWalk::ngbiter, TreeWalk::ngbiter_type_elsize, NHSML, TreeWalk::NoNgblist, ActiveParticles::NumActiveParticle, StellarDensityPriv::NumNgb, P, TreeWalk::postprocess, TreeWalk::priv, TreeWalk::query_type_elsize, TreeWalk::reduce, TreeWalk::result_type_elsize, StellarDensityPriv::Right, slot_info::size, SlotsManager, stellar_density_check_neighbours(), stellar_density_copy(), stellar_density_haswork(), stellar_density_ngbiter(), stellar_density_reduce(), TreeWalk::timecommsumm1, TreeWalk::timecommsumm2, TreeWalk::timecomp1, TreeWalk::timecomp2, TreeWalk::timecomp3, TreeWalk::timewait1, TreeWalk::timewait2, TreeWalk::tree, treewalk_do_hsml_loop(), treewalk_visit_nolist_ngbiter(), TreeWalk::visit, StellarDensityPriv::VolumeSPH, walltime_add, WALLTIME_IGNORE, and walltime_measure.
Referenced by metal_return().
void stellar_density_check_neighbours | ( | int | i, |
TreeWalk * | tw | ||
) |
Definition at line 820 of file metal_return.c.
References ForceTree::BoxSize, effhsml(), metal_return_params::MaxNgbDeviation, TreeWalk::maxnumngb, message(), MetalParams, TreeWalk::minnumngb, ngb_narrow_down(), NHSML, TreeWalk::Niteration, TreeWalk::NPLeft, TreeWalk::NPRedo, P, STELLAR_DENSITY_GET_PRIV, and TreeWalk::tree.
Referenced by stellar_density().
|
static |
Definition at line 800 of file metal_return.c.
References effhsml(), TreeWalkQueryStellarDensity::Hsml, and NHSML.
Referenced by stellar_density().
|
static |
Definition at line 765 of file metal_return.c.
References metals_haswork(), and STELLAR_DENSITY_GET_PRIV.
Referenced by stellar_density().
|
static |
Definition at line 872 of file metal_return.c.
References TreeWalkNgbIterStellarDensity::base, density_kernel_init(), density_kernel_volume(), density_kernel_wk(), GetDensityKernelType(), DensityKernel::Hinv, TreeWalkQueryStellarDensity::Hsml, TreeWalkNgbIterBase::Hsml, kernel(), TreeWalkNgbIterStellarDensity::kernel, TreeWalkNgbIterStellarDensity::kernel_volume, TreeWalkNgbIterBase::mask, TreeWalkResultStellarDensity::maxcmpte, MetalParams, TreeWalkResultStellarDensity::Ngb, NGB_TREEFIND_ASYMMETRIC, NHSML, TreeWalkNgbIterBase::other, P, TreeWalkNgbIterBase::r, TreeWalkNgbIterBase::r2, SPHP, metal_return_params::SPHWeighting, STELLAR_DENSITY_GET_PRIV, TreeWalkNgbIterBase::symmetric, LocalTreeWalk::tw, TreeWalkResultStellarDensity::VolumeSPH, and wk.
Referenced by stellar_density().
|
static |
Definition at line 808 of file metal_return.c.
References TreeWalkResultStellarDensity::maxcmpte, TreeWalkResultStellarDensity::Ngb, P, STELLAR_DENSITY_GET_PRIV, TREEWALK_REDUCE, and TreeWalkResultStellarDensity::VolumeSPH.
Referenced by stellar_density().
|
static |