コード例 #1
0
def main():
    """
    Driver function that parses command line arguments and passes them to the execute function.
    """
    # Parse the command-line arguments (requires the argparse module)
    args = parse_command_line_arguments()

    # Initialize the logging system (resets the RMG.log file)
    level = logging.INFO
    if args.debug:
        level = 0
    elif args.verbose:
        level = logging.DEBUG
    elif args.quiet:
        level = logging.WARNING

    kwargs = {
            'restart': args.restart,
            'walltime': args.walltime,
            'log': level,
            'kineticsdatastore': args.kineticsdatastore
    }

    initializeLog(level, os.path.join(args.output_directory, 'RMG.log'))

    rmg = RMG(inputFile=args.file, outputDirectory=args.output_directory)

    # Add output listeners:
    rmg.attach(ChemkinWriter(args.output_directory))
    rmg.attach(OutputHTMLWriter(args.output_directory))

    execute(rmg, **kwargs)
コード例 #2
0
    def createOutput(self):
        """
        Generate output html file from the path containing chemkin and dictionary files.
        """

        import rmgpy.tools.generate_reactions as generate_reactions
        from rmgpy.rmg.main import initializeLog, RMG
        from rmgpy.chemkin import ChemkinWriter
        from rmgpy.rmg.output import OutputHTMLWriter

        inputFile = self.input
        output_directory = self.getDirname()

        rmg = RMG()
        # Add output listeners:
        rmg.attach(ChemkinWriter(output_directory))
        rmg.attach(OutputHTMLWriter(output_directory))

        generate_reactions.execute(rmg, inputFile, output_directory)
コード例 #3
0
ファイル: generate_reactions.py プロジェクト: keceli/RMG-Py
def main():
    """
    Driver function that parses command line arguments and passes them to the execute function.
    """
    # Parse the command-line arguments (requires the argparse module)
    args = parseCommandLineArguments()

    # For output and scratch directories, if they are empty strings, set them
    # to match the input file location
    inputFile = args.file[0]

    inputDirectory = os.path.abspath(os.path.dirname(inputFile))

    if args.output_directory == '':
        args.output_directory = inputDirectory
    if args.scratch_directory == '':
        args.scratch_directory = inputDirectory
    
    # Initialize the logging system (resets the RMG.log file)
    level = logging.INFO
    if args.debug: level = 0
    elif args.verbose: level = logging.DEBUG
    elif args.quiet: level = logging.WARNING

    kwargs = {
            'scratch_directory': args.scratch_directory,
            'restart': args.restart,
            'walltime': args.walltime,
            'log': level,
            'kineticsdatastore': args.kineticsdatastore
    }

    initializeLog(level, os.path.join(args.output_directory,'RMG.log'))

    rmg = RMG(inputFile=inputFile, outputDirectory=args.output_directory)

    # Add output listeners:
    rmg.attach(ChemkinWriter(args.output_directory))
    rmg.attach(OutputHTMLWriter(args.output_directory))

    execute(rmg, **kwargs)
コード例 #4
0
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