This notebook produces IMF integrated metallicity dependent net yields. As an example we produce the default and alternative tables for the single sun+ best fit (which fix the SSP parameter). This notebook is just an example showing illustratively how to produce these yield tables. If you actually want to use these for your Chemical evolution model you will probably want to increase the time_steps and the mass_steps. You could also consult me to get an idea of sensible Parameters and yield sets that one could use. Mostly those ideas will be based on: http://adsabs.harvard.edu/abs/2018ApJ...861...40P


In [1]:
%pylab inline
import multiprocessing as mp


Populating the interactive namespace from numpy and matplotlib

In [2]:
from Chempy.parameter import ModelParameters
a = ModelParameters()

In [3]:
# Load solar abundances

from Chempy.solar_abundance import solar_abundances
basic_solar = solar_abundances()
getattr(basic_solar, 'Asplund09')()

# Initialise the SSP class with time-steps

time_steps = np.linspace(0.,13.5,521)

# Load the default yields

from Chempy.yields import SN2_feedback, AGB_feedback, SN1a_feedback
basic_sn2 = SN2_feedback()
getattr(basic_sn2, 'Nomoto2013_net')()
basic_1a = SN1a_feedback()
getattr(basic_1a, "Seitenzahl")()
basic_agb = AGB_feedback()
getattr(basic_agb, "Karakas_net_yield")()

# Load the alternative yields
alt_sn2 = SN2_feedback()
getattr(alt_sn2, 'chieffi04_net')()
alt_1a = SN1a_feedback()
getattr(alt_1a, "Thielemann")()
alt_agb = AGB_feedback()
getattr(alt_agb, "Ventura")()

# Use all elements that are traced

elements_to_trace = list(np.unique(basic_agb.elements+basic_sn2.elements+basic_1a.elements+alt_agb.elements+alt_sn2.elements+alt_1a.elements))
#elements_to_trace = ['H','He','C','N','O','Na','Al','Mg','Si','Ca','Ti','Mn','Fe','Ba','Ne']
print('all the traced elements: ',elements_to_trace)

# Producing the SSP birth elemental fractions (here we use solar)

solar_fractions = []
elements = np.hstack(basic_solar.all_elements)
for item in elements_to_trace:
    solar_fractions.append(float(basic_solar.fractions[np.where(elements==item)]))


all the traced elements:  ['Al', 'Ar', 'As', 'B', 'Be', 'Br', 'C', 'Ca', 'Cl', 'Co', 'Cr', 'Cu', 'F', 'Fe', 'Ga', 'Ge', 'H', 'He', 'K', 'Kr', 'Li', 'Mg', 'Mn', 'Mo', 'N', 'Na', 'Nb', 'Ne', 'Ni', 'O', 'P', 'Rb', 'S', 'Sc', 'Se', 'Si', 'Sr', 'Ti', 'V', 'Y', 'Zn', 'Zr']

In [4]:
# yieldset default
a.yield_table_name_sn2 = 'Nomoto2013_net'
a.yield_table_name_agb = 'Karakas_net_yield'
a.yield_table_name_1a = 'Seitenzahl'
# yieldset alternative
#a.yield_table_name_sn2 = 'chieffi04_net'
#a.yield_table_name_agb = 'Ventura'
#a.yield_table_name_1a = 'Thielemann'

# imf parameters
a.only_net_yields_in_process_tables = True
a.imf_type_name = 'Chabrier_2'
#default
a.high_mass_slope = -2.46
#alternative
#a.high_mass_slope = -2.51
a.imf_parameter = (22.8978, 716.4, 0.25, a.high_mass_slope)
a.mmin = 0.1
a.mmax = 100
# 100,000,000 mass steps are smooth enough for 1000 time steps
a.mass_steps = 200000 #2000 # 200000
a.sn2mmin = 8.
a.sn2mmax = 100.
a.bhmmin = float(a.sn2mmax) ## maximum of hypernova
a.bhmmax = float(a.mmax) ## maximum of the IMF

# sn1a delay parameters for maoz
#default
a.N_0 = np.power(10,-3.07)
a.sn1a_time_delay = np.power(10,-0.8)
#alternative
#a.N_0 = np.power(10,-3.49)
#a.sn1a_time_delay = np.power(10,-0.88)

