def generate_conditions(self, reactor_type_list: Type[List[tuple]], reaction_time_list: Type[List[tuple]], mol_frac_list: Type[List[dict]], T0_list: Type[List[tuple]] = None, P0_list: Type[List[tuple]] = None, V0_list: Type[List[tuple]] = None, ): """ Saves all the reaction conditions. Args: reactor_type_list (list): A list of strings specifying the type of supported Cantera reactor: IdealGasReactor: A constant volume, zero-dimensional reactor for ideal gas mixtures IdealGasConstPressureReactor: A homogeneous, constant pressure, zero-dimensional reactor for ideal gas mixtures IdealGasConstPressureTemperatureReactor: A homogenous, constant pressure and constant temperature, zero-dimensional reactor for ideal gas mixtures (the same as RMG's SimpleReactor) reaction_time_list (tuple): A tuple object giving the ([list of reaction times], units) mol_frac_list (list): A list of molfrac dictionaries with species object keys and mole fraction values To specify the system for an ideal gas, 2 of the following 3 parameters must be defined: T0_list (tuple): A tuple giving the ([list of initial temperatures], units) P0_list (tuple): A tuple giving the ([list of initial pressures], units) V0_list (tuple): A tuple giving the ([list of initial specific volumes], units) """ self.conditions = generate_cantera_conditions(reactor_type_list, reaction_time_list, mol_frac_list, T0_list, P0_list, V0_list, )
def generate_conditions(self, reactor_type_list, reaction_time_list, mol_frac_list, Tlist=None, Plist=None, Vlist=None): """ Creates a list of conditions from from the lists provided. ======================= ==================================================== Argument Description ======================= ==================================================== `reactor_type_list` A list of strings of the cantera reactor type. List of supported types below: IdealGasReactor: A constant volume, zero-dimensional reactor for ideal gas mixtures IdealGasConstPressureReactor: A homogeneous, constant pressure, zero-dimensional reactor for ideal gas mixtures `reaction_time_list` A tuple object giving the ([list of reaction times], units) `mol_frac_list` A list of molfrac dictionaries with species object keys and mole fraction values To specify the system for an ideal gas, you must define 2 of the following 3 parameters: `T0List` A tuple giving the ([list of initial temperatures], units) 'P0List' A tuple giving the ([list of initial pressures], units) 'V0List' A tuple giving the ([list of initial specific volumes], units) This saves all the reaction conditions into both the old and new cantera jobs. """ # Store the conditions in the observables test case, for bookkeeping self.conditions = generate_cantera_conditions(reactor_type_list, reaction_time_list, mol_frac_list, Tlist=Tlist, Plist=Plist, Vlist=Vlist) # Map the mole fractions dictionaries to species objects from the old and new models old_mol_frac_list = [] new_mol_frac_list = [] for mol_frac in mol_frac_list: old_condition = {} new_condition = {} old_species_dict = get_rmg_species_from_user_species(list(mol_frac.keys()), self.old_sim.species_list) new_species_dict = get_rmg_species_from_user_species(list(mol_frac.keys()), self.new_sim.species_list) for smiles, molfrac in mol_frac.items(): if old_species_dict[smiles] is None: raise Exception('SMILES {0} was not found in the old model!'.format(smiles)) if new_species_dict[smiles] is None: raise Exception('SMILES {0} was not found in the new model!'.format(smiles)) old_condition[old_species_dict[smiles]] = molfrac new_condition[new_species_dict[smiles]] = molfrac old_mol_frac_list.append(old_condition) new_mol_frac_list.append(new_condition) # Generate the conditions in each simulation self.old_sim.generate_conditions(reactor_type_list, reaction_time_list, old_mol_frac_list, Tlist=Tlist, Plist=Plist, Vlist=Vlist) self.new_sim.generate_conditions(reactor_type_list, reaction_time_list, new_mol_frac_list, Tlist=Tlist, Plist=Plist, Vlist=Vlist)