def execute(self, output_directory=None, plot=True): """ Execute the kinetics job, saving the results within the `output_directory`. If `plot` is True, then plots of the raw and fitted values for the kinetics will be saved. """ self.generate_kinetics() if output_directory is not None: try: self.write_output(output_directory) except Exception as e: logging.warning("Could not write kinetics output file due to error: " "{0} in reaction {1}".format(e, self.reaction.label)) try: self.write_chemkin(output_directory) except Exception as e: logging.warning("Could not write kinetics chemkin output due to error: " "{0} in reaction {1}".format(e, self.reaction.label)) if plot: try: self.plot(output_directory) except Exception as e: logging.warning("Could not plot kinetics due to error: " "{0} in reaction {1}".format(e, self.reaction.label)) try: self.draw(output_directory) except Exception as e: logging.warning("Could not draw reaction {1} due to error: {0}".format(e, self.reaction.label)) if self.sensitivity_conditions is not None: logging.info('\n\nRunning sensitivity analysis...') SensAnalysis(self, output_directory) logging.debug('Finished kinetics job for reaction {0}.'.format(self.reaction)) logging.debug(repr(self.reaction))
def execute(self, output_file, plot, file_format='pdf', print_summary=True): """Execute a PressureDependenceJob""" for config in self.network.isomers + self.network.reactants + self.network.products: for spec in config.species: if spec.conformer.E0 is None: raise AttributeError('species {0} is missing energy for its conformer'.format(spec.label)) # set transition state Energy if not set previously using same method as RMG pdep for reaction in self.network.path_reactions: transition_state = reaction.transition_state if transition_state.conformer and transition_state.conformer.E0 is None: transition_state.conformer.E0 = (sum([spec.conformer.E0.value_si for spec in reaction.reactants]) + reaction.kinetics.Ea.value_si, 'J/mol') logging.info('Approximated transitions state E0 for reaction {3} from kinetics ' 'A={0}, n={1}, Ea={2} J/mol'.format(reaction.kinetics.A.value_si, reaction.kinetics.n.value_si, reaction.kinetics.Ea.value_si, reaction.label)) if print_summary: self.network.log_summary() if output_file is not None: self.draw(os.path.dirname(output_file), file_format) self.initialize() self.K = self.network.calculate_rate_coefficients(self.Tlist.value_si, self.Plist.value_si, self.method) self.fit_interpolation_models() if output_file is not None: self.save(output_file) if plot: self.plot(os.path.dirname(output_file)) if self.sensitivity_conditions is not None: perturbation = 0.1 # kcal/mol logging.info('\n\nRunning sensitivity analysis...') for i in range(3): try: SensAnalysis(self, os.path.dirname(output_file), perturbation=perturbation) except (InvalidMicrocanonicalRateError, ModifiedStrongCollisionError) as e: logging.warning('Could not complete the sensitivity analysis with a perturbation of {0} ' 'kcal/mol, trying {1} kcal/mol instead.'.format( perturbation, perturbation / 2.0)) perturbation /= 2.0 else: break else: logging.error("Could not complete the sensitivity analysis even with a perturbation of {0}" " kcal/mol".format(perturbation)) raise e logging.info("Completed the sensitivity analysis using a perturbation of {0} kcal/mol".format( perturbation)) logging.debug('Finished pdep job for reaction {0}.'.format(self.network.label)) logging.debug(repr(self.network))