a.sn1a_exponent = 1.12
a.dummy = 0.0
a.sn1a_parameter = [a.N_0,a.sn1a_time_delay,a.sn1a_exponent,a.dummy]
######################## END OF SETTING CHEMPY PARAMETER FOR SSP YIELD TABLE PRODUCTION

In [5]:
list_of_metallicities = np.logspace(-4,-2,2)
list_of_SSP_tables = []
list_of_SSP_tables.append(list_of_metallicities)
list_of_SSP_tables.append(time_steps)

from Chempy.wrapper import SSP_wrap


def create_one_SSP_table(parameters):
    differential_table = True # True is the default Chempy behaviour
    metallicity = parameters
    print(metallicity,a.yield_table_name_sn2)
    basic_ssp = SSP_wrap(a)
    basic_ssp.calculate_feedback(metallicity,list(elements_to_trace),list(solar_fractions),np.copy(time_steps))

    x = basic_ssp.agb_table
    y = basic_ssp.sn1a_table
    z = basic_ssp.sn2_table
    s = basic_ssp.bh_table
    d = basic_ssp.table

    u = np.zeros_like(x)
    names = list(u.dtype.names)

    # here we still add all processes, but we can also make individual process contribution to element
    for j,jtem in enumerate(names):
        u[jtem] = x[jtem] + y[jtem] + z[jtem] + s[jtem]
    if differential_table:
        for el in elements_to_trace:
            d[el] = u[el]
    else:
        for el in elements_to_trace:
            d[el] = np.cumsum(u[el])
        for name in ['mass_of_ms_stars_dying', 'mass_in_remnants', 'sn2', 'sn1a', 'pn', 'bh', 'hydrogen_mass_accreted_onto_white_dwarfs', 'unprocessed_ejecta']:
            d[name] = np.cumsum(d[name])
    return(d)

In [6]:
print("There are %d CPUs on this machine" % mp.cpu_count())
number_processes = max(1,mp.cpu_count() - 1)
pool = mp.Pool(number_processes)
results = pool.map(create_one_SSP_table, list_of_metallicities)
pool.close()
pool.join()

list_of_SSP_tables.append(results)
np.save('data/paper_1_ssp_tables/SSP_tables_default', list_of_SSP_tables)


There are 8 CPUs on this machine
0.0001 Nomoto2013_net
0.01 Nomoto2013_net

In [7]:
print('the metallicities for which SSP yield tables were calculated: ',list_of_SSP_tables[0])
print('metallicities: ',len(list_of_SSP_tables[2]))
print('timesteps: ', len(list_of_SSP_tables[2][0]), '= ', len(list_of_SSP_tables[1]))


the metallicities for which SSP yield tables were calculated:  [0.0001 0.01  ]
metallicities:  2
timesteps:  521 =  521

In [8]:
print('the data type of the SSP yield table: ',list_of_SSP_tables[2][0].dtype)
x = list_of_SSP_tables[2][0]
z = list_of_SSP_tables[2][1]


the data type of the SSP yield table:  (numpy.record, [('mass_of_ms_stars_dying', '<f8'), ('mass_in_ms_stars', '<f8'), ('mass_in_remnants', '<f8'), ('sn2', '<f8'), ('sn1a', '<f8'), ('pn', '<f8'), ('bh', '<f8'), ('hydrogen_mass_accreted_onto_white_dwarfs', '<f8'), ('unprocessed_ejecta', '<f8'), ('Al', '<f8'), ('Ar', '<f8'), ('As', '<f8'), ('B', '<f8'), ('Be', '<f8'), ('Br', '<f8'), ('C', '<f8'), ('Ca', '<f8'), ('Cl', '<f8'), ('Co', '<f8'), ('Cr', '<f8'), ('Cu', '<f8'), ('F', '<f8'), ('Fe', '<f8'), ('Ga', '<f8'), ('Ge', '<f8'), ('H', '<f8'), ('He', '<f8'), ('K', '<f8'), ('Kr', '<f8'), ('Li', '<f8'), ('Mg', '<f8'), ('Mn', '<f8'), ('Mo', '<f8'), ('N', '<f8'), ('Na', '<f8'), ('Nb', '<f8'), ('Ne', '<f8'), ('Ni', '<f8'), ('O', '<f8'), ('P', '<f8'), ('Rb', '<f8'), ('S', '<f8'), ('Sc', '<f8'), ('Se', '<f8'), ('Si', '<f8'), ('Sr', '<f8'), ('Ti', '<f8'), ('V', '<f8'), ('Y', '<f8'), ('Zn', '<f8'), ('Zr', '<f8')])

