@@ -605,6 +605,9 @@ cdef class ArrheniusBM(KineticsModel):
605
605
"""
606
606
Fit an ArrheniusBM model to a list of reactions at the given temperatures,
607
607
w0 must be either given or estimated using the family object
608
+
609
+ WARNING: there's a lot of code duplication with ArrheniusChargeTransferBM.fit_to_reactions
610
+ so anything you change here you should probably change there too and vice versa!
608
611
"""
609
612
assert w0 is not None or recipe is not None , ' either w0 or recipe must be specified'
610
613
@@ -654,23 +657,22 @@ cdef class ArrheniusBM(KineticsModel):
654
657
for T in Ts:
655
658
xdata.append([T, rxn.get_enthalpy_of_reaction(298.0 )])
656
659
ydata.append(np.log(rxn.get_rate_coefficient(T)))
657
-
658
660
sigmas.append(s / (8.314 * T))
659
661
660
662
xdata = np.array(xdata)
661
663
ydata = np.array(ydata)
662
664
663
665
# fit parameters
664
- boo = True
666
+ keep_trying = True
665
667
xtol = 1e-8
666
668
ftol = 1e-8
667
669
while boo:
668
- boo = False
670
+ keep_trying = False
669
671
try :
670
672
params = curve_fit(kfcn, xdata, ydata, sigma = sigmas, p0 = [1.0 , 1.0 , w0 / 10.0 ], xtol = xtol, ftol = ftol)
671
673
except RuntimeError :
672
674
if xtol < 1.0 :
673
- boo = True
675
+ keep_trying = True
674
676
xtol *= 10.0
675
677
ftol *= 10.0
676
678
else :
@@ -687,6 +689,8 @@ cdef class ArrheniusBM(KineticsModel):
687
689
# fill in parameters
688
690
A_units = [' ' , ' s^-1' , ' m^3/(mol*s)' , ' m^6/(mol^2*s)' ]
689
691
order = len (rxns[0 ].reactants)
692
+ if order != 1 and rxn.is_surface_reaction:
693
+ raise NotImplementedError (" Units not implemented for surface reactions." )
690
694
self .A = (A, A_units[order])
691
695
692
696
self .n = n
@@ -1534,8 +1538,11 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
1534
1538
1535
1539
def fit_to_reactions (self , rxns , w0 = None , recipe = None , Ts = None ):
1536
1540
"""
1537
- Fit an ArrheniusBM model to a list of reactions at the given temperatures,
1541
+ Fit an ArrheniusChargeTransferBM model to a list of reactions at the given temperatures,
1538
1542
w0 must be either given or estimated using the family object
1543
+
1544
+ WARNING: there's a lot of code duplication with ArrheniusBM.fit_to_reactions
1545
+ so anything you change here you should probably change there too and vice versa!
1539
1546
"""
1540
1547
assert w0 is not None or recipe is not None , ' either w0 or recipe must be specified'
1541
1548
@@ -1588,23 +1595,22 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
1588
1595
for T in Ts:
1589
1596
xdata.append([T, rxn.get_enthalpy_of_reaction(298.0 )])
1590
1597
ydata.append(np.log(rxn.get_rate_coefficient(T)))
1591
-
1592
1598
sigmas.append(s / (8.314 * T))
1593
1599
1594
1600
xdata = np.array(xdata)
1595
1601
ydata = np.array(ydata)
1596
1602
1597
1603
# fit parameters
1598
- boo = True
1604
+ keep_trying = True
1599
1605
xtol = 1e-8
1600
1606
ftol = 1e-8
1601
- while boo :
1602
- boo = False
1607
+ while keep_trying :
1608
+ keep_trying = False
1603
1609
try :
1604
1610
params = curve_fit(kfcn, xdata, ydata, sigma = sigmas, p0 = [1.0 , 1.0 , w0 / 10.0 ], xtol = xtol, ftol = ftol)
1605
1611
except RuntimeError :
1606
1612
if xtol < 1.0 :
1607
- boo = True
1613
+ keep_trying = True
1608
1614
xtol *= 10.0
1609
1615
ftol *= 10.0
1610
1616
else :
@@ -1620,6 +1626,8 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
1620
1626
# fill in parameters
1621
1627
A_units = [' ' , ' s^-1' , ' m^3/(mol*s)' , ' m^6/(mol^2*s)' ]
1622
1628
order = len (rxns[0 ].reactants)
1629
+ if order != 1 and rxn.is_surface_reaction:
1630
+ raise NotImplementedError (" Units not implemented for surface reactions" )
1623
1631
self .A = (A, A_units[order])
1624
1632
1625
1633
self .n = n
0 commit comments