Added support for explicit reverse rate constants to ck2cti.py
This commit is contained in:
parent
1a60d55135
commit
0da94ea0c2
1 changed files with 23 additions and 8 deletions
|
|
@ -910,6 +910,7 @@ def readKineticsEntry(entry, speciesDict, energyUnits, moleculeUnits):
|
||||||
n = float(tokens[-2])
|
n = float(tokens[-2])
|
||||||
Ea = float(tokens[-1])
|
Ea = float(tokens[-1])
|
||||||
reaction = ''.join(tokens[:-3])
|
reaction = ''.join(tokens[:-3])
|
||||||
|
revReaction = None
|
||||||
thirdBody = False
|
thirdBody = False
|
||||||
|
|
||||||
# Split the reaction equation into reactants and products
|
# Split the reaction equation into reactants and products
|
||||||
|
|
@ -1001,10 +1002,10 @@ def readKineticsEntry(entry, speciesDict, energyUnits, moleculeUnits):
|
||||||
pdepArrhenius = None
|
pdepArrhenius = None
|
||||||
efficiencies = {}
|
efficiencies = {}
|
||||||
chebyshevCoeffs = []
|
chebyshevCoeffs = []
|
||||||
|
explicitReverseRate = False
|
||||||
|
|
||||||
# Note that the subsequent lines could be in any order
|
# Note that the subsequent lines could be in any order
|
||||||
for line in lines[1:]:
|
for line in lines[1:]:
|
||||||
|
|
||||||
tokens = line.split('/')
|
tokens = line.split('/')
|
||||||
if 'DUP' in line or 'dup' in line:
|
if 'DUP' in line or 'dup' in line:
|
||||||
# Duplicate reaction
|
# Duplicate reaction
|
||||||
|
|
@ -1020,6 +1021,22 @@ def readKineticsEntry(entry, speciesDict, energyUnits, moleculeUnits):
|
||||||
T0 = (1,"K"),
|
T0 = (1,"K"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
elif 'rev' in line.lower():
|
||||||
|
reaction.reversible = False
|
||||||
|
explicitReverseRate = True
|
||||||
|
|
||||||
|
# Create a reaction proceeding in the opposite direction
|
||||||
|
revReaction = Reaction(reactants=reaction.products,
|
||||||
|
products=reaction.reactants,
|
||||||
|
reversible=False)
|
||||||
|
tokens = tokens[1].split()
|
||||||
|
revReaction.kinetics = Arrhenius(
|
||||||
|
A = (float(tokens[0].strip()),klow_units),
|
||||||
|
n = float(tokens[1].strip()),
|
||||||
|
Ea = (float(tokens[2].strip()),"kcal/mol"),
|
||||||
|
T0 = (1,"K"),
|
||||||
|
)
|
||||||
|
|
||||||
elif 'TROE' in line or 'troe' in line:
|
elif 'TROE' in line or 'troe' in line:
|
||||||
# Troe falloff parameters
|
# Troe falloff parameters
|
||||||
tokens = tokens[1].split()
|
tokens = tokens[1].split()
|
||||||
|
|
@ -1132,12 +1149,12 @@ def readKineticsEntry(entry, speciesDict, energyUnits, moleculeUnits):
|
||||||
elif thirdBody:
|
elif thirdBody:
|
||||||
reaction.kinetics = ThirdBody(arrheniusHigh=arrheniusHigh)
|
reaction.kinetics = ThirdBody(arrheniusHigh=arrheniusHigh)
|
||||||
reaction.kinetics.efficiencies = efficiencies
|
reaction.kinetics.efficiencies = efficiencies
|
||||||
elif reaction.duplicate:
|
elif reaction.duplicate or explicitReverseRate:
|
||||||
reaction.kinetics = arrheniusHigh
|
reaction.kinetics = arrheniusHigh
|
||||||
else:
|
else:
|
||||||
raise InputParseError('Unable to determine pressure-dependent kinetics for reaction {0}.'.format(reaction))
|
raise InputParseError('Unable to determine pressure-dependent kinetics for reaction {0}.'.format(reaction))
|
||||||
|
|
||||||
return reaction
|
return reaction, revReaction
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
@ -1239,10 +1256,6 @@ def loadChemkinFile(path, speciesList=None):
|
||||||
line, comment = removeCommentFromLine(line)
|
line, comment = removeCommentFromLine(line)
|
||||||
line = line.strip(); comment = comment.strip()
|
line = line.strip(); comment = comment.strip()
|
||||||
|
|
||||||
if 'rev' in line or 'REV' in line:
|
|
||||||
# can no longer name reactants rev...
|
|
||||||
line = f.readline()
|
|
||||||
|
|
||||||
if '=' in line and not lineStartsWithComment:
|
if '=' in line and not lineStartsWithComment:
|
||||||
# Finish previous record
|
# Finish previous record
|
||||||
kineticsList.append(kinetics)
|
kineticsList.append(kinetics)
|
||||||
|
|
@ -1282,8 +1295,10 @@ def loadChemkinFile(path, speciesList=None):
|
||||||
commentsList = ['' for kinetics in kineticsList]
|
commentsList = ['' for kinetics in kineticsList]
|
||||||
|
|
||||||
for kinetics, comments in zip(kineticsList, commentsList):
|
for kinetics, comments in zip(kineticsList, commentsList):
|
||||||
reaction = readKineticsEntry(kinetics, speciesDict, energyUnits, moleculeUnits)
|
reaction,revReaction = readKineticsEntry(kinetics, speciesDict, energyUnits, moleculeUnits)
|
||||||
reactionList.append(reaction)
|
reactionList.append(reaction)
|
||||||
|
if revReaction is not None:
|
||||||
|
reactionList.append(revReaction)
|
||||||
|
|
||||||
elif 'TRAN' in line:
|
elif 'TRAN' in line:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue