Example #1
0
def main():

    args = parseCommandLineArguments()
    if args.useOriginalReactions and not args.original:
        raise InputError(
            'Cannot use original reactions without a previously run RMG job')
    maximumIsotopicAtoms = args.maximumIsotopicAtoms[0]
    useOriginalReactions = args.useOriginalReactions
    inputFile = args.input
    outputdir = os.path.abspath(
        args.output[0]) if args.output else os.path.abspath('.')
    original = os.path.abspath(args.original[0]) if args.original else None
    kie = args.kineticIsotopeEffect[0] if args.kineticIsotopeEffect else None
    supported_kie_methods = ['simple']
    if kie not in supported_kie_methods and kie is not None:
        raise InputError(
            'The kie input, {0}, is not one of the currently supported methods, {1}'
            .format(kie, supported_kie_methods))
    initializeLog(logging.INFO, os.path.join(os.getcwd(), 'RMG.log'))
    run(inputFile,
        outputdir,
        original=original,
        maximumIsotopicAtoms=maximumIsotopicAtoms,
        useOriginalReactions=useOriginalReactions,
        kineticIsotopeEffect=kie)
Example #2
0
def main():
    initializeLog(logging.INFO,'treegen.log')
    dbdir = settings['database.directory']
    familyName, nprocs = parse_arguments()
    database = RMGDatabase()
    database.load(
        path=dbdir,
        thermoLibraries=['Klippenstein_Glarborg2016', 'BurkeH2O2', 'thermo_DFT_CCSDTF12_BAC', 'DFT_QCI_thermo',
                           'primaryThermoLibrary', 'primaryNS', 'NitrogenCurran', 'NOx2018', 'FFCM1(-)',
                           'SulfurLibrary', 'SulfurGlarborgH2S'],
        transportLibraries=[],
        reactionLibraries=[],
        seedMechanisms=[],
        kineticsFamilies=[familyName],
        kineticsDepositories=['training'],
        # frequenciesLibraries = self.statmechLibraries,
        depository=False,  # Don't bother loading the depository information, as we don't use it
    )
    family = database.kinetics.families[familyName]
    family.cleanTree(database.thermo)
    family.generateTree(thermoDatabase=database.thermo, nprocs=min(4, nprocs))
    family.checkTree()
    family.regularize()
    templateRxnMap = family.getReactionMatches(thermoDatabase=database.thermo, removeDegeneracy=True, getReverse=True, fixLabels=True)
    family.makeBMRulesFromTemplateRxnMap(templateRxnMap, nprocs=min(6, nprocs))
    family.checkTree()
    family.save(os.path.join(dbdir,'kinetics','families',familyName))
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)
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)
Example #5
0
def run_simulation(inputFile,
                   chemkinFile,
                   dictFile,
                   diffusionLimited=True,
                   checkDuplicates=True):
    """
    Runs a standalone simulation of RMG.  Runs sensitivity analysis if sensitive species are given.
    Also runs uncertainty analysis if uncertainty options block is present in input file.

    diffusionLimited=True implies that if it is a liquid reactor diffusion limitations will be enforced
    otherwise they will not be in a liquid reactor
    """
    output_dir = os.path.abspath(os.path.dirname(inputFile))
    initializeLog(logging.INFO, os.path.join(output_dir, 'simulate.log'))

    rmg = loadRMGJob(inputFile,
                     chemkinFile,
                     dictFile,
                     generateImages=False,
                     checkDuplicates=checkDuplicates)

    start_time = time()
    # conduct simulation
    simulate(rmg, diffusionLimited)
    end_time = time()
    time_taken = end_time - start_time
    logging.info("Simulation took {0} seconds".format(time_taken))
Example #6
0
def main():
    # Parse the command-line arguments (requires the argparse module)
    # args = parse_command_line_arguments()
    # AJ: change path to intended input file
    # args = parse_command_line_arguments(["/Users/agnes/Documents/Software/RMG/RMG-Py/examples/rmg/superminimal/input.py"])
    args = parse_command_line_arguments(
        ["./examples/rmg/superminimal/input.py"])

    if args.postprocess:
        print "Postprocessing the profiler statistics (will be appended to RMG.log)"
    else:
        # 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
        initializeLog(level, os.path.join(args.output_directory, 'RMG.log'))

    logging.info(rmgpy.settings.report())

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

    if args.profile:
        import cProfile
        global_vars = {}
        local_vars = {
            'inputFile': args.file,
            'output_dir': args.output_directory,
            'kwargs': kwargs,
            'RMG': RMG
        }

        command = """rmg = RMG(inputFile=inputFile, outputDirectory=output_dir); rmg.execute(**kwargs)"""

        stats_file = os.path.join(args.output_directory, 'RMG.profile')
        print("Running under cProfile")
        if not args.postprocess:
            # actually run the program!
            cProfile.runctx(command, global_vars, local_vars, stats_file)
        # postprocess the stats
        log_file = os.path.join(args.output_directory, 'RMG.log')
        processProfileStats(stats_file, log_file)
        makeProfileGraph(stats_file)

    else:

        rmg = RMG(inputFile=args.file, outputDirectory=args.output_directory)
        rmg.execute(**kwargs)
