def generate_isotope_model(output_directory, rmg0, isotopes, use_original_reactions=False, kinetic_isotope_effect=None): """ Replace the core species of the rmg model with the parameter list of species. Generate all reactions between new list of core species. Returns created RMG object. """ logging.debug("isotope: called generateIsotopeModel") rmg = RMG(input_file=rmg0.input_file, output_directory=output_directory) rmg.attach(ChemkinWriter(output_directory)) logging.info("isotope: making the isotope model for with all species") initialize_isotope_model(rmg, isotopes) if use_original_reactions: logging.info("isotope: finding reactions from the original reactions") rxns = generate_isotope_reactions(rmg0.reaction_model.core.reactions, isotopes) rmg.reaction_model.process_new_reactions(rxns, new_species=[]) else: logging.info("isotope: enlarging the isotope model") rmg.reaction_model.enlarge(react_edge=True, unimolecular_react=rmg.unimolecular_react, bimolecular_react=rmg.bimolecular_react) logging.info("isotope: clustering reactions") clusters = cluster(rmg.reaction_model.core.reactions) logging.info( 'isotope: fixing the directions of every reaction to a standard') for isotopomerRxnList in clusters: ensure_reaction_direction(isotopomerRxnList) consistent = True logging.info("isotope: checking symmetry is consistent among isotopomers") for species_list in cluster(rmg.reaction_model.core.species): if not ensure_correct_symmetry(species_list): logging.info("isotopomers of {} with index {} may have wrong " "symmetry".format(species_list[0], species_list[0].index)) consistent = False logging.info( "isotope: checking that reaction degeneracy is consistent among isotopomers" ) for rxn_list in clusters: if not ensure_correct_degeneracies(rxn_list): logging.info("isotopomers of {} with index {} may have incorrect " "degeneracy.".format(rxn_list[0], rxn_list[0].index)) consistent = False if not consistent: logging.warning( "isotope: non-consistent degeneracy and/or symmetry was detected. This may lead to " "unrealistic deviations in enrichment. check log for more details") if kinetic_isotope_effect: logging.info( 'isotope: modifying reaction rates using kinetic isotope effect ' 'method "{0}"'.format(kinetic_isotope_effect)) if kinetic_isotope_effect == 'simple': apply_kinetic_isotope_effect_simple(clusters, rmg.database.kinetics) else: logging.warning( 'isotope: kinetic isotope effect {0} is not supported. ' 'skipping adding kinetic isotope effects.') else: logging.info( 'isotope: not adding kinetic isotope effects since no method was supplied.' ) logging.info("isotope: saving files") rmg.save_everything() rmg.finish() return rmg
def generate_isotope_model(outputDirectory, rmg0, isotopes, useOriginalReactions = False, kineticIsotopeEffect = None): """ Replace the core species of the rmg model with the parameter list of species. Generate all reactions between new list of core species. Returns created RMG object. """ logging.debug("isotope: called generateIsotopeModel") rmg = RMG(inputFile=rmg0.inputFile, outputDirectory=outputDirectory) rmg.attach(ChemkinWriter(outputDirectory)) logging.info("isotope: making the isotope model for with all species") initialize_isotope_model(rmg, isotopes) if useOriginalReactions: logging.info("isotope: finding reactions from the original reactions") rxns = generate_isotope_reactions(rmg0.reactionModel.core.reactions, isotopes) rmg.reactionModel.processNewReactions(rxns,newSpecies=[]) else: logging.info("isotope: enlarging the isotope model") rmg.reactionModel.enlarge(reactEdge=True, unimolecularReact=rmg.unimolecularReact, bimolecularReact=rmg.bimolecularReact) logging.info("isotope: clustering reactions") clusters = cluster(rmg.reactionModel.core.reactions) logging.info('isotope: fixing the directions of every reaction to a standard') for isotopomerRxnList in clusters: ensure_reaction_direction(isotopomerRxnList) consistent = True logging.info("isotope: checking symmetry is consistent among isotopomers") for species_list in cluster(rmg.reactionModel.core.species): if not ensure_correct_symmetry(species_list): logging.info("isotopomers of {} with index {} may have wrong symmetry".format(species_list[0], species_list[0].index)) consistent = False logging.info("isotope: checking that reaction degeneracy is consistent among isotopomers") for rxn_list in clusters: if not ensure_correct_degeneracies(rxn_list): logging.info("isotopomers of {} with index {} may have incorrect degeneracy.".format(rxn_list[0], rxn_list[0].index)) consistent = False if not consistent: logging.warning("isotope: non-consistent degeneracy and/or symmetry was detected. This may lead to unrealistic deviations in enrichment. check log for more details") if kineticIsotopeEffect: logging.info('isotope: modifying reaction rates using kinetic isotope effect method "{0}"'.format(kineticIsotopeEffect)) if kineticIsotopeEffect == 'simple': apply_kinetic_isotope_effect_simple(clusters,rmg.database.kinetics) else: logging.warning('isotope: kinetic isotope effect {0} is not supported. skipping adding kinetic isotope effects.') else: logging.info('isotope: not adding kinetic isotope effects since no method was supplied.') logging.info("isotope: saving files") rmg.saveEverything() rmg.finish() return rmg