MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Macros | Functions | Variables
metal_tables.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NSPECIES   9
 
#define MAXMASS   40
 
#define MINMASS   0.1
 
#define SNAGBSWITCH   8
 
#define LIFE_NMET   5
 
#define LIFE_NMASS   30
 
#define AGB_NMET   4
 
#define AGB_NMASS   18
 
#define SNII_NMET   4
 
#define SNII_NMASS   7
 
#define GSL_WORKSPACE   1000
 

Functions

double compute_imf_norm (gsl_integration_workspace *gsl_work)
 
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)
 
double chabrier_mass (double mass, void *params)
 
double sn1a_number (double dtmyrstart, double dtmyrend, double hub)
 
void set_metal_params (double Sn1aN0)
 
void find_mass_bin_limits (double *masslow, double *masshigh, const double dtstart, const double dtend, double stellarmetal, gsl_interp2d *lifetime_tables)
 

Variables

static const double lifetime_metallicity [LIFE_NMET] = { 0.0004 , 0.004 , 0.008, 0.02, 0.05 }
 
static const double lifetime_masses [LIFE_NMASS]
 
static const double lifetime [LIFE_NMASS *LIFE_NMET]
 
static const double sn1a_total_metals = 1.3743416565891
 
static const double sn1a_yields [NSPECIES] = {0, 0, 4.83E-02, 1.16E-06 , 1.43E-01 , 4.51E-03, 8.57E-03, 1.53E-01, 7.43e-01}
 
static const double agb_masses [AGB_NMASS] = { 1.00,1.25,1.50,1.75,1.90,2.00,2.25,2.50,3.00,3.50,4.00,4.50,5.00,5.50,6.00,6.50,7.00,7.50 }
 
static const double agb_metallicities [AGB_NMET] = { 0.0001,0.0040,0.0080,0.0200 }
 
static const double agb_total_mass [AGB_NMET *AGB_NMASS]
 
static const double agb_total_metals [AGB_NMET *AGB_NMASS]
 
static const double agb_yield [NSPECIES][AGB_NMET *AGB_NMASS]
 
static const double snii_masses [SNII_NMASS] = { 13.00,15.00,18.00,20.00,25.00,30.00,40.00 }
 
static const double snii_metallicities [SNII_NMET] = { 0.0000,0.0010,0.0040,0.0200 }
 
static const double snii_total_mass [SNII_NMET *SNII_NMASS]
 
static const double snii_total_metals [SNII_NMET *SNII_NMASS]
 
static const double snii_yield [NSPECIES][SNII_NMET *SNII_NMASS]
 

Macro Definition Documentation

◆ AGB_NMASS

#define AGB_NMASS   18

Definition at line 69 of file metal_tables.h.

◆ AGB_NMET

#define AGB_NMET   4

Definition at line 68 of file metal_tables.h.

◆ GSL_WORKSPACE

#define GSL_WORKSPACE   1000

Definition at line 426 of file metal_tables.h.

◆ LIFE_NMASS

#define LIFE_NMASS   30

Definition at line 17 of file metal_tables.h.

◆ LIFE_NMET

#define LIFE_NMET   5

Definition at line 16 of file metal_tables.h.

◆ MAXMASS

#define MAXMASS   40

Definition at line 9 of file metal_tables.h.

◆ MINMASS

#define MINMASS   0.1

Definition at line 11 of file metal_tables.h.

◆ NSPECIES

#define NSPECIES   9

Definition at line 7 of file metal_tables.h.

◆ SNAGBSWITCH

#define SNAGBSWITCH   8

Definition at line 13 of file metal_tables.h.

◆ SNII_NMASS

#define SNII_NMASS   7

Definition at line 309 of file metal_tables.h.

◆ SNII_NMET

#define SNII_NMET   4

Definition at line 308 of file metal_tables.h.

Function Documentation

◆ chabrier_mass()

double chabrier_mass ( double  mass,
void *  params 
)

