示例#1
0
def function_element_mass_primary_fraction(solar_abu_reference_name,
                                           element_name, Z_0, Z_solar):
    if element_name == "H":
        element_mass_fraction = primary_H_mass_fraction
    elif element_name == "He":
        element_mass_fraction = primary_He_mass_fraction
    elif element_name == "C":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "C") - 12) \
                                        * element_weight_table.function_element_weight("C") * Z_0 / Z_solar
    elif element_name == "N":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "N") - 12) \
                                        * element_weight_table.function_element_weight("N") * Z_0 / Z_solar
    elif element_name == "O":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "O") - 12) \
                                        * element_weight_table.function_element_weight("O") * Z_0 / Z_solar
    elif element_name == "Ne":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "Ne") - 12) \
                                        * element_weight_table.function_element_weight("Ne") * Z_0 / Z_solar
    elif element_name == "Mg":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "Mg") - 12) \
                                        * element_weight_table.function_element_weight("Mg") * Z_0 / Z_solar
    elif element_name == "Si":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "Si") - 12) \
                                        * element_weight_table.function_element_weight("Si") * Z_0 / Z_solar
    elif element_name == "S":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "S") - 12) \
                                        * element_weight_table.function_element_weight("S") * Z_0 / Z_solar
    elif element_name == "Ca":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "Ca") - 12) \
                                        * element_weight_table.function_element_weight("Ca") * Z_0 / Z_solar
    elif element_name == "Fe":
        element_mass_fraction = primary_H_mass_fraction / H_weight\
                                        * 10**(element_abundances_solar.function_solar_element_abundances(solar_abu_reference_name, "Fe") - 12) \
                                        * element_weight_table.function_element_weight("Fe") * Z_0 / Z_solar
    else:
        print("Wrong element name for function_element_mass_primary_fraction")
        element_mass_fraction = None
    return element_mass_fraction
示例#2
0
import time
import math
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
import element_abundances_solar

reference_name = 'Anders1989'
H_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'H')
# He_abundances_solar = element_abundances_solar.function_solar_element_abundances(reference_name, 'He')
C_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'C')
# N_abundances_solar = element_abundances_solar.function_solar_element_abundances(reference_name, 'N')
O_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'O')
Mg_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'Mg')
Fe_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'Fe')
Si_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'Si')
Ca_abundances_solar = element_abundances_solar.function_solar_element_abundances(
    reference_name, 'Ca')


def plot_lifetime_and_finalmass():
    Z2_list = [0.0004, 0.004, 0.008, 0.012]

    file = open(
        'yield_tables/rearranged/setllar_final_mass_from_portinari98/portinari98_Z=0.004.txt',
示例#3
0
def simulate(imf, Log_SFR, SFEN, STF):
    Z_0 = 0.00000001886
    solar_mass_component = "Anders1989_mass"
    Z_solar = element_abundances_solar.function_solar_element_abundances(
        solar_mass_component, 'Metal')

    galevo.galaxy_evol(
        imf=imf,
        STF=
        STF,  # unrealistic results if more star are forming at a time step than the instantaneous gas mass
        SFEN=SFEN,
        Z_0=Z_0,
        solar_mass_component=solar_mass_component,
        str_yield_table='portinari98',
        IMF_name='Kroupa',
        steller_mass_upper_bound=150,
        time_resolution_in_Myr=1,
        mass_boundary_observe_low=1.5,
        mass_boundary_observe_up=8,
        SFH_model='provided',
        SFE=0.013,  # This parameter is not applied when SFH_model='provided'.
        SNIa_ON=True,
        high_time_resolution=None,
        plot_show=None,
        plot_save=None,
        outflow=None,
        check_igimf=None)
    end_time = time()

    log_Z_0 = round(math.log(Z_0 / Z_solar, 10), 2)
    file = open(
        'simulation_results_from_galaxy_evol/imf{}STF{}log_SFR{}SFEN{}Z_0{}.txt'
        .format(imf, STF, Log_SFR, SFEN, log_Z_0), 'r')
    data = file.readlines()
    file.close()

    Alive_stellar_mass = [float(x) for x in data[7].split()]
    dynamical_mass = [float(x) for x in data[11].split()]
    gas_Mg_over_Fe = [float(x) for x in data[23].split()]
    Mass_weighted_stellar_Mg_over_Fe = [float(x) for x in data[25].split()]
    luminosity_weighted_stellar_Mg_over_Fe = [
        float(x) for x in data[63].split()
    ]
    gas_Z_over_X = [float(x) for x in data[39].split()]
    Mass_weighted_stellar_Z_over_X = [float(x) for x in data[41].split()]
    luminosit_weighted_stellar_Z_over_X = [float(x) for x in data[61].split()]
    gas_Fe_over_H = [float(x) for x in data[19].split()]
    Mass_weighted_stellar_Fe_over_H = [float(x) for x in data[21].split()]
    # luminosit_weighted_stellar_Fe_over_H = [float(x) for x in data[??].split()]

    file_name = 'Metal_mass_relation'
    if imf == 'igimf':
        file_name = 'Metal_mass_relation_igimf'

    file = open('simulation_results_from_galaxy_evol/{}.txt'.format(file_name),
                'r')
    old_lines = file.read()
    file.close()

    file = open('simulation_results_from_galaxy_evol/{}.txt'.format(file_name),
                'w')
    if imf == 'Kroupa':
        imf__ = 0
    elif imf == 'igimf':
        imf__ = 1
    else:
        imf__ = imf
    new_line = old_lines + "{} {} {} {} {} {} {} {} {} {} {} {} {} {}\n".format(
        imf__, Log_SFR, SFEN, STF, Alive_stellar_mass[0], dynamical_mass[0],
        Mass_weighted_stellar_Mg_over_Fe[-1],
        Mass_weighted_stellar_Z_over_X[-1], gas_Mg_over_Fe[-1],
        gas_Z_over_X[-1], luminosity_weighted_stellar_Mg_over_Fe[-1],
        luminosit_weighted_stellar_Z_over_X[-1], gas_Fe_over_H[-1],
        Mass_weighted_stellar_Fe_over_H[-1])
    file.write(new_line)
    file.close()
    return