def setUp(self): unittest.TestCase.setUp(self) # Testing Ideal Gas Model CO2 = molecule('CO2') CO2_pmutt_parameters = { 'name': 'CO2', 'elements': { 'C': 1, 'O': 2 }, 'trans_model': trans.FreeTrans, 'n_degrees': 3, 'molecular_weight': get_molecular_weight('CO2'), 'rot_model': rot.RigidRotor, 'rot_temperatures': rot.get_rot_temperatures_from_atoms(CO2, geometry='linear'), 'geometry': 'linear', 'symmetrynumber': 2, 'elec_model': elec.GroundStateElec, 'potentialenergy': -22.994202, 'spin': 0., 'vib_model': vib.HarmonicVib, 'vib_wavenumbers': [3360., 954., 954., 1890.], } CO2_ase_parameters = { 'atoms': CO2, 'potentialenergy': -22.994202, 'vib_energies': [ c.wavenumber_to_energy(x) * c.convert_unit(initial='J', final='eV') for x in CO2_pmutt_parameters['vib_wavenumbers'] ], 'geometry': 'linear', 'symmetrynumber': 2, 'spin': 0. } self.CO2_pmutt = StatMech(**CO2_pmutt_parameters) self.CO2_ASE = IdealGasThermo(**CO2_ase_parameters) self.T0 = c.T0('K') # K self.P0 = c.P0('Pa') self.V0 = c.V0('m3') self.mw = get_molecular_weight({'C': 1, 'O': 2})
def setUp(self): slope = 0.5 intercept = 10. # kcal/mol del_E = -1. # kcal/mol del_E_eV = del_E * c.convert_unit(initial='kcal/mol', final='eV/molecule') E_surf = -2. # kcal/mol E_surf_eV = E_surf * c.convert_unit(initial='kcal/mol', final='eV/molecule') E_gas = -3. # kcal/mol E_gas_eV = E_gas * c.convert_unit(initial='kcal/mol', final='eV/molecule') species = { 'A(g)_shomate': Shomate(name='A(g)_shomate', T_low=100., T_high=500., a=np.zeros(8)), 'A(g)_statmech': StatMech(), '*': StatMech(), 'A*': StatMech(U=del_E_eV, H=del_E_eV, **presets['constant']), 'surf': StatMech(U=E_surf_eV, H=E_surf_eV, **presets['constant']), 'gas': StatMech(U=E_gas_eV, H=E_gas_eV, **presets['constant']) } reaction_shomate = Reaction.from_string('A(g)_shomate + * = A*', species) reaction_statmech = Reaction.from_string('A(g)_statmech + * = A*', species) self.lsr_const = LSR(slope=slope, intercept=intercept, reaction=del_E, surf_species=E_surf, gas_species=E_gas) self.lsr_shomate = LSR(slope=slope, intercept=intercept, reaction=reaction_shomate, surf_species=species['surf'], gas_species=species['gas']) self.lsr_statmech = LSR(slope=slope, intercept=intercept, reaction=reaction_statmech, surf_species=species['surf'], gas_species=species['gas'])
def setUp(self): unittest.TestCase.setUp(self) self.Nasa9_direct = Nasa9( name='CO2', elements={'C': 1, 'O': 2}, phase='g', nasas = [ SingleNasa9(T_low=200., T_high=1000., a=np.array([4.943650540E+04, -6.264116010E+02, 5.301725240E+00, 2.503813816E-03, -2.127308728E-07, -7.689988780E-10, 2.849677801E-13, -4.528198460E+04, -7.048279440E+00])), SingleNasa9(T_low=1000., T_high=6000., a=np.array([1.176962419E+05, -1.788791477E+03, 8.291523190E+00, -9.223156780E-05, 4.863676880E-09, -1.891053312E-12, 6.330036590E-16, -3.908350590E+04, -2.652669281E+01])), SingleNasa9(T_low=6000., T_high=20000., a=np.array([-1.544423287E+09, 1.016847056E+06, -2.561405230E+02, 3.369401080E-02, -2.181184337E-06, 6.991420840E-11, -8.842351500E-16, -8.043214510E+06, 2.254177493E+03]))] ) H2O_statmech = StatMech(name='H2O', spin=0, symmetrynumber=2, atoms=molecule('H2O'), potentialenergy=-14.2209, vib_wavenumbers=np.array([3825.434, 3710.2642, 1582.432]), **presets['idealgas']) self.Nasa9_statmech = Nasa9.from_model( name='H2O', elements={'H': 2, 'O': 1}, phase='g', T_low=100., T_high=5000., model=H2O_statmech)
def _float_to_specie(self, val): """Converts a float to a :class:`~pmutt.statmech.StatMech` object Parameters ---------- val : float Value (in kcal/mol) Returns ------- obj : :class:`~pmutt.statmech.StatMech` object :class:`~pmutt.statmech.StatMech` object that gives the val when `get_E` is called """ val = val*c.convert_unit(initial='kcal/mol', final='eV/molecule') return StatMech(U=val, H=val, F=val, G=val, **presets['constant'])
def _float_to_reaction(self, val): """Converts a float to a :class:`~pmutt.reaction.Reaction` object Parameters ---------- val : float Value (in kcal/mol) Returns ------- obj : :class:`~pmutt.reaction.Reaction` object :class:`~pmutt.reaction.Reaction` object that gives the val when `get_delta_E` is called """ reactant = StatMech() product = self._float_to_specie(val=val) return Reaction(reactants=[reactant], reactants_stoich=[1.], products=[product], products_stoich=[1.])
1150.401492, 1027.841298, 1018.203753, 945.310074, 929.15992, 911.661049, 808.685354, 730.986587, 475.287654, 339.164649, 264.682213, 244.584138, 219.956713, 115.923768, 35.56194]) '''Rotational''' butane_rot = rot.RigidRotor(symmetrynumber=2, atoms=butane_atoms) '''Electronic''' butane_elec = elec.GroundStateElec(potentialenergy=-73.7051, spin=0) '''StatMech Initialization''' butane_statmech = StatMech(name='butane', trans_model=butane_trans, vib_model=butane_vib, rot_model=butane_rot, elec_model=butane_elec) H_statmech = butane_statmech.get_H(T=298., units='kJ/mol') S_statmech = butane_statmech.get_S(T=298., units='J/mol/K') print('H_butane(T=298) = {:.1f} kJ/mol'.format(H_statmech)) print('S_butane(T=298) = {:.2f} J/mol/K'.format(S_statmech)) # ### Presets # The [``presets``][0] dictionary stores commonly used models to ease the initialization of [``StatMech``][1] objects. The same water molecule before can be initialized this way instead. # # [0]: https://vlachosgroup.github.io/pmutt/statmech.html#presets # [1]: https://vlachosgroup.github.io/pmutt/statmech.html#pmutt.statmech.StatMech
from pmutt.statmech import StatMech, trans, vib, rot, elec H2_atoms = molecule('H2') '''Translational''' H2_trans = trans.FreeTrans(n_degrees=3, atoms=H2_atoms) '''Vibrational''' H2_vib = vib.HarmonicVib(vib_wavenumbers=[4342.]) # vib_wavenumbers in cm-1 '''Rotational''' H2_rot = rot.RigidRotor(symmetrynumber=2, atoms=H2_atoms) '''Electronic''' H2_elec = elec.GroundStateElec(potentialenergy=-6.77, spin=0) # potentialenergy in eV '''StatMech Initialization''' H2_statmech = StatMech(name='H2', trans_model=H2_trans, vib_model=H2_vib, rot_model=H2_rot, elec_model=H2_elec) '''Calculate thermodynamic properties''' H_statmech = H2_statmech.get_H(T=298., units='kJ/mol') S_statmech = H2_statmech.get_S(T=298., units='J/mol/K') print('H_H2(T=298 K) = {:.1f} kJ/mol'.format(H_statmech)) print('S_H2(T=298 K) = {:.2f} J/mol/K'.format(S_statmech)) # <a id='section_5_3'></a> # ## 5.3. Initializing StatMech modes using presets # # Commonly used models can be accessed via [``presets``](https://vlachosgroup.github.io/pMuTT/statmech.html#presets). The currently supported models are: # # - [``idealgas``](https://vlachosgroup.github.io/pMuTT/statmech.html#ideal-gas-idealgas) - Ideal gases
class TestStatMech(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) # Testing Ideal Gas Model CO2 = molecule('CO2') CO2_pmutt_parameters = { 'name': 'CO2', 'elements': { 'C': 1, 'O': 2 }, 'trans_model': trans.FreeTrans, 'n_degrees': 3, 'molecular_weight': get_molecular_weight('CO2'), 'rot_model': rot.RigidRotor, 'rot_temperatures': rot.get_rot_temperatures_from_atoms(CO2, geometry='linear'), 'geometry': 'linear', 'symmetrynumber': 2, 'elec_model': elec.GroundStateElec, 'potentialenergy': -22.994202, 'spin': 0., 'vib_model': vib.HarmonicVib, 'vib_wavenumbers': [3360., 954., 954., 1890.], } CO2_ase_parameters = { 'atoms': CO2, 'potentialenergy': -22.994202, 'vib_energies': [ c.wavenumber_to_energy(x) * c.convert_unit(initial='J', final='eV') for x in CO2_pmutt_parameters['vib_wavenumbers'] ], 'geometry': 'linear', 'symmetrynumber': 2, 'spin': 0. } self.CO2_pmutt = StatMech(**CO2_pmutt_parameters) self.CO2_ASE = IdealGasThermo(**CO2_ase_parameters) self.T0 = c.T0('K') # K self.P0 = c.P0('Pa') self.V0 = c.V0('m3') self.mw = get_molecular_weight({'C': 1, 'O': 2}) def test_get_q(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_q(T=self.T0, ignore_q_elec=True, V=self.V0), 6.163652058396284e+25) def test_get_CvoR(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_CvoR(T=self.T0, V=self.V0), 2.9422622359004853) def test_get_Cv(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_Cv(T=self.T0, V=self.V0, units='J/mol/K'), 2.9422622359004853 * c.R('J/mol/K')) np.testing.assert_almost_equal( self.CO2_pmutt.get_Cv(T=self.T0, V=self.V0, units='J/g/K'), 2.9422622359004853 * c.R('J/mol/K') / self.mw) def test_get_CpoR(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_CpoR(T=self.T0, V=self.V0), 3.9422622359004853) def test_get_Cp(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_Cp(T=self.T0, V=self.V0, units='J/mol/K'), 3.9422622359004853 * c.R('J/mol/K')) np.testing.assert_almost_equal( self.CO2_pmutt.get_Cp(T=self.T0, V=self.V0, units='J/g/K'), 3.9422622359004853 * c.R('J/mol/K') / self.mw) def test_get_EoRT(self): np.testing.assert_almost_equal(self.CO2_pmutt.get_EoRT(T=self.T0), -894.97476277965) np.testing.assert_almost_equal( self.CO2_pmutt.get_EoRT(T=self.T0, include_ZPE=True), -877.703643641077) def test_get_E(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_E(T=self.T0, units='J/mol'), -894.97476277965 * c.R('J/mol/K') * self.T0) np.testing.assert_almost_equal(self.CO2_pmutt.get_E(T=self.T0, units='J/mol', include_ZPE=True), -877.703643641077 * c.R('J/mol/K') * self.T0, decimal=2) np.testing.assert_almost_equal( self.CO2_pmutt.get_E(T=self.T0, units='J/g'), -894.97476277965 * c.R('J/mol/K') * self.T0 / self.mw) def test_get_UoRT(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_UoRT(T=self.T0, V=self.V0), -875.1095022368354) def test_get_U(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_U(T=self.T0, V=self.V0, units='J/mol'), -875.1095022368354 * c.R('J/mol/K') * self.T0) np.testing.assert_almost_equal( self.CO2_pmutt.get_U(T=self.T0, V=self.V0, units='J/g'), -875.1095022368354 * c.R('J/mol/K') * self.T0 / self.mw) def test_get_HoRT(self): expected_HoRT_CO2 = \ self.CO2_ASE.get_enthalpy(temperature=self.T0, verbose=False) \ / c.R('eV/K')/self.T0 calc_HoRT_CO2 = self.CO2_pmutt.get_HoRT(T=self.T0) np.testing.assert_almost_equal(expected_HoRT_CO2, calc_HoRT_CO2, 3) def test_get_H(self): expected_H_CO2 = \ self.CO2_ASE.get_enthalpy(temperature=self.T0, verbose=False) calc_H_CO2 = self.CO2_pmutt.get_H(T=self.T0, units='eV') np.testing.assert_almost_equal(expected_H_CO2, calc_H_CO2, 3) def test_get_SoR(self): expected_SoR_CO2 = \ self.CO2_ASE.get_entropy(temperature=self.T0, pressure=self.P0, verbose=False)/c.R('eV/K') calc_SoR_CO2 = self.CO2_pmutt.get_SoR(T=self.T0, V=self.V0) np.testing.assert_almost_equal(expected_SoR_CO2, calc_SoR_CO2, 3) def test_get_S(self): expected_S_CO2 = \ self.CO2_ASE.get_entropy(temperature=self.T0, pressure=self.P0, verbose=False) calc_S_CO2 = self.CO2_pmutt.get_S(T=self.T0, V=self.V0, units='eV/K') np.testing.assert_almost_equal(expected_S_CO2, calc_S_CO2, 1) def test_get_FoRT(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_FoRT(T=self.T0, V=self.V0), -900.6031596134445) def test_get_F(self): np.testing.assert_almost_equal( self.CO2_pmutt.get_F(T=self.T0, V=self.V0, units='J/mol'), -900.6031596134445 * c.R('J/mol/K') * self.T0) np.testing.assert_almost_equal( self.CO2_pmutt.get_F(T=self.T0, V=self.V0, units='J/g'), -900.6031596134445 * c.R('J/mol/K') * self.T0 / self.mw) def test_get_GoRT(self): expected_GoRT_CO2 = \ self.CO2_ASE.get_gibbs_energy(temperature=self.T0, pressure=self.P0, verbose=False)/c.R('eV/K')/self.T0 calc_GoRT_CO2 = self.CO2_pmutt.get_GoRT(T=self.T0, V=self.V0) np.testing.assert_almost_equal(expected_GoRT_CO2, calc_GoRT_CO2, 3) def test_get_G(self): expected_G_CO2 = \ self.CO2_ASE.get_gibbs_energy(temperature=self.T0, pressure=self.P0, verbose=False) calc_G_CO2 = self.CO2_pmutt.get_G(T=self.T0, V=self.V0, units='eV') np.testing.assert_almost_equal(expected_G_CO2, calc_G_CO2, 3)
potentialenergy=-14.2209, symmetrynumber=2, spin=0., atoms=molecule('H2O'), vib_wavenumbers=[3825.434, 3710.2642, 1582.432], T_ref=298., HoRT_ref=-97.60604334, **presets['idealgas']) refs = References(references=[H2_ref, H2O_ref]) H2O_statmech = StatMech(name='H2O', phase='G', atoms=molecule('H2O'), potentialenergy=-14.2209, symmetrynumber=2, spin=0, references=refs, vib_wavenumbers=[3825.434, 3710.264, 1582.432], **presets['idealgas']) H2O_TS_statmech = StatMech(name='H2O', elements={ 'H': 2, 'O': 1 }, phase='G', atoms=molecule('H2O'), potentialenergy=0., symmetrynumber=2, spin=0,
12.47757489, 12.52697445, 12.64787689, 12.7652535, 12.87931824, 12.99026871, 13.09828757, 13.20354395, 13.3061946, 13.40638501, 13.50425036, 13.59991643, 13.69350035, 13.78511133, 13.87485131, 13.96281555, 14.04909315, 14.13376754, 14.21691692, 14.29861465, 14.37892962, 14.45792659, 14.53566649, 14.6122067, 14.68760129, 14.76190128, 14.83515483, 14.90740747, 14.97870223, 15.04907987, 15.11857898, 15.18723616, 15.25508613, 15.32216185, 15.38849466, 15.45411434, 15.51904926, 15.58332641, 15.64697155, 15.71000921, 15.77246282, 15.83435478 ]) HoRT_Fe2O3 = -333.1719719 SoR_Fe2O3 = 10.49736076 O2 = StatMech(vib_wavenumbers=np.array([1580.2]), potentialenergy=-0.1879339246281043, spin=1., symmetrynumber=2, atoms=molecule('O2'), **presets['idealgas']) species = { 'Fe': Nasa.from_data(name='Fe', T=T, CpoR=CpoR_Fe, T_ref=T_ref, HoRT_ref=HoRT_Fe, SoR_ref=SoR_Fe), 'FeO': Nasa.from_data(name='FeO', T=T, CpoR=CpoR_FeO,
def setUp(self): self.T = c.T0('K') # Factor to convert potential energy to dimensionless number dim_factor = c.R('eV/K')*self.T self.m = 0.5 # BEP Slope self.c = 20. # BEP Intercept in kcal/mol species = { 'H2': StatMech(name='H2', potentialenergy=2.*dim_factor, **presets['electronic']), 'O2': StatMech(name='O2', potentialenergy=4.*dim_factor, **presets['electronic']), 'H2O': StatMech(name='H2O', potentialenergy=3.*dim_factor, **presets['electronic']), 'BEP': BEP(slope=self.m, intercept=self.c, name='BEP') } self.rxn_delta_H = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='delta_H') self.bep_delta_H = self.rxn_delta_H.transition_state[0] rxn_rev_delta_H = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='rev_delta_H') self.bep_rev_delta_H = rxn_rev_delta_H.transition_state[0] rxn_reactants_H = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='reactants_H') self.bep_reactants_H = rxn_reactants_H.transition_state[0] rxn_products_H = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='products_H') self.bep_products_H = rxn_products_H.transition_state[0] self.rxn_delta_E = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='delta_E') self.bep_delta_E = self.rxn_delta_E.transition_state[0] rxn_rev_delta_E = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='rev_delta_E') self.bep_rev_delta_E = rxn_rev_delta_E.transition_state[0] rxn_reactants_E = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='reactants_E') self.bep_reactants_E = rxn_reactants_E.transition_state[0] rxn_products_E = Reaction.from_string( reaction_str='H2 + 0.5O2 = BEP = H2O', species=species, bep_descriptor='products_E') self.bep_products_E = rxn_products_E.transition_state[0]
def setUp(self): '''Reactions using Nasa polynomial''' self.H2O_nasa = Nasa(name='H2O', T_low=200., T_mid=1000., T_high=3500., elements={ 'H': 2, 'O': 1 }, a_low=[ 4.19864056E+00, -2.03643410E-03, 6.52040211E-06, -5.48797062E-09, 1.77197817E-12, -3.02937267E+04, -8.49032208E-01 ], a_high=[ 3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00 ]) self.H2_nasa = Nasa(name='H2', T_low=200., T_mid=1000., T_high=3500., elements={'H': 2}, a_low=[ 2.34433112E+00, 7.98052075E-03, -1.94781510E-05, 2.01572094E-08, -7.37611761E-12, -9.17935173E+02, 6.83010238E-01 ], a_high=[ 3.33727920E+00, -4.94024731E-05, 4.99456778E-07, -1.79566394E-10, 2.00255376E-14, -9.50158922E+02, -3.20502331E+00 ]) self.O2_nasa = Nasa(name='O2', T_low=200., T_mid=1000., T_high=3500., elements={'O': 2}, a_low=[ 3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03, 3.65767573E+00 ], a_high=[ 3.28253784E+00, 1.48308754E-03, -7.57966669E-07, 2.09470555E-10, -2.16717794E-14, -1.08845772E+03, 5.45323129E+00 ]) self.rxn_nasa = rxn.Reaction(reactants=[self.H2_nasa, self.O2_nasa], reactants_stoich=[1., 0.5], products=[self.H2O_nasa], products_stoich=[1.]) self.rxn_nasa_dict = { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331 ], 'a_low': [ 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2 }, 'name': 'H2', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, -1088.45772, 5.45323129 ], 'a_low': [ 3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, -1063.94356, 3.65767573 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 2 }, 'name': 'O2', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'reactants_stoich': [1.0, 0.5], 'transition_state': None, 'transition_state_stoich': None, 'reaction_str': 'H2+0.50O2=H2O', } '''Reactions using StatMech''' ideal_gas_param = presets['idealgas'] self.H2O_sm = StatMech(name='H2O', atoms=molecule('H2O'), symmetrynumber=2, vib_wavenumbers=[3825.434, 3710.2642, 1582.432], potentialenergy=-6.7598, spin=0., **ideal_gas_param) self.H2_sm = StatMech(name='H2', atoms=molecule('H2'), symmetrynumber=2, vib_wavenumbers=[4306.1793], potentialenergy=-14.2209, spin=0., **ideal_gas_param) self.O2_sm = StatMech(name='O2', atoms=molecule('O2'), symmetrynumber=2, vib_wavenumbers=[1556.], potentialenergy=-9.862407, spin=1., **ideal_gas_param) # This is an arbitrary transition state for testing self.H2O_TS_sm = StatMech(name='H2O_TS', atoms=molecule('H2O'), symmetrynumber=1., vib_wavenumbers=[4000., 3900., 1600.], potentialenergy=-5.7598, spin=0., **ideal_gas_param) self.rxn_sm = rxn.Reaction(reactants=[self.H2_sm, self.O2_sm], reactants_stoich=[1., 0.5], products=[self.H2O_sm], products_stoich=[1.], transition_state=[self.H2O_TS_sm], transition_state_stoich=[1.]) self.species_dict = { 'H2O': self.H2O_sm, 'H2': self.H2_sm, 'O2': self.O2_sm, 'H2O_TS': self.H2O_TS_sm } self.maxDiff = None
class TestReaction(unittest.TestCase): def setUp(self): '''Reactions using Nasa polynomial''' self.H2O_nasa = Nasa(name='H2O', T_low=200., T_mid=1000., T_high=3500., elements={ 'H': 2, 'O': 1 }, a_low=[ 4.19864056E+00, -2.03643410E-03, 6.52040211E-06, -5.48797062E-09, 1.77197817E-12, -3.02937267E+04, -8.49032208E-01 ], a_high=[ 3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00 ]) self.H2_nasa = Nasa(name='H2', T_low=200., T_mid=1000., T_high=3500., elements={'H': 2}, a_low=[ 2.34433112E+00, 7.98052075E-03, -1.94781510E-05, 2.01572094E-08, -7.37611761E-12, -9.17935173E+02, 6.83010238E-01 ], a_high=[ 3.33727920E+00, -4.94024731E-05, 4.99456778E-07, -1.79566394E-10, 2.00255376E-14, -9.50158922E+02, -3.20502331E+00 ]) self.O2_nasa = Nasa(name='O2', T_low=200., T_mid=1000., T_high=3500., elements={'O': 2}, a_low=[ 3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03, 3.65767573E+00 ], a_high=[ 3.28253784E+00, 1.48308754E-03, -7.57966669E-07, 2.09470555E-10, -2.16717794E-14, -1.08845772E+03, 5.45323129E+00 ]) self.rxn_nasa = rxn.Reaction(reactants=[self.H2_nasa, self.O2_nasa], reactants_stoich=[1., 0.5], products=[self.H2O_nasa], products_stoich=[1.]) self.rxn_nasa_dict = { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331 ], 'a_low': [ 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2 }, 'name': 'H2', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, -1088.45772, 5.45323129 ], 'a_low': [ 3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, -1063.94356, 3.65767573 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 2 }, 'name': 'O2', 'notes': None, 'phase': None, 'model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'reactants_stoich': [1.0, 0.5], 'transition_state': None, 'transition_state_stoich': None, 'reaction_str': 'H2+0.50O2=H2O', } '''Reactions using StatMech''' ideal_gas_param = presets['idealgas'] self.H2O_sm = StatMech(name='H2O', atoms=molecule('H2O'), symmetrynumber=2, vib_wavenumbers=[3825.434, 3710.2642, 1582.432], potentialenergy=-6.7598, spin=0., **ideal_gas_param) self.H2_sm = StatMech(name='H2', atoms=molecule('H2'), symmetrynumber=2, vib_wavenumbers=[4306.1793], potentialenergy=-14.2209, spin=0., **ideal_gas_param) self.O2_sm = StatMech(name='O2', atoms=molecule('O2'), symmetrynumber=2, vib_wavenumbers=[1556.], potentialenergy=-9.862407, spin=1., **ideal_gas_param) # This is an arbitrary transition state for testing self.H2O_TS_sm = StatMech(name='H2O_TS', atoms=molecule('H2O'), symmetrynumber=1., vib_wavenumbers=[4000., 3900., 1600.], potentialenergy=-5.7598, spin=0., **ideal_gas_param) self.rxn_sm = rxn.Reaction(reactants=[self.H2_sm, self.O2_sm], reactants_stoich=[1., 0.5], products=[self.H2O_sm], products_stoich=[1.], transition_state=[self.H2O_TS_sm], transition_state_stoich=[1.]) self.species_dict = { 'H2O': self.H2O_sm, 'H2': self.H2_sm, 'O2': self.O2_sm, 'H2O_TS': self.H2O_TS_sm } self.maxDiff = None def test_compare_element_balance(self): self.assertIsNone(self.rxn_nasa.check_element_balance()) def test_get_species(self): self.assertDictEqual(self.rxn_sm.get_species(key='name'), self.species_dict) def test_get_q_state(self): exp_q_react = self.H2_sm.get_q(T=c.T0('K')) \ * self.O2_sm.get_q(T=c.T0('K'))**0.5 exp_q_prod = self.H2O_sm.get_q(T=c.T0('K')) exp_q_TS = self.H2O_TS_sm.get_q(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_q_state(state='reactants', T=c.T0('K')), exp_q_react) self.assertAlmostEqual( self.rxn_sm.get_q_state(state='products', T=c.T0('K')), exp_q_prod) self.assertAlmostEqual( self.rxn_sm.get_q_state(state='transition state', T=c.T0('K')), exp_q_TS) def test_get_CvoR_state(self): exp_CvoR_react = self.H2_sm.get_CvoR(T=c.T0('K')) \ + self.O2_sm.get_CvoR(T=c.T0('K'))*0.5 exp_CvoR_prod = self.H2O_sm.get_CvoR(T=c.T0('K')) exp_CvoR_TS = self.H2O_TS_sm.get_CvoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_CvoR_state(state='reactants', T=c.T0('K')), exp_CvoR_react) self.assertAlmostEqual( self.rxn_sm.get_CvoR_state(state='products', T=c.T0('K')), exp_CvoR_prod) self.assertAlmostEqual( self.rxn_sm.get_CvoR_state(state='transition state', T=c.T0('K')), exp_CvoR_TS) def test_get_Cv_state(self): units = 'J/mol/K' exp_Cv_react = self.H2_sm.get_Cv(T=c.T0('K'), units=units) \ + self.O2_sm.get_Cv(T=c.T0('K'), units=units)*0.5 exp_Cv_prod = self.H2O_sm.get_Cv(T=c.T0('K'), units=units) exp_Cv_TS = self.H2O_TS_sm.get_Cv(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_Cv_state(state='reactants', T=c.T0('K'), units=units), exp_Cv_react) self.assertAlmostEqual( self.rxn_sm.get_Cv_state(state='products', T=c.T0('K'), units=units), exp_Cv_prod) self.assertAlmostEqual( self.rxn_sm.get_Cv_state(state='transition state', T=c.T0('K'), units=units), exp_Cv_TS) def test_get_CpoR_state(self): exp_CpoR_react = self.H2_sm.get_CpoR(T=c.T0('K')) \ + self.O2_sm.get_CpoR(T=c.T0('K'))*0.5 exp_CpoR_prod = self.H2O_sm.get_CpoR(T=c.T0('K')) exp_CpoR_TS = self.H2O_TS_sm.get_CpoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_CpoR_state(state='reactants', T=c.T0('K')), exp_CpoR_react) self.assertAlmostEqual( self.rxn_sm.get_CpoR_state(state='products', T=c.T0('K')), exp_CpoR_prod) self.assertAlmostEqual( self.rxn_sm.get_CpoR_state(state='transition state', T=c.T0('K')), exp_CpoR_TS) def test_get_Cp_state(self): units = 'J/mol/K' exp_Cp_react = self.H2_sm.get_Cp(T=c.T0('K'), units=units) \ + self.O2_sm.get_Cp(T=c.T0('K'), units=units)*0.5 exp_Cp_prod = self.H2O_sm.get_Cp(T=c.T0('K'), units=units) exp_Cp_TS = self.H2O_TS_sm.get_Cp(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_Cp_state(state='reactants', T=c.T0('K'), units=units), exp_Cp_react) self.assertAlmostEqual( self.rxn_sm.get_Cp_state(state='products', T=c.T0('K'), units=units), exp_Cp_prod) self.assertAlmostEqual( self.rxn_sm.get_Cp_state(state='transition state', T=c.T0('K'), units=units), exp_Cp_TS) def test_get_EoRT_state(self): exp_EoRT_react = self.H2_sm.get_EoRT(T=c.T0('K')) \ + self.O2_sm.get_EoRT(T=c.T0('K'))*0.5 exp_EoRT_prod = self.H2O_sm.get_EoRT(T=c.T0('K')) exp_EoRT_TS = self.H2O_TS_sm.get_EoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_EoRT_state(state='reactants', T=c.T0('K')), exp_EoRT_react) self.assertAlmostEqual( self.rxn_sm.get_EoRT_state(state='products', T=c.T0('K')), exp_EoRT_prod) self.assertAlmostEqual( self.rxn_sm.get_EoRT_state(state='transition state', T=c.T0('K')), exp_EoRT_TS) def test_get_E_state(self): units = 'J/mol' exp_E_react = self.H2_sm.get_E(T=c.T0('K'), units=units) \ + self.O2_sm.get_E(T=c.T0('K'), units=units)*0.5 exp_E_prod = self.H2O_sm.get_E(T=c.T0('K'), units=units) exp_E_TS = self.H2O_TS_sm.get_E(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_E_state(state='reactants', T=c.T0('K'), units=units), exp_E_react) self.assertAlmostEqual( self.rxn_sm.get_E_state(state='products', T=c.T0('K'), units=units), exp_E_prod) self.assertAlmostEqual( self.rxn_sm.get_E_state(state='transition state', T=c.T0('K'), units=units), exp_E_TS) def test_get_UoRT_state(self): exp_UoRT_react = self.H2_sm.get_UoRT(T=c.T0('K')) \ + self.O2_sm.get_UoRT(T=c.T0('K'))*0.5 exp_UoRT_prod = self.H2O_sm.get_UoRT(T=c.T0('K')) exp_UoRT_TS = self.H2O_TS_sm.get_UoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_UoRT_state(state='reactants', T=c.T0('K')), exp_UoRT_react) self.assertAlmostEqual( self.rxn_sm.get_UoRT_state(state='products', T=c.T0('K')), exp_UoRT_prod) self.assertAlmostEqual( self.rxn_sm.get_UoRT_state(state='transition state', T=c.T0('K')), exp_UoRT_TS) def test_get_U_state(self): units = 'J/mol' exp_U_react = self.H2_sm.get_U(T=c.T0('K'), units=units) \ + self.O2_sm.get_U(T=c.T0('K'), units=units)*0.5 exp_U_prod = self.H2O_sm.get_U(T=c.T0('K'), units=units) exp_U_TS = self.H2O_TS_sm.get_U(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_U_state(state='reactants', T=c.T0('K'), units=units), exp_U_react) self.assertAlmostEqual( self.rxn_sm.get_U_state(state='products', T=c.T0('K'), units=units), exp_U_prod) self.assertAlmostEqual( self.rxn_sm.get_U_state(state='transition state', T=c.T0('K'), units=units), exp_U_TS) def test_get_HoRT_state(self): exp_HoRT_react = self.H2_sm.get_HoRT(T=c.T0('K')) \ + self.O2_sm.get_HoRT(T=c.T0('K'))*0.5 exp_HoRT_prod = self.H2O_sm.get_HoRT(T=c.T0('K')) exp_HoRT_TS = self.H2O_TS_sm.get_HoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_HoRT_state(state='reactants', T=c.T0('K')), exp_HoRT_react) self.assertAlmostEqual( self.rxn_sm.get_HoRT_state(state='products', T=c.T0('K')), exp_HoRT_prod) self.assertAlmostEqual( self.rxn_sm.get_HoRT_state(state='transition state', T=c.T0('K')), exp_HoRT_TS) def test_get_H_state(self): units = 'J/mol' exp_H_react = self.H2_sm.get_H(T=c.T0('K'), units=units) \ + self.O2_sm.get_H(T=c.T0('K'), units=units)*0.5 exp_H_prod = self.H2O_sm.get_H(T=c.T0('K'), units=units) exp_H_TS = self.H2O_TS_sm.get_H(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_H_state(state='reactants', T=c.T0('K'), units=units), exp_H_react) self.assertAlmostEqual( self.rxn_sm.get_H_state(state='products', T=c.T0('K'), units=units), exp_H_prod) self.assertAlmostEqual( self.rxn_sm.get_H_state(state='transition state', T=c.T0('K'), units=units), exp_H_TS) def test_get_SoR_state(self): exp_SoR_react = self.H2_sm.get_SoR(T=c.T0('K')) \ + self.O2_sm.get_SoR(T=c.T0('K'))*0.5 exp_SoR_prod = self.H2O_sm.get_SoR(T=c.T0('K')) exp_SoR_TS = self.H2O_TS_sm.get_SoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_SoR_state(state='reactants', T=c.T0('K')), exp_SoR_react) self.assertAlmostEqual( self.rxn_sm.get_SoR_state(state='products', T=c.T0('K')), exp_SoR_prod) self.assertAlmostEqual( self.rxn_sm.get_SoR_state(state='transition state', T=c.T0('K')), exp_SoR_TS) def test_get_S_state(self): units = 'J/mol/K' exp_S_react = self.H2_sm.get_S(T=c.T0('K'), units=units) \ + self.O2_sm.get_S(T=c.T0('K'), units=units)*0.5 exp_S_prod = self.H2O_sm.get_S(T=c.T0('K'), units=units) exp_S_TS = self.H2O_TS_sm.get_S(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_S_state(state='reactants', T=c.T0('K'), units=units), exp_S_react) self.assertAlmostEqual( self.rxn_sm.get_S_state(state='products', T=c.T0('K'), units=units), exp_S_prod) self.assertAlmostEqual( self.rxn_sm.get_S_state(state='transition state', T=c.T0('K'), units=units), exp_S_TS) def test_get_FoRT_state(self): exp_FoRT_react = self.H2_sm.get_FoRT(T=c.T0('K')) \ + self.O2_sm.get_FoRT(T=c.T0('K'))*0.5 exp_FoRT_prod = self.H2O_sm.get_FoRT(T=c.T0('K')) exp_FoRT_TS = self.H2O_TS_sm.get_FoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_FoRT_state(state='reactants', T=c.T0('K')), exp_FoRT_react) self.assertAlmostEqual( self.rxn_sm.get_FoRT_state(state='products', T=c.T0('K')), exp_FoRT_prod) self.assertAlmostEqual( self.rxn_sm.get_FoRT_state(state='transition state', T=c.T0('K')), exp_FoRT_TS) def test_get_F_state(self): units = 'J/mol' exp_F_react = self.H2_sm.get_F(T=c.T0('K'), units=units) \ + self.O2_sm.get_F(T=c.T0('K'), units=units)*0.5 exp_F_prod = self.H2O_sm.get_F(T=c.T0('K'), units=units) exp_F_TS = self.H2O_TS_sm.get_F(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_F_state(state='reactants', T=c.T0('K'), units=units), exp_F_react) self.assertAlmostEqual( self.rxn_sm.get_F_state(state='products', T=c.T0('K'), units=units), exp_F_prod) self.assertAlmostEqual( self.rxn_sm.get_F_state(state='transition state', T=c.T0('K'), units=units), exp_F_TS) def test_get_GoRT_state(self): exp_GoRT_react = self.H2_sm.get_GoRT(T=c.T0('K')) \ + self.O2_sm.get_GoRT(T=c.T0('K'))*0.5 exp_GoRT_prod = self.H2O_sm.get_GoRT(T=c.T0('K')) exp_GoRT_TS = self.H2O_TS_sm.get_GoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_GoRT_state(state='reactants', T=c.T0('K')), exp_GoRT_react) self.assertAlmostEqual( self.rxn_sm.get_GoRT_state(state='products', T=c.T0('K')), exp_GoRT_prod) self.assertAlmostEqual( self.rxn_sm.get_GoRT_state(state='transition state', T=c.T0('K')), exp_GoRT_TS) def test_get_G_state(self): units = 'J/mol' exp_G_react = self.H2_sm.get_G(T=c.T0('K'), units=units) \ + self.O2_sm.get_G(T=c.T0('K'), units=units)*0.5 exp_G_prod = self.H2O_sm.get_G(T=c.T0('K'), units=units) exp_G_TS = self.H2O_TS_sm.get_G(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_G_state(state='reactants', T=c.T0('K'), units=units), exp_G_react) self.assertAlmostEqual( self.rxn_sm.get_G_state(state='products', T=c.T0('K'), units=units), exp_G_prod) self.assertAlmostEqual( self.rxn_sm.get_G_state(state='transition state', T=c.T0('K'), units=units), exp_G_TS) def test_get_delta_CvoR(self): exp_sm_CvoR = self.H2O_sm.get_CvoR(T=c.T0('K')) \ - self.H2_sm.get_CvoR(T=c.T0('K')) \ - self.O2_sm.get_CvoR(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_sm.get_delta_CvoR(T=c.T0('K')), exp_sm_CvoR) self.assertAlmostEqual( self.rxn_sm.get_delta_CvoR(T=c.T0('K'), rev=True), -exp_sm_CvoR) exp_sm_CvoR_TS = self.H2O_TS_sm.get_CvoR(T=c.T0('K')) \ - self.H2_sm.get_CvoR(T=c.T0('K')) \ - self.O2_sm.get_CvoR(T=c.T0('K'))*0.5 exp_sm_CvoR_rev_TS = self.H2O_TS_sm.get_CvoR(T=c.T0('K')) \ - self.H2O_sm.get_CvoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_CvoR(T=c.T0('K'), act=True), exp_sm_CvoR_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_CvoR(T=c.T0('K'), rev=True, act=True), exp_sm_CvoR_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_CvoR_act(T=c.T0('K'), rev=True), exp_sm_CvoR_rev_TS) def test_get_delta_Cv(self): units = 'J/mol/K' exp_sm_Cv = self.H2O_sm.get_Cv(T=c.T0('K'), units=units) \ - self.H2_sm.get_Cv(T=c.T0('K'), units=units) \ - self.O2_sm.get_Cv(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_sm.get_delta_Cv(T=c.T0('K'), units=units), exp_sm_Cv) self.assertAlmostEqual( self.rxn_sm.get_delta_Cv(T=c.T0('K'), units=units, rev=True), -exp_sm_Cv) exp_sm_Cv_TS = self.H2O_TS_sm.get_Cv(T=c.T0('K'), units=units) \ - self.H2_sm.get_Cv(T=c.T0('K'), units=units) \ - self.O2_sm.get_Cv(T=c.T0('K'), units=units)*0.5 exp_sm_Cv_rev_TS = self.H2O_TS_sm.get_Cv(T=c.T0('K'), units=units) \ - self.H2O_sm.get_Cv(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_Cv(T=c.T0('K'), act=True, units=units), exp_sm_Cv_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_Cv(T=c.T0('K'), rev=True, units=units, act=True), exp_sm_Cv_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_Cv_act(T=c.T0('K'), rev=True, units=units), exp_sm_Cv_rev_TS) def test_get_delta_CpoR(self): exp_nasa_CpoR = self.H2O_nasa.get_CpoR(T=c.T0('K')) \ - self.H2_nasa.get_CpoR(T=c.T0('K')) \ - self.O2_nasa.get_CpoR(T=c.T0('K'))*0.5 exp_sm_CpoR = self.H2O_sm.get_CpoR(T=c.T0('K')) \ - self.H2_sm.get_CpoR(T=c.T0('K')) \ - self.O2_sm.get_CpoR(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_nasa.get_delta_CpoR(T=c.T0('K')), exp_nasa_CpoR) self.assertAlmostEqual( self.rxn_nasa.get_delta_CpoR(T=c.T0('K'), rev=True), -exp_nasa_CpoR) self.assertAlmostEqual(self.rxn_sm.get_delta_CpoR(T=c.T0('K')), exp_sm_CpoR) self.assertAlmostEqual( self.rxn_sm.get_delta_CpoR(T=c.T0('K'), rev=True), -exp_sm_CpoR) exp_sm_CpoR_TS = self.H2O_TS_sm.get_CpoR(T=c.T0('K')) \ - self.H2_sm.get_CpoR(T=c.T0('K')) \ - self.O2_sm.get_CpoR(T=c.T0('K'))*0.5 exp_sm_CpoR_rev_TS = self.H2O_TS_sm.get_CpoR(T=c.T0('K')) \ - self.H2O_sm.get_CpoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_CpoR(T=c.T0('K'), act=True), exp_sm_CpoR_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_CpoR(T=c.T0('K'), rev=True, act=True), exp_sm_CpoR_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_CpoR_act(T=c.T0('K'), rev=True), exp_sm_CpoR_rev_TS) def test_get_delta_Cp(self): units = 'J/mol/K' exp_nasa_Cp = self.H2O_nasa.get_Cp(T=c.T0('K'), units=units) \ - self.H2_nasa.get_Cp(T=c.T0('K'), units=units) \ - self.O2_nasa.get_Cp(T=c.T0('K'), units=units)*0.5 exp_sm_Cp = self.H2O_sm.get_Cp(T=c.T0('K'), units=units) \ - self.H2_sm.get_Cp(T=c.T0('K'), units=units) \ - self.O2_sm.get_Cp(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_nasa.get_delta_Cp(T=c.T0('K'), units=units), exp_nasa_Cp) self.assertAlmostEqual( self.rxn_nasa.get_delta_Cp(T=c.T0('K'), units=units, rev=True), -exp_nasa_Cp) self.assertAlmostEqual( self.rxn_sm.get_delta_Cp(T=c.T0('K'), units=units), exp_sm_Cp) self.assertAlmostEqual( self.rxn_sm.get_delta_Cp(T=c.T0('K'), units=units, rev=True), -exp_sm_Cp) exp_sm_Cp_TS = self.H2O_TS_sm.get_Cp(T=c.T0('K'), units=units) \ - self.H2_sm.get_Cp(T=c.T0('K'), units=units) \ - self.O2_sm.get_Cp(T=c.T0('K'), units=units)*0.5 exp_sm_Cp_rev_TS = self.H2O_TS_sm.get_Cp(T=c.T0('K'), units=units) \ - self.H2O_sm.get_Cp(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_Cp(T=c.T0('K'), act=True, units=units), exp_sm_Cp_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_Cp(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_Cp_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_Cp_act(T=c.T0('K'), rev=True, units=units), exp_sm_Cp_rev_TS) def test_get_delta_EoRT(self): exp_sm_EoRT = self.H2O_sm.get_EoRT(T=c.T0('K')) \ - self.H2_sm.get_EoRT(T=c.T0('K')) \ - self.O2_sm.get_EoRT(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_sm.get_delta_EoRT(T=c.T0('K')), exp_sm_EoRT) self.assertAlmostEqual( self.rxn_sm.get_delta_EoRT(T=c.T0('K'), rev=True), -exp_sm_EoRT) exp_sm_EoRT_TS = self.H2O_TS_sm.get_EoRT(T=c.T0('K')) \ - self.H2_sm.get_EoRT(T=c.T0('K')) \ - self.O2_sm.get_EoRT(T=c.T0('K'))*0.5 exp_sm_EoRT_rev_TS = self.H2O_TS_sm.get_EoRT(T=c.T0('K')) \ - self.H2O_sm.get_EoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_EoRT(T=c.T0('K'), act=True), exp_sm_EoRT_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_EoRT(T=c.T0('K'), rev=True, act=True), exp_sm_EoRT_rev_TS) def test_get_delta_E(self): units = 'J/mol' exp_sm_E = self.H2O_sm.get_E(T=c.T0('K'), units=units) \ - self.H2_sm.get_E(T=c.T0('K'), units=units) \ - self.O2_sm.get_E(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_sm.get_delta_E(T=c.T0('K'), units=units), exp_sm_E) self.assertAlmostEqual( self.rxn_sm.get_delta_E(T=c.T0('K'), rev=True, units=units), -exp_sm_E) exp_sm_E_TS = self.H2O_TS_sm.get_E(T=c.T0('K'), units=units) \ - self.H2_sm.get_E(T=c.T0('K'), units=units) \ - self.O2_sm.get_E(T=c.T0('K'), units=units)*0.5 exp_sm_E_rev_TS = self.H2O_TS_sm.get_E(T=c.T0('K'), units=units) \ - self.H2O_sm.get_E(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_E(T=c.T0('K'), act=True, units=units), exp_sm_E_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_E(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_E_rev_TS) def test_get_delta_UoRT(self): exp_sm_UoRT = self.H2O_sm.get_UoRT(T=c.T0('K')) \ - self.H2_sm.get_UoRT(T=c.T0('K')) \ - self.O2_sm.get_UoRT(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_sm.get_delta_UoRT(T=c.T0('K')), exp_sm_UoRT) self.assertAlmostEqual( self.rxn_sm.get_delta_UoRT(T=c.T0('K'), rev=True), -exp_sm_UoRT) exp_sm_UoRT_TS = self.H2O_TS_sm.get_UoRT(T=c.T0('K')) \ - self.H2_sm.get_UoRT(T=c.T0('K')) \ - self.O2_sm.get_UoRT(T=c.T0('K'))*0.5 exp_sm_UoRT_rev_TS = self.H2O_TS_sm.get_UoRT(T=c.T0('K')) \ - self.H2O_sm.get_UoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_UoRT(T=c.T0('K'), act=True), exp_sm_UoRT_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_UoRT(T=c.T0('K'), rev=True, act=True), exp_sm_UoRT_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_UoRT_act(T=c.T0('K'), rev=True), exp_sm_UoRT_rev_TS) def test_get_delta_U(self): units = 'J/mol' exp_sm_U = self.H2O_sm.get_U(T=c.T0('K'), units=units) \ - self.H2_sm.get_U(T=c.T0('K'), units=units) \ - self.O2_sm.get_U(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_sm.get_delta_U(T=c.T0('K'), units=units), exp_sm_U) self.assertAlmostEqual( self.rxn_sm.get_delta_U(T=c.T0('K'), rev=True, units=units), -exp_sm_U) exp_sm_U_TS = self.H2O_TS_sm.get_U(T=c.T0('K'), units=units) \ - self.H2_sm.get_U(T=c.T0('K'), units=units) \ - self.O2_sm.get_U(T=c.T0('K'), units=units)*0.5 exp_sm_U_rev_TS = self.H2O_TS_sm.get_U(T=c.T0('K'), units=units) \ - self.H2O_sm.get_U(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_U(T=c.T0('K'), act=True, units=units), exp_sm_U_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_U(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_U_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_U_act(T=c.T0('K'), rev=True, units=units), exp_sm_U_rev_TS) def test_get_delta_HoRT(self): exp_nasa_HoRT = self.H2O_nasa.get_HoRT(T=c.T0('K')) \ - self.H2_nasa.get_HoRT(T=c.T0('K')) \ - self.O2_nasa.get_HoRT(T=c.T0('K'))*0.5 exp_sm_HoRT = self.H2O_sm.get_HoRT(T=c.T0('K')) \ - self.H2_sm.get_HoRT(T=c.T0('K')) \ - self.O2_sm.get_HoRT(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_nasa.get_delta_HoRT(T=c.T0('K')), exp_nasa_HoRT) self.assertAlmostEqual( self.rxn_nasa.get_delta_HoRT(T=c.T0('K'), rev=True), -exp_nasa_HoRT) self.assertAlmostEqual(self.rxn_sm.get_delta_HoRT(T=c.T0('K')), exp_sm_HoRT) self.assertAlmostEqual( self.rxn_sm.get_delta_HoRT(T=c.T0('K'), rev=True), -exp_sm_HoRT) exp_sm_HoRT_TS = self.H2O_TS_sm.get_HoRT(T=c.T0('K')) \ - self.H2_sm.get_HoRT(T=c.T0('K')) \ - self.O2_sm.get_HoRT(T=c.T0('K'))*0.5 exp_sm_HoRT_rev_TS = self.H2O_TS_sm.get_HoRT(T=c.T0('K')) \ - self.H2O_sm.get_HoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_HoRT(T=c.T0('K'), act=True), exp_sm_HoRT_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_HoRT(T=c.T0('K'), rev=True, act=True), exp_sm_HoRT_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_HoRT_act(T=c.T0('K'), rev=True), exp_sm_HoRT_rev_TS) def test_get_delta_H(self): units = 'J/mol' exp_nasa_H = self.H2O_nasa.get_H(T=c.T0('K'), units=units) \ - self.H2_nasa.get_H(T=c.T0('K'), units=units) \ - self.O2_nasa.get_H(T=c.T0('K'), units=units)*0.5 exp_sm_H = self.H2O_sm.get_H(T=c.T0('K'), units=units) \ - self.H2_sm.get_H(T=c.T0('K'), units=units) \ - self.O2_sm.get_H(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_nasa.get_delta_H(T=c.T0('K'), units=units), exp_nasa_H) self.assertAlmostEqual( self.rxn_nasa.get_delta_H(T=c.T0('K'), units=units, rev=True), -exp_nasa_H) self.assertAlmostEqual( self.rxn_sm.get_delta_H(T=c.T0('K'), units=units), exp_sm_H) self.assertAlmostEqual( self.rxn_sm.get_delta_H(T=c.T0('K'), units=units, rev=True), -exp_sm_H) exp_sm_H_TS = self.H2O_TS_sm.get_H(T=c.T0('K'), units=units) \ - self.H2_sm.get_H(T=c.T0('K'), units=units) \ - self.O2_sm.get_H(T=c.T0('K'), units=units)*0.5 exp_sm_H_rev_TS = self.H2O_TS_sm.get_H(T=c.T0('K'), units=units) \ - self.H2O_sm.get_H(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_H(T=c.T0('K'), act=True, units=units), exp_sm_H_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_H(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_H_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_H_act(T=c.T0('K'), rev=True, units=units), exp_sm_H_rev_TS) def test_get_delta_SoR(self): exp_nasa_SoR = self.H2O_nasa.get_SoR(T=c.T0('K')) \ - self.H2_nasa.get_SoR(T=c.T0('K')) \ - self.O2_nasa.get_SoR(T=c.T0('K'))*0.5 exp_sm_SoR = self.H2O_sm.get_SoR(T=c.T0('K')) \ - self.H2_sm.get_SoR(T=c.T0('K')) \ - self.O2_sm.get_SoR(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_nasa.get_delta_SoR(T=c.T0('K')), exp_nasa_SoR) self.assertAlmostEqual( self.rxn_nasa.get_delta_SoR(T=c.T0('K'), rev=True), -exp_nasa_SoR) self.assertAlmostEqual(self.rxn_sm.get_delta_SoR(T=c.T0('K')), exp_sm_SoR) self.assertAlmostEqual( self.rxn_sm.get_delta_SoR(T=c.T0('K'), rev=True), -exp_sm_SoR) exp_sm_SoR_TS = self.H2O_TS_sm.get_SoR(T=c.T0('K')) \ - self.H2_sm.get_SoR(T=c.T0('K')) \ - self.O2_sm.get_SoR(T=c.T0('K'))*0.5 exp_sm_SoR_rev_TS = self.H2O_TS_sm.get_SoR(T=c.T0('K')) \ - self.H2O_sm.get_SoR(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_SoR(T=c.T0('K'), act=True), exp_sm_SoR_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_SoR(T=c.T0('K'), rev=True, act=True), exp_sm_SoR_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_SoR_act(T=c.T0('K'), rev=True), exp_sm_SoR_rev_TS) def test_get_delta_S(self): units = 'J/mol/K' exp_nasa_S = self.H2O_nasa.get_S(T=c.T0('K'), units=units) \ - self.H2_nasa.get_S(T=c.T0('K'), units=units) \ - self.O2_nasa.get_S(T=c.T0('K'), units=units)*0.5 exp_sm_S = self.H2O_sm.get_S(T=c.T0('K'), units=units) \ - self.H2_sm.get_S(T=c.T0('K'), units=units) \ - self.O2_sm.get_S(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_nasa.get_delta_S(T=c.T0('K'), units=units), exp_nasa_S) self.assertAlmostEqual( self.rxn_nasa.get_delta_S(T=c.T0('K'), units=units, rev=True), -exp_nasa_S) self.assertAlmostEqual( self.rxn_sm.get_delta_S(T=c.T0('K'), units=units), exp_sm_S) self.assertAlmostEqual( self.rxn_sm.get_delta_S(T=c.T0('K'), rev=True, units=units), -exp_sm_S) exp_sm_S_TS = self.H2O_TS_sm.get_S(T=c.T0('K'), units=units) \ - self.H2_sm.get_S(T=c.T0('K'), units=units) \ - self.O2_sm.get_S(T=c.T0('K'), units=units)*0.5 exp_sm_S_rev_TS = self.H2O_TS_sm.get_S(T=c.T0('K'), units=units) \ - self.H2O_sm.get_S(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_S(T=c.T0('K'), act=True, units=units), exp_sm_S_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_S(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_S_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_S_act(T=c.T0('K'), rev=True, units=units), exp_sm_S_rev_TS) def test_get_delta_FoRT(self): exp_sm_FoRT = self.H2O_sm.get_FoRT(T=c.T0('K')) \ - self.H2_sm.get_FoRT(T=c.T0('K')) \ - self.O2_sm.get_FoRT(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_sm.get_delta_FoRT(T=c.T0('K')), exp_sm_FoRT) self.assertAlmostEqual( self.rxn_sm.get_delta_FoRT(T=c.T0('K'), rev=True), -exp_sm_FoRT) exp_sm_FoRT_TS = self.H2O_TS_sm.get_FoRT(T=c.T0('K')) \ - self.H2_sm.get_FoRT(T=c.T0('K')) \ - self.O2_sm.get_FoRT(T=c.T0('K'))*0.5 exp_sm_FoRT_rev_TS = self.H2O_TS_sm.get_FoRT(T=c.T0('K')) \ - self.H2O_sm.get_FoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_FoRT(T=c.T0('K'), act=True), exp_sm_FoRT_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_FoRT(T=c.T0('K'), rev=True, act=True), exp_sm_FoRT_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_FoRT_act(T=c.T0('K'), rev=True), exp_sm_FoRT_rev_TS) def test_get_delta_F(self): units = 'J/mol' exp_sm_F = self.H2O_sm.get_F(T=c.T0('K'), units=units) \ - self.H2_sm.get_F(T=c.T0('K'), units=units) \ - self.O2_sm.get_F(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_sm.get_delta_F(T=c.T0('K'), units=units), exp_sm_F) self.assertAlmostEqual( self.rxn_sm.get_delta_F(T=c.T0('K'), units=units, rev=True), -exp_sm_F) exp_sm_F_TS = self.H2O_TS_sm.get_F(T=c.T0('K'), units=units) \ - self.H2_sm.get_F(T=c.T0('K'), units=units) \ - self.O2_sm.get_F(T=c.T0('K'), units=units)*0.5 exp_sm_F_rev_TS = self.H2O_TS_sm.get_F(T=c.T0('K'), units=units) \ - self.H2O_sm.get_F(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_F(T=c.T0('K'), act=True, units=units), exp_sm_F_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_F(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_F_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_F_act(T=c.T0('K'), rev=True, units=units), exp_sm_F_rev_TS) def test_get_delta_GoRT(self): exp_nasa_GoRT = self.H2O_nasa.get_GoRT(T=c.T0('K')) \ - self.H2_nasa.get_GoRT(T=c.T0('K')) \ - self.O2_nasa.get_GoRT(T=c.T0('K'))*0.5 exp_sm_GoRT = self.H2O_sm.get_GoRT(T=c.T0('K')) \ - self.H2_sm.get_GoRT(T=c.T0('K')) \ - self.O2_sm.get_GoRT(T=c.T0('K'))*0.5 self.assertAlmostEqual(self.rxn_nasa.get_delta_GoRT(T=c.T0('K')), exp_nasa_GoRT) self.assertAlmostEqual( self.rxn_nasa.get_delta_GoRT(T=c.T0('K'), rev=True), -exp_nasa_GoRT) self.assertAlmostEqual(self.rxn_sm.get_delta_GoRT(T=c.T0('K')), exp_sm_GoRT) self.assertAlmostEqual( self.rxn_sm.get_delta_GoRT(T=c.T0('K'), rev=True), -exp_sm_GoRT) exp_sm_GoRT_TS = self.H2O_TS_sm.get_GoRT(T=c.T0('K')) \ - self.H2_sm.get_GoRT(T=c.T0('K')) \ - self.O2_sm.get_GoRT(T=c.T0('K'))*0.5 exp_sm_GoRT_rev_TS = self.H2O_TS_sm.get_GoRT(T=c.T0('K')) \ - self.H2O_sm.get_GoRT(T=c.T0('K')) self.assertAlmostEqual( self.rxn_sm.get_delta_GoRT(T=c.T0('K'), act=True), exp_sm_GoRT_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_GoRT(T=c.T0('K'), rev=True, act=True), exp_sm_GoRT_rev_TS) self.assertAlmostEqual(self.rxn_sm.get_GoRT_act(T=c.T0('K'), rev=True), exp_sm_GoRT_rev_TS) def test_get_delta_G(self): units = 'J/mol' exp_nasa_G = self.H2O_nasa.get_G(T=c.T0('K'), units=units) \ - self.H2_nasa.get_G(T=c.T0('K'), units=units) \ - self.O2_nasa.get_G(T=c.T0('K'), units=units)*0.5 exp_sm_G = self.H2O_sm.get_G(T=c.T0('K'), units=units) \ - self.H2_sm.get_G(T=c.T0('K'), units=units) \ - self.O2_sm.get_G(T=c.T0('K'), units=units)*0.5 self.assertAlmostEqual( self.rxn_nasa.get_delta_G(T=c.T0('K'), units=units), exp_nasa_G) self.assertAlmostEqual( self.rxn_nasa.get_delta_G(T=c.T0('K'), rev=True, units=units), -exp_nasa_G) self.assertAlmostEqual( self.rxn_sm.get_delta_G(T=c.T0('K'), units=units), exp_sm_G) self.assertAlmostEqual( self.rxn_sm.get_delta_G(T=c.T0('K'), rev=True, units=units), -exp_sm_G) exp_sm_G_TS = self.H2O_TS_sm.get_G(T=c.T0('K'), units=units) \ - self.H2_sm.get_G(T=c.T0('K'), units=units) \ - self.O2_sm.get_G(T=c.T0('K'), units=units)*0.5 exp_sm_G_rev_TS = self.H2O_TS_sm.get_G(T=c.T0('K'), units=units) \ - self.H2O_sm.get_G(T=c.T0('K'), units=units) self.assertAlmostEqual( self.rxn_sm.get_delta_G(T=c.T0('K'), act=True, units=units), exp_sm_G_TS) self.assertAlmostEqual( self.rxn_sm.get_delta_G(T=c.T0('K'), rev=True, act=True, units=units), exp_sm_G_rev_TS) self.assertAlmostEqual( self.rxn_sm.get_G_act(T=c.T0('K'), rev=True, units=units), exp_sm_G_rev_TS) def test_get_EoRT_act(self): exp_sm_EoRT = self.H2O_TS_sm.get_HoRT(T=c.T0('K')) \ - self.H2_sm.get_HoRT(T=c.T0('K')) \ - self.O2_sm.get_HoRT(T=c.T0('K'))*0.5 exp_sm_EoRT_rev = self.H2O_TS_sm.get_HoRT(T=c.T0('K')) \ - self.H2O_sm.get_HoRT(T=c.T0('K')) self.assertAlmostEqual(self.rxn_sm.get_EoRT_act(T=c.T0('K')), exp_sm_EoRT) self.assertAlmostEqual(self.rxn_sm.get_EoRT_act(T=c.T0('K'), rev=True), exp_sm_EoRT_rev) def test_get_E_act(self): units = 'J/mol' exp_sm_E = self.H2O_TS_sm.get_H(T=c.T0('K'), units=units) \ - self.H2_sm.get_H(T=c.T0('K'), units=units) \ - self.O2_sm.get_H(T=c.T0('K'), units=units)*0.5 exp_sm_E_rev = self.H2O_TS_sm.get_H(T=c.T0('K'), units=units) \ - self.H2O_sm.get_H(T=c.T0('K'), units=units) self.assertAlmostEqual(self.rxn_sm.get_E_act(T=c.T0('K'), units=units), exp_sm_E) self.assertAlmostEqual( self.rxn_sm.get_E_act(T=c.T0('K'), rev=True, units=units), exp_sm_E_rev) def test_get_A(self): # Testing partition function method exp_sm_q = self.H2O_TS_sm.get_q(T=c.T0('K'), include_ZPE=False) \ / self.H2_sm.get_q(T=c.T0('K'), include_ZPE=False) \ / self.O2_sm.get_q(T=c.T0('K'), include_ZPE=False)**0.5 exp_sm_A = c.kb('J/K') * c.T0('K') / c.h('J s') * exp_sm_q exp_sm_q_rev = self.H2O_TS_sm.get_q(T=c.T0('K'), include_ZPE=False) \ / self.H2O_sm.get_q(T=c.T0('K'), include_ZPE=False) exp_sm_A_rev = c.kb('J/K') * c.T0('K') / c.h('J s') * exp_sm_q_rev np.testing.assert_almost_equal(self.rxn_sm.get_A(T=c.T0('K')), exp_sm_A, decimal=0) np.testing.assert_almost_equal(self.rxn_sm.get_A(T=c.T0('K'), rev=True), exp_sm_A_rev, decimal=0) # Testing entropy method exp_sm_SoR = self.H2O_TS_sm.get_SoR(T=c.T0('K')) \ - self.H2_sm.get_SoR(T=c.T0('K')) \ - self.O2_sm.get_SoR(T=c.T0('K'))*0.5 exp_sm_A = c.kb('J/K') * c.T0('K') / c.h('J s') * np.exp(exp_sm_SoR) exp_sm_SoR_rev = self.H2O_TS_sm.get_SoR(T=c.T0('K')) \ - self.H2O_sm.get_SoR(T=c.T0('K')) exp_sm_A_rev = c.kb('J/K')*c.T0('K')/c.h('J s') \ * np.exp(exp_sm_SoR_rev) np.testing.assert_almost_equal(self.rxn_sm.get_A(T=c.T0('K'), use_q=False), exp_sm_A, decimal=0) np.testing.assert_almost_equal(self.rxn_sm.get_A(T=c.T0('K'), rev=True, use_q=False), exp_sm_A_rev, decimal=0) def test_from_string(self): reaction_str = 'H2+0.5O2=H2O_TS=H2O' self.assertEqual( rxn.Reaction.from_string(reaction_str=reaction_str, species=self.species_dict), self.rxn_sm) def test_to_dict(self): self.assertEqual(self.rxn_nasa.to_dict(), self.rxn_nasa_dict) def test_from_dict(self): self.assertEqual(rxn.Reaction.from_dict(self.rxn_nasa_dict), self.rxn_nasa)
# # <img src="images/configurations.png" width=600> # # First, we initialize the species as a dictionary to enable easy `Reaction` initialization. # In[1]: from ase.build import molecule from pmutt.statmech import StatMech, presets species = { 'CO': StatMech(name='CO', atoms=molecule('CO'), potentialenergy=-14.8021, vib_wavenumbers=[2121.2], symmetrynumber=1, **presets['idealgas']), 'Pt': StatMech(name='Pt', potentialenergy=-383.161235, **presets['electronic']), 'CO(S) 1/16ML fcc': StatMech(name='CO(S) 1/16ML fcc', potentialenergy=-399.48282843, vib_wavenumbers=[ 1731.942697, 349.970617, 322.15111, 319.114152, 161.45669 ], **presets['harmonic']), 'CO(S) 1/16ML br': StatMech(name='CO(S) 1/16ML br', potentialenergy=-399.464095, vib_wavenumbers=[
# In[2]: from pmutt.statmech import StatMech, trans, vib, rot, elec '''Translational''' H2_trans = trans.FreeTrans(n_degrees=3, atoms=H2_atoms) '''Vibrational''' H2_vib = vib.HarmonicVib(vib_wavenumbers=[4342.]) # vib_wavenumbers in cm-1 '''Rotational''' H2_rot = rot.RigidRotor(symmetrynumber=2, atoms=H2_atoms) '''Electronic''' H2_elec = elec.GroundStateElec(potentialenergy=-6.77, spin=0) # potentialenergy in eV '''StatMech Initialization''' H2_statmech = StatMech(name='H2', trans_model=H2_trans, vib_model=H2_vib, rot_model=H2_rot, elec_model=H2_elec) '''Calculate thermodynamic properties per mole basis''' H_statmech = H2_statmech.get_H(T=298., units='kJ/mol') S_statmech = H2_statmech.get_S(T=298., units='J/mol/K') print('H_H2(T=298 K) = {:.1f} kJ/mol'.format(H_statmech)) print('S_H2(T=298 K) = {:.2f} J/mol/K'.format(S_statmech)) # If you specify the composition of your species, you can calculate per mass quantities too. # In[3]: '''Input composition''' H2_statmech.elements = {'H': 2} '''Calculate thermodynamic properties per mass basis''' H_statmech = H2_statmech.get_H(T=298., units='kJ/g')
def setUp(self): self.species_dict = { 'H2O': Nasa(name='H2O', T_low=200., T_mid=1000., T_high=3500., elements={ 'H': 2, 'O': 1 }, a_low=[ 4.19864056E+00, -2.03643410E-03, 6.52040211E-06, -5.48797062E-09, 1.77197817E-12, -3.02937267E+04, -8.49032208E-01 ], a_high=[ 3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04, 4.96677010E+00 ]), 'H2': Nasa(name='H2', T_low=200., T_mid=1000., T_high=3500., elements={'H': 2}, a_low=[ 2.34433112E+00, 7.98052075E-03, -1.94781510E-05, 2.01572094E-08, -7.37611761E-12, -9.17935173E+02, 6.83010238E-01 ], a_high=[ 3.33727920E+00, -4.94024731E-05, 4.99456778E-07, -1.79566394E-10, 2.00255376E-14, -9.50158922E+02, -3.20502331E+00 ]), 'O2': Nasa(name='O2', T_low=200., T_mid=1000., T_high=3500., elements={'O': 2}, a_low=[ 3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03, 3.65767573E+00 ], a_high=[ 3.28253784E+00, 1.48308754E-03, -7.57966669E-07, 2.09470555E-10, -2.16717794E-14, -1.08845772E+03, 5.45323129E+00 ]), 'O': Nasa(name='O', T_low=200., T_mid=1000., T_high=3500., elements={'O': 1}, a_low=[ 3.16826710E+00, -3.27931884E-03, 6.64306396E-06, -6.12806624E-09, 2.11265971E-12, 2.91222592E+04, 2.05193346E+00 ], a_high=[ 2.56942078E+00, -8.59741137E-05, 4.19484589E-08, -1.00177799E-11, 1.22833691E-15, 2.92175791E+04, 4.78433864E+00 ]), 'H': Nasa(name='H', T_low=200., T_mid=1000., T_high=3500., elements={'H': 1}, a_low=[ 2.50000000E+00, 7.05332819E-13, -1.99591964E-15, 2.30081632E-18, -9.27732332E-22, 2.54736599E+04, -4.46682853E-01 ], a_high=[ 2.50000001E+00, -2.30842973E-11, 1.61561948E-14, -4.73515235E-18, 4.98197357E-22, 2.54736599E+04, -4.46682914E-01 ]), 'OH': Nasa(name='OH', T_low=200., T_mid=1000., T_high=3500., elements={ 'O': 1, 'H': 1 }, a_high=[ 3.09288767E+00, 5.48429716E-04, 1.26505228E-07, -8.79461556E-11, 1.17412376E-14, 3.85865700E+03, 4.47669610E+00 ], a_low=[ 3.99201543E+00, -2.40131752E-03, 4.61793841E-06, -3.88113333E-09, 1.36411470E-12, 3.61508056E+03, -1.03925458E-01 ]) } self.reactions = Reactions(reactions=[ Reaction.from_string('O+2H=H2O', self.species_dict), Reaction.from_string('O+H2=H2O', self.species_dict), Reaction.from_string('OH+H=H2O', self.species_dict), Reaction.from_string('OH+0.5H2=H2O', self.species_dict), Reaction.from_string('0.5O+2H=H2O', self.species_dict), Reaction.from_string('0.5O2+H2=H2O', self.species_dict) ]) self.reactions_dict = { 'class': "<class 'pmutt.reaction.Reactions'>", 'reactions': [{ 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, 29217.5791, 4.78433864 ], 'a_low': [ 3.1682671, -0.00327931884, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, 29122.2592, 2.05193346 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 1 }, 'name': 'O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, 25473.6599, -0.446682914 ], 'a_low': [ 2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 25473.6599, -0.446682853 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 1 }, 'name': 'H', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'reactants_stoich': [1.0, 2.0], 'transition_state': None, 'transition_state_stoich': None }, { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, 29217.5791, 4.78433864 ], 'a_low': [ 3.1682671, -0.00327931884, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, 29122.2592, 2.05193346 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 1 }, 'name': 'O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331 ], 'a_low': [ 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2 }, 'name': 'H2', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'reactants_stoich': [1.0, 1.0], 'transition_state': None, 'transition_state_stoich': None }, { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.09288767, 0.000548429716, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, 3858.657, 4.4766961 ], 'a_low': [ 3.99201543, -0.00240131752, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, 3615.08056, -0.103925458 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 1, 'O': 1 }, 'name': 'OH', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, 25473.6599, -0.446682914 ], 'a_low': [ 2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 25473.6599, -0.446682853 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 1 }, 'name': 'H', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'reactants_stoich': [1.0, 1.0], 'transition_state': None, 'transition_state_stoich': None }, { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.09288767, 0.000548429716, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, 3858.657, 4.4766961 ], 'a_low': [ 3.99201543, -0.00240131752, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, 3615.08056, -0.103925458 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 1, 'O': 1 }, 'name': 'OH', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331 ], 'a_low': [ 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2 }, 'name': 'H2', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'reactants_stoich': [1.0, 0.5], 'transition_state': None, 'transition_state_stoich': None }, { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, 29217.5791, 4.78433864 ], 'a_low': [ 3.1682671, -0.00327931884, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, 29122.2592, 2.05193346 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 1 }, 'name': 'O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, 25473.6599, -0.446682914 ], 'a_low': [ 2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 25473.6599, -0.446682853 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 1 }, 'name': 'H', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'reactants_stoich': [0.5, 2.0], 'transition_state': None, 'transition_state_stoich': None }, { 'class': "<class 'pmutt.reaction.Reaction'>", 'products': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701 ], 'a_low': [ 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2, 'O': 1 }, 'name': 'H2O', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'products_stoich': [1.0], 'reactants': [{ 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, -1088.45772, 5.45323129 ], 'a_low': [ 3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, -1063.94356, 3.65767573 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'O': 2 }, 'name': 'O2', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }, { 'T_high': 3500.0, 'T_low': 200.0, 'T_mid': 1000.0, 'a_high': [ 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331 ], 'a_low': [ 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238 ], 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'elements': { 'H': 2 }, 'name': 'H2', 'notes': None, 'phase': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa', }], 'reactants_stoich': [0.5, 1.0], 'transition_state': None, 'transition_state_stoich': None }] } species_pathway = { 'A': StatMech(G=1., **presets['constant']), 'A_TS1': StatMech(G=3., **presets['constant']), 'A_TS2': StatMech(G=2., **presets['constant']), 'B': StatMech(G=-1., **presets['constant']), 'C': StatMech(G=2., **presets['constant']), 'C_TS': StatMech(G=2.5, **presets['constant']), 'D': StatMech(G=0., **presets['constant']), } self.rxn_pathway1 = Reactions(reactions=[ Reaction.from_string('A = A_TS1 = B', species_pathway), Reaction.from_string('B = C', species_pathway), Reaction.from_string('C = C_TS = D', species_pathway) ]) self.rxn_pathway2 = Reactions(reactions=[ Reaction.from_string('A = A_TS2 = B', species_pathway), Reaction.from_string('B = C', species_pathway), Reaction.from_string('C = C_TS = D', species_pathway) ])
O2_nasa = Nasa(name='O2', T_low=200., T_mid=1000., T_high=3500., elements={'O': 2}, a_low=np.array([ 3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03, 3.65767573E+00 ]), a_high=np.array([ 3.28253784E+00, 1.48308754E-03, -7.57966669E-07, 2.09470555E-10, -2.16717794E-14, -1.08845772E+03, 5.45323129E+00 ])) H2_shomate = Shomate(name='H2', T_low=298., T_high=1000., a=np.array([ 33.066178, -11.363417, 11.432816, -2.772874, -0.158558, -9.980797, 172.707974, 0. ])) H2O_statmech = StatMech(atoms=molecule('H2O'), potentialenergy=-6.7598, symmetrynumber=2, spin=0, vib_wavenumbers=[3825.434, 3710.264, 1582.432], **presets['idealgas'])