0% found this document useful (0 votes)
45 views

CP213: Tutorial Notebook 1

a

Uploaded by

Bilal Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

CP213: Tutorial Notebook 1

a

Uploaded by

Bilal Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Product Team Enterprise Explore Marketplace Pricing Search Sign in Sign up

mjksill / CP213-online Public Notifications Fork 2 Star 1

Code Issues Pull requests Actions Projects Wiki Security Insights

master CP213-online / tutorials / tutorialS1_1.ipynb Go to file

awsharif syy fix to tutorial 1 Latest commit 124fab8 on 20 Sep 2021 History

2 contributors

448 lines (448 sloc) 13.5 KB Raw Blame

CP213: Tutorial Notebook 1

Question 1

B. Find the exact value of the integral

1
∫ dx x3 .
0

G. Use the trapezium rule with four equal intervals to estimate the value of the integral. Determine the percentage error between the exact value and the value
estimated by the trapezium rule.

L. Repeat part 2. using eight equal intervals.

N. Make a plot of the percentage error between the exact value and the value estimated by the trapezium rule and the number N of equal intervals used from
N = 1 to 100.

In [ ]:

Question 2
A projectile initially located at the origin has an initial speed v0 = 10 m s−1 directed at an angle of θ = 30∘ from the horizontal. It travels a gravitational field
g = 9.81 m s−2 which points in the negative y-direction.

B. Write an equation for how the x- and y-coordinates of the particle change depend on time t.

G. When will the projectile strike the ground, which is located at y = 0?

L. Plot the variation of the x- and y-coordinates of the projectile with time, from t = 0 until it hits the ground. Also, plot the trajectory (i.e. y(t) vs x(t)) of the
projectile.

N. Repeat parts 2 and 3 of the problem if the velocity of the projectile is at an angle of 60∘ from the horizontal. At what angle will the projectile travel the furthest
in the x-direction?

In [ ]:

Question 3
Plot the data set given in the code block below:

In [ ]:
x_dat = [1220, 1139, 1874, 1550, 1203, 1488, 2003, 1368, 1389, 1300, 1877, 1670, 1080, 1766, 1445, 1718, 1263, 1432, 1557, 1127]
y_dat = [42, 46.5, 28.5, 37.5, 43.5, 36, 21, 36, 37.5, 40.5, 27, 33, 49.5, 30, 39, 31.5, 48, 21, 34.5, 61.5]

The average value of x and y, denoted by x̄ and ȳ, respectively, are defined by


1 N 1
x̄ = ∑ xk
N k=0

1 N 1
ȳ = ∑ yk
N k=0

where N is the number of data points.

Compute x
¯ and y¯ for the data set provided.

In [ ]:

The variance of x (denoted by Sxx ), the variance of y (denoted by Syy ), and the covariance between x and y (denoted by Sxy ) are defined as:

N−1
1
Sxx = ∑(xk − x̄)2
N k=0
N−1
1
Sxy = ∑(xk − x̄)(yk − ȳ)
N k=0
1 N−1
Syy = ∑(yk − y¯)2
N k=0

Compute Sxx , Sxy , and Syy .

In [ ]:

The general equation for the best fit line through a set of data is given by:

y = ax + b

where the slope a and the intercept b are given by

Sxy
a=
Sxx
b = ȳ − ax̄.

We will derive these equation next semester in the module.

Plot the equation of the best fit line along with the original data.

In [ ]:

Question 4
Consider the gas-water shift reaction

CO(g) + H2 O(g) ⇆ CO2 (g) + H2 (g)

gas Mw Hf Gf

g mol −1 kJ mol −1 kJ mol −1

CO(g) 28.01 −110.5 −137.2


CO 2 (g) 44.01 −393.3 −394.6
H 2 (g) 2.02 0.0 0.0
H 2 O(g) 18.02 −241.8 −228.4

The data in the table have been summarized in the dictionary data . The stoichiometric coefficients (the stoichiometric coefficient for species k is typically
denoted by the symbol νk ) of the reaction are held in the dictionary nu . Note that product species have a positive stoichiometric coefficient, and reactant species
have a negative stoichiometric coefficient.

In [ ]:
R = 8.314e-3 # ideal gas constant / kJ mol^{-1} K^{-1}
T0 = 298.15 # reference temperature / K
p0 = 1.0e5 # reference pressure / Pa

# Data about the gases:


# Mw - molecular weight g/mol
# Hf - heat of formation
# Gf - Gibbs free energy
data = {}
data['CO'] = {'Mw':28.01, 'Hf':-110.5, 'Gf':-137.2 }
data['CO2'] = {'Mw':44.01, 'Hf':-393.3, 'Gf':-394.6 }
data['H2'] = {'Mw': 2.02, 'Hf': 0.0, 'Gf': 0.0 }
data['H2O'] = {'Mw':18.02, 'Hf':-241.8, 'Gf':-228.4 }

