def main(): initialize_log(logging.INFO, 'treegen.log') dbdir = settings['database.directory'] family_name = parse_arguments() database = RMGDatabase() database.load( path=dbdir, thermo_libraries=['Klippenstein_Glarborg2016', 'BurkeH2O2', 'thermo_DFT_CCSDTF12_BAC', 'DFT_QCI_thermo', 'primaryThermoLibrary', 'primaryNS', 'NitrogenCurran', 'NOx2018', 'FFCM1(-)', 'SulfurLibrary', 'SulfurGlarborgH2S', 'SABIC_aromatics'], transport_libraries=[], reaction_libraries=[], seed_mechanisms=[], kinetics_families=[family_name], kinetics_depositories=['training'], # frequenciesLibraries = self.statmechLibraries, depository=False, # Don't bother loading the depository information, as we don't use it ) family = database.kinetics.families[family_name] num_training_rxns = len(family.get_training_depository().entries) max_batch_size = 800 family.clean_tree() if (num_training_rxns/max_batch_size > 1) and (num_training_rxns/max_batch_size <= 1.3): family.generate_tree(thermo_database=database.thermo, nprocs=1, max_batch_size=num_training_rxns) else: family.generate_tree(thermo_database=database.thermo, nprocs=1) family.check_tree() family.regularize() template_rxn_map = family.get_reaction_matches(thermo_database=database.thermo, remove_degeneracy=True, get_reverse=True, fix_labels=True) family.make_bm_rules_from_template_rxn_map(template_rxn_map, nprocs=1) family.check_tree() family.save(os.path.join(dbdir, 'kinetics', 'families', family_name))
def run_simulation(input_file, chemkin_file, dict_file, diffusion_limited=True, check_duplicates=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. diffusion_limited=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(input_file)) initialize_log(logging.INFO, os.path.join(output_dir, 'simulate.log')) rmg = load_rmg_job(input_file, chemkin_file, dict_file, generate_images=False, check_duplicates=check_duplicates) start_time = time() # conduct simulation simulate(rmg, diffusion_limited) end_time = time() time_taken = end_time - start_time logging.info("Simulation took {0} seconds".format(time_taken))
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, 'maxproc': args.maxproc, 'kineticsdatastore': args.kineticsdatastore } initialize_log(level, os.path.join(args.output_directory, 'RMG.log')) rmg = RMG(input_file=args.file, output_directory=args.output_directory) # Add output listeners: rmg.attach(ChemkinWriter(args.output_directory)) rmg.attach(OutputHTMLWriter(args.output_directory)) execute(rmg, **kwargs)
def main(): # Parse the command-line arguments (requires the argparse module) args = parse_command_line_arguments() if args.postprocess: logging.info( "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 initialize_log(level, os.path.join(args.output_directory, 'RMG.log')) logging.info(rmgpy.settings.report()) kwargs = { 'restart': args.restart, 'walltime': args.walltime, 'maxproc': args.maxproc, '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(input_file=inputFile, output_directory=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') process_profile_stats(stats_file, log_file) make_profile_graph(stats_file) else: rmg = RMG(input_file=args.file, output_directory=args.output_directory) rmg.execute(**kwargs)
def generate_rmg_model(input_file, output_directory): """ Generate the RMG-Py model NOT containing any non-normal isotopomers. Returns created RMG object. """ initialize_log(logging.INFO, os.path.join(output_directory, 'RMG.log')) # generate mechanism: rmg = RMG(input_file=os.path.abspath(input_file), output_directory=os.path.abspath(output_directory)) rmg.execute() return rmg
def setUpClass(cls): """A function that is run ONCE before all unit tests in this class.""" cls.testDir = os.path.join(originalPath, 'rmg', 'test_data', 'restartTest') cls.outputDir = os.path.join(cls.testDir, 'output_no_filters') cls.databaseDirectory = settings['database.directory'] os.mkdir(cls.outputDir) initialize_log(logging.INFO, os.path.join(cls.outputDir, 'RMG.log')) cls.rmg = RMG(input_file=os.path.join(cls.testDir, 'restart_no_filters.py'), output_directory=os.path.join(cls.outputDir))
def main(): args = parse_command_line_arguments() if args.useOriginalReactions and not args.original: raise InputError('Cannot use original reactions without a previously run RMG job') maximum_isotopic_atoms = args.maximumIsotopicAtoms[0] use_original_reactions = args.useOriginalReactions input_file = 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)) initialize_log(logging.INFO, os.path.join(os.getcwd(), 'RMG.log')) run(input_file, outputdir, original=original, maximum_isotopic_atoms=maximum_isotopic_atoms, use_original_reactions=use_original_reactions, kinetic_isotope_effect=kie)