Stoichiometry - Part 2#
Goal:#
The aim of this lesson is to help you design functions to create stoichiometric tables in Python.
Here, an example of how to create a stoichiometric table for an equalmolar reaction is provided. Afterwards, a few exercises are provided, so you can try to write your own functions, making them as much generalizable as possible. It’s a good idea, once you have a working solution, to test the functions of different parameters to see if the results are still correct!
Remember, the provided solution is is only one of the many possible solutions, so please do try to re-write the function yourself, optimize it and make it more generalizable.
Motivation:#
Writing these functions in Python might look like a lot of (manual) work, since the tables are populated by strings.
However, if you manage to create the functions for the different types of systems, then you can reuse them and just change the initial parameters provided!
This will also (hopefully) help you thinking carefully about the conditions and the assumptions given (e.g. is the reaction isothermal? Is there a volume change?), since you will have to choose the specific function based on that. In our experience, this is something that students often struggle with, so we hope to provide a tool that helps you taking into account all of this!
Example 1:#
A company is about to start the production of B, this happens by the catalytic reaction: \(A → B\)
The feed stream consists of \(1 kmol/m^3\) A and \(0.01 kmol/m^3\) B, this is done at a rate of \(120 m^3/min\). The reaction rate can be written as an elementary reaction and is carried out isothermally in the liquid phase. The reaction rate constant k is \(0.18 \cdot 10^{-3}m^3 \cdot mol^{-1} \cdot s^{-1}\)
Draw up a stoichiometric table for the equation (here one possible solution is provided below):
# Create a stoichiometric table here
import pandas as pd
def stoichiometry_equalmolar_reaction(A0, B0):
"""
Function to create the stoichiomatric table for an eualmolar reaction with one reactant (A) and one product (B).
Input:
A0, B0: initial streams of A and B, respectively, in kmol/m^3.
Output:
stoichiometry_table (pd.DataFrame): pandas dataframe of the stoichiometric table of the given reaction.
It contains 5 columns: the species,
the number of moles that each species initially presents (feed rate),
the change in the number of moles brought about by reaction,
the number of moles after time t (effluent rate),
the concentration.
"""
# initial cnditions
Fj0_A = 'F_A0'
Fj0_B = f'{B0}*F_A0'
Fj0_T = f'{A0 + B0}*F_A0'
# change
change_A = '-F_A0*X'
change_B = f'{B0/A0}*F_A0*X'
change_T = 0
# after time t
Fj_A = 'F_A0*(1-X)'
Fj_B = f'F_A0*({B0}+X)'
Fj_T = Fj0_T
# concentration
Cj_A = 'C_A0*(1-X)'
Cj_B = f'C_A0*({B0}+X)'
stoichiometry_table = pd.DataFrame()
stoichiometry_table['species'] = ['A', 'B', 'T']
stoichiometry_table['F_j0'] = [Fj0_A, Fj0_B, Fj0_T]
stoichiometry_table['change'] = [change_A, change_B, change_T]
stoichiometry_table['F_j'] = [Fj_A, Fj_B, Fj_T]
stoichiometry_table['C_j'] = [Cj_A, Cj_B, None]
return stoichiometry_table
stoichiometry_equalmolar_reaction(1, 0.01)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 2
1 # Create a stoichiometric table here
----> 2 import pandas as pd
4 def stoichiometry_equalmolar_reaction(A0, B0):
5 """
6 Function to create the stoichiomatric table for an eualmolar reaction with one reactant (A) and one product (B).
7 Input:
(...)
15 the concentration.
16 """
ModuleNotFoundError: No module named 'pandas'
Example 2:#
\(2A(1)→ B(1)\)
takes place in the liquid phase. A kinetic study is carried out in a batch reactor under the following operating conditions. The concentration of A in the reactor at the start is \(120 mol/m^3\). There is no B in the reactor at the start of the experiment and the temperature is assumed to be constant at 330 K.
When solving the problem, it can be assumed that there are no volume changes during the reaction.
1.1. Set up a stoichiometric table and find expressions for \(C_A\) and \(C_B\) as a function of the degree of conversion of A.
# Your code here
Example 3:#
A company is considering implementing a new reaction in their existing process plant. The reaction takes place in the gas phase and is autocatalytic. The reaction is described by the following expression:
\(A+0.5B → C+D\)
Where the product of the reaction, C, also catalyzes the reaction.
The feed stream consists of equal amounts of A and B. \(C_{A0} = C_{B0} = 5 kmol/m^3\). and the flow rate to the reactor is \(v_0 = 10 m^3/h\). Laboratory experiments have shown that the reaction rate can be described with the following expression:
\(-r_A = k_1C_AC_BC_C \quad [\frac{kmol}{hm^3}]\)
Under the relevant conditions, the rate constant has been determined to be \(k_1 = 0.05 \frac{m^6}{kmol^2 \cdot h}\). The reaction is carried out under isothermal conditions.
Question 1.1 Set up a stoichiometric table for a flow reactor and derive expressions for the concentration of A, B and C as a function of the degree of conversion, X.
# Your code here
Example 4:#
The reaction
\(3A+ \frac{4}{5}B → \frac{1}{4}C+D\)
takes place in liquid fase. A kinetic study is carried out in a batch reactor at the following operating conditions: the initial concentration of A in the reactor is \(75 mol/m^3\). There is no C or D in the reactor at the start of the experiment and the temperature is assumed to be constant. A is the limiting reactant and B is present in excess.
When solving the problem, it can be assumed that there are no volume changes during the reaction.
Question 2.1. Draw up a stoichiometric table and find expressions for \(C_A\) and \(C_D\) as a function of the degree of conversion of A. Plot \(C_A\), \(C_C\) and \(C_D\) as a function of time.
# Your code here