Skip to content

Commit e098371

Browse files
committed
Now fitting and saving k(T,P) values in both directions in MEASURE.
Previously we were only keeping the k(T,P) values in one direction, where that direction was chosen solely based on the order of configurations in the network. This is almost certainly not a good method of choice. Instead of forcing one on everyone, however, I think it's better to leave it up to the end user to decide what to do with things. Some applications might prefer to keep both directions, while others might just want the exothermic direction, or perhaps something else.
1 parent e1f226c commit e098371

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

rmgpy/measure/main.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,25 @@ def execute(inputFile, outputFile=None, drawFile=None, logFile=None, quiet=False
165165
configurations.extend([reactants for reactants in network.reactants])
166166
configurations.extend([products for products in network.products])
167167
for i in range(Nisom+Nreac+Nprod):
168-
for j in range(min(i, Nisom+Nreac)):
169-
170-
# Check that we have nonzero k(T,P) values
171-
if (numpy.any(K[:,:,i,j]) and not numpy.all(K[:,:,i,j])):
172-
raise NetworkError('Zero rate coefficient encountered while updating network {0}.'.format(network))
173-
174-
# Make a new net reaction
175-
forward = True
176-
netReaction = Reaction(
177-
reactants=configurations[j],
178-
products=configurations[i],
179-
kinetics=None,
180-
reversible=(i<Nisom+Nreac),
181-
)
182-
network.netReactions.append(netReaction)
183-
184-
# Set/update the net reaction kinetics using interpolation model
185-
netReaction.kinetics = fitInterpolationModel(netReaction, Tlist, Plist,
186-
K[:,:,i,j] if forward else K[:,:,j,i],
187-
model, Tmin, Tmax, Pmin, Pmax, errorCheck=True)
168+
for j in range(Nisom+Nreac):
169+
if i != j:
170+
# Check that we have nonzero k(T,P) values
171+
if (numpy.any(K[:,:,i,j]) and not numpy.all(K[:,:,i,j])):
172+
raise NetworkError('Zero rate coefficient encountered while updating network {0}.'.format(network))
173+
174+
# Make a new net reaction
175+
netReaction = Reaction(
176+
reactants=configurations[j],
177+
products=configurations[i],
178+
kinetics=None,
179+
reversible=(i<Nisom+Nreac),
180+
)
181+
network.netReactions.append(netReaction)
182+
183+
# Set/update the net reaction kinetics using interpolation model
184+
netReaction.kinetics = fitInterpolationModel(netReaction, Tlist, Plist,
185+
K[:,:,i,j],
186+
model, Tmin, Tmax, Pmin, Pmax, errorCheck=True)
188187
logging.info('')
189188

190189
# Save results to file

0 commit comments

Comments
 (0)