Skip to content

Commit 9c36c6f

Browse files
committed
uncertainty: separate family and non-exact error
The previous implementation combined family and non-exact error into a total estimation error. But this requires assuming that family and non-exact error are perfectly correlated. I don't think that was the paper's original intention, nor do I think it makes sense, but more importantly the log10(N+1) doesn't play nicely with the new uncertainty formulation if you write it this way. If you look at the local analysis example in uncertaintyTest.py, you'll see that the correlated variance goes from about 3 to 1.8, which makes sense because we are no longer stacking non-exact on top of family, but considering them as unrelated.
1 parent be1040e commit 9c36c6f

2 files changed

Lines changed: 32 additions & 24 deletions

File tree

rmgpy/tools/uncertainty.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def get_partial_uncertainty_value(self, source, corr_source_type, corr_param=Non
223223
Obtain the partial uncertainty dlnk/dlnk_corr*dlnk_corr, where dlnk_corr is the correlated parameter
224224
225225
`corr_param` is the parameter identifier itself, which is the string identifier of the rate rule
226-
`corr_source_type` is a string, being either 'Rate Rules', 'Library', 'PDep', 'Training' or 'Estimation'
226+
`corr_source_type` is a string, being either 'Rate Rules', 'Library', 'PDep', 'Training', 'Estimation Nonexact', or 'Estimation Family'
227227
`corr_family` is a string used only when the source type is 'Rate Rules' and indicates the family
228228
"""
229229

@@ -275,24 +275,22 @@ def get_partial_uncertainty_value(self, source, corr_source_type, corr_param=Non
275275
else:
276276
return self.dlnk_training
277277

278-
elif corr_source_type == 'Estimation':
279-
# Return all the uncorrelated uncertainty associated with using an estimation scheme
280278

279+
elif corr_source_type == 'Estimation Nonexact':
280+
# Return the uncorrelated uncertainty associated with using a non-exact rate rule
281281
if 'Rate Rules' in source:
282282
source_dict = source['Rate Rules'][1]
283283
exact = source_dict['exact']
284-
285-
family_label = source['Rate Rules'][0]
286-
dlnk = self.dlnk_family # Base uncorrelated uncertainty just from using rate rule estimation
287-
288-
# Additional uncertainty from using non-exact rate rule
289284
N = len(source_dict['rules']) + len(source_dict['training'])
290285
if not exact:
291286
# nonexactness contribution increases as N increases
292-
dlnk += np.log10(N + 1) * self.dlnk_nonexact
293-
return dlnk
287+
return np.log10(N + 1) * self.dlnk_nonexact
288+
elif corr_source_type == 'Estimation Family':
289+
# Return the uncertainty associated with using a family decision tree
290+
if 'Rate Rules' in source:
291+
return self.dlnk_family
294292
else:
295-
raise Exception('Kinetics correlated source must be Rate Rules, Library, PDep, Training, or Estimation')
293+
raise Exception('Kinetics correlated source must be Rate Rules, Library, PDep, Training, Estimation Nonexact, or Estimation Family')
296294

297295
# If we get here, it means that we did not find the correlated parameter in the source
298296
return None
@@ -733,11 +731,16 @@ def assign_parameter_uncertainties(self, g_param_engine=None, k_param_engine=Non
733731
label = '{}Rate Rule {} {}'.format(surface_prefix, family, ruleEntry)
734732
dlnk[label] = dplnk
735733

736-
# There is also estimation error if rate rules are used
737-
est_dplnk = k_param_engine.get_partial_uncertainty_value(source, 'Estimation')
738-
if est_dplnk:
739-
label = 'Estimation {}'.format(reaction.to_chemkin(self.species_list, kinetics=False))
740-
dlnk[label] = est_dplnk
734+
# There is also estimation error if rate rules are used (nonexact and family contribute to this)
735+
nonexact_dplnk = k_param_engine.get_partial_uncertainty_value(source, 'Estimation Nonexact', corr_family=family)
736+
if nonexact_dplnk:
737+
label = 'Estimation Nonexact {}'.format(reaction.to_chemkin(self.species_list, kinetics=False))
738+
dlnk[label] = nonexact_dplnk
739+
740+
family_dplnk = k_param_engine.get_partial_uncertainty_value(source, 'Estimation Family', corr_family=family)
741+
if family_dplnk:
742+
label = 'Estimation Family {}'.format(reaction.to_chemkin(self.species_list, kinetics=False))
743+
dlnk[label] = family_dplnk
741744

742745
elif 'PDep' in source:
743746
dplnk = k_param_engine.get_partial_uncertainty_value(source, 'PDep', source['PDep'])

test/rmgpy/tools/uncertaintyTest.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def test_local_analysis(self):
189189
expected_uncorrelated_total_variance = 1.8329056941266446
190190
expected_uncorrelated_thermo_variances = np.array([0.17092419, 0.09781627, 0.06186124, 0.04856985, 0.00391013, 0.00306632, 0.00041446, 9.953e-05])
191191
expected_uncorrelated_kinetics_variances = np.array([1.1311145, 0.15888459, 0.085189, 0.02022449, 0.01687337, 0.01605351, 0.01588366, 0.0010829, 0.00080811, 0.00012957])
192-
expected_correlated_total_variance = 3.006637059881831
192+
expected_correlated_total_variance = 1.7732795017083922
193193
expected_correlated_thermo_variances = np.array([0.09145902, 0.07672388, 0.04856985, 0.04573167, 0.03236887, 0.01747643, 0.01098087, 0.00143231, 0.0013764, 0.00031352, 0.00028968, 0.00014685, 0.0001338, 3.263e-05])
194-
expected_correlated_kinetics_variances = np.array([2.0212174, 0.28939964, 0.15516713, 0.11981721, 0.02838292, 0.01687337, 0.0161796, 0.01605351, 0.0040449, 0.00253735, 0.00253735, 0.00193506, 0.00168253, 0.00136045, 0.00136045, 0.00080811, 0.00012957, 0.00011471])
194+
expected_correlated_kinetics_variances = np.array([0.53202843, 0.47926886, 0.11981721, 0.11321232, 0.06070094, 0.04059757, 0.02176716, 0.01687337, 0.0161796, 0.01605351, 0.007471, 0.00673013, 0.0040449, 0.00253735, 0.00253735, 0.00168253, 0.00136045, 0.00136045, 0.00080811, 0.00050935, 0.00045884, 0.00012957, 0.00011471])
195195
expected_uncorrelated_thermo_labels = [
196196
'dln[C2H6(18)]/dG[CH(4)]',
197197
'dln[C2H6(18)]/dG[C2H3(20)]',
@@ -231,22 +231,27 @@ def test_local_analysis(self):
231231
'Estimation C2H5(12)',
232232
]
233233
expected_correlated_kinetics_labels = [
234-
'Estimation C2H5(12)+CH3CHCH3(21)<=>C2H6(18)+C3H6(22)',
235-
'Estimation C2H6(18)+PC3H7(15)<=>C2H5(12)+C3H8(19)',
236-
'Estimation C2H3(20)+C3H8(19)<=>C2H4(11)+PC3H7(15)',
234+
'Estimation Nonexact C2H5(12)+CH3CHCH3(21)<=>C2H6(18)+C3H6(22)',
235+
'Estimation Family C2H5(12)+CH3CHCH3(21)<=>C2H6(18)+C3H6(22)',
237236
'Rate Rule Disproportionation Root_Ext-2R!H-R_2R!H->C_4R->C',
238-
'Estimation CH3(14)+C3H8(19)<=>CH4(16)+PC3H7(15)',
237+
'Estimation Nonexact C2H6(18)+PC3H7(15)<=>C2H5(12)+C3H8(19)',
238+
'Estimation Nonexact C2H3(20)+C3H8(19)<=>C2H4(11)+PC3H7(15)',
239+
'Estimation Family C2H6(18)+PC3H7(15)<=>C2H5(12)+C3H8(19)',
240+
'Estimation Family C2H3(20)+C3H8(19)<=>C2H4(11)+PC3H7(15)',
239241
'Library O(0)+H2O2(3)<=>OH(1)+HO2(2)',
240-
'Estimation CH3(14)+PC3H7(15)<=>CH4(16)+CH2CH2CH2(17)',
242+
'Estimation Family CH3(14)+PC3H7(15)<=>CH4(16)+CH2CH2CH2(17)',
241243
'PDep HCCO(10)(+M)<=>O(0)+C2H(8)(+M)',
244+
'Estimation Nonexact CH3(14)+C3H8(19)<=>CH4(16)+PC3H7(15)',
245+
'Estimation Family CH3(14)+C3H8(19)<=>CH4(16)+PC3H7(15)',
242246
'Rate Rule H_Abstraction C/H3/Cs;C_methyl',
243247
'Rate Rule H_Abstraction C/H3/Cs\\H3;C_rad/H2/Cs\\H\\Cs\\Cs|O',
244248
'Rate Rule H_Abstraction C/H3/Cs\\H3;C_rad/H2/Cs\\H3',
245-
'Estimation C3H5(24)+CH2CH2CH2(17)<=>C3H5(23)+C3H6(22)',
246249
'Rate Rule H_Abstraction C/H3/Cs\\H2\\O;C_methyl',
247250
'Rate Rule H_Abstraction C/H3/Cs\\H3;Cd_Cd\\H2_pri_rad',
248251
'Rate Rule H_Abstraction C/H3/Cs\\H2\\Cs|O;Cd_Cd\\H2_rad/Cs',
249252
'Training Disproportionation CH3(14)+C2H5(12)<=>CH4(16)+C2H4(11)',
253+
'Estimation Nonexact C3H5(24)+CH2CH2CH2(17)<=>C3H5(23)+C3H6(22)',
254+
'Estimation Family C3H5(24)+CH2CH2CH2(17)<=>C3H5(23)+C3H6(22)',
250255
'Training H_Abstraction CH3(14)+C2H6(18)<=>CH4(16)+C2H5(12)',
251256
'Rate Rule Disproportionation Root_Ext-1R!H-R_N-4R->O_N-Sp-5R!H=1R!H_Ext-4CHNS-R_N-6R!H->S_4CHNS->C_N-Sp-6BrBrBrCCCClClClFFFIIINNNOOOPPPSiSiSi#4C_6BrCClFINOPSi->C_N-1R!H-inRing_N-Sp-6C-4C',
252257
]

0 commit comments

Comments
 (0)