forked from ReactionMechanismGenerator/RMG-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thermoEstimator.py
executable file
·70 lines (53 loc) · 2.35 KB
/
thermoEstimator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script runs stand-alone thermo estimation using RMG for a list of species in a
thermo input file. It generates an output.txt file containing the chemkin format
thermochemistry as well as a ThermoLibrary file containing the enthalpy, entropy, and
heat capacity data in RMG-database format.
"""
import os.path
from rmgpy.rmg.main import RMG
from rmgpy.data.thermo import ThermoLibrary
from rmgpy.chemkin import writeThermoEntry
from rmgpy.rmg.model import Species
################################################################################
def runThermoEstimator(inputFile):
"""
Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file.
"""
rmg = RMG()
rmg.loadThermoInput(inputFile)
# initialize and load the database as well as any QM settings
rmg.loadDatabase()
if rmg.quantumMechanics:
rmg.quantumMechanics.initialize()
if rmg.solvent:
Species.solventData = rmg.database.solvation.getSolventData(rmg.solvent)
Species.solventName = rmg.solvent
# Generate the thermo for all the species and write them to chemkin format as well as
# ThermoLibrary format with values for H, S, and Cp's.
output = open(os.path.join(rmg.outputDirectory, 'output.txt'),'wb')
library = ThermoLibrary(name='Thermo Estimation Library')
for species in rmg.initialSpecies:
species.generateThermoData(rmg.database, quantumMechanics=rmg.reactionModel.quantumMechanics)
library.loadEntry(
index = len(library.entries) + 1,
label = species.label,
molecule = species.molecule[0].toAdjacencyList(),
thermo = species.thermo.toThermoData(),
shortDesc = species.thermo.comment,
)
output.write(writeThermoEntry(species))
output.write('\n')
output.close()
library.save(os.path.join(rmg.outputDirectory,'ThermoLibrary.py'))
################################################################################
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('input', metavar='INPUT', type=str, nargs=1,
help='Thermo input file')
args = parser.parse_args()
inputFile = os.path.abspath(args.input[0])
runThermoEstimator(inputFile)