Definition at line 308 of file metal_return.c.

309 {
310  return mass * chabrier_imf(mass);
311 }
static double chabrier_imf(double mass)
Definition: metal_return.c:144

References chabrier_imf().

Referenced by compute_imf_norm(), and test_yields().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_agb_yield()

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.

343 {
344  struct imf_integ_params para;
345  gsl_function ff = {chabrier_imf_integ, &para};
346  double agbyield = 0, abserr;
347  /* Only return AGB metals for the range of AGB stars*/
348  if (masshigh > SNAGBSWITCH)
349  masshigh = SNAGBSWITCH;
350  if (masslow < agb_masses[0])
351  masslow = agb_masses[0];
352  if (stellarmetal > agb_metallicities[AGB_NMET-1])
353  stellarmetal = agb_metallicities[AGB_NMET-1];
354  if (stellarmetal < agb_metallicities[0])
355  stellarmetal = agb_metallicities[0];
356  /* This happens if no bins in range had dying stars this timestep*/
357  if(masslow >= masshigh)
358  return 0;
359  para.interp = agb_interp;
360  para.masses = agb_masses;
361  para.metallicities = agb_metallicities;
362  para.metallicity = stellarmetal;
363  para.weights = agb_weights;
364  gsl_integration_qag(&ff, masslow, masshigh, 1e-7, 1e-3, GSL_WORKSPACE, GSL_INTEG_GAUSS61, gsl_work, &agbyield, &abserr);
365  return agbyield;
366 }
double chabrier_imf_integ(double mass, void *params)
Definition: metal_return.c:289
#define AGB_NMET
Definition: metal_tables.h:68
static const double agb_masses[AGB_NMASS]
Definition: metal_tables.h:70
#define SNAGBSWITCH
Definition: metal_tables.h:13
#define GSL_WORKSPACE
Definition: metal_tables.h:426
static const double agb_metallicities[AGB_NMET]
Definition: metal_tables.h:71

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_imf_norm()

double compute_imf_norm ( gsl_integration_workspace *  gsl_work)

Definition at line 314 of file metal_return.c.

315 {
316  double norm, abserr;
317  gsl_function ff = {chabrier_mass, NULL};
318  gsl_integration_qag(&ff, MINMASS, MAXMASS, 1e-4, 1e-3, GSL_WORKSPACE, GSL_INTEG_GAUSS61, gsl_work, &norm, &abserr);
319  return norm;
320 }
double chabrier_mass(double mass, void *params)
Definition: metal_return.c:308
#define MINMASS
Definition: metal_tables.h:11
#define MAXMASS
Definition: metal_tables.h:9

References chabrier_mass(), GSL_WORKSPACE, MAXMASS, and MINMASS.

Referenced by metal_return_init(), and test_yields().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_snii_yield()

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.

369 {
370  struct imf_integ_params para;
371  gsl_function ff = {chabrier_imf_integ, &para};
372  double yield = 0, abserr;
373  /* Only return metals for the range of SNII stars.*/
374  if (masshigh > snii_masses[SNII_NMASS-1])
375  masshigh = snii_masses[SNII_NMASS-1];
376  if (masslow < SNAGBSWITCH)
377  masslow = SNAGBSWITCH;
378  if (stellarmetal > snii_metallicities[SNII_NMET-1])
379  stellarmetal = snii_metallicities[SNII_NMET-1];
380  if (stellarmetal < snii_metallicities[0])
381  stellarmetal = snii_metallicities[0];
382  para.interp = snii_interp;
383  para.masses = snii_masses;
384  para.metallicities = snii_metallicities;
385  para.metallicity = stellarmetal;
386  para.weights = snii_weights;
387  /* This happens if no bins in range had dying stars this timestep*/
388  if(masslow >= masshigh)
389  return 0;
390  gsl_integration_qag(&ff, masslow, masshigh, 1e-7, 1e-3, GSL_WORKSPACE, GSL_INTEG_GAUSS61, gsl_work, &yield, &abserr);
391  return yield;
392 }
static const double snii_metallicities[SNII_NMET]
Definition: metal_tables.h:311
#define SNII_NMASS
Definition: metal_tables.h:309
#define SNII_NMET
Definition: metal_tables.h:308
static const double snii_masses[SNII_NMASS]
Definition: metal_tables.h:310

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_mass_bin_limits()

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.

