Chemical Reaction Engineering - Assignment 1

Chemical Reaction Engineering - Assignment 1#

Instructions#

Please use Python to solve the exercises below.

Your should hand in a jupyter notebook with your answers. When handing in, you are welcome to submit additional material you may have used, such as a scan of the paper to solve parts of the equations, Word and PDF documents and similar.

The exercises sum up to a total of 12 points, but you only need 10 points to get top marks. Please note that there are two optional exercises (for a total of 12 points). Consider solving the optional exercises if you are unsure about some of the others.

You will also get partial points for trying to solve the different exercises.

Assignment 1#

In your company, you need to evaluate the composition of the feed stream (containing only A and B) of an isothermal gas-phase reaction expressed as:

\(A+\frac{1}{12}B→\frac{1}{6}C+\frac{1}{2}D\)

  1. First, set up the stoichiometric table for the reaction for a flow reactor with constant pressure (2 points). Afterwards, write the concentrations of A, B, C and D as function of the conversion X (1 point).

# Set up the stoichiometric table for the reaction for a flow reactor with constant pressure

# Your code here
# Write the concentrations of A, B, C and D as function of the conversion X 

CA = f'C_A0'

During a laboratory experiment you measure in a batch reactor with constant volume:

$\( Time (h) \)$

$\( Cc (mol \cdot m^{-3}) \)$

0

0

2

2,5

4

3,13

6

3,41

8

3,57

10

3,68

12

3,75

14

3,81

16

3,85

18

3,88

20

3,91

  1. First of all, create a pandas dataframe of the data in the table below (1 point).

# Create pandas dataframe
import pandas as pd

df = pd.DataFrame()
df['Time'] = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
df['Cc'] = [0, 2.5, 3.13, 3.41, 3.57, 3.68, 3.75, 3.81, 3.85, 3.88, 3.91]
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[3], line 2
      1 # Create pandas dataframe
----> 2 import pandas as pd
      4 df = pd.DataFrame()
      5 df['Time'] = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

ModuleNotFoundError: No module named 'pandas'
  1. Calculate the rate of the reaction, which follows the expression:

\(-\frac{dC_A}{dt} = k{C_{A}}^n\)

To do so, consider that this data is obtained with a constant volume reactor and the initial concentration of \(C_A\) is 25 \(mol \cdot m^{-3}\). Choose between using the differential or the integral method (2,5 points).

Optional: Backup your answer with the other method (1 point).

# Calculate the rate of the reaction
import numpy as np

def calculate_CA(C_A0, Cc):
    C_A = C_A0-(6*Cc)
    return C_A

df['Ca'] = calculate_CA(25, df['Cc'])
df['ln(Ca)'] = round(np.log(df['Ca']), 2)

x = [a - b for a, b in zip(df['Ca'].iloc[1:], df['Ca'][:-1])]
t = [a - b for a, b in zip(df['Time'].iloc[1:], df['Time'][:-1])]

df['-delta Ca/delta t'] = [None] + [round(-(i/j), 2) for i, j in zip(x, t)]
df['ln(-delta Ca/delta t)'] = round(np.log(df['-delta Ca/delta t']), 2)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 2
      1 # Calculate the rate of the reaction
----> 2 import numpy as np
      4 def calculate_CA(C_A0, Cc):
      5     C_A = C_A0-(6*Cc)

ModuleNotFoundError: No module named 'numpy'
df
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 df

NameError: name 'df' is not defined
import matplotlib.pyplot as plt
import scipy
from scipy import stats

m, b, r_value, p_value, std_err = scipy.stats.linregress(df['ln(Ca)'].iloc[1:], df['ln(-delta Ca/delta t)'].iloc[1:])
print(r_value)
fig, ax = plt.subplots()
ax.scatter(df['ln(Ca)'].iloc[1:], df['ln(-delta Ca/delta t)'].iloc[1:])
ax.plot(df['ln(Ca)'].iloc[1:], m*df['ln(Ca)'].iloc[1:] + b)
ax.annotate('r^2: ' + str("{:.2f}".format(r_value**2)), xy=(0.5, 2))
ax.annotate('formula: ' + str("{:.2f}".format(m)) + 'x + ' + str("{:.2f}".format(b)), xy=(0.5,1.7))
plt.title('Differential method')
plt.xlabel('ln(Ca)')
plt.ylabel('ln(-delta Ca/delta t)')
plt.legend()
plt.grid()
plt.ylim([-3, 3])
fig.show()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[6], line 1
----> 1 import matplotlib.pyplot as plt
      2 import scipy
      3 from scipy import stats

ModuleNotFoundError: No module named 'matplotlib'
df['1/Ca'] = round(1/df['Ca'], 2)

m, b, r_value, p_value, std_err = scipy.stats.linregress(df['Time'].iloc[1:], df['1/Ca'].iloc[1:])

