def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('model_path', type=str, nargs=1, help='The folder path to RMG model') parser.add_argument('fuel', metavar='FUEL', nargs=1, help='The label or the smiles of the fuel') parser.add_argument('-T', '--temperature', nargs='+', help='Temperatures [K]') parser.add_argument('-P', '--pressure', nargs='+', help='Pressures [atm]') parser.add_argument('-p', '--phi', nargs='+', help='Fue-to-air equivalence ratio') parser.add_argument('-f', '--final_time', nargs=1, help='The t_final of the simulation') parser.add_argument('-s', '--simulate_path', nargs=1, help='Path to save simulation results') parser.add_argument('-S', '--sensitivity_path', nargs=1, help='Path to save sensitivity results') parser.add_argument('-F', '--flux_diagram_path', nargs=1, help='Path to save flux diagram results') parser.add_argument('--pool_size', nargs='?', type=int, help='The size of the job pool') args = parser.parse_args() model_path = regularize_path(args.model_path[0]) fuel = args.fuel[0] Ts = [float(T) for T in args.temperature] if args.temperature else TS_POST_PROCESS Ps = [float(P) for P in args.pressure] if args.pressure else PS_POST_PROCESS phis = [float(phi) for phi in args.phi] if args.phi else PHIS_POST_PROCESS tf = float( args.final_time[0]) if args.final_time else SIM_TIME_FINAL_POST_PROCESS outputs = {} for job_type in ['simulate', 'sensitivity', 'flux_diagram']: job_path = getattr(args, f'{job_type}_path') outputs[job_type] = regularize_path(job_path[0]) if job_path else \ os.path.join(os.path.dirname(model_path), job_type) pool_size = POOL_SIZE_POST_PROCESS if not args.pool_size else args.pool_size[ 0] return model_path, fuel, Ts, Ps, phis, tf, outputs, pool_size
def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('input', type=str, help='The ARC input file to be cleaned.') parser.add_argument( '-l', '--libraries', type=str, nargs='?', help='A yaml file contains the thermo library list to be ' 'checked. If any entry is included in the library, it ' 'will be removed from the input file.') # TODO: In the future can filter by its substructure parser.add_argument('-f', '--filter_species', type=str, nargs='?', help='A file contains the species to be filtered.') parser.add_argument('-o', '--output', type=str, nargs='?', help='The dir path to save results.') args = parser.parse_args() input_file = regularize_path(args.input) libraries = regularize_path(args.libraries) \ if args.libraries else '' filter_spc_dict = regularize_path(args.filter_species) \ if args.filter_species else '' output = regularize_path(args.output) if args.output else '' return input_file, libraries, filter_spc_dict, output
def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('input1', type=str, help='The first input ARC input file') parser.add_argument('input2', type=str, help='The second input ARC input file') parser.add_argument('--other_inputs', nargs='+', help='Other inputs to be merged') parser.add_argument( '-n', '--non_resonance', nargs='?', const=True, default=False, help='Whether generating resonance structure to check duplicates') parser.add_argument('-o', '--output', help='The dir path to save results') args = parser.parse_args() input1 = regularize_path(args.input1) input2 = regularize_path(args.input2) if args.other_inputs: other_inputs = [ regularize_path(input_file) for input_file in args.other_inputs ] else: other_inputs = [] resonance = True if not args.non_resonance else False output = regularize_path(args.output) if args.output else None inputs = [input1, input2] + other_inputs return inputs, output, resonance
def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('model_path', metavar='MODELPATH', type=str, nargs=1, help='The folder path to RMG model') parser.add_argument('-o', '--output', nargs=1, help='The path to save results') args = parser.parse_args() model_path = regularize_path(args.model_path[0]) output = regularize_path(args.output[0]) if args.output else None return model_path, output
def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('model_path', metavar='MODELPATH', type=str, nargs=1, help='The folder path to RMG model') parser.add_argument('sensitivity_path', metavar='SENSITIVITY', type=str, nargs=1, help='The folder path to sensitivity results') parser.add_argument('-s', '--software', nargs='?', const='rmg', default='rmg', type=str, help='The software used to generate the flux diagram') parser.add_argument('-o', '--output', nargs=1, help='The dir path to save results') args = parser.parse_args() model_path = regularize_path(args.model_path[0]) if args.software.lower() not in ['rmg', 'cantera', 'rms']: raise ValueError( 'Not an invalid software arguments. Currently support "RMG", "RMS" and "Cantera"' ) else: software = args.software.lower() sens_path = regularize_path(args.sensitivity_path[0]) output = regularize_path(args.output[0]) if args.output else None if output and os.path.isfile(output): raise ValueError('The path to the output exists.') return model_path, sens_path, software, output
def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument('model_path', type=str, nargs=1, help='The folder path to RMG model') parser.add_argument('sensitivity_path', type=str, nargs=1, help='Path to save sensitivity results') parser.add_argument('-T', '--temperature', nargs='+', help='Temperatures [K]') parser.add_argument('-P', '--pressure', nargs='+', help='Pressures [atm]') parser.add_argument('-p', '--phi', nargs='+', help='Fue-to-air equivalence ratio') parser.add_argument('--pool_size', nargs='?', type=int, help='The size of the job pool') args = parser.parse_args() model_path = regularize_path(args.model_path[0]) sens_path = regularize_path(args.sensitivity_path[0]) Ts = [float(T) for T in args.temperature] if args.temperature else TS_POST_PROCESS Ps = [float(P) for P in args.pressure] if args.pressure else PS_POST_PROCESS phis = [float(phi) for phi in args.phi] if args.phi else PHIS_POST_PROCESS pool_size = POOL_SIZE_POST_PROCESS if not args.pool_size else args.pool_size[ 0] return model_path, sens_path, Ts, Ps, phis, pool_size