231 {
232  /* Clamp metallicities to the table values.*/
233  if(stellarmetal < lifetime_metallicity[0])
234  stellarmetal = lifetime_metallicity[0];
235  if(stellarmetal > lifetime_metallicity[LIFE_NMET-1])
236  stellarmetal = lifetime_metallicity[LIFE_NMET-1];
237 
238  /* Find the root with GSL routines. */
239  struct massbin_find_params p = {0};
240  p.metalacc = gsl_interp_accel_alloc();
241  p.massacc = gsl_interp_accel_alloc();
244  /* First find stars that died before the end of this timebin*/
245  p.dtfind = dtend;
246  /* If no stars have died yet*/
247  if(massendlife (MAXMASS, &p) >= 0)
248  {
249  *masslow = MAXMASS;
250  *masshigh = MAXMASS;
251  return;
252  }
253  /* All stars die before the end of this timestep*/
254  if(massendlife (agb_masses[0], &p) <= 0)
255  *masslow = lifetime_masses[0];
256  else
257  *masslow = do_rootfinding(&p, agb_masses[0], MAXMASS);
258 
259  /* Now find stars that died before the start of this timebin*/
260  p.dtfind = dtstart;
261  /* Now we know that life(masslow) = dtend, so life(masslow) > dtstart, so life(masslow) - dtstart > 0
262  * This is when no stars have died at the beginning of this timestep.*/
263  if(massendlife (MAXMASS, &p) >= 0)
264  *masshigh = MAXMASS;
265  /* This can sometimes happen due to root finding inaccuracy.
266  * Just do this star next timestep.*/
267  else if(massendlife (*masslow, &p) <= 0)
268  *masshigh = *masslow;
269  else
270  *masshigh = do_rootfinding(&p, *masslow, MAXMASS);
271  gsl_interp_accel_free(p.metalacc);
272  gsl_interp_accel_free(p.massacc);
273 }
double do_rootfinding(struct massbin_find_params *p, double mass_low, double mass_high)
Definition: metal_return.c:194
double massendlife(double mass, void *params)
Definition: metal_return.c:185
#define LIFE_NMET
Definition: metal_tables.h:16
static const double lifetime_metallicity[LIFE_NMET]
Definition: metal_tables.h:18
static const double lifetime_masses[LIFE_NMASS]
Definition: metal_tables.h:20
gsl_interp_accel * massacc
Definition: metal_return.c:179
gsl_interp_accel * metalacc
Definition: metal_return.c:178
gsl_interp2d * lifetime_tables
Definition: metal_return.c:177

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_metal_params()

void set_metal_params ( double  Sn1aN0)

Definition at line 55 of file metal_return.c.

56 {
57  MetalParams.Sn1aN0 = Sn1aN0;
58 }
static struct metal_return_params MetalParams

References MetalParams, and metal_return_params::Sn1aN0.

Referenced by test_yields().

Here is the caller graph for this function:

◆ sn1a_number()

double sn1a_number ( double  dtmyrstart,
double  dtmyrend,
double  hub 
)

Definition at line 324 of file metal_return.c.

