Ejemplo n.º 1
0
# 
# ## Files Required
# - [thermdat](thermdat) Thermdat file used to initialize ``Nasa`` species

# ## Initialize Species Used For Reaction
# First, we need to describe our species as pMuTT objects. For this example, we will be importing the thermdat from the [combustion database by Berkeley](http://combustion.berkeley.edu/gri_mech/version30/files30/thermo30.dat). We will store the species in a dictionary for code clarity later on.

# In[1]:


from pprint import pprint
from pMuTT.io_.thermdat import read_thermdat
from pMuTT import pMuTT_list_to_dict

# The output will be a list
species_list = read_thermdat(filename='thermdat')

# This function converts the list to a dict for easier usage downstream
species_dict = pMuTT_list_to_dict(pMuTT_list=species_list, key='name')

# (Optional) Print the species_dict to see what's in it
pprint(species_dict)


# To calculate transition state properties, we will need to represent the transition state species as a pMuTT object. For this example, we will create a new ``Nasa`` object based on the H2O entry but modify the a6 parameter arbitrarily to give it a higher enthalpy.

# In[2]:


from copy import deepcopy
Ejemplo n.º 2
0
import os
import json

import numpy as np
from matplotlib import pyplot as plt

from pMuTT import pMuTT_list_to_dict
from pMuTT.reaction import Reaction
from pMuTT.io_.thermdat import read_thermdat
from pMuTT.io_.excel import read_excel
from pMuTT.io_.json import pMuTTEncoder

os.chdir(os.path.dirname(__file__))

'''Read species'''
nasa_species = read_thermdat('thermdat')
nasa_dict = pMuTT_list_to_dict(nasa_species)

'''Read reactions'''
rxns_data = read_excel('reactions.xlsx')
rxns = [Reaction.from_string(species=nasa_dict, **rxn_data) for rxn_data in rxns_data]

'''Save reactions as json'''
with open('reactions.json', 'w') as f_ptr:
    json.dump(rxns, f_ptr, cls=pMuTTEncoder, indent=True)

'''
Get thermodynamics from Reaction
'''
T = np.linspace(200., 3500.)
for rxn in rxns:
import os
import numpy as np
from matplotlib import pyplot as plt
from pMuTT.io_.thermdat import read_thermdat
from pMuTT import pMuTT_list_to_dict
from pMuTT import reaction as rxn

'''
Read the thermdat
'''
base_path = os.path.dirname(__file__)
nasa_list = read_thermdat(os.path.join(base_path, 'thermdat'))
nasa_dict = pMuTT_list_to_dict(nasa_list, key='name')

'''
Create the reaction object
'''
reaction_str = 'H2+0.5O2=H2O'
rxn_nasa = rxn.Reaction.from_string(reaction_str=reaction_str,
                                    species=nasa_dict)

'''
Check that the equation is balanced
'''
rxn_nasa.check_element_balance()

'''
Get thermodynamics from Reaction
'''
T = np.linspace(200., 3500.)
HoRT_rxn = rxn_nasa.get_delta_HoRT(T=T)
Ejemplo n.º 4
0
import os
import json
import numpy as np
from matplotlib import pyplot as plt
from pMuTT.io_.thermdat import read_thermdat
from pMuTT.io_.json import pMuTTEncoder, json_to_pMuTT

base_path = os.path.dirname(__file__)
thermdat_path = os.path.join(base_path, 'thermdat')
json_path = os.path.join(base_path, 'nasa_obj.json')
'''
Loading thermdat file
'''
# Thermdat file from
# http://combustion.berkeley.edu/gri_mech/version30/files30/thermo30.dat
species = read_thermdat(thermdat_path)
'''
Saving and Loading from JSON
'''
with open(json_path, 'w') as f_ptr:
    json.dump(species, f_ptr, cls=pMuTTEncoder, indent=True)

with open(json_path, 'r') as f_ptr:
    species_json = json.load(f_ptr, object_hook=json_to_pMuTT)
'''
Plotting to ensure the object was written and read correctly
'''
for specie, specie_json in zip(species, species_json):
    T = np.linspace(specie.T_low, specie.T_high)
    plt.figure()
    f, ax = plt.subplots(4, sharex=True)
Ejemplo n.º 5
0
# 
# [0]: https://vlachosgroup.github.io/pMuTT/io.html#pMuTT.io_.thermdat.read_thermdat

# ## Reactions
# You can also evaluate reactions properties. The most straightforward way to do this is to initialize using strings.

# In[15]:


from pMuTT.io_.thermdat import read_thermdat
from pMuTT import pMuTT_list_to_dict
from pMuTT.reaction import Reaction

# Get a dictionary of species
thermdat_H2O_path = os.path.join(notebook_folder, 'thermdat_H2O')
species_list = read_thermdat(thermdat_H2O_path)
species_dict = pMuTT_list_to_dict(species_list)

# Initialize the reaction
rxn_H2O = Reaction.from_string('H2 + 0.5O2 = H2O', species=species_dict)

# Calculate reaction properties
H_rxn = rxn_H2O.get_delta_H(T=298., units='kJ/mol')
S_rxn = rxn_H2O.get_delta_S(T=298., units='J/mol/K')
print('H_rxn(T=298) = {:.1f} kJ/mol'.format(H_rxn))
print('S_rxn(T=298) = {:.2f} J/mol/K'.format(S_rxn))


# ## Exercise
# Write a script to calculate the Enthalpy of adsorption (in kcal/mol) of H2O on Cu(111) at T = 298 K. Some important details are given below.
# 
Ejemplo n.º 6
0
import os
from pprint import pprint
from matplotlib import pyplot as plt
from pMuTT.io_.thermdat import read_thermdat

base_path = os.path.dirname(__file__)
# Thermdat file from
# http://combustion.berkeley.edu/gri_mech/version30/files30/thermo30.dat
species = read_thermdat('{}/thermdat'.format(base_path))

# Printing information related to each specie
pprint(species)

# Plot an example of an imported NASA polynomial
species[1].plot_empirical()
plt.show()