Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit 773b29b

Browse files
committed
Seed Mechanisms reactions now added to core or edge properly.
Previously, they were all placed on the edge. This was a problem when a reaction should have been in the core (based on all reagents being in the core in the condition file). Such reactions are now placed in the core. Also, we now add both forward and reverse directions, if reverse directions exist. The addReactionSet(LinkedHashSet) method did almost exactly what I needed, but it would discard reactions that had a reactant not in the core (you couldn't have something entirely in the edge). Rather than change the behaviour of that method (which is used elsewhere) I made a new method: addReactionSetFromSeed
1 parent 4b4384a commit 773b29b

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

source/RMG/jing/rxnSys/CoreEdgeReactionModel.java

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ else if (rxnType == -1) {
164164

165165
return;
166166
}
167-
167+
168168
//## operation addReactedReaction(Reaction)
169169
public void addReactedReaction(Reaction p_reaction) throws InvalidReactedReactionException {
170170
//#[ operation addReactedReaction(Reaction)
@@ -243,23 +243,32 @@ public void addReactionSet(LinkedHashSet p_reactionSet) {
243243
int rxnType = categorizeReaction(rxn);
244244
if (rxnType == 1) {
245245
addReactedReaction(rxn);
246+
//Logger.info(String.format("Adding to model core: %s",rxn));
246247
}
247248
else if (rxnType == -1) {
248249
addUnreactedReaction(rxn);
250+
//Logger.info(String.format("Adding to model edge: %s",rxn));
249251
}
250-
252+
else {
253+
Logger.warning(String.format("Adding to neither edge nor core: %s",rxn));
254+
}
255+
251256
//also add the reverse reaction
252257
if (rxn.hasReverseReaction()){
253258
Reaction reverse = (Reaction)rxn.getReverseReaction();
254259
rxnType = categorizeReaction(reverse);
255260
if (rxnType == 1){
256261
addReactedReaction(reverse);
262+
//Logger.info(String.format("Adding to model core: %s",reverse));
257263
}
258264
else if (rxnType == -1){
259265
addUnreactedReaction(reverse);
266+
//Logger.info(String.format("Adding to model edge: %s",reverse));
260267
}
268+
else {
269+
Logger.warning(String.format("Adding to neither edge nor core: %s",reverse));
270+
}
261271
}
262-
263272
}
264273

265274
return;
@@ -279,7 +288,46 @@ public void addReaction(Reaction p_reaction){
279288
else
280289
addUnreactedReaction(p_reaction);
281290
}
282-
291+
292+
293+
//## operation addReactionSetFromSeed(HashSet)
294+
/*
295+
This is like addReactionSet(p_reactionSet) but it insists on adding
296+
the reaction *somewhere*, either the core or the edge. It should be
297+
particularly useful for reaction sets that come from seed mechanisms.
298+
Adds both the forward and reverse reactions.
299+
*/
300+
public void addReactionSetFromSeed(LinkedHashSet p_reactionSet) {
301+
//#[ operation addReactionSetFromSeed(HashSet)
302+
for (Iterator iter = p_reactionSet.iterator(); iter.hasNext(); ) {
303+
Reaction rxn = (Reaction)iter.next();
304+
int rxnType = categorizeReaction(rxn);
305+
if (rxnType == 1) {
306+
addReactedReaction(rxn);
307+
Logger.info(String.format("Adding to model core: %s",rxn));
308+
}
309+
else {
310+
addUnreactedReaction(rxn);
311+
Logger.info(String.format("Adding to model edge: %s",rxn));
312+
}
313+
//also add the reverse reaction
314+
if (rxn.hasReverseReaction()){
315+
Reaction reverse = (Reaction)rxn.getReverseReaction();
316+
rxnType = categorizeReaction(reverse);
317+
if (rxnType == 1){
318+
addReactedReaction(reverse);
319+
Logger.info(String.format("Adding to model core: %s",reverse));
320+
}
321+
else {
322+
addUnreactedReaction(reverse);
323+
Logger.info(String.format("Adding to model edge: %s",reverse));
324+
}
325+
}
326+
}
327+
return;
328+
//#]
329+
}
330+
283331
//## operation addUnreactedReaction(Reaction)
284332
public void addUnreactedReaction(Reaction p_reaction) throws InvalidUnreactedReactionException {
285333
//#[ operation addUnreactedReaction(Reaction)

source/RMG/jing/rxnSys/ReactionModelGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,9 +3553,9 @@ public void initializeCoreEdgeModel() {
35533553

35543554
// Add the species and reactions from the seed mechanisms, if they exist, to the edge.
35553555
if (hasSeedMechanisms()) {
3556-
Logger.info("Adding seed mechanisms to edge");
3556+
Logger.info("Adding seed mechanisms.");
35573557
cerm.addUnreactedSpeciesSet(getSeedMechanism().getSpeciesSet());
3558-
cerm.addUnreactedReactionSet(getSeedMechanism().getReactionSet());
3558+
cerm.addReactionSetFromSeed(getSeedMechanism().getReactionSet());
35593559
// Store the seed mechanism in the CERM so that we can access it from there when writing chemkin files:
35603560
cerm.setSeedMechanism(getSeedMechanism());
35613561
}

0 commit comments

Comments
 (0)