ChE 365. 2022F. FE. Name: Small
Assignment: You will have to implement Python scripts which solve chemical engineering
problems using numerical methods and tools covered in ChE 365. Each of you will receive an
email with the problem statement and parameters.
Submission: The solution has to be submitted on Canvas as two files:
1. A ZIP file which includes the python and data files. The working scripts (use a separate script
for each of the problem), the scripts should be well-documented and tested. Non-working script
giving an e
or on execution will result in zero for the problem.
2. A PDF file with the report (one for all problems). The report should include the problem
statements, short description of the numerical methods, summary of the results from different
methods, the plots (where applicable), and the conclusion regarding implemented solutions. The
eport should not include the code.
The final scripts and report should be uploaded on Canvas by the deadline. Late submissions
will not be accepted, and you will receive zero for the exam! Please name your scripts and reports
using your last name, e.g. if your name is John Doe, your script for the Problem 1 should be:
“Doe-P1.py” and report should be “Doe-Report.pdf”.
Grading: The exam will be graded based on the two components:
1. The code itself. The code will be graded for (1) co
ectness, (2) readability, (3) efficiency. Note
that for all the tasks that require plots, the axis and all the curves should be clearly labeled, a
legend should be included.
2. The code report and presentation. Each student will meet with me (or a proctor) on WebEx
to present the project XXXXXXXXXXminutes). The presentation will be graded based on the answers to
the following or similar questions:
(1) I will ask you to explain me what certain parts of your code do
(2) I will ask the details on the numerical methods used in the script, be they implemented by
the student, or used from the numpy/scipy li
aries. This can include questions on alternative
methods for solving the same problem (covered in ChE 365).
(3) I will ask to implement minor changes in the code, or explain how to modify the code to
implement some additional features
(4) I will ask to predict changes in the code behavior upon some hypothetical changes
Exam format: This is an “open book” exam. You can use any resources on the Internet to
help you solve your problem. However, you must summarize the list of resources you used in the
eport. Furthermore, you cannot copy the code from existing sources, except your own codes fo
the in-class activities or the examples I provided. Copied parts of the code will be considered as
plagiarism. The oral part of your exam is “closed book”: you cannot use any resources other than
your own code and report while presenting and answering questions.
You are not allowed to discuss your project with other people from the class or anyone except
the instructor. Furthermore, you are not allowed to show or share the code, and the assignment
itself or posting it on online resources, such as Chegg. This will be considered as cheating, and
will result is zero for the exam.
1
ChE 365. 2022F. FE. Name: Small
Problem 1. The table gives the experimental Pxy data for VLE of a binary mixture at a constant
temperature. Assume that the VLE is described by modified Raoult’s law
yiP = xiγiP
sat
i (i = 1, 2) (1)
where P is the equili
ium pressure, yi is the mole fraction in the vapor phase, xi is the mole
fraction in the liquid phase, γi is the activity coefficient, P
sat
i is the vapor pressure for the species
i. Obviously x1 + x2 = 1 and y1 + y2 = 1.
The excess Gi
s free energy is given by the 2-parameter Margules equation
GE
RT
= (A21x1 + A12x2)x1x2, (2)
so that the activity coefficients are given as
ln γ1 = x
2
2 [A XXXXXXXXXXA21 − A12)x1] ln γ2 = x21 [A XXXXXXXXXXA12 − A21)x2] (3)
It is useful to remember that the logarithms of the activity coefficients satisfy the summability
elation:
GE
RT
= x1 ln γ1 + x2 ln γ2. (4)
1. Perform the data reduction to calculate the parameters of the Margules equation, A12, A21,
from the linear regression for the G
E
RTx1x2
data.
2. Plot the data for ln γ1, ln γ2,
GE
RT
, and G
E
RTx1x2
as a function of x1 on the same plot. Use markers
for values based on the experimental data and lines for the model predictions.
3. The integral criterion for thermodynamic consistency of the VLE data is given by:
1∫
0
ln
(
γ1
γ2
)
dx1 = 0 (5)
Calculate the integral in Eq. 5 using Simpson’s 1/3 rule (implement your own algorithm and verify
with an algorithm from scipy).
4. Fit the ln
(
γ1
γ2
)
data with a 4th degree polynomial. Plot the data as markers and the fit as a
line. Using the polynomial fit, calculate the integral in Eq. 5 analytically.
P (kPa) x1 y1
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
2
ChE 365. 2022F. FE. Name: Small
Problem 2. The isothermal compressibility of a fluid, βT , is defined as
βT ≡ −
1
V
(
∂V
∂P
)
T
, (6)
where V is the volume, P is the fluid pressure, and T is the absolute temperature. Consider a fluid
confined in a pore, assuming that it is a uniform macroscopic system, we can relate the pressure in
the pore P to the chemical potential of the fluid µ through the Gi
s-Duhem relation at constant
temperature
dP = n dµ. (7)
Using n = N/V (molar density) and Eq. 7, Eq. 6 can be rewritten as
βT =
1
n2
(
∂n
∂µ
)
T,N
=
1
n2
(
∂n
∂µ
)
T,V
. (8)
The last expression in the right hand side of Eq. 8 can be calculated by numerical differentiation
of the adsorption isotherm, i.e. density n as a function of the chemical potential µ.
The table gives the data for argon adsorption in a silica pore at 87.3 K, use numerical derivative
to calculate isothermal compressibility βT of confined argon as a function of chemical potential.
Use the following methods:
1. Forward finite difference.
2. Based on the second-order Lagrange interpolation polynomials for each of the three consecutive
points.
3. Fit the n = n(µ) data with a polynomial function of the order m, calculate the derivative of
the resulting polynomial. Try two different values of m.
Plot all four results on the same axis, compare the results from different methods.
µ (J/mol) n (mol/m3)
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
3
ChE 365. 2022F. FE. Name: Small
Problem 3. The problem of growth and evaporation of aerosols has multiple application in
industry and in nature. The latter, in particular includes the evolution of atmospheric aerosols.
Consider condensation of a supersaturated vapor on a surface of a microscopic spherical particle
of radius R0. The growth of the spherical liquid droplet is governed by the kinetic (free molecular)
flux of the vapor molecules towards the droplet. The resulting equation for the radius of the droplet
R as a function of time t reads:
dR
dt
= C
{
1− 1
s
exp
[
`K
R
]}
. (9)
where
C ≡ αvTn0
4nl
. (10)
The parameter s describes the deviation on the vapor from the chemical equili
ium with the
condensate, the saturation ratio
s ≡ n0
n∞
. (11)
The parameter `K is the characteristic Kelvin length defined as
`K ≡
2γ
nlkBT
. (12)
Here α is the molecular accommodation coefficient, vT is the mean thermal velocity of the molecules,
n0 is the unpertu
ed vapor number density far from the droplet, nl is the number density of the
liquid phase, n∞ is the number density of the saturated vapor at the flat surface, γ is the vapor-
liquid surface tension, kB is the Boltzmann constant, T is the absolute temperature.
Solve the initial value problem, given by Eq. 9 the natural initial condition
R |t=0= R0 . (13)
1. Solve it using Euler’s method
2. Solve it using solve ivp function, compare the resulting solution with the solution from part 1
graphically.
3. Unfortunately the problem given by Eqs. 9 and Eq. 13 cannot be solved in the closed form
to test the numerical solution. However, if the exponent in Eq. 9 is linearized, it can be solved.
Linearize the exponent and write the closed-form solution for Eqs. 9 and Eq. 13.
4. Apply the methods implemented above to the linearized equation, and compare the results to
the closed-form solution.
The parameters for the problem are the following:
C = 1, s = 2.25, `K = 0.65, R0 = 1, tinitial = 0, tfinal = 10, δt = 0.5
4
Page i
Applied Numerical Methods
with Python for Engineers and Scientists
Steven C. Chapra
Tufts University, Professor Emeritus
David E. Clough
University of Colorado, Boulder, Professor Emeritus
Page ii
APPLIED NUMERICAL METHODS WITH PYTHON FOR ENGINEERS AND SCIENTISTS
Published by McGraw Hill LLC, 1325 Avenue of the Americas, New York, NY XXXXXXXXXXCopyright
©2022 by McGraw Hill LLC. All rights reserved. Printed in the United States of America. No part of
this publication may be reproduced or distributed in any form or by any means, or stored in a database
or retrieval system, without the prior written consent of McGraw Hill LLC, including, but not limited
to, in any network or other electronic storage or transmission, or
oadcast for distance learning.
Some ancillaries, including electronic and print components, may not be available to customers
outside the United States.
This book is printed on acid-free paper.
XXXXXXXXXXLWI XXXXXXXXXX
ISBN XXXXXXXXXX
MHID XXXXXXXXXX
Cover Image: VisualCommunications/E+/Getty Images
All credits appearing on page or at the end of the book are considered to be an extension of the
copyright page.
The Internet addresses listed in the text were accurate at the time of publication. The inclusion of a
website does not indicate an endorsement by the authors or McGraw Hill LLC, and McGraw Hill
LLC does not guarantee the accuracy of the information presented at these sites.
mheducation.com/highered
Page iii
Dedication:
Steven C. Chapra
To Cynthia K. Chapra
in gratitude for her love, support,
and for allowing this nerd the time and space to play with his computer.
David E. Clough
To my parents, John and Eunice Clough, for providing a loving, supportive home and a launching pad
for my career as an educator.
Page iv
ABOUT THE AUTHORS
Steve Chapra is the Emeritus Professor and Louis Berger Chair in the Civil and Environmental
Engineering Department at Tufts University. His other books include Surface Water-Quality Modeling,
Numerical Methods for Engineers, and Applied Numerical Methods with MATLAB.
Dr. Chapra received engineering degrees from Manhattan College and the University of Michigan.
Before joining Tufts, he worked for the U.S. Environmental Protection Agency and the National
Oceanic and Atmospheric Administration and taught at Texas A&M University, the University of
Colorado, and Imperial College London. His general research interests focus on surface water-quality
modeling and advanced computer applications in environmental engineering.
He is a Fellow and Life Member of the American Society of Civil Engineering (ASCE) and has
eceived several awards for his scholarly and academic contributions, including the Rudolph Hering
Medal (ASCE) for his research, and the Meriam-Wiley Distinguished Author Award (American
Society for Engineering Education). He has also been recognized as an outstanding teacher and
advisor among the engineering faculties at Texas A&M University, the University of Colorado, and
Tufts University. As a strong proponent of continuing education, he has taught over 90 workshops fo
professionals on numerical methods, computer programming, and environmental modeling.
David Clough joined the faculty of the Department of Chemical and Biological Engineering at the
University of Colorado in 1975 after a
ief career with DuPont in Wilmington, Delaware. He retired
from Colorado in 2017 and holds the position of Professor Emeritus. He remains active at Colorado
y assisting faculty and students in teaching and research. Notably, he teaches a series of workshops
on process modeling and computer simulation as part of the senior design course sequence.
Dr. Clough received degrees in chemical engineering from Case Western Reserve University and the
University of Colorado. He has extensive experience in applied computing, process automation, and