Exemple #1
0
    def get_enthalpy(self, temperature=T_std, electronic_energy='Default'):
        """Returns the internal energy of an adsorbed molecule.

        Parameters
        ----------
        temperature : numeric
        temperature in K
        electronic_energy : numeric
        energy in eV


        Returns
        -------
        internal_energy : numeric
        Internal energy in eV
        """
        if not temperature:  # either None or 0
            return (0, 0, 0)
        if electronic_energy == 'Default':
            electronic_energy = molecule_dict[self.name]['electronic_energy']
        else:
            ideal_gas_object = IdealGasThermo(
                vib_energies=self.get_vib_energies(),
                potentialenergy=electronic_energy,
                atoms=self.atom_object,
                geometry=molecule_dict[self.name]['geometry'],
                symmetrynumber=molecule_dict[self.name]['symmetrynumber'],
                spin=molecule_dict[self.name]['spin'])
            energy = ideal_gas_object.get_enthalpy(temperature=temperature,
                                                   verbose=False)
            self.enthalpy = energy
            return (self.enthalpy)
Exemple #2
0
                      potentialenergy=E_H2, atoms=H2,
                      geometry='linear', symmetrynumber=2,
                      spin=0)
H2O_t = IdealGasThermo(vib_energies=H2O_vib_energies[0:3],
                      potentialenergy=E_H2O, atoms=H2O,
                      geometry='nonlinear', symmetrynumber=2,
                      spin=0)
# now we can compute G_rxn for a range of temperatures from 298 to 1000 K
Trange = np.linspace(298, 1000, 20)  # K
P = 101325. # Pa
Grxn = np.array([(CO2_t.get_gibbs_energy(temperature=T, pressure=P)
                  + H2_t.get_gibbs_energy(temperature=T, pressure=P)
                  - H2O_t.get_gibbs_energy(temperature=T, pressure=P)
                  - CO_t.get_gibbs_energy(temperature=T, pressure=P)) * 96.485
                 for T in Trange])
Hrxn = np.array([(CO2_t.get_enthalpy(temperature=T)
                  + H2_t.get_enthalpy(temperature=T)
                  - H2O_t.get_enthalpy(temperature=T)
                  - CO_t.get_enthalpy(temperature=T)) * 96.485
                 for T in Trange])
plt.plot(Trange, Grxn, 'bo-', label='$\Delta G_{rxn}$')
plt.plot(Trange, Hrxn, 'ro:', label='$\Delta H_{rxn}$')
plt.xlabel('Temperature (K)')
plt.ylabel(r'$\Delta G_{rxn}$ (kJ/mol)')
plt.legend(loc='best')
plt.savefig('images/wgs-dG-T.png')
plt.figure()
R = 8.314e-3  # gas constant in kJ/mol/K
Keq = np.exp(-Grxn/R/Trange)
plt.plot(Trange, Keq)
plt.ylim([0, 100])
class TestStatMech(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        # Testing Ideal Gas Model
        CO2 = molecule('CO2')
        CO2_pMuTT_parameters = {
            'name': 'CO2',

            'trans_model': trans.IdealTrans,
            '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.IdealElec,
            '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)
                             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')

    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.083051624373337e+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'))

    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'))

    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)

    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)

    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)

    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)

    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.5899966269182)

    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.5899966269182*c.R('J/mol/K')*self.T0)

    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, 5)
Exemple #4
0
H2O_t = IdealGasThermo(vib_energies=H2O_vib_energies[0:3],
                       potentialenergy=E_H2O,
                       atoms=H2O,
                       geometry='nonlinear',
                       symmetrynumber=2,
                       spin=0)
# now we can compute G_rxn for a range of temperatures from 298 to 1000 K
Trange = np.linspace(298, 1000, 20)  # K
P = 101325.  # Pa
Grxn = np.array([(CO2_t.get_gibbs_energy(temperature=T, pressure=P) +
                  H2_t.get_gibbs_energy(temperature=T, pressure=P) -
                  H2O_t.get_gibbs_energy(temperature=T, pressure=P) -
                  CO_t.get_gibbs_energy(temperature=T, pressure=P)) * 96.485
                 for T in Trange])