In [9]:
alpha = 0.5
factor = 1.05

## Actual plotting

fig = plt.figure(figsize=(8.69,6.69), dpi=100)
ax = fig.add_subplot(111)
ax.plot(time_steps,np.cumsum(x["Fe"]),'b', label = 'Z = 0.0001')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(x["Fe"])*0.9) ,s = 'Fe',color = 'b')
ax.plot(time_steps,np.cumsum(z["Fe"]), 'r', label = 'Z = 0.01')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Fe"])) ,s = 'Fe',color = 'r')

ax.plot(time_steps,np.cumsum(x["Mg"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(x["Mg"])*0.9) ,s = 'Mg',color = 'b')
ax.plot(time_steps,np.cumsum(z["Mg"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Mg"])) ,s = 'Mg',color = 'r')

ax.plot(time_steps,np.cumsum(x["Al"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(x["Al"])*0.9) ,s = 'Al',color = 'b')
ax.plot(time_steps,np.cumsum(z["Al"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Al"])) ,s = 'Al',color = 'r')

ax.plot(time_steps,np.cumsum(x["C"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(x["C"])*0.9) ,s = 'C',color = 'b')
ax.plot(time_steps,np.cumsum(z["C"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["C"])) ,s = 'C',color = 'r')

ax.plot(time_steps,np.ones_like(time_steps)*5e-3,marker = '|', markersize = 10, linestyle = '', color = 'k', alpha = 2*alpha)#, label = 'time-steps')
ax.annotate(xy = (time_steps[1],2.7e-3),s = 'model time-steps', color = 'k', alpha = 2*alpha)
ax.legend(loc = 'best')

ax.set_ylim(2e-5,6e-3)
ax.set_xlim(7e-3,25)
ax.set_title(r'default yield of SSP with mass = 1M$_\odot$ for different metallicies')
ax.set_ylabel(r"net yield in M$_\odot$")
ax.set_xlabel("time in Gyr")

ax.set_yscale('log')
ax.set_xscale('log')
plt.show()



In [10]:
# yieldset alternative
a.yield_table_name_sn2 = 'chieffi04_net'
a.yield_table_name_agb = 'Ventura'
a.yield_table_name_1a = 'Thielemann'

a.high_mass_slope = -2.51
a.imf_parameter = (22.8978, 716.4, 0.25, a.high_mass_slope)
a.N_0 = np.power(10,-3.49)
a.sn1a_time_delay = np.power(10,-0.88)
a.sn1a_parameter = [a.N_0,a.sn1a_time_delay,a.sn1a_exponent,a.dummy]
######################## END OF SETTING CHEMPY PARAMETER FOR SSP YIELD TABLE PRODUCTION

list_of_SSP_tables_alt = []
list_of_SSP_tables_alt.append(list_of_metallicities)
list_of_SSP_tables_alt.append(time_steps)

print("There are %d CPUs on this machine" % mp.cpu_count())
number_processes = max(1,mp.cpu_count() - 1)
pool = mp.Pool(number_processes)
results = pool.map(create_one_SSP_table, list_of_metallicities)
pool.close()
pool.join()

list_of_SSP_tables_alt.append(results)
np.save('data/paper_1_ssp_tables/SSP_tables_alternative', list_of_SSP_tables_alt)


There are 8 CPUs on this machine
0.01 chieffi04_net
0.0001 chieffi04_net

In [11]:
print('the data type of the SSP yield table: ',list_of_SSP_tables[2][0].dtype)
y = list_of_SSP_tables_alt[2][1]


the data type of the SSP yield table:  (numpy.record, [('mass_of_ms_stars_dying', '<f8'), ('mass_in_ms_stars', '<f8'), ('mass_in_remnants', '<f8'), ('sn2', '<f8'), ('sn1a', '<f8'), ('pn', '<f8'), ('bh', '<f8'), ('hydrogen_mass_accreted_onto_white_dwarfs', '<f8'), ('unprocessed_ejecta', '<f8'), ('Al', '<f8'), ('Ar', '<f8'), ('As', '<f8'), ('B', '<f8'), ('Be', '<f8'), ('Br', '<f8'), ('C', '<f8'), ('Ca', '<f8'), ('Cl', '<f8'), ('Co', '<f8'), ('Cr', '<f8'), ('Cu', '<f8'), ('F', '<f8'), ('Fe', '<f8'), ('Ga', '<f8'), ('Ge', '<f8'), ('H', '<f8'), ('He', '<f8'), ('K', '<f8'), ('Kr', '<f8'), ('Li', '<f8'), ('Mg', '<f8'), ('Mn', '<f8'), ('Mo', '<f8'), ('N', '<f8'), ('Na', '<f8'), ('Nb', '<f8'), ('Ne', '<f8'), ('Ni', '<f8'), ('O', '<f8'), ('P', '<f8'), ('Rb', '<f8'), ('S', '<f8'), ('Sc', '<f8'), ('Se', '<f8'), ('Si', '<f8'), ('Sr', '<f8'), ('Ti', '<f8'), ('V', '<f8'), ('Y', '<f8'), ('Zn', '<f8'), ('Zr', '<f8')])

In [12]:
## Actual plotting

fig = plt.figure(figsize=(8.69,6.69), dpi=100)
ax = fig.add_subplot(111)
ax.plot(time_steps,np.cumsum(y["Fe"]),'b', label = 'alternative')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(y["Fe"])*0.9) ,s = 'Fe',color = 'b')
ax.plot(time_steps,np.cumsum(z["Fe"]), 'r', label = 'default')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Fe"])) ,s = 'Fe',color = 'r')

ax.plot(time_steps,np.cumsum(y["Mg"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(y["Mg"])*0.9) ,s = 'Mg',color = 'b')
ax.plot(time_steps,np.cumsum(z["Mg"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Mg"])) ,s = 'Mg',color = 'r')

ax.plot(time_steps,np.cumsum(y["Al"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(y["Al"])*0.9) ,s = 'Al',color = 'b')
ax.plot(time_steps,np.cumsum(z["Al"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["Al"])) ,s = 'Al',color = 'r')

ax.plot(time_steps,np.cumsum(y["C"]),'b')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(y["C"])*0.9) ,s = 'C',color = 'b')
ax.plot(time_steps,np.cumsum(z["C"]), 'r')
ax.annotate(xy = (time_steps[-1]*factor,np.sum(z["C"])) ,s = 'C',color = 'r')

ax.plot(time_steps,np.ones_like(time_steps)*5e-3,marker = '|', markersize = 10, linestyle = '', color = 'k', alpha = 2*alpha)#, label = 'time-steps')
ax.annotate(xy = (time_steps[1],2.7e-3),s = 'model time-steps', color = 'k', alpha = 2*alpha)
ax.legend(loc = 'best')

ax.set_ylim(2e-5,6e-3)
ax.set_xlim(7e-3,25)
ax.set_title(r'yield of SSP with mass = 1M$_\odot$ for the different yieldsets for Z=0.01')
ax.set_ylabel(r"net yield in M$_\odot$")
ax.set_xlabel("time in Gyr")

ax.set_yscale('log')
ax.set_xscale('log')
plt.show()


Beware, that both yieldsets for optimized to reproduce solar abundances, so in fact they look more similar here than they actually are, because the IMF and SNIa contribution is different. If you want to see the difference for the same SSP parameters check Paper 1 figure 4.


In [13]:
### so what is actually in these files:
print('these are the respective metal mass fractions for which the SSP yield tables were calculated')
print(list_of_SSP_tables[0])


these are the respective metal mass fractions for which the SSP yield tables were calculated
[0.0001 0.01  ]

In [14]:
print('these are the %d timesteps for which the yield was calculated. It is the time after SSP birth in Gyrs starting at 0 and going up to 13.5Gyrs' %(len(list_of_SSP_tables[1])))
print(list_of_SSP_tables[1])


these are the 521 timesteps for which the yield was calculated. It is the time after SSP birth in Gyrs starting at 0 and going up to 13.5Gyrs
[ 0.          0.02596154  0.05192308  0.07788462  0.10384615  0.12980769
  0.15576923  0.18173077  0.20769231  0.23365385  0.25961538  0.28557692
  0.31153846  0.3375      0.36346154  0.38942308  0.41538462  0.44134615
  0.46730769  0.49326923  0.51923077  0.54519231  0.57115385  0.59711538
  0.62307692  0.64903846  0.675       0.70096154  0.72692308  0.75288462
  0.77884615  0.80480769  0.83076923  0.85673077  0.88269231  0.90865385
  0.93461538  0.96057692  0.98653846  1.0125      1.03846154  1.06442308
  1.09038462  1.11634615  1.14230769  1.16826923  1.19423077  1.22019231
  1.24615385  1.27211538  1.29807692  1.32403846  1.35        1.37596154
  1.40192308  1.42788462  1.45384615  1.47980769  1.50576923  1.53173077
  1.55769231  1.58365385  1.60961538  1.63557692  1.66153846  1.6875
  1.71346154  1.73942308  1.76538462  1.79134615  1.81730769  1.84326923
  1.86923077  1.89519231  1.92115385  1.94711538  1.97307692  1.99903846
  2.025       2.05096154  2.07692308  2.10288462  2.12884615  2.15480769
  2.18076923  2.20673077  2.23269231  2.25865385  2.28461538  2.31057692
  2.33653846  2.3625      2.38846154  2.41442308  2.44038462  2.46634615
  2.49230769  2.51826923  2.54423077  2.57019231  2.59615385  2.62211538
  2.64807692  2.67403846  2.7         2.72596154  2.75192308  2.77788462
  2.80384615  2.82980769  2.85576923  2.88173077  2.90769231  2.93365385
  2.95961538  2.98557692  3.01153846  3.0375      3.06346154  3.08942308
  3.11538462  3.14134615  3.16730769  3.19326923  3.21923077  3.24519231
  3.27115385  3.29711538  3.32307692  3.34903846  3.375       3.40096154
  3.42692308  3.45288462  3.47884615  3.50480769  3.53076923  3.55673077
  3.58269231  3.60865385  3.63461538  3.66057692  3.68653846  3.7125
  3.73846154  3.76442308  3.79038462  3.81634615  3.84230769  3.86826923
  3.89423077  3.92019231  3.94615385  3.97211538  3.99807692  4.02403846
  4.05        4.07596154  4.10192308  4.12788462  4.15384615  4.17980769
  4.20576923  4.23173077  4.25769231  4.28365385  4.30961538  4.33557692
  4.36153846  4.3875      4.41346154  4.43942308  4.46538462  4.49134615
  4.51730769  4.54326923  4.56923077  4.59519231  4.62115385  4.64711538
  4.67307692  4.69903846  4.725       4.75096154  4.77692308  4.80288462
  4.82884615  4.85480769  4.88076923  4.90673077  4.93269231  4.95865385
  4.98461538  5.01057692  5.03653846  5.0625      5.08846154  5.11442308
  5.14038462  5.16634615  5.19230769  5.21826923  5.24423077  5.27019231
  5.29615385  5.32211538  5.34807692  5.37403846  5.4         5.42596154
  5.45192308  5.47788462  5.50384615  5.52980769  5.55576923  5.58173077
  5.60769231  5.63365385  5.65961538  5.68557692  5.71153846  5.7375
  5.76346154  5.78942308  5.81538462  5.84134615  5.86730769  5.89326923
  5.91923077  5.94519231  5.97115385  5.99711538  6.02307692  6.04903846
  6.075       6.10096154  6.12692308  6.15288462  6.17884615  6.20480769
  6.23076923  6.25673077  6.28269231  6.30865385  6.33461538  6.36057692
  6.38653846  6.4125      6.43846154  6.46442308  6.49038462  6.51634615
  6.54230769  6.56826923  6.59423077  6.62019231  6.64615385  6.67211538
  6.69807692  6.72403846  6.75        6.77596154  6.80192308  6.82788462
  6.85384615  6.87980769  6.90576923  6.93173077  6.95769231  6.98365385
  7.00961538  7.03557692  7.06153846  7.0875      7.11346154  7.13942308
  7.16538462  7.19134615  7.21730769  7.24326923  7.26923077  7.29519231
  7.32115385  7.34711538  7.37307692  7.39903846  7.425       7.45096154
  7.47692308  7.50288462  7.52884615  7.55480769  7.58076923  7.60673077
  7.63269231  7.65865385  7.68461538  7.71057692  7.73653846  7.7625
  7.78846154  7.81442308  7.84038462  7.86634615  7.89230769  7.91826923
  7.94423077  7.97019231  7.99615385  8.02211538  8.04807692  8.07403846
  8.1         8.12596154  8.15192308  8.17788462  8.20384615  8.22980769
  8.25576923  8.28173077  8.30769231  8.33365385  8.35961538  8.38557692
  8.41153846  8.4375      8.46346154  8.48942308  8.51538462  8.54134615
  8.56730769  8.59326923  8.61923077  8.64519231  8.67115385  8.69711538
  8.72307692  8.74903846  8.775       8.80096154  8.82692308  8.85288462
  8.87884615  8.90480769  8.93076923  8.95673077  8.98269231  9.00865385
  9.03461538  9.06057692  9.08653846  9.1125      9.13846154  9.16442308
  9.19038462  9.21634615  9.24230769  9.26826923  9.29423077  9.32019231
  9.34615385  9.37211538  9.39807692  9.42403846  9.45        9.47596154
  9.50192308  9.52788462  9.55384615  9.57980769  9.60576923  9.63173077
  9.65769231  9.68365385  9.70961538  9.73557692  9.76153846  9.7875
  9.81346154  9.83942308  9.86538462  9.89134615  9.91730769  9.94326923
  9.96923077  9.99519231 10.02115385 10.04711538 10.07307692 10.09903846
 10.125      10.15096154 10.17692308 10.20288462 10.22884615 10.25480769
 10.28076923 10.30673077 10.33269231 10.35865385 10.38461538 10.41057692
 10.43653846 10.4625     10.48846154 10.51442308 10.54038462 10.56634615
 10.59230769 10.61826923 10.64423077 10.67019231 10.69615385 10.72211538
 10.74807692 10.77403846 10.8        10.82596154 10.85192308 10.87788462
 10.90384615 10.92980769 10.95576923 10.98173077 11.00769231 11.03365385
 11.05961538 11.08557692 11.11153846 11.1375     11.16346154 11.18942308
 11.21538462 11.24134615 11.26730769 11.29326923 11.31923077 11.34519231
 11.37115385 11.39711538 11.42307692 11.44903846 11.475      11.50096154
 11.52692308 11.55288462 11.57884615 11.60480769 11.63076923 11.65673077
 11.68269231 11.70865385 11.73461538 11.76057692 11.78653846 11.8125
 11.83846154 11.86442308 11.89038462 11.91634615 11.94230769 11.96826923
 11.99423077 12.02019231 12.04615385 12.07211538 12.09807692 12.12403846
 12.15       12.17596154 12.20192308 12.22788462 12.25384615 12.27980769
 12.30576923 12.33173077 12.35769231 12.38365385 12.40961538 12.43557692
 12.46153846 12.4875     12.51346154 12.53942308 12.56538462 12.59134615
 12.61730769 12.64326923 12.66923077 12.69519231 12.72115385 12.74711538
 12.77307692 12.79903846 12.825      12.85096154 12.87692308 12.90288462
 12.92884615 12.95480769 12.98076923 13.00673077 13.03269231 13.05865385
 13.08461538 13.11057692 13.13653846 13.1625     13.18846154 13.21442308
 13.24038462 13.26634615 13.29230769 13.31826923 13.34423077 13.37019231
 13.39615385 13.42211538 13.44807692 13.47403846 13.5       ]

In [15]:
print('in the last index of list_of_SSP_tables the actual tables are stored. For each metallicity there is one corresponding table in the same order. Therefore we have to tables')
len(list_of_SSP_tables[2])


in the last index of list_of_SSP_tables the actual tables are stored. For each metallicity there is one corresponding table in the same order. Therefore we have to tables
Out[15]:
2

In [16]:
print("let's have a look at the table calculated for 0.01 metallicity:")
y = list_of_SSP_tables[2][1]
time = list_of_SSP_tables[1]
print(len(y), len(time),y.dtype.names)
print('we see that it has a length of the number of timesteps. So each entry corresponds to the respective timestep')


let's have a look at the table calculated for 0.01 metallicity:
521 521 ('mass_of_ms_stars_dying', 'mass_in_ms_stars', 'mass_in_remnants', 'sn2', 'sn1a', 'pn', 'bh', 'hydrogen_mass_accreted_onto_white_dwarfs', 'unprocessed_ejecta', 'Al', 'Ar', 'As', 'B', 'Be', 'Br', 'C', 'Ca', 'Cl', 'Co', 'Cr', 'Cu', 'F', 'Fe', 'Ga', 'Ge', 'H', 'He', 'K', 'Kr', 'Li', 'Mg', 'Mn', 'Mo', 'N', 'Na', 'Nb', 'Ne', 'Ni', 'O', 'P', 'Rb', 'S', 'Sc', 'Se', 'Si', 'Sr', 'Ti', 'V', 'Y', 'Zn', 'Zr')
we see that it has a length of the number of timesteps. So each entry corresponds to the respective timestep

In [17]:
print('lets have a look at the different fields:')
print('as you can see the differential values are given, i.e. the amount of change per time interval, except for "mass_in_ms_stars" which gives the actual fraction')
print('note also all values are given in mass fraction, i.e. normed to 1Msun(, as if the SSP had a mass of 1Msun)')
fields = ['mass_of_ms_stars_dying', 'mass_in_ms_stars', 'mass_in_remnants', 'sn2', 'sn1a', 'pn', 'bh', 'hydrogen_mass_accreted_onto_white_dwarfs', 'unprocessed_ejecta', 'Fe']
for i,item in enumerate(fields):
    plt.plot(time,y[item])
    plt.xlabel('time in Gyr')
    plt.ylabel(item)
    plt.title(i)
    plt.show()
    plt.clf()
    plt.close()


lets have a look at the different fields:
as you can see the differential values are given, i.e. the amount of change per time interval, except for "mass_in_ms_stars" which gives the actual fraction
note also all values are given in mass fraction, i.e. normed to 1Msun(, as if the SSP had a mass of 1Msun)

In [18]:
plt.plot(time,np.cumsum(y[fields[0]]), label=fields[0])
plt.plot(time,y[fields[1]],label = fields[1])
plt.plot(time,np.cumsum(y[fields[0]])+y[fields[1]],label = 'ms + ms_dying')
plt.legend()
plt.xlabel('time in Gyr')
plt.ylabel('mass fraction of SSP')
print('beware that for "mass_in_ms_stars" we do not need to use the cumulative sum')


beware that for "mass_in_ms_stars" we do not need to use the cumulative sum

In [19]:
plt.plot(time,np.cumsum(y[fields[2]]), label=fields[2])
plt.plot(time,np.cumsum(y[fields[8]]), label=fields[8])
plt.plot(time,np.cumsum(y[fields[7]]), label=fields[7])
plt.plot(time,np.cumsum(y[fields[0]]), label=fields[0])
plt.legend()
plt.title("'unprocessed_ejecta' + 'mass_in_remnants' + 'hydrogen_mass_accreted_onto_white_dwarfs' = 'mass_of_ms_stars_dying', modula numerical instabilities")
plt.xlabel('time in Gyr')
plt.ylabel('mass fraction of SSP')
print("'unprocessed_ejecta' should be everything that is not turned into remnants and dies (for net yields)")
print("'hydrogen_mass_accreted_onto_white_dwarfs', probably negligible but for mass conservation for each supernova type 1a we remove remnant mass of 0.6Msun and add the missing 0.84Msun in form of hydrogen")


'unprocessed_ejecta' should be everything that is not turned into remnants and dies (for net yields)
'hydrogen_mass_accreted_onto_white_dwarfs', probably negligible but for mass conservation for each supernova type 1a we remove remnant mass of 0.6Msun and add the missing 0.84Msun in form of hydrogen

In [20]:
plt.plot(time,np.cumsum(y[fields[3]]),label = fields[3])
plt.plot(time,np.cumsum(y[fields[4]]),label = fields[4])
plt.plot(time,np.cumsum(y[fields[5]]),label = fields[5])
plt.plot(time,np.cumsum(y[fields[6]]),label = fields[6])
plt.title('Cumulative occurence of different enrichment processes over time')
plt.legend()
plt.xlabel('time in Gyr')
plt.ylabel('number per 1Msun of SSP')
plt.yscale('log')
print('These are no mass fractions but occurence rate per 1Msun of SSP.')
print('Over a Hubble time, per 1Msun of SSP we have approximately 0.1 Planetary nebula, 0.01 SNII, 0.001 SN1a. Black holes were not used in this SPP generation')


These are no mass fractions but occurence rate per 1Msun of SSP.
Over a Hubble time, per 1Msun of SSP we have approximately 0.1 Planetary nebula, 0.01 SNII, 0.001 SN1a. Black holes were not used in this SPP generation

In [21]:
elements = ['Al', 'Ar', 'As', 'B', 'Be', 'Br', 'C', 'Ca', 'Cl', 'Co', 'Cr', 'Cu', 'F', 'Fe', 'Ga', 'Ge', 'H', 'He', 'K', 'Kr', 'Li', 'Mg', 'Mn', 'Mo', 'N', 'Na', 'Nb', 'Ne', 'Ni', 'O', 'P', 'Rb', 'S', 'Sc', 'Se', 'Si', 'Sr', 'Ti', 'V', 'Y', 'Zn', 'Zr']

In [22]:
net_metals = np.zeros_like(y['Fe'])
for item in elements:
    if item not in ['H','He']:
        net_metals += np.cumsum(y[item])

plt.plot(time,np.cumsum(y['H'])+np.cumsum(y['He']), label = 'H+He')
plt.plot(time,net_metals,label = 'metals = all other elements summed')
plt.plot(time,net_metals+np.cumsum(y['H'])+np.cumsum(y['He']),label = 'H+He+metals')
plt.xlabel('time in Gyr')
plt.ylabel('mass fraction')
plt.legend()
plt.show()
plt.clf()
plt.close()
print('we see that all elements are synthesised from H. If we look at metals produced we see that 0.015 percent of an SSP is turned into metals within a Hubble time for a 0.01Z SSP.')
print('my guess for the small discrepancy we see are hydrogen accreted onto dwarfs, or elements that are not part of the yields tables or numerical instabilities. I can look that up upon request')


we see that all elements are synthesised from H. If we look at metals produced we see that 0.015 percent of an SSP is turned into metals within a Hubble time for a 0.01Z SSP.
my guess for the small discrepancy we see are hydrogen accreted onto dwarfs, or elements that are not part of the yields tables or numerical instabilities. I can look that up upon request

In [23]:
plt.plot(time,net_metals,label = 'metals')
plt.plot(time,np.cumsum(y['unprocessed_ejecta']), label = 'unprocessed_ejecta')
plt.xlabel('time in Gyr')
plt.ylabel('mass fraction')
plt.legend()
plt.show()
plt.clf()
plt.close()
print('we see that most of the ejecta are truly unprocessed, i.e. it is returned what were the initial abundances of the SSP')
print('only a tiny fraction new metals are ejected')


we see that most of the ejecta are truly unprocessed, i.e. it is returned what were the initial abundances of the SSP
only a tiny fraction new metals are ejected

In [24]:
## Just for completeness all elements over time!
for i,element in enumerate(elements):
    plt.plot(time,np.cumsum(y[element]))
    plt.xlabel('time in Gyr')
    plt.ylabel(element)
    plt.show()
    plt.clf()
    plt.close()