def generate_RMG_model(inputFile, outputDirectory):
    """
    Generate the RMG-Py model NOT containing any non-normal isotopomers.

    Returns created RMG object.
    """
    initializeLog(logging.INFO, os.path.join(outputDirectory, 'RMG.log'))
    # generate mechanism:
    rmg = RMG(inputFile = os.path.abspath(inputFile),
              outputDirectory = os.path.abspath(outputDirectory))
    rmg.execute()

    return rmg
Example #8
0
def generate_RMG_model(inputFile, outputDirectory):
    """
    Generate the RMG-Py model NOT containing any non-normal isotopomers.

    Returns created RMG object.
    """
    initializeLog(logging.INFO, os.path.join(outputDirectory, 'RMG.log'))
    # generate mechanism:
    rmg = RMG(inputFile=os.path.abspath(inputFile),
              outputDirectory=os.path.abspath(outputDirectory))
    rmg.execute()

    return rmg
Example #9
0
File: rmg.py Project: cainja/RMG-Py
def main():
    # Parse the command-line arguments (requires the argparse module)
    args = parse_command_line_arguments()

    if args.postprocess:
        print "Postprocessing the profiler statistics (will be appended to RMG.log)"
    else:
        # 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
        initializeLog(level, os.path.join(args.output_directory, 'RMG.log'))

    logging.info(rmgpy.settings.report())

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

    if args.profile:
        import cProfile
        global_vars = {}
        local_vars = {
            'inputFile': args.file,
            'output_dir': args.output_directory,
            'kwargs': kwargs,
            'RMG': RMG
        }

        command = """rmg = RMG(inputFile=inputFile, outputDirectory=output_dir); rmg.execute(**kwargs)"""

        stats_file = os.path.join(args.output_directory, 'RMG.profile')
        print("Running under cProfile")
        if not args.postprocess:
            # actually run the program!
            cProfile.runctx(command, global_vars, local_vars, stats_file)
        # postprocess the stats
        log_file = os.path.join(args.output_directory, 'RMG.log')
        processProfileStats(stats_file, log_file)
        makeProfileGraph(stats_file)

    else:

        rmg = RMG(inputFile=args.file, outputDirectory=args.output_directory)
        rmg.execute(**kwargs)
def main():

    args = parseCommandLineArguments()
    if args.useOriginalReactions and not args.original:
        raise InputError('Cannot use original reactions without a previously run RMG job')
    maximumIsotopicAtoms = args.maximumIsotopicAtoms[0]
    useOriginalReactions = args.useOriginalReactions
    inputFile = args.input
    outputdir = os.path.abspath(args.output[0]) if args.output else os.path.abspath('.')
    original = os.path.abspath(args.original[0]) if args.original else None
    kie = args.kineticIsotopeEffect[0] if args.kineticIsotopeEffect else None
    supported_kie_methods = ['simple']
    if kie not in supported_kie_methods and kie is not None:
        raise InputError('The kie input, {0}, is not one of the currently supported methods, {1}'.format(kie,supported_kie_methods))
    initializeLog(logging.INFO, os.path.join(os.getcwd(), 'RMG.log'))
    run(inputFile, outputdir, original=original,
        maximumIsotopicAtoms=maximumIsotopicAtoms,
        useOriginalReactions=useOriginalReactions,
        kineticIsotopeEffect = kie)
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,
    }

    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)
Example #12
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 = 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)
Example #13
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

    if args.postprocess:
        print "Postprocessing the profiler statistics (will be appended to RMG.log)"
        args.profile = True
    else:
        # 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
        initializeLog(level, os.path.join(args.output_directory, 'RMG.log'))

    logging.info(rmgpy.settings.report())

    output_dir = args.output_directory
    kwargs = {
        'scratch_directory': args.scratch_directory,
        'restart': args.restart,
        'walltime': args.walltime,
    }

    if args.profile:
        import cProfile, sys, pstats, os
        global_vars = {}
        local_vars = {
            'inputFile': inputFile,
Example #14
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

    if args.postprocess:
        print "Postprocessing the profiler statistics (will be appended to RMG.log)"
        args.profile = True
    else:
        # 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
        initializeLog(level, os.path.join(args.output_directory, 'RMG.log'))

    logging.info(rmgpy.settings.report())

    output_dir = args.output_directory
    kwargs = {
        'scratch_directory': args.scratch_directory,
        'restart': args.restart,
        'walltime': args.walltime,
        }

    if args.profile:
        import cProfile, sys, pstats, os
        global_vars = {}
        local_vars = {
            'inputFile': inputFile,