325 {
326  /* Number of Sn1a events follows a delay time distribution (1305.2913, eq. 10) */
327  const double sn1aindex = 1.12;
328  const double tau8msun = 40;
329  if(dtmyrend < tau8msun)
330  return 0;
331  /* Lower integration limit modelling formation time of WDs*/
332  if(dtmyrstart < tau8msun)
333  dtmyrstart = tau8msun;
334  /* Total number of Sn1a events from this star: integral evaluated from t=tau8msun to t=hubble time.*/
335  const double totalSN1a = 1- pow(1/(hub*HUBBLE * SEC_PER_MEGAYEAR)/tau8msun, 1-sn1aindex);
336  /* This is the integral of the DTD, normalised to the N0 rate which is in SN/M_sun.*/
337  double Nsn1a = MetalParams.Sn1aN0 /totalSN1a * (pow(dtmyrstart / tau8msun, 1-sn1aindex) - pow(dtmyrend / tau8msun, 1-sn1aindex));
338  return Nsn1a;
339 }
#define HUBBLE
Definition: physconst.h:25
#define SEC_PER_MEGAYEAR
Definition: physconst.h:31

References HUBBLE, MetalParams, SEC_PER_MEGAYEAR, and metal_return_params::Sn1aN0.

Referenced by mass_yield(), metal_yield(), and test_yields().

Here is the caller graph for this function:

Variable Documentation

◆ agb_masses

const double agb_masses[AGB_NMASS] = { 1.00,1.25,1.50,1.75,1.90,2.00,2.25,2.50,3.00,3.50,4.00,4.50,5.00,5.50,6.00,6.50,7.00,7.50 }
static

◆ agb_metallicities

const double agb_metallicities[AGB_NMET] = { 0.0001,0.0040,0.0080,0.0200 }
static

Definition at line 71 of file metal_tables.h.

Referenced by compute_agb_yield(), and setup_metal_table_interp().

◆ agb_total_mass

const double agb_total_mass[AGB_NMET *AGB_NMASS]
static
Initial value:
= {
0.280,0.390,0.423,0.436,
0.582,0.608,0.650,0.676,
0.839,0.872,0.867,0.900,
1.086,1.120,1.114,1.135,
1.219,1.260,1.260,1.270,
1.315,1.450,1.456,1.360,
1.537,1.586,1.598,1.590,
1.768,1.829,1.837,1.837,
2.187,2.269,2.306,2.318,
2.646,2.686,2.734,2.782,
3.126,3.148,3.164,3.208,
3.603,3.628,3.639,3.648,
4.071,4.095,4.114,4.121,
4.534,4.568,4.593,4.600,
4.994,5.023,5.052,5.071,
5.401,5.494,5.548,5.537,
5.827,5.936,6.001,6.033,
6.269,6.342,6.442,6.489,
}

Definition at line 72 of file metal_tables.h.

Referenced by mass_yield(), setup_metal_table_interp(), and test_yields().

◆ agb_total_metals

const double agb_total_metals[AGB_NMET *AGB_NMASS]
static
Initial value:
= {
2.674e-04,6.293e-06,1.198e-05,2.701e-05,
3.907e-03,1.942e-04,3.162e-05,7.465e-05,
1.247e-02,1.939e-03,3.072e-04,1.282e-04,
2.578e-02,5.893e-03,3.192e-03,1.818e-04,
3.371e-02,9.377e-03,5.453e-03,2.050e-04,
4.116e-02,1.256e-02,1.081e-02,2.204e-04,
5.712e-02,2.538e-02,1.576e-02,1.269e-03,
5.633e-02,3.826e-02,2.290e-02,6.299e-03,
2.561e-02,4.226e-02,4.220e-02,1.771e-02,
2.685e-02,2.557e-02,2.842e-02,2.396e-02,
3.358e-02,3.340e-02,2.094e-02,1.405e-02,
2.737e-02,5.052e-02,4.058e-02,1.406e-02,
2.825e-02,6.915e-02,5.270e-02,1.450e-02,
3.203e-02,4.969e-02,4.459e-02,2.389e-02,
4.010e-02,5.086e-02,4.063e-02,2.019e-02,
1.001e-01,2.534e-02,3.349e-02,1.729e-02,
4.911e-02,1.478e-02,2.021e-02,1.449e-02,
3.322e-02,1.289e-02,1.541e-02,1.375e-02,
}

