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

Commit 226aeaf

Browse files
committed
Check is a Seed Mechanism exists before grabbing species/reactions
This commit adds if statements to three classes, checking whether a Seed Mechanism exists before attempting to grab the species (reactions) stored in the Seed. Otherwise, NPE occurs when running RMG with no Seed Mechanisms.
1 parent 773b29b commit 226aeaf

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

source/RMG/jing/rxnSys/Chemkin.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,15 @@ public static BufferedWriter writeChemkinPdepReactions(ReactionModel p_reactionM
581581
CoreEdgeReactionModel cerm = (CoreEdgeReactionModel)p_reactionModel;
582582

583583
// First, get all the seed mechanism reactions into the seedList.
584-
for (Iterator iter = cerm.getSeedMechanism().getReactionSet().iterator(); iter.hasNext(); ) {
585-
Reaction r = (Reaction)iter.next();
586-
if (r.isForward()) {
587-
seedList.add(r);
588-
}
589-
}
584+
// ... if a seed mechanism exists
585+
if (cerm.getSeedMechanism() != null) {
586+
for (Iterator iter = cerm.getSeedMechanism().getReactionSet().iterator(); iter.hasNext(); ) {
587+
Reaction r = (Reaction)iter.next();
588+
if (r.isForward()) {
589+
seedList.add(r);
590+
}
591+
}
592+
}
590593

591594
// Then get troe, thirdbody, and Lindemann reactions (from primary reaction library) and add them to the pDepList
592595
// UNLESS they are already in the seed mechanism.

source/RMG/jing/rxnSys/CoreEdgeReactionModel.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ public LinkedHashSet getSpeciesSet() {
621621
public LinkedHashSet getCoreAndSeedSpeciesSet() {
622622
LinkedHashSet speciesSet = new LinkedHashSet();
623623
speciesSet.addAll(getCore().getSpeciesSet());
624-
speciesSet.addAll(seed.getSpeciesSet());
624+
if (seed != null)
625+
speciesSet.addAll(seed.getSpeciesSet());
625626
return speciesSet;
626627
}
627628

source/RMG/jing/rxnSys/JDAS.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ public void generatePDepReactionList(ReactionModel p_reactionModel,
263263
LinkedList nonPDepList, LinkedList pDepList) {
264264

265265
CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;
266-
LinkedHashSet seedList = cerm.getSeedMechanism().getReactionSet();
266+
LinkedHashSet seedList = new LinkedHashSet();
267+
if (cerm.getSeedMechanism() != null)
268+
seedList = cerm.getSeedMechanism().getReactionSet();
267269

268270
for (Iterator iter = PDepNetwork.getCoreReactions(cerm).iterator(); iter.hasNext();) {
269271
PDepReaction rxn = (PDepReaction) iter.next();

0 commit comments

Comments
 (0)