Hrxn = np.array([
    (CO2_t.get_enthalpy(temperature=T) + H2_t.get_enthalpy(temperature=T) -
     H2O_t.get_enthalpy(temperature=T) - CO_t.get_enthalpy(temperature=T)) *
    96.485 for T in Trange
])
plt.plot(Trange, Grxn, 'bo-', label='$\Delta G_{rxn}$')
plt.plot(Trange, Hrxn, 'ro:', label='$\Delta H_{rxn}$')
plt.xlabel('Temperature (K)')
plt.ylabel(r'$\Delta G_{rxn}$ (kJ/mol)')
plt.legend(loc='best')
plt.savefig('images/wgs-dG-T.png')
plt.figure()
R = 8.314e-3  # gas constant in kJ/mol/K
Keq = np.exp(-Grxn / R / Trange)
plt.plot(Trange, Keq)
plt.ylim([0, 100])
plt.xlabel('Temperature (K)')
Exemple #5
0
from ase.thermochemistry import IdealGasThermo
from ase import Atoms
mat.rcParams['mathtext.default'] = 'regular'
mat.rcParams['legend.numpoints'] = 1
mat.rcParams['lines.linewidth'] = 3
mat.rcParams['lines.markersize'] = 20
c = 29979245800 #cm/s
h = 6.6260693*10**(-34) #planks constant
kB = 1.3806505*10**(-23) #boltzman's constant
JeV = 1.60217653*10**(-19) #eV to Joules
COr = (0.51388868234-0.486111317659)*41.3427602451982
COfreq = 0.260119879
CO = Atoms('CO')
CO[1].z = COr
COThermo = IdealGasThermo([COfreq],'linear',atoms=CO,symmetrynumber=1,spin=0,natoms=2)
COh100 = COThermo.get_enthalpy(100)
COh100 = COThermo.get_enthalpy(145)
COh100 = COThermo.get_enthalpy(130)
COh100 = COThermo.get_enthalpy(420)
COh100 = COThermo.get_enthalpy(350)
COh100 = COThermo.get_enthalpy(450)
COh100 = COThermo.get_enthalpy(340)
COh100 = COThermo.get_enthalpy(500)

H_Ag=np.array([234.060289,22.823011,16.915597,16.786227,3.576371,2.197334])*8.06573
vibAg = statmech.vibenergy(H_Ag,100)
print(vibAg)
H_Cu=np.array([223.437829,31.524364,27.338489,27.112873,13.374554,12.939494])*8.06573
vibCu = statmech.vibenergy(H_Cu,130)
print(vibCu)
H_Ir=np.array([211.367202,44.397834,31.685160,30.837878,18.670770,17.712435])*8.06573
Exemple #6
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 25 14:20:17 2016
 
@author: lansford
 
