GreenGroup/RMG-Java — comment on commit a75660378885f95a1a9ec55e2d0dc164b881db5a
File:  line 0
By gmagoon:

I was thinking there might be some opportunity for speeding up the code by eliminating the second block in the PTL lookup, starting at https://github.com/GreenGroup/RMG-Java/blob/a75660378885f95a1a9ec55e2d0dc164b881db5a/source/RMG/jing/chem/PrimaryThermoLibrary.java#L214

At first at seemed that this block wouldn't be used, based on earlier ThermoDataEstimator debugging, but then I found that during mechanism generation a chemGraph is passed in with centralIDs set:

1 *2 H 0 {7,S}
2 C 0 {3,S} {10,S} {11,S} {12,S}
3 C 0 {2,S} {4,S} {7,S} {13,S}
4 C 0 {3,S} {5,S} {14,S} {15,S}
5 C 0 {4,S} {6,S} {16,S} {17,S}
6 C 0 {5,S} {7,S} {18,S} {19,S}
7 *3 C 0 {6,S} {3,S} {8,S} {1,S}
8 C 0 {7,S} {9,S} {11,S} {20,S}
9 C 0 {8,S} {10,S} {21,S} {22,S}
10 C 0 {9,S} {2,S} {23,S} {24,S}
11 C 0 {2,S} {8,S} {25,S} {26,S}
12 H 0 {2,S}
13 H 0 {3,S}
14 H 0 {4,S}
15 H 0 {4,S}
16 H 0 {5,S}
17 H 0 {5,S}
18 H 0 {6,S}
19 H 0 {6,S}
20 H 0 {8,S}
21 H 0 {9,S}
22 H 0 {9,S}
23 H 0 {10,S}
24 H 0 {10,S}
25 H 0 {11,S}
26 H 0 {11,S}

It looks like the central IDs are set because RMG is the middle of generating a reaction when the thermo is being estimated (call stack goes through ReactionTemplate.reactTwoReactants())

Even when the "hydrogenated" version of this molecule is specified in the PTL, however, it isn't recognized by the first block of PrimaryThermoLibrary.getThermoData().It is however, recognized by the second block.

It seems that this discrepancy arises because the get() method in ThermoData td = (ThermoData)library.get(p_graph) uses (via HashMap) Graph.equals(), which, in turn, uses Graph.isEquivalentAtCentralNodes(), which checks whether the graphs have the same number of centralIDs, and this check fails. However, the second block uses Graph.isEquivalent(), which doesn't seem to perform this check.

Assuming the above issue is addressed and all cases can be caught by the first block, I think a (possibly substantial) speedup should be possible, particularly when there are lots of species in the primary thermo libraries, as I don't think the addition of hydrogens is key to the recognition of the two graphs as equivalent (I think they may be added at the point the PTL is read in anyway?).