Skip to content

Commit 4fadd44

Browse files
committed
Improved argument parsing and increased chunk size
1 parent dad02b4 commit 4fadd44

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

thermoEstimator.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ def runThermoEstimator(inputFile):
4242
output = open(os.path.join(rmg.outputDirectory, 'output.txt'),'wb')
4343
library = ThermoLibrary(name='Thermo Estimation Library')
4444
listOfSpecies=rmg.initialSpecies
45-
chunksize=50
45+
chunksize=1000
4646
if rmg.reactionModel.quantumMechanics: logging.debug("qmValue fine @ runThermoEstimator")
4747
shared.setConst(qmValue=rmg.reactionModel.quantumMechanics)
4848
for chunk in list(chunks(listOfSpecies,chunksize)):
49-
logging.debug("Parallelized section starts...")
5049
# There will be no stdout from workers except the main one.
5150
outputList = futures.map(makeThermoForSpecies, chunk)
52-
logging.debug("Parallelized section ends.")
5351
for species, thermo in zip(chunk, outputList):
5452
logging.debug("Species {0}".format(species.label))
5553
species.thermo = thermo
@@ -60,7 +58,6 @@ def runThermoEstimator(inputFile):
6058
thermo = species.thermo.toThermoData(),
6159
shortDesc = species.thermo.comment,
6260
)
63-
logging.debug("chunk done")
6461
output.write(writeThermoEntry(species))
6562
output.write('\n')
6663

@@ -74,12 +71,22 @@ def runThermoEstimator(inputFile):
7471

7572
import argparse
7673

77-
parser = argparse.ArgumentParser()
74+
parser = argparse.ArgumentParser(description=
75+
"""
76+
thermoEstimator.py generates thermochemical parameters based on Benson group additivity
77+
or quantum mechanical calculations. \n
78+
Generates three output files.
79+
RMG.log: Contains information about the process.
80+
output.txt: Contains string representations of the NASA model for each species, readable by Chemkin.
81+
ThermoLibrary.py: Thermo library that can be used in RMG simulations. Can be uploaded to RMG-database.
82+
""")
7883
parser.add_argument('input', metavar='FILE', type=str, nargs=1,
7984
help='Thermo input file')
8085
parser.add_argument('-p', '--profile', action='store_true', help='run under cProfile to gather profiling statistics, and postprocess them if job completes')
8186
parser.add_argument('-P', '--postprocess', action='store_true', help='postprocess profiling statistics from previous [failed] run; does not run the simulation')
82-
87+
group = parser.add_mutually_exclusive_group()
88+
group.add_argument('-d', '--debug', action='store_true', help='print debug information')
89+
group.add_argument('-q', '--quiet', action='store_true', help='only print warnings and errors')
8390
args = parser.parse_args()
8491

8592
inputFile = os.path.abspath(args.input[0])
@@ -106,7 +113,10 @@ def runThermoEstimator(inputFile):
106113
makeProfileGraph(stats_file)
107114

108115
else:
109-
level = logging.INFO
110-
initializeLog(level, 'thermo.log')
116+
117+
if args.debug: level = logging.DEBUG
118+
elif args.quiet: level = logging.WARNING
119+
else: level = logging.INFO
120+
initializeLog(level, 'RMG.log')
111121
logging.debug("runThermoEstimator starts...")
112122
runThermoEstimator(inputFile)

0 commit comments

Comments
 (0)