@@ -605,6 +605,9 @@ cdef class ArrheniusBM(KineticsModel):
605605 """
606606 Fit an ArrheniusBM model to a list of reactions at the given temperatures,
607607 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!
608611 """
609612 assert w0 is not None or recipe is not None , ' either w0 or recipe must be specified'
610613
@@ -654,23 +657,22 @@ cdef class ArrheniusBM(KineticsModel):
654657 for T in Ts:
655658 xdata.append([T, rxn.get_enthalpy_of_reaction(298.0 )])
656659 ydata.append(np.log(rxn.get_rate_coefficient(T)))
657-
658660 sigmas.append(s / (8.314 * T))
659661
660662 xdata = np.array(xdata)
661663 ydata = np.array(ydata)
662664
663665 # fit parameters
664- boo = True
666+ keep_trying = True
665667 xtol = 1e-8
666668 ftol = 1e-8
667669 while boo:
668- boo = False
670+ keep_trying = False
669671 try :
670672 params = curve_fit(kfcn, xdata, ydata, sigma = sigmas, p0 = [1.0 , 1.0 , w0 / 10.0 ], xtol = xtol, ftol = ftol)
671673 except RuntimeError :
672674 if xtol < 1.0 :
673- boo = True
675+ keep_trying = True
674676 xtol *= 10.0
675677 ftol *= 10.0
676678 else :
@@ -687,6 +689,8 @@ cdef class ArrheniusBM(KineticsModel):
687689 # fill in parameters
688690 A_units = [' ' , ' s^-1' , ' m^3/(mol*s)' , ' m^6/(mol^2*s)' ]
689691 order = len (rxns[0 ].reactants)
692+ if order != 1 and rxn.is_surface_reaction:
693+ raise NotImplementedError (" Units not implemented for surface reactions." )
690694 self .A = (A, A_units[order])
691695
692696 self .n = n
@@ -1534,8 +1538,11 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
15341538
15351539 def fit_to_reactions (self , rxns , w0 = None , recipe = None , Ts = None ):
15361540 """
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,
15381542 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!
15391546 """
15401547 assert w0 is not None or recipe is not None , ' either w0 or recipe must be specified'
15411548
@@ -1588,23 +1595,22 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
15881595 for T in Ts:
15891596 xdata.append([T, rxn.get_enthalpy_of_reaction(298.0 )])
15901597 ydata.append(np.log(rxn.get_rate_coefficient(T)))
1591-
15921598 sigmas.append(s / (8.314 * T))
15931599
15941600 xdata = np.array(xdata)
15951601 ydata = np.array(ydata)
15961602
15971603 # fit parameters
1598- boo = True
1604+ keep_trying = True
15991605 xtol = 1e-8
16001606 ftol = 1e-8
1601- while boo :
1602- boo = False
1607+ while keep_trying :
1608+ keep_trying = False
16031609 try :
16041610 params = curve_fit(kfcn, xdata, ydata, sigma = sigmas, p0 = [1.0 , 1.0 , w0 / 10.0 ], xtol = xtol, ftol = ftol)
16051611 except RuntimeError :
16061612 if xtol < 1.0 :
1607- boo = True
1613+ keep_trying = True
16081614 xtol *= 10.0
16091615 ftol *= 10.0
16101616 else :
@@ -1620,6 +1626,8 @@ cdef class ArrheniusChargeTransferBM(KineticsModel):
16201626 # fill in parameters
16211627 A_units = [' ' , ' s^-1' , ' m^3/(mol*s)' , ' m^6/(mol^2*s)' ]
16221628 order = len (rxns[0 ].reactants)
1629+ if order != 1 and rxn.is_surface_reaction:
1630+ raise NotImplementedError (" Units not implemented for surface reactions" )
16231631 self .A = (A, A_units[order])
16241632
16251633 self .n = n
0 commit comments