@@ -4778,11 +4778,13 @@ def _make_rule(rr):
4778
4778
if n > 1 :
4779
4779
kin = arr ().fit_to_reactions (rs , recipe = recipe )
4780
4780
if n == 1 or kin .E0 .value_si < 0.0 :
4781
+ # still run it through the averaging function when n=1 to standardize the units and run checks
4781
4782
kin = average_kinetics ([r .kinetics for r in rs ])
4782
- #kin.comment = "Only one reaction or Arrhenius BM fit bad. Instead averaged from {} reactions.".format(n)
4783
4783
if n == 1 :
4784
4784
kin .uncertainty = RateUncertainty (mu = 0.0 , var = (np .log (fmax ) / 2.0 ) ** 2 , N = 1 , Tref = Tref , data_mean = data_mean , correlation = label )
4785
+ kin .comment = f"Only one reaction rate: { rs [0 ]!s} "
4785
4786
else :
4787
+ kin .comment = f"Blowers-Masel fit was bad (E0<0) so instead averaged from { n } reactions."
4786
4788
dlnks = np .array ([
4787
4789
np .log (
4788
4790
average_kinetics ([r .kinetics for r in rs [list (set (range (len (rs ))) - {i })]]).get_rate_coefficient (T = Tref ) / rxn .get_rate_coefficient (T = Tref )
@@ -4796,34 +4798,31 @@ def _make_rule(rr):
4796
4798
mu = np .dot (ws , dlnks ) / V1
4797
4799
s = np .sqrt (np .dot (ws , (dlnks - mu ) ** 2 ) / (V1 - V2 / V1 ))
4798
4800
kin .uncertainty = RateUncertainty (mu = mu , var = s ** 2 , N = n , Tref = Tref , data_mean = data_mean , correlation = label )
4799
- else :
4800
- if n == 1 :
4801
- kin .uncertainty = RateUncertainty (mu = 0.0 , var = (np .log (fmax ) / 2.0 ) ** 2 , N = 1 , Tref = Tref , data_mean = data_mean , correlation = label )
4802
- else :
4803
- if isinstance (rs [0 ].kinetics , Arrhenius ):
4804
- dlnks = np .array ([
4805
- np .log (
4806
- arr ().fit_to_reactions (rs [list (set (range (len (rs ))) - {i })], recipe = recipe )
4807
- .to_arrhenius (rxn .get_enthalpy_of_reaction (Tref ))
4808
- .get_rate_coefficient (T = Tref ) / rxn .get_rate_coefficient (T = Tref )
4809
- ) for i , rxn in enumerate (rs )
4810
- ]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
4811
- else :
4812
- dlnks = np .array ([
4813
- np .log (
4814
- arr ().fit_to_reactions (rs [list (set (range (len (rs ))) - {i })], recipe = recipe )
4815
- .to_arrhenius_charge_transfer (rxn .get_enthalpy_of_reaction (Tref ))
4816
- .get_rate_coefficient (T = Tref ) / rxn .get_rate_coefficient (T = Tref )
4817
- ) for i , rxn in enumerate (rs )
4818
- ]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
4819
- varis = (np .array ([rank_accuracy_map [rxn .rank ].value_si for rxn in rs ]) / (2.0 * 8.314 * Tref )) ** 2
4820
- # weighted average calculations
4821
- ws = 1.0 / varis
4822
- V1 = ws .sum ()
4823
- V2 = (ws ** 2 ).sum ()
4824
- mu = np .dot (ws , dlnks ) / V1
4825
- s = np .sqrt (np .dot (ws , (dlnks - mu ) ** 2 ) / (V1 - V2 / V1 ))
4826
- kin .uncertainty = RateUncertainty (mu = mu , var = s ** 2 , N = n , Tref = Tref , data_mean = data_mean , correlation = label )
4801
+ else : # Blowers-Masel fit was good
4802
+ if isinstance (rs [0 ].kinetics , Arrhenius ):
4803
+ dlnks = np .array ([
4804
+ np .log (
4805
+ arr ().fit_to_reactions (rs [list (set (range (len (rs ))) - {i })], recipe = recipe )
4806
+ .to_arrhenius (rxn .get_enthalpy_of_reaction (Tref ))
4807
+ .get_rate_coefficient (T = Tref ) / rxn .get_rate_coefficient (T = Tref )
4808
+ ) for i , rxn in enumerate (rs )
4809
+ ]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
4810
+ else : # SurfaceChargeTransfer or ArrheniusChargeTransfer
4811
+ dlnks = np .array ([
4812
+ np .log (
4813
+ arr ().fit_to_reactions (rs [list (set (range (len (rs ))) - {i })], recipe = recipe )
4814
+ .to_arrhenius_charge_transfer (rxn .get_enthalpy_of_reaction (Tref ))
4815
+ .get_rate_coefficient (T = Tref ) / rxn .get_rate_coefficient (T = Tref )
4816
+ ) for i , rxn in enumerate (rs )
4817
+ ]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
4818
+ varis = (np .array ([rank_accuracy_map [rxn .rank ].value_si for rxn in rs ]) / (2.0 * 8.314 * Tref )) ** 2
4819
+ # weighted average calculations
4820
+ ws = 1.0 / varis
4821
+ V1 = ws .sum ()
4822
+ V2 = (ws ** 2 ).sum ()
4823
+ mu = np .dot (ws , dlnks ) / V1
4824
+ s = np .sqrt (np .dot (ws , (dlnks - mu ) ** 2 ) / (V1 - V2 / V1 ))
4825
+ kin .uncertainty = RateUncertainty (mu = mu , var = s ** 2 , N = n , Tref = Tref , data_mean = data_mean , correlation = label )
4827
4826
4828
4827
#site solute parameters
4829
4828
site_datas = [get_site_solute_data (rxn ) for rxn in rxns ]
0 commit comments