init_values["H_1"] = (1 - X) * init_array init_values['H_2'] = X * init_array init_values['H_m0'] = init_array * tiny init_values['He_1'] = init_array * tiny init_values['He_2'] = init_array * tiny init_values['He_3'] = init_array * tiny init_values['H2_1'] = init_array * tiny init_values['H2_2'] = init_array * tiny init_values['de'] = init_array * 0.0 # update and calculate electron density and etc with the handy functions total_density = primordial.calculate_total_density(init_values) init_values = primordial.convert_to_mass_density(init_values) init_values['de'] = primordial.calculate_free_electrons(init_values) init_values['density'] = primordial.calculate_total_density(init_values) number_density = primordial.calculate_number_density(init_values) # set up initial temperatures values used to define ge init_values['T'] = temperature # calculate ge (very crudely, no H2 help here) gamma = 5.0 / 3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) # Write the initial conditions file # IF you need to use the Makefile, and c-library # you will have to specified the library_path library_path = {} library_path["CVODE_PATH"] = "/home/kwoksun2/cvode-3.1.0/instdir" library_path["HDF5_PATH"] = "/home/kwoksun2/anaconda3"
# however this attr is not defined for fully ionized species... # fix that later, take this as 1 for now first #ion_frac = ion.IoneqOne ion_frac = 1.0 # ion.Abundance is the elemental abundance relative to hydrogen init_values[s.name] = ion_frac * init_array * ion.Abundance # in case something is negative or super small: init_values[s.name][init_values[s.name] < tiny] = tiny init_values['de'] = init_array * 0.0 init_values = ion_by_ion.convert_to_mass_density(init_values) init_values['de'] = ion_by_ion.calculate_free_electrons(init_values) init_values['density'] = ion_by_ion.calculate_total_density(init_values) number_density = ion_by_ion.calculate_number_density(init_values) # calculate ge (very crudely) gamma = 5.0/3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) # Write the initial conditions file # IF you need to use the Makefile, and c-library # you will have to specified the library_path library_path = {} library_path["CVODE_PATH"] = "/home/kwoksun2/cvode-3.1.0/instdir" library_path["HDF5_PATH"] = "/home/kwoksun2/anaconda3" library_path["SUITESPARSE_PATH"] = "/home/kwoksun2/SuiteSparse" library_path["DENGO_INSTALL_PATH"] = "/home/kwoksun2/dengo_install"
init_values['OII'] = X * init_array init_values['OIII'] = init_array * X init_values['OIV'] = init_array * X init_values['OV'] = init_array * X init_values['OVI'] = init_array * X init_values['OVII'] = init_array * X init_values['OVIII'] = init_array * X init_values['OIX'] = init_array * X init_values['de'] = init_array * 0.0 total_density = oxygen.calculate_total_density(init_values, ("OI", )) init_values["OI"] = init_array.copy() - total_density init_values = oxygen.convert_to_mass_density(init_values) init_values['de'] = oxygen.calculate_free_electrons(init_values) init_values['density'] = oxygen.calculate_total_density(init_values) number_density = oxygen.calculate_number_density(init_values) # set up initial temperatures values used to define ge init_values['T'] = temperature # calculate ge (very crudely, no H2 help here) gamma = 5.0 / 3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) # Write the initial conditions file oxygen.write_solver("oxygen", output_dir=".") import pyximport pyximport.install(setup_args={"include_dirs": np.get_include()}, reload_support=True,
init_values['HOIO_1'] = 9.0e-11 * init_array * (126 + 32 + 1) init_values['IO3m_0'] = 0.01 * init_array * (1 + 16 * 3) init_values['O2_1'] = 2.5e3 * init_array * (16 * 2) init_values['CH2_COOH2_1'] = 0.0015 * init_array * (12 + 2 + (12 + 16 * 2 + 1) * 2) init_values['CHI_COOH2_1'] = 1.0e-20 * init_array * (12 + 126 + (12 + 16 * 2 + 1) * 2) init_values["H2O2_1"] = 0.33 * init_array * (2 + 16) * 2 print(new.required_species) total_density = new.calculate_total_density(init_values) init_values = new.convert_to_mass_density(init_values) init_values['de'] = new.calculate_free_electrons(init_values) init_values['density'] = init_array # new.calculate_total_density(init_values) number_density = new.calculate_number_density(init_values) # set up initial temperatures values used to define ge init_values['T'] = temperature # calculate ge (very crudely, no H2 help here) gamma = 5.0 / 3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) # Write the initial conditions file # IF you need to use the Makefile, and c-library # you will have to specified the library_path library_path = {} library_path["CVODE_PATH"] = "/home/kwoksun2/cvode-3.1.0/instdir" library_path["HDF5_PATH"] = "/home/kwoksun2/anaconda3"
init_values['us_H_1'] = init_array * X init_values['us_H2_1'] = init_array * X init_values['us_e_0'] = init_array * 0.0 print(init_values) #print sorted(umist.reactions.values()) for species in umist.required_species: if species.name not in init_values: init_values[species.name] = init_array * 0.0 total_density = umist.calculate_total_density(init_values) init_values = umist.convert_to_mass_density(init_values) init_values['us_e_0'] = umist.calculate_free_electrons(init_values) init_values['density'] = umist.calculate_total_density(init_values) number_density = umist.calculate_number_density(init_values) # set up initial temperatures values used to define ge init_values['T'] = temperature # calculate ge (very crudely, no H2 help here) gamma = 5.0 / 3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) print(init_values) import pdb pdb.set_trace() #import pdb; pdb.set_trace()
if s.name == 'de': continue else: print s.name, s.number, s.free_electrons + 1 ion_name = chu.zion2name(np.int(s.number), np.int(s.free_electrons + 1)) ion = ch.ion(ion_name, temperature=init_values['T']) ion.ioneqOne() ion_frac = ion.IoneqOne init_values[s.name] = ion_frac * init_array * ion.Abundance # in case something is negative or super small: init_values[s.name][init_values[s.name] < tiny] = tiny init_values['de'] = init_array * 0.0 # total_density = combined.calculate_total_density(init_values, ("OI",)) # init_values["OI"] = init_array.copy() - total_density init_values = combined.convert_to_mass_density(init_values) init_values['de'] = combined.calculate_free_electrons(init_values) init_values['density'] = combined.calculate_total_density(init_values) number_density = combined.calculate_number_density(init_values) # calculate ge (very crudely) gamma = 5.0 / 3.0 init_values['ge'] = ((temperature * number_density * kboltz) / (init_values['density'] * mh * (gamma - 1))) # Write the initial conditions file combined.write_solver("combined", output_dir=".", init_values=init_values)