# stoichiometric coefficients
nu = {}
nu['CO'] = -1.0
nu['CO2'] = 1.0
nu['H2'] = 1.0
nu['H2O'] = -1.0

Part 1: Standard reaction enthalpy and Gibbs energy


The standard enthalpy of reaction ΔHrxn is defined by

ΔHrxn = ∑ νk Hf,k
k

where Hf,k is the standard enthalpy of formation of species k. The standard Gibbs energy of reaction ΔGrxn is given by

ΔGrxn = ∑ νk Gf,k
k

where Gf,k is the standard enthalpy of formation of species k.

Task: Calculate the standard enthalpy of reaction and the standard Gibbs energy of reaction.

In [ ]:
Hrxn = 0.0 # Heat of reaction
Grxn = 0.0 # Gibbs free energy of reaction
for gas, coeff in nu.items():
# TODO sum up Hrxn and Grxn here <---------------------------------

print(f'standard enthalpy of reaction: {Hrxn} kJ mol^{{-1}}')


print(f'standard Gibbs energy of reaction: {Grxn} kJ mol^{{-1}}')

Part 2: Conversion between mole numbers and mole fractions


The mole fraction of species k, denoted by xk , in a system is given by

Nk
xk =
N
where Nk is the number of moles of species k, and N = ∑j Nj is the total moles in the system.

Task: From the dictionary with the mole numbers as an input, create a dictionary of mole fractions.

In [ ]:
# some test data - mole numbers of some gases
mole = {}
mole['CO'] = 1.0
mole['CO2'] = 1.0
mole['H2'] = 1.0
mole['H2O'] = 1.0

total_moles = # ???

x_dict = {}
for name, N in mole.items():

# TODO main body goes here <-----------------------------

# output your answer


for name, x in x_dict.items():
print(f'{name}: mole fraction = {x}')

Part 3: Heat capacity


The heat capacity of the gases can be described by the equation

Cp
= a0 + a1 T + a2 T 2 + a3 T 3 + a4 T 4
R
where T is the absolute temperature in kelvin, R = 8.314\,J−1 \,mol\,K−1 is the ideal gas constant, and the coefficients ak are given in the table below.

gas a 0 a 1 × 10 3 a 2 × 10 5 a 3 × 10 8 a 4 × 10 11

K −1 K −2 K −3 K −4

CO(g) 3.912 −3.913 1.182 −1.302 0.515


CO 2 (g) 3.259 1.356 1.502 −2.374 1.056
H 2 (g) 2.883 3.681 −0.772 0.692 −0.213
H 2 O(g) 4.395 −4.186 1.405 −1.564 0.632

The coefficients of the heat capacity have been added to the dictionary data (see below). In what follows below, assume that the mixtures behave as an ideal gas.

In [ ]:
data['CO'] ['Cp_coeff'] = [3.912, -3.913e-3, 1.182e-5, -1.302e-8, 0.515e-11]
data['CO2']['Cp_coeff'] = [3.259, 1.356e-3, 1.502e-5, -2.374e-8, 1.056e-11]
data['H2'] ['Cp_coeff'] = [2.883, 3.681e-3, -0.772e-5, 0.692e-8, -0.213e-11]
data['H2O']['Cp_coeff'] = [4.395, -4.186e-3, 1.405e-5, -1.564e-8, 0.632e-11]

R = 8.314 # J mol^{-1} K^{-1}

Task: Plot the molar heat capacity of the mixture and of each of the individual components as a function of temperature.

In [ ]:
moles = {'CO':1, 'CO2':2, 'H2':0, 'H2O':1}
T_data = np.arange(200.0, 600.0, 10.0)

# TODO <--- your work here

plt.legend()
plt.xlabel('temperature / K')
plt.ylabel(r'molar heat capacity / J mol$^{-1}$ K$^{-1}$')
plt.show()

Task: Plot the heat capacity of reaction ΔCp,rxn (T ) of the gas-water shift reaction as a function of temperature.

Note that the heat capacity of reaction is defined as

ΔCp,rxn = ∑ νk Cp,k (T )
k

where T is the absolute temperature of the system, and Cp,k (T ) is the molar heat capacity of species k at temperature T .

In [ ]:
T_data = np.arange(200.0, 600.0, 10.0)

# TODO <--- your work here

plt.xlabel('temperature / K')
plt.ylabel(r'$\Delta C_{p,{\rm rxn}}$ / J mol$^{-1}$ K$^{-1}$')
plt.show()

In [ ]:

© 2022 GitHub, Inc. Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About

You might also like