|
41 | 41 | from rmgpy.molecule.molecule import Molecule |
42 | 42 | from rmgpy.reaction import Reaction |
43 | 43 | from rmgpy.species import Species |
44 | | -from rmgpy.thermo import NASA, NASAPolynomial |
| 44 | +from rmgpy.thermo import NASA, NASAPolynomial, ThermoData |
45 | 45 |
|
46 | 46 |
|
47 | 47 | ################################################################################ |
@@ -460,6 +460,42 @@ def setUp(self): |
460 | 460 | comment="""Thermo library: Spiekermann_refining_elementary_reactions""" |
461 | 461 | ) |
462 | 462 |
|
| 463 | + CF2 = Species().from_adjacency_list( |
| 464 | + """ |
| 465 | + 1 F u0 p3 c0 {2,S} |
| 466 | + 2 C u0 p1 c0 {1,S} {3,S} |
| 467 | + 3 F u0 p3 c0 {2,S} |
| 468 | + """ |
| 469 | + ) |
| 470 | + CF2.thermo = NASA( |
| 471 | + polynomials=[ |
| 472 | + NASAPolynomial(coeffs=[2.28591,0.0107608,-1.05382e-05,4.89881e-09,-8.86384e-13,-24340.7,13.1348], Tmin=(298,'K'), Tmax=(1300,'K')), |
| 473 | + NASAPolynomial(coeffs=[5.33121,0.00197748,-9.60248e-07,2.10704e-10,-1.5954e-14,-25190.9,-2.56367], Tmin=(1300,'K'), Tmax=(3000,'K')) |
| 474 | + ], |
| 475 | + Tmin=(298,'K'), Tmax=(3000,'K'), Cp0=(33.2579,'J/mol/K'), CpInf=(58.2013,'J/mol/K'), |
| 476 | + comment="""Thermo library: halogens""" |
| 477 | + ) |
| 478 | + C2H6 = Species(smiles="CC") |
| 479 | + C2H6.thermo = ThermoData( |
| 480 | + Tdata = ([300,400,500,600,800,1000,1500],'K'), |
| 481 | + Cpdata = ([12.565,15.512,18.421,21.059,25.487,28.964,34.591],'cal/(mol*K)','+|-',[0.8,1.1,1.3,1.4,1.5,1.5,1.2]), |
| 482 | + H298 = (-20.028,'kcal/mol','+|-',0.1), |
| 483 | + S298 = (54.726,'cal/(mol*K)','+|-',0.6), |
| 484 | + comment="""Thermo library: DFT_QCI_thermo""" |
| 485 | + ) |
| 486 | + CH3CF2CH3 = Species(smiles="CC(F)(F)C") |
| 487 | + CH3CF2CH3.thermo = NASA( |
| 488 | + polynomials = [ |
| 489 | + NASAPolynomial(coeffs=[3.89769,0.00706735,0.000140168,-3.37628e-07,2.51812e-10,-68682.1,8.74321], Tmin=(10,'K'), Tmax=(436.522,'K')), |
| 490 | + NASAPolynomial(coeffs=[2.78849,0.0356982,-2.16715e-05,6.45057e-09,-7.47989e-13,-68761.2,11.1597], Tmin=(436.522,'K'), Tmax=(3000,'K')), |
| 491 | + ], |
| 492 | + Tmin = (10,'K'), Tmax = (3000,'K'), Cp0 = (33.2579,'J/(mol*K)'), CpInf = (249.434,'J/(mol*K)'), |
| 493 | + comment="""Thermo library: CHOF_G4""" |
| 494 | + ) |
| 495 | + kinetics = Arrhenius(A=(0.222791,'cm^3/(mol*s)'), n=3.59921, Ea=(320.496,'kJ/mol'), T0=(1,'K'), Tmin=(298,'K'), Tmax=(2500,'K'), comment="""Training Rxn 54 for 1,2_Insertion_carbene""") |
| 496 | + self.reaction = Reaction(reactants=[CF2,C2H6],products=[CH3CF2CH3],kinetics=kinetics) |
| 497 | + self.reaction_w0 = 519000 # J/mol |
| 498 | + |
463 | 499 | def test_a_factor(self): |
464 | 500 | """ |
465 | 501 | Test that the ArrheniusBM A property was properly set. |
@@ -510,17 +546,25 @@ def test_fit_to_data(self): |
510 | 546 | """ |
511 | 547 | Test the ArrheniusBM.fit_to_data() method. |
512 | 548 | """ |
| 549 | + Tdata = np.array([300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) |
| 550 | + |
513 | 551 | reactant = Molecule(smiles=self.rsmi) |
514 | 552 | product = Molecule(smiles=self.psmi) |
515 | 553 | reaction = Reaction(reactants=[Species(molecule=[reactant], thermo=self.r_thermo,)], |
516 | 554 | products=[Species(molecule=[product], thermo=self.p_thermo)], |
517 | 555 | kinetics=self.arrhenius, |
518 | 556 | ) |
519 | | - |
| 557 | + kdata = np.array([reaction.kinetics.get_rate_coefficient(T) for T in Tdata]) |
520 | 558 | arrhenius_bm = ArrheniusBM().fit_to_reactions([reaction], w0=self.w0) |
521 | | - self.assertAlmostEqual(arrhenius_bm.A.value_si, self.arrhenius_bm.A.value_si, delta=1.5e1) |
522 | | - self.assertAlmostEqual(arrhenius_bm.n.value_si, self.arrhenius_bm.n.value_si, 1, 4) |
523 | | - self.assertAlmostEqual(arrhenius_bm.E0.value_si, self.arrhenius_bm.E0.value_si, 1) |
| 559 | + arrhenius = arrhenius_bm.to_arrhenius(reaction.get_enthalpy_of_reaction(298)) |
| 560 | + for T, k in zip(Tdata, kdata): |
| 561 | + self.assertAlmostEqual(k, arrhenius.get_rate_coefficient(T), delta=1e-6 * k) |
| 562 | + |
| 563 | + arrhenius_bm = ArrheniusBM().fit_to_reactions([self.reaction], w0=self.reaction_w0) |
| 564 | + arrhenius = arrhenius_bm.to_arrhenius(self.reaction.get_enthalpy_of_reaction(298)) |
| 565 | + kdata = np.array([self.reaction.kinetics.get_rate_coefficient(T) for T in Tdata]) |
| 566 | + for T, k in zip(Tdata, kdata): |
| 567 | + self.assertAlmostEqual(k, arrhenius.get_rate_coefficient(T), delta=1e-6 * k) |
524 | 568 |
|
525 | 569 | def test_get_activation_energy(self): |
526 | 570 | """ |
@@ -1195,3 +1239,8 @@ def test_generate_reverse_rate_coefficient(self): |
1195 | 1239 | Arrhenius(A=(-2.1e+11,"cm^3/(mol*s)"), n=0.618, Ea=(30251,"cal/mol"), T0=(1,"K"))]) |
1196 | 1240 | ]), duplicate=True) |
1197 | 1241 | test_reaction.generate_reverse_rate_coefficient() |
| 1242 | + |
| 1243 | +################################################################################ |
| 1244 | + |
| 1245 | +if __name__ == '__main__': |
| 1246 | + unittest.main(testRunner=unittest.TextTestRunner(verbosity=2)) |
0 commit comments