print( "\n\n### Warning: Wrong input 'SFEN' smaller than 1! Correct SFEN to 1. ###\n\n" ) SFEN = 1 print('\nGenerating new SFH...') galevo.generate_SFH(SFH_shape, Log_SFR, SFEN, sfr_tail, skewness, location) print('\nStart galaxy simulation...\n') galevo.galaxy_evol( imf='igimf', STF= 0.3, # unrealistic results if more star are forming at a time step than the instantaneous gas mass SFEN=SFEN, Z_0=0.00000001886, solar_mass_component="Anders1989_mass", 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=True, plot_save=None, outflow=None, check_igimf=True)
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
float( input( "\n\n Please input the characteristic star formation timescale in the unit of 10 Myr (integer only) " "and ended the input with the return key.\n" " We recommend a value smaller than 10 for 'flat' SFH and smaller than 3 for 'skewnorm' SFH for the first run, " "as longer timescale calculations take more time.\n\n" " SFT [10Myr] = "))) if SFEN < 1: print( "\n\n### Warning: Wrong input 'SFEN' smaller than 1! Correct SFEN to 1. ###\n\n" ) SFEN = 1 print('\nGenerating new SFH...') galevo.generate_SFH(SFH_shape, Log_SFR, SFEN, sfr_tail, skewness, location) galevo.galaxy_evol( imf='igimf', STF= 0.3, # can be larger than 1 since gas is recycled from dying stars but if set too high # unrealistic results may generated if, at a later time step, more star are forming than the available gas mass. SFH_model='provided', SFE=0.013, SFEN= SFEN, # Parameter "SFE" and "SFEN" is not applied when SFH_model='provided'. # printout_galevo_info=True, plot_show=True, # high_time_resolution=True, # plot_save=True, SNIa_ON=True, )