fig, ax = plt.subplots()
ax.scatter(df['Time'].iloc[1:], df['1/Ca'].iloc[1:])
ax.plot(df['Time'].iloc[1:], m*df['Time'].iloc[1:] + b)
ax.annotate('r^2: ' + str("{:.2f}".format(r_value**2)), xy=(2.5, 0.6))
ax.annotate('formula: ' + str("{:.2f}".format(m)) + 'x + ' + str("{:.2f}".format(b)), xy=(1950,18500))
plt.title('Integral method')
plt.xlabel('Time [h]')
plt.ylabel('1/Ca')
plt.legend()
plt.grid()
#plt.ylim([-3, 3])
fig.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 df['1/Ca'] = round(1/df['Ca'], 2)
      3 m, b, r_value, p_value, std_err = scipy.stats.linregress(df['Time'].iloc[1:], df['1/Ca'].iloc[1:])
      5 fig, ax = plt.subplots()

NameError: name 'df' is not defined
  1. Plot the concentrations of A, B, C and D versus time. Explain the assumption you have made (1,5 point).

# Plot the concentrations of A, B, C and D versus time

df['Cb'] = round(df['Ca']*1/12, 2)
df['Cd'] = round(df['Cc']/(1/6)*(1/2), 2)

plt.figure(figsize=(10,7))
plt.plot(df['Time'], df['Ca'], color='red', label='Ca', marker='o')
plt.plot(df['Time'], df['Cb'], color='orange', label='Cb', marker='o')
plt.plot(df['Time'], df['Cc'], color='green', label='Cc', marker='o')
plt.plot(df['Time'], df['Cd'], color='blue', label='Cd', marker='o')
plt.title('Concentration vs time')
plt.xlabel('Time [h]')
plt.ylabel('Concentration [mol/mL]')
plt.grid()
plt.legend()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[8], line 3
      1 # Plot the concentrations of A, B, C and D versus time
----> 3 df['Cb'] = round(df['Ca']*1/12, 2)
      4 df['Cd'] = round(df['Cc']/(1/6)*(1/2), 2)
      6 plt.figure(figsize=(10,7))

NameError: name 'df' is not defined
  1. Finally, correlate the rate constant k with the temperature through the Arrhenius expression. Calculate the activation energy (0,75 point) and the Arrhenius constant (0,75 point) using the data below:

$\( Temperature (^\circ C) \)$

$\( {k (m^3 \cdot mol^{-1} \cdot h^{-1})} \)$

25

0,02764

30

0,03548

35

0,04519

45

0,07165

Hint: \( R = 8.314 J \cdot mol^{-1}·K^{-1} \)

Plot the relation between the rate constant k and the temperature (0,5 point).

# Calculate the activation energy

def calculate_k(A, Ea, R, T):
    return A* np.exp(-EA/(R*T))

def calculate_ln_k(A, Ea, R, T):
    return np.log(A)-(Ea/R)*1/T

df_arrhenius = pd.DataFrame()
df_arrhenius['T_C'] = [25, 30, 35, 45]
df_arrhenius['k'] = [0.02764, 0.03548, 0.04519, 0.07165]
df_arrhenius['T_K'] = round(273.15 + df_arrhenius['T_C'])
df_arrhenius['1/T'] = 1/df_arrhenius['T_K']
df_arrhenius['ln(k)'] = np.log(df_arrhenius['k'])

df_arrhenius
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[9], line 9
      6 def calculate_ln_k(A, Ea, R, T):
      7     return np.log(A)-(Ea/R)*1/T
----> 9 df_arrhenius = pd.DataFrame()
     10 df_arrhenius['T_C'] = [25, 30, 35, 45]
     11 df_arrhenius['k'] = [0.02764, 0.03548, 0.04519, 0.07165]

NameError: name 'pd' is not defined
plt.plot(df_arrhenius['1/T'], df_arrhenius['ln(k)'], marker='o')
z = np.polyfit(df_arrhenius['1/T'].tolist(), df_arrhenius['ln(k)'].tolist(), 1)
p = np.poly1d(z)
ER = z[0]
print(p)
Ea = z[0]*R
print(Ea)
A = np.exp(z[1])
print(A)
plt.grid()
plt.xlabel('1/T')
plt.ylabel('ln(k)')
plt.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[10], line 1
----> 1 plt.plot(df_arrhenius['1/T'], df_arrhenius['ln(k)'], marker='o')
      2 z = np.polyfit(df_arrhenius['1/T'].tolist(), df_arrhenius['ln(k)'].tolist(), 1)
      3 p = np.poly1d(z)

NameError: name 'plt' is not defined
# Calculate the Arrhenius constant
k = 0.02764
R = 8.314
Ea = 4513.5*R 
print(Ea)

T = 25+273
A = k/(np.exp(-Ea/(R*T)))
A
37525.239
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[11], line 8
      5 print(Ea)
      7 T = 25+273
----> 8 A = k/(np.exp(-Ea/(R*T)))
      9 A

NameError: name 'np' is not defined
np.exp(-3.376)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[12], line 1
----> 1 np.exp(-3.376)

NameError: name 'np' is not defined
# Plot the relation between the rate constant k and the temperature

# Your code here

Optional: Write the complete kinetic expression written with the concentration of \(C_A\) expressed with help of the initial concentration \(C_{A0}\) and X (1 point).

# Write the complete kinetic expression

# Your code here