def read_thermdat(filename): """Directly read thermdat file that is in the Chemkin format Parameters ---------- filename : str Input filename Returns ------- Nasas : list of :class:`~pmutt.empirical.nasa.Nasa` Raises ------ FileNotFoundError If the file isn't found. IOError Invalid line number found. """ species = [] with open(filename, 'r') as f_ptr: for line in f_ptr: ''' Lines to skip ''' # Skip the header line if 'THERMO' in line: continue # Skip the end line if 'END' in line: continue # Skip blank lines if line == '\n': continue # Skip comment lines if line[0] == '!': continue # Skip header temperatures if _is_temperature_header(line): continue ''' Parse lines ''' line_num = _read_line_num(line) if line_num == 1: nasa_data = _read_line1(line) elif line_num == 2: nasa_data = _read_line2(line, nasa_data) elif line_num == 3: nasa_data = _read_line3(line, nasa_data) elif line_num == 4: nasa_data = _read_line4(line, nasa_data) species.append(Nasa(**nasa_data)) else: raise IOError('Invalid line number, {}, in thermdat file: {}' .format(line_num, filename)) return species
class TestNasa(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.Nasa_direct = Nasa( name='H2O', elements={'H': 2, 'O': 1}, phase='g', a_low=np.array([4.04618796E+00, -6.87238823E-04, 2.79722240E-06, -1.42318006E-09, 2.34551159E-13, -3.02826236E+04, -2.50036531E-01]), a_high=np.array([2.41854323E+00, 3.35448922E-03, -9.66398101E-07, 1.34441829E-10, -7.18940063E-15, -2.97582484E+04, 8.37839787E+00]), T_low=100., T_mid=1610.97, T_high=5000. ) self.Nasa_direct_dict = { 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'name': 'H2O', 'elements': {'H': 2, 'O': 1}, 'phase': 'g', 'a_low': [4.04618796E+00, -6.87238823E-04, 2.79722240E-06, -1.42318006E-09, 2.34551159E-13, -3.02826236E+04, -2.50036531E-01], 'a_high': [2.41854323E+00, 3.35448922E-03, -9.66398101E-07, 1.34441829E-10, -7.18940063E-15, -2.97582484E+04, 8.37839787E+00], 'T_low': 100., 'T_mid': 1610.97, 'T_high': 5000., 'notes': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' } self.Nasa_data = Nasa.from_data( name='H2O', elements={'H': 2, 'O': 1}, phase='g', T=np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]), CpoR=np.array([4.238636088, 4.363835667, 4.503924733, 4.654023202, 4.809813915, 4.967542636, 5.124018051, 5.276611768, 5.423258319, 5.56245516, 5.693262665, 5.815304137, 5.928750505, 6.034087273, 6.131819121, 6.222433488, 6.306400563, 6.384173277]), T_ref=500., HoRT_ref=-56.49930957, SoR_ref=24.84583501 ) self.Nasa_statmech = Nasa.from_statmech( name='H2O', elements={'H': 2, 'O': 1}, phase='g', statmech_model=StatMech, trans_model=trans.FreeTrans, n_degrees=3, vib_model=vib.HarmonicVib, elec_model=elec.GroundStateElec, rot_model=rot.RigidRotor, potentialenergy=-14.2209, atoms=molecule('H2O'), symmetrynumber=2, spin=0, vib_wavenumbers=np.array([0.47462, 0.46033, 0.19633]), T_low=100., T_mid=1610.97, T_high=5000. ) def test_get_a(self): np.testing.assert_array_equal(self.Nasa_direct.get_a(T=300.), self.Nasa_direct.a_low) np.testing.assert_array_equal(self.Nasa_direct.get_a(T=2000.), self.Nasa_direct.a_high) with self.assertWarns(RuntimeWarning): np.testing.assert_array_equal(self.Nasa_direct.get_a(T=6000.), self.Nasa_direct.a_high) with self.assertWarns(RuntimeWarning): np.testing.assert_array_equal(self.Nasa_direct.get_a(T=50.), self.Nasa_direct.a_low) def test_get_CpoR(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) CpoR_expected = np.array([4.238636088, 4.363835667, 4.503924733, 4.654023202, 4.809813915, 4.967542636, 5.124018051, 5.276611768, 5.423258319, 5.56245516, 5.693262665, 5.815304137, 5.928750505, 6.034087273, 6.131819121, 6.222433488, 6.306400563, 6.384173277]) np.testing.assert_almost_equal(self.Nasa_direct.get_CpoR(T=T[0]), CpoR_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_CpoR(T=T), CpoR_expected) def test_get_Cp(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) Cp_expected = c.R('J/mol/K') *\ np.array([4.238636088, 4.363835667, 4.503924733, 4.654023202, 4.809813915, 4.967542636, 5.124018051, 5.276611768, 5.423258319, 5.56245516, 5.693262665, 5.815304137, 5.928750505, 6.034087273, 6.131819121, 6.222433488, 6.306400563, 6.384173277]) np.testing.assert_almost_equal(self.Nasa_direct.get_Cp(T=T[0], units='J/mol/K'), Cp_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_Cp(T=T, units='J/mol/K'), Cp_expected) def test_get_HoRT(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) HoRT_expected = np.array([-56.49930957, -46.36612849, -39.10913137, -33.64819891, -29.38377578, -25.95653237, -23.13812007, -20.77654898, -18.76677584, -17.03389718, -15.52306522, -14.19318522, -13.01283758, -11.95756475, -11.00803153, -10.14874498, -9.367140366, -8.652916499]) np.testing.assert_almost_equal(self.Nasa_direct.get_HoRT(T=T[0]), HoRT_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_HoRT(T=T), HoRT_expected) def test_get_H(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) H_expected = c.R('J/mol/K')*T *\ np.array([-56.49930957, -46.36612849, -39.10913137, -33.64819891, -29.38377578, -25.95653237, -23.13812007, -20.77654898, -18.76677584, -17.03389718, -15.52306522, -14.19318522, -13.01283758, -11.95756475, -11.00803153, -10.14874498, -9.367140366, -8.652916499]) np.testing.assert_almost_equal(self.Nasa_direct.get_H(T=T[0], units='J/mol'), H_expected[0], decimal=4) np.testing.assert_array_almost_equal(self.Nasa_direct.get_H(T=T, units='J/mol'), H_expected, decimal=4) def test_get_SoR(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) SoR_expected = np.array([24.84583501, 25.62943045, 26.31248017, 26.92360771, 27.48073089, 27.99565652, 28.47647349, 28.92890014, 29.35709049, 29.76414079, 30.15242096, 30.52379873, 30.87979567, 31.22169282, 31.55059054, 31.86744523, 32.17309661, 32.46828858]) np.testing.assert_almost_equal(self.Nasa_direct.get_SoR(T=T[0]), SoR_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_SoR(T=T), SoR_expected) def test_get_S(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) S_expected = c.R('J/mol/K') *\ np.array([24.84583501, 25.62943045, 26.31248017, 26.92360771, 27.48073089, 27.99565652, 28.47647349, 28.92890014, 29.35709049, 29.76414079, 30.15242096, 30.52379873, 30.87979567, 31.22169282, 31.55059054, 31.86744523, 32.17309661, 32.46828858]) np.testing.assert_almost_equal(self.Nasa_direct.get_S(T=T[0], units='J/mol/K'), S_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_S(T=T, units='J/mol/K'), S_expected) def test_get_GoRT(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) HoRT_expected = np.array([-56.49930957, -46.36612849, -39.10913137, -33.64819891, -29.38377578, -25.95653237, -23.13812007, -20.77654898, -18.76677584, -17.03389718, -15.52306522, -14.19318522, -13.01283758, -11.95756475, -11.00803153, -10.14874498, -9.367140366, -8.652916499]) SoR_expected = np.array([24.84583501, 25.62943045, 26.31248017, 26.92360771, 27.48073089, 27.99565652, 28.47647349, 28.92890014, 29.35709049, 29.76414079, 30.15242096, 30.52379873, 30.87979567, 31.22169282, 31.55059054, 31.86744523, 32.17309661, 32.46828858]) GoRT_expected = HoRT_expected - SoR_expected np.testing.assert_almost_equal(self.Nasa_direct.get_GoRT(T=T[0]), GoRT_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_GoRT(T=T), GoRT_expected) def test_get_G(self): T = np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]) HoRT_expected = np.array([-56.49930957, -46.36612849, -39.10913137, -33.64819891, -29.38377578, -25.95653237, -23.13812007, -20.77654898, -18.76677584, -17.03389718, -15.52306522, -14.19318522, -13.01283758, -11.95756475, -11.00803153, -10.14874498, -9.367140366, -8.652916499]) SoR_expected = np.array([24.84583501, 25.62943045, 26.31248017, 26.92360771, 27.48073089, 27.99565652, 28.47647349, 28.92890014, 29.35709049, 29.76414079, 30.15242096, 30.52379873, 30.87979567, 31.22169282, 31.55059054, 31.86744523, 32.17309661, 32.46828858]) GoRT_expected = HoRT_expected - SoR_expected np.testing.assert_almost_equal(self.Nasa_direct.get_GoRT(T=T[0]), GoRT_expected[0]) np.testing.assert_array_almost_equal(self.Nasa_direct.get_GoRT(T=T), GoRT_expected) def test_to_dict(self): self.maxDiff = None self.assertEqual(self.Nasa_direct.to_dict(), self.Nasa_direct_dict) def test_from_dict(self): self.assertEqual(Nasa.from_dict(self.Nasa_direct_dict), self.Nasa_direct)
def test_from_dict(self): self.assertEqual(Nasa.from_dict(self.Nasa_direct_dict), self.Nasa_direct)
# ### NASA polynomial # The [``NASA``][0] format is used for our microkinetic modeling software, Chemkin. # # #### Initializing Nasa from StatMech # Below, we initialize the NASA polynomial from the ``StatMech`` object we created earlier. # # [0]: https://vlachosgroup.github.io/pmutt/empirical.html#nasa # In[6]: from pmutt.empirical.nasa import Nasa butane_nasa = Nasa.from_statmech(name='butane', statmech_model=butane_statmech, T_low=298., T_high=800., elements={'C': 4, 'H': 10}, phase='G') H_nasa = butane_nasa.get_H(T=298., units='kJ/mol') S_nasa = butane_nasa.get_S(T=298., units='J/mol/K') print('H_butane(T=298) = {:.1f} kJ/mol'.format(H_nasa)) print('S_butane(T=298) = {:.2f} J/mol/K'.format(S_nasa)) # Although it is not covered here, you can also generate empirical objects from experimental data using the ``.from_data`` method. See [Experimental to Empirical][6] example. # # [6]: https://vlachosgroup.github.io/pmutt/examples.html#experimental-to-empirical # #### Initializing Nasa Directly # We can also initialize the NASA polynomial if we have the polynomials. Using an entry from the [Reaction Mechanism Generator (RMG) database][0].
# # This can be translated to pMuTT syntax using: # In[9]: from pmutt.empirical.nasa import Nasa # Initialize NASA polynomial H2_nasa = Nasa(name='H2', elements={'H': 2}, phase='G', T_low=200., T_mid=1000., T_high=3500., 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 ]) # Calculate thermodynamic quantities using the same syntax as StatMech H_H2 = H2_nasa.get_H(units='kcal/mol', T=298.) print('H_H2(T=298 K) = {} kcal/mol'.format(H_H2)) # Show thermodynamic quantities vs. T T = np.linspace(200., 3500.) f2, ax2 = plot_1D(H2_nasa,
def read_thermdat(filename, format='list', key='name'): """Directly read thermdat file that is in the Chemkin format Parameters ---------- filename : str Input filename format : str, optional Format to output NASA polynomials. Supported options are: 'list', 'tuple', 'dict'. Default is 'list' key : str, optional If `format` is 'dict', uses this attribute as the key for the output dictionary. Default is 'name' Returns ------- Nasas : list, tuple or dict of :class:`~pmutt.empirical.nasa.Nasa` Raises ------ FileNotFoundError If the file isn't found. IOError Invalid line number found. """ species = [] with open(filename, 'r') as f_ptr: for line in f_ptr: ''' Lines to skip ''' # Skip the header line if 'THERMO' in line: continue # Skip the end line if 'END' in line: continue # Skip blank lines if line == '\n': continue # Skip comment lines if line[0] == '!': continue # Skip header temperatures if _is_temperature_header(line): continue ''' Parse lines ''' line_num = _read_line_num(line) if line_num == 1: nasa_data = _read_line1(line) elif line_num == 2: nasa_data = _read_line2(line, nasa_data) elif line_num == 3: nasa_data = _read_line3(line, nasa_data) elif line_num == 4: nasa_data = _read_line4(line, nasa_data) species.append(Nasa(**nasa_data)) else: err_msg = ('Invalid line number, {}, in thermdat file: {}' ''.format(line_num, filename)) raise IOError(err_msg) # Format the NASA polynomials in the required format if format == 'list': pass elif format == 'tuple': species = tuple(species) elif format == 'dict': species = pmutt_list_to_dict(species, key=key) else: err_msg = ( 'Unsupported format: {}. See pmutt.io.thermdat.read_thermdat' ' docstring for supported formats.'.format(format)) raise ValueError(err_msg) return species
from ase.build import molecule from pmutt.empirical.nasa import Nasa from pmutt.empirical.references import Reference, References from pmutt.empirical.shomate import Shomate from pmutt.reaction import Reaction, Reactions from pmutt.statmech import StatMech, presets O2_nasa = Nasa(name='O2', T_low=200., T_mid=1000., T_high=3500., elements={'O': 2}, phase='G', 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., phase='G', elements={'H': 2}, a=np.array([ 33.066178, -11.363417, 11.432816, -2.772874,
# The ``References`` object calculated the offset between C, H, and O. # ## Initialize the Nasa objects # The ``from_statmech`` method allows us to initialize the Nasa objects from the data. # In[4]: from pmutt.empirical.nasa import Nasa T_low = 300. # K T_high = 1100. # K species = [Nasa.from_statmech(references=refs, T_low=T_low, T_high=T_high, **specie_data) for specie_data in species_data] # Printing an example of a Nasa species print(species[0]) # ## Writing Nasa objects to a Thermdat file # In[5]: from pmutt.io.thermdat import write_thermdat write_thermdat(nasa_species=species, filename='thermdat', write_date=True)
# In[3]: from pmutt.empirical.nasa import Nasa # Lower and higher temperatures T_low = 298. # K T_high = 800. # K species_data = read_excel(io=input_path, sheet_name='species') species = [] species_phases = {} for ind_species_data in species_data: # Initialize NASA from statistical mechanical data ind_species = Nasa.from_model(T_low=T_low, T_high=T_high, references=refs, **ind_species_data) species.append(ind_species) # Group the species by phase for later use try: species_phases[ind_species.phase].append(ind_species) except KeyError: species_phases[ind_species.phase] = [ind_species] # ### Adding species from other empirical sources # In[4]: import numpy as np from pmutt.empirical.shomate import Shomate
'The "refs" sheet could not be found in {}. Skiping references'.format( input_path)) refs = None else: refs = [Reference(**ref_data) for ref_data in refs_data] refs = References(references=refs) # ### Reading Species # # Third, we will use the ``refs`` defined before and the ``species`` sheet to convert statistical mechanical data to [``NASA``](https://vlachosgroup.github.io/pMuTT/api/empirical/nasa/pmutt.empirical.nasa.Nasa.html#pmutt.empirical.nasa.Nasa) objects. # Read the species' data species_data = read_excel(io=input_path, sheet_name='species') # Create NASA polynomials from the species species = [ Nasa.from_model(references=refs, **ind_species_data) for ind_species_data in species_data ] # ### Adding species from other empirical sources (optional) # # Note that OpenMKM also supports [``Shomate``](https://vlachosgroup.github.io/pMuTT/api/empirical/shomate/pmutt.empirical.shomate.Shomate.html#pmutt.empirical.shomate.Shomate) and [``NASA9``](https://vlachosgroup.github.io/pMuTT/api/empirical/nasa/pmutt.empirical.nasa.Nasa9.html) objects. Below, we define a single ``Shomate`` species. Ar = Shomate(name='Ar', elements={'Ar': 1}, phase='gas', T_low=298., T_high=6000., a=np.array([ 20.78600, 2.825911e-7, -1.464191e-7, 1.092131e-8, -3.661371e-8, -6.19735, 179.999, 0. ]))
# ### Reading species # In[9]: from pmutt.empirical.nasa import Nasa # Range of data to fit the Nasa polynomials T_low = 298. # K T_high = 800. # K species_data = read_excel(io=excel_path, sheet_name='species') species = [] for specie_data in species_data: specie = Nasa.from_model(T_low=T_low, T_high=T_high, references=refs, **specie_data) # If the species is a surface species, assign the catalyst site specified above if specie.phase.lower() == 's': specie.cat_site = cat_site specie.n_sites = 1 species.append(specie) # The warning above is typical when empirical objects are fitting to `StatMech` objects with the `placeholder` preset. # ### Reading reactions # In[10]: from pmutt import pmutt_list_to_dict
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)
def setUp(self): unittest.TestCase.setUp(self) self.Nasa_direct = Nasa( name='H2O', elements={'H': 2, 'O': 1}, phase='g', a_low=np.array([4.04618796E+00, -6.87238823E-04, 2.79722240E-06, -1.42318006E-09, 2.34551159E-13, -3.02826236E+04, -2.50036531E-01]), a_high=np.array([2.41854323E+00, 3.35448922E-03, -9.66398101E-07, 1.34441829E-10, -7.18940063E-15, -2.97582484E+04, 8.37839787E+00]), T_low=100., T_mid=1610.97, T_high=5000. ) self.Nasa_direct_dict = { 'class': "<class 'pmutt.empirical.nasa.Nasa'>", 'name': 'H2O', 'elements': {'H': 2, 'O': 1}, 'phase': 'g', 'a_low': [4.04618796E+00, -6.87238823E-04, 2.79722240E-06, -1.42318006E-09, 2.34551159E-13, -3.02826236E+04, -2.50036531E-01], 'a_high': [2.41854323E+00, 3.35448922E-03, -9.66398101E-07, 1.34441829E-10, -7.18940063E-15, -2.97582484E+04, 8.37839787E+00], 'T_low': 100., 'T_mid': 1610.97, 'T_high': 5000., 'notes': None, 'statmech_model': None, 'misc_models': None, 'cat_site': None, 'n_sites': None, 'smiles': None, 'type': 'nasa' } self.Nasa_data = Nasa.from_data( name='H2O', elements={'H': 2, 'O': 1}, phase='g', T=np.array([500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000., 2100., 2200]), CpoR=np.array([4.238636088, 4.363835667, 4.503924733, 4.654023202, 4.809813915, 4.967542636, 5.124018051, 5.276611768, 5.423258319, 5.56245516, 5.693262665, 5.815304137, 5.928750505, 6.034087273, 6.131819121, 6.222433488, 6.306400563, 6.384173277]), T_ref=500., HoRT_ref=-56.49930957, SoR_ref=24.84583501 ) self.Nasa_statmech = Nasa.from_statmech( name='H2O', elements={'H': 2, 'O': 1}, phase='g', statmech_model=StatMech, trans_model=trans.FreeTrans, n_degrees=3, vib_model=vib.HarmonicVib, elec_model=elec.GroundStateElec, rot_model=rot.RigidRotor, potentialenergy=-14.2209, atoms=molecule('H2O'), symmetrynumber=2, spin=0, vib_wavenumbers=np.array([0.47462, 0.46033, 0.19633]), T_low=100., T_mid=1610.97, T_high=5000. )
# ### Reading species # In[3]: from pmutt.empirical.nasa import Nasa # Range of data to fit the Nasa polynomials T_low = 298. # K T_high = 800. # K species_data = read_excel(io=excel_path, sheet_name='species') species = [] for specie_data in species_data: specie = Nasa.from_statmech(T_low=T_low, T_high=T_high, references=refs, **specie_data) # If the species is a surface species, assign the catalyst site specified above if specie.phase.lower() == 's': specie.cat_site = cat_site specie.n_sites = 1 species.append(specie) # The warning above is typical when empirical objects are fitting to `StatMech` objects with the `placeholder` preset. # ### Reading reactions # In[4]: from pmutt import pmutt_list_to_dict from pmutt.reaction import ChemkinReaction, Reactions
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) ])
]) 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, T_ref=T_ref, HoRT_ref=HoRT_FeO, SoR_ref=SoR_FeO), 'Fe3O4': Nasa.from_data(name='Fe3O4', T=T, CpoR=CpoR_Fe3O4, T_ref=T_ref, HoRT_ref=HoRT_Fe3O4,