Example #1
0
    def execute(self, outputFile, plot, 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.pathReactions:
            transitionState = reaction.transitionState
            if transitionState.conformer and transitionState.conformer.E0 is None:
                transitionState.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.printSummary()

        if outputFile is not None:
            self.draw(os.path.dirname(outputFile), format)

        self.initialize()

        self.K = self.network.calculateRateCoefficients(self.Tlist.value_si, self.Plist.value_si, self.method)

        self.fitInterpolationModels()

        if outputFile is not None:
            self.save(outputFile)
            if plot:
                self.plot(os.path.dirname(outputFile))
            if self.sensitivity_conditions is not None:
                perturbation = 0.1  # kcal/mol
                logging.info('\n\nRunning sensitivity analysis...')
                for i in xrange(3):
                    try:
                        sa(self, os.path.dirname(outputFile), perturbation=perturbation)
                    except (InvalidMicrocanonicalRateError, ModifiedStrongCollisionError) as exept:
                        logging.warn("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 exept
                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))
    def execute(self, outputFile, plot, format='pdf', print_summary=True):
        
        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.pathReactions:
            transitionState = reaction.transitionState
            if transitionState.conformer and transitionState.conformer.E0 is None:
                transitionState.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.printSummary()
        
        if outputFile is not None:
            self.draw(os.path.dirname(outputFile), format)
        
        self.initialize()
        
        self.K = self.network.calculateRateCoefficients(self.Tlist.value_si, self.Plist.value_si, self.method)

        self.fitInterpolationModels()

        if outputFile is not None:
            self.save(outputFile)
            if plot:
                self.plot(os.path.dirname(outputFile))
            if self.sensitivity_conditions is not None:
                perturbation = 0.1  # kcal/mol
                logging.info('\n\nRunning sensitivity analysis...')
                for i in xrange(3):
                    try:
                        sa(self, os.path.dirname(outputFile), perturbation=perturbation)
                    except (InvalidMicrocanonicalRateError, ModifiedStrongCollisionError) as exept:
                        logging.warn("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 exept
                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))
Example #3
0
 def execute(self, outputFile=None, plot=True):
     """
     Execute the kinetics job, saving the results to the given `outputFile` on disk.
     """
     if self.Tlist is not None:
         self.generateKinetics(self.Tlist.value_si)
     else:
         self.generateKinetics()
     if outputFile is not None:
         self.save(outputFile)
         if plot:
             self.plot(os.path.dirname(outputFile))
         self.draw(os.path.dirname(outputFile))
         if self.sensitivity_conditions is not None:
             logging.info('\n\nRunning sensitivity analysis...')
             sa(self, os.path.dirname(outputFile))
     logging.debug('Finished kinetics job for reaction {0}.'.format(self.reaction))
     logging.debug(repr(self.reaction))
Example #4
0
    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.generateKinetics()
        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:
                    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...')
                sa(self, output_directory)
        logging.debug('Finished kinetics job for reaction {0}.'.format(
            self.reaction))
        logging.debug(repr(self.reaction))