"""
from __future__ import division
from ase.thermochemistry import IdealGasThermo
from ase import Atoms
OOH = Atoms('OOH')
OOHfreqs = [.484418503,.146088952,.003153291,.002971872]
OOHThermo = IdealGasThermo(OOHfreqs,'linear',atoms=OOH,symmetrynumber=1,spin=0.5,natoms=3)
OOHgibbs = OOHThermo.get_gibbs_energy(298,101325);
OOHZPE = OOHThermo.get_enthalpy(0);
print(OOHgibbs)
print(OOHZPE)
    for i in freq_remove:
        if i in Freq:
            Freq.remove(i)

## get the strucuter from the output file
struc = read(log_file,format='gaussian-out')

## get the ideal gas limit thermodynamic values
thermo = IdealGasThermo(vib_energies=Freq, potentialenergy=scf_energy_eV,
                        atoms=struc, geometry=shape,
                        symmetrynumber=symnum, spin=spin)

print "Ideal Gas Limit"

ZPE = thermo.get_ZPE_correction()
H = thermo.get_enthalpy(temperature=temp)
S = thermo.get_entropy(temperature=temp,pressure=pres)
G = thermo.get_gibbs_energy(temperature=temp,pressure=pres)

print " "
print "ZPE correction (ZPE) = ", ZPE, " eV"
print "Ethalpy (H) = ", H, " eV"
print "Entropy (S) = ", S, " eV/K"
print "Gibbs Energy (G) = ", G, " eV"

## get the harmonic limit thermodynamic values
thermo = HarmonicThermo(vib_energies=Freq, potentialenergy=scf_energy_eV)

print
print "Harmonic Approximation"
class TestStatMech(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        # Testing Ideal Gas Model
        CO2 = molecule('CO2')
        CO2_PyMuTT_parameters = {
            'trans_model':
            trans.IdealTrans,
            '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.IdealElec,
            '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) \
                for x in CO2_PyMuTT_parameters['vib_wavenumbers']],
            'geometry':'linear',
            'symmetrynumber': 2,
            'spin': 0.
        }
        self.CO2_PyMuTT = StatMech(**CO2_PyMuTT_parameters)
        self.CO2_ASE = IdealGasThermo(**CO2_ase_parameters)

        self.T0 = c.T0('K')  # K
        self.P0 = c.P0('Pa')
        self.V0 = c.V0('m3')

    def test_get_q(self):
        self.assertAlmostEqual(
            self.CO2_PyMuTT.get_q(T=self.T0, ignore_q_elec=True, V=self.V0),
            6.083051624373337e+25)

    def test_get_CvoR(self):
        self.assertAlmostEqual(self.CO2_PyMuTT.get_CvoR(T=self.T0, V=self.V0),
                               2.9422622359004853)

    def test_get_CpoR(self):
        self.assertAlmostEqual(self.CO2_PyMuTT.get_CpoR(T=self.T0, V=self.V0),
                               3.9422622359004853)

    def test_get_UoRT(self):
        self.assertAlmostEqual(self.CO2_PyMuTT.get_UoRT(T=self.T0, V=self.V0),
                               -875.1095022368354)

    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_PyMuTT.get_HoRT(T=self.T0)
        self.assertTrue(np.isclose(expected_HoRT_CO2, calc_HoRT_CO2))

    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_PyMuTT.get_SoR(T=self.T0, V=self.V0)
        self.assertTrue(np.isclose(expected_SoR_CO2, calc_SoR_CO2))

    def test_get_AoRT(self):
        self.assertAlmostEqual(self.CO2_PyMuTT.get_AoRT(T=self.T0, V=self.V0),
                               -900.5899966269182)

    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_PyMuTT.get_GoRT(T=self.T0, V=self.V0)
        self.assertTrue(np.isclose(expected_GoRT_CO2, calc_GoRT_CO2))
Exemple #9
0
H2_t = IdealGasThermo(vib_energies=H2_vib_energies[0:0],
                      electronicenergy=E_H2, atoms=H2,
                      geometry='linear', symmetrynumber=2,
                      spin=0)
H2O_t = IdealGasThermo(vib_energies=H2O_vib_energies[0:3],
                      electronicenergy=E_H2O, atoms=H2O,
                      geometry='nonlinear', symmetrynumber=2,
                      spin=0)
# now we can compute G_rxn for a range of temperatures from 298 to 1000 K
Trange = np.linspace(298,1000,20) #K
P = 101325. # Pa
Grxn = np.array([(CO2_t.get_free_energy(temperature=T, pressure=P)
                  + H2_t.get_free_energy(temperature=T, pressure=P)
                  - H2O_t.get_free_energy(temperature=T, pressure=P)
                  - CO_t.get_free_energy(temperature=T, pressure=P))*96.485 for T in Trange])
Hrxn = np.array([(CO2_t.get_enthalpy(temperature=T)
                  + H2_t.get_enthalpy(temperature=T)
                  - H2O_t.get_enthalpy(temperature=T)
                  - CO_t.get_enthalpy(temperature=T))*96.485 for T in Trange])
plt.plot(Trange, Grxn, 'bo-',label='$\Delta G_{rxn}$')
plt.plot(Trange, Hrxn, 'ro:',label='$\Delta H_{rxn}$')
plt.xlabel('Temperature (K)')
plt.ylabel('$\Delta G_{rxn}$ (kJ/mol)')
plt.legend(loc='best')
plt.savefig('images/wgs-dG-T.png')
plt.figure()
R = 8.314e-3 # gas constant in kJ/mol/K
Keq = np.exp(-Grxn/R/Trange)
plt.plot(Trange, Keq)
plt.ylim([0, 100])
plt.xlabel('Temperature (K)')