Definition at line 94 of file metal_tables.h.

Referenced by metal_yield(), and setup_metal_table_interp().

◆ agb_yield

const double agb_yield[NSPECIES][AGB_NMET *AGB_NMASS]
static

Definition at line 116 of file metal_tables.h.

Referenced by metal_yield(), and setup_metal_table_interp().

◆ lifetime

const double lifetime[LIFE_NMASS *LIFE_NMET]
static

Definition at line 24 of file metal_tables.h.

Referenced by massendlife(), and setup_metal_table_interp().

◆ lifetime_masses

const double lifetime_masses[LIFE_NMASS]
static
Initial value:
= {0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5,
1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3 , 4 , 5 , 6 , 7 , 9 , 12 , 15 , 20 , 30 , 40 , 60 , 100, 120}

Definition at line 20 of file metal_tables.h.

Referenced by find_mass_bin_limits(), massendlife(), and setup_metal_table_interp().

◆ lifetime_metallicity

const double lifetime_metallicity[LIFE_NMET] = { 0.0004 , 0.004 , 0.008, 0.02, 0.05 }
static

Definition at line 18 of file metal_tables.h.

Referenced by find_mass_bin_limits(), massendlife(), and setup_metal_table_interp().

◆ sn1a_total_metals

const double sn1a_total_metals = 1.3743416565891
static

Definition at line 60 of file metal_tables.h.

Referenced by mass_yield(), metal_yield(), and test_yields().

◆ sn1a_yields

const double sn1a_yields[NSPECIES] = {0, 0, 4.83E-02, 1.16E-06 , 1.43E-01 , 4.51E-03, 8.57E-03, 1.53E-01, 7.43e-01}
static

Definition at line 61 of file metal_tables.h.

Referenced by metal_yield().

◆ snii_masses

const double snii_masses[SNII_NMASS] = { 13.00,15.00,18.00,20.00,25.00,30.00,40.00 }
static

Definition at line 310 of file metal_tables.h.

Referenced by compute_snii_yield(), setup_metal_table_interp(), and test_yields().

◆ snii_metallicities

const double snii_metallicities[SNII_NMET] = { 0.0000,0.0010,0.0040,0.0200 }
static

Definition at line 311 of file metal_tables.h.

Referenced by compute_snii_yield(), metal_return_init(), and setup_metal_table_interp().

◆ snii_total_mass

const double snii_total_mass[SNII_NMET *SNII_NMASS]
static
Initial value:
= {
11.430,11.350,11.390,11.400,
13.520,13.470,13.500,13.500,
16.350,16.300,16.390,16.420,
18.340,18.150,18.240,18.450,
23.080,23.090,23.320,23.310,
27.930,27.940,27.440,27.900,
37.110,36.830,37.190,37.790,
}

Definition at line 312 of file metal_tables.h.

Referenced by mass_yield(), setup_metal_table_interp(), and test_yields().

◆ snii_total_metals

const double snii_total_metals[SNII_NMET *SNII_NMASS]
static
Initial value:
= {
8.208e-01,9.820e-01,8.451e-01,6.734e-01,
1.539e+00,7.860e-01,8.312e-01,6.045e-01,
2.501e+00,1.135e+00,1.451e+00,1.539e+00,
3.634e+00,3.489e+00,1.778e+00,2.110e+00,
4.411e+00,5.733e+00,3.703e+00,4.296e+00,
6.712e+00,7.570e+00,6.944e+00,5.378e+00,
1.120e+01,1.088e+01,1.171e+01,1.136e+01,
}

Definition at line 323 of file metal_tables.h.

Referenced by metal_yield(), and setup_metal_table_interp().

◆ snii_yield

const double snii_yield[NSPECIES][SNII_NMET *SNII_NMASS]
static

Definition at line 334 of file metal_tables.h.

Referenced by metal_yield(), and setup_metal_table_interp().