Mathcad Solutions To The Chemical Engineering Problem Set
Mathcad Solutions To The Chemical Engineering Problem Set
Mathcad Solutions To The Chemical Engineering Problem Set
INTRODUCTION
This document contains Mathcad solutions for a set of chemical engineering problems developed
for the Use of Mathematical Software Packages in Chemical Engineering Education Session at the
ASEE Chemical Engineering Summer School held in Snowbird, Utah on August 13, 1997. The
problems chosen are representative of numerical problems that are typically found in most
chemical engineering undergraduate courses.
a .( V
P b ) R .T
2
V
atm .liter
R 0.08206 .
mole .K
2.
R .T c
2
27 . R T c atm .liter
2
liter
a a = 4.197 b b = 0.037
64 Pc mole
2 8 .P c mole
a .( V
P b ) R .T Equation to be solved
2
V
liter
V Find( V ) V = 0.575 End of Solve Block
mole
P.V
Z Z = 0.872
R .T
In the Find statement above, Mathcad solves for the value of the unknown variable but does
not change the value of the variable (V). Therefore, the value of the solution of the equation is
assigned to the variable (V) so that it can be used in subsequent calculations (e.g., calculation
of the compressibility factor (Z).
Page MC-3 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
b) Reformulate solution in terms of Pr. One powerful feature of Mathcad is the ability to define a
function using a solve block. The argument of the function is one of the variables in the equation
being solved and the value of the function is the solution of the equation. In this case the molar
volume is defined as a function of the reduced pressure. The structure of the solve block is
essentially the same as in part a).
liter
Initial guess for volume: V 0.6 .
mole
Given
a .
P r .P c (V b ) R .T
2
V
P r . P c .V P r
V Pr Find( V ) Z Pr
R .T
i 1 .. 5 The variable i here is called a range variable and takes on a range of values, in
this case 1, 2, ..., 5. This is similar to an index variable in a counted loop. Pr is
an array of values specified in the problem statement.
Pr V Pr
i i
Z Pr
liter .mole
1 i
1
0.704
2 0.234
0.466
4 0.077
0.731
10 0.061
1.533
20 0.051
2.783
0.046
c) The reduced pressure can be defined as a range variable and the molar volume can then be
plotted as a function of reduced pressure.
Pr 0.1 , 0.2 .. 50
8
7
6
5
Z Pr 4
3
2
1
0
0 5 10 15 20 25 30 35 40 45 50
Pr
Page MC-4 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
There are two approaches to solving this problem in Mathcad. The first is to simply include
all of the equations in a Solve Block and solve for the unknown variables. This simplifies the
formulation of the numerical problem because the problem does not need to be rewritten in
matrix form. In the second method, the problem is broken up into a problem requiring the
solution of 4 simultaneous linear equations followed by a series of simple algebraic equations.
F D D
Guess values of flow rates D D1 B1
and mole fractions: 2 2 2
F B B
B D2 B2
2 2 2
Given
Component balances over entire system
D
B
D1
B1
D2
B2
x DX
x DS Find D , B , D 1 , B 1 , D 2 , B 2 , x DX , x DS , x DT , x DB , x BX , x BS , x BT , x BB
x DXT
x DXB
x BX
x BS
x BT
x BB
Page MC-6 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Answer
D 1 = 26.25
D = 43.75 x DX = 0.114 x DS = 0.12 x DT = 0.25 x DB = 0.25
B 1 = 17.5
D 2 = 8.75
B = 26.25 x BX = 0.21 x BS = 0.467 x BT = 0.247 x BB = 0.077
B 2 = 17.5
The second method starts with the solution the component balances over the entire process.
This yields a system of four linear equations in four unknowns. The problem is formulated in
matrix form and is solved by matrix inversion.
The remaining total and component balances yield a series of simple algebraic equations.
B D2 B2
D D1 B1
x D2X . D 2 x B2X . B 2
x D1X . D 1 x B1X . B 1 x BX
x DX B
D
x D2S .D 2 x B2S . B 2
x D1S .D 1 x B1S .B 1 x BS
x DS B
D
x D2T .D 2 x B2T .B 2
x D1T .D 1 x B1T .B 1 x BT
x DT B
D
x D2B .D 2 x B2B .B 2
x D1B .D 1 x B1B .B 1 x BB
x DB B
D
Answer
D 1 = 26.25
D = 43.75 x DX = 0.114 x DS = 0.12 x DT = 0.492 x DB = 0.274
B 1 = 17.5
D 2 = 8.75
B = 26.25 x BX = 0.21 x BS = 0.467 x BT = 0.247 x BB = 0.077
B 2 = 17.5
Page MC-7 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
There are a variety of ways to solve this problem in Mathcad. To fit a polynomial, the
Mathcad function, linfit, can be used to fit any linear combination of arbitrary functions in the
form y = a0 + a1*f 1(x) + a2*f 2(x) + ... + an*fn(x). Mathcad gives as the result the vector a, the
coefficients of the linear combination.
Both the Clausius-Clapeyron and Antoine equations can be rewritten in a form so that linear
regression can be used. Otherwise, a non-linear least-squares technique could be applied.
a) To fit an nth order polynomial, an vector containing the n+1 functions is used in the linfit
function. The function also requires the vectors containing the data. To calculate the
variance of the error, the Mathcad function var is used. This example shows the calculation
for the polynomial that gave the smallest variance. The variance for other polynomials is
shown in a table below.
36.7 1
Define vectors T and P containing the data:
19.6 5
11.5 10
Define the vector of functions, F(x), to be fit:
2.6 20
1
7.6 40
x T P
15.4 60
2
x
26.1 100
F( x ) 3
x 42.2 200
4
x 60.6 400
5 80.1 760
x
Use the last function to count the number of data points, ndata, and the number of terms in
the function array. Note that Mathcad starts vectors and matrices with index 0 as the default.
The last function actually gives the index of the last term in the vector.
ndata last( T ) i 0 .. ndata n last( F( 1 ) )
24.754264
Results:
1.609017
c linfit( T , P , F ) 0.035605 Order Variance
1 11,859
c= 4 2 852
4.129782 10
3 20
6 4 0.199
4.226066 10
5 0.1944
9 6 0.1210
2.505099 10
n
Calculate the errors
c. T
j
errori P var( error ) = 0.194361
and then the variance i j i
j=0
Page MC-8 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
800
600
P
i
n
j 400
c. T
j i
j= 0
200
0
40 20 0 20 40 60 80 100
T
i
For the Clausius-Clapeyron and Antoine equations the equations can be rearranged into a form
so that linear regression can be used. By multiplying by the denominator of the second term on
the right hand side and rearranging algebraically, the following equations are obtained:
For the Clausius-Clapeyron equation linear regression can be used by setting y = log(P) and
x = 1/(T+273.15). The slope = -B and the intercept = A. Mathcad has slope and intercept
functions for linear regression.
For the Antoine equation, least squares is used using a psuedo-inverse calculation.
A intercept( x , y ) A = 8.75201
3
B slope ( x , y ) B = 2.035 10
B 3
Calculate the errors errori log Pi A var( error ) = 6.073244 10
and then the variance Ti 273.15
Page MC-9 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
P
i
B 500
A
T 273.15
i
10
0
220 240 260 280 300 320 340 360
T 273.15
i
Mi , 0 Ti Mi , 1 log Pi Mi , 2 1
B
Calculate the errors errori log Pi A 4
Ti C var( error ) = 2.26 10
and then the variance
P
i
B 500
A
T C
i
10
0
40 20 0 20 40 60 80 100
T
i
Page MC-10 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
This problem can be solved directly using a Mathcad Solve Block. The Solve Block includes
the equilibrium equations as well as the equations describing the stoichiometry. An initial
guess must be made for the concentrations. Initial guesses will be used as given.
Given initial concentrations and equilibrium constants: C A0 1.5 C B0 1.5
K C1 1.06 K C2 2.63 K C3 5
C A0 C B0 C A0
CA CB CC CY 0
2 2 2
Given
K C1 . C A .C B C C .C D K C2 . C B .C C C X .C Y K C3 . C A .C X CZ
C A C A0 CD CZ C B C B0 CD CY CC CD CY CY CX CZ
0.4207
0.2429
0.1536
Find C A , C B , C C , C D , C X , C Y , C Z = 0.7053
0.1778
0.5518
0.374
K C1 . C A .C B C C .C D K C2 . C B .C C C X .C Y K C3 . C A .C X CZ
C A C A0 CD CZ C B C B0 CD CY CC CD CY CY CX CZ
0.4207
0.2429
0.1536
Find C A , C B , C C , C D , C X , C Y , C Z = 0.7053
0.1778
0.5518
0.374
Page MC-11 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
K C1 . C A .C B C C .C D K C2 . C B .C C C X .C Y K C3 . C A .C X CZ
C A C A0 CD CZ C B C B0 CD CY CC CD CY CY CX CZ
0.4207
0.2429
0.1536
Find C A , C B , C C , C D , C X , C Y , C Z = 0.7053
0.1778
0.5518
0.374
Mathcad gives the same results for all sets of starting values.
Page MC-12 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Define the drag coefficient, CD, based on the value of the Reynolds number.
8 .10
4
24 24 .
0.14 .Re
0.7
C D ( Re ) if Re < 0.1 , , if Re < 1000 , 1 , if Re < 350000 , 0.44 , 0.19
Re Re Re
kg
0.208 .10 .m 1800 .
3
Particle diameter and density Dp ρp
3
m
4 kg kg
Fluid viscosity and density µ 8.931 .10 . ρ 994.6 .
m . sec m
3
m
vt 1.
Guess a starting value of the terminal velocity: sec
Given
4 . g. ρ p ρ . D p
vt
3 . C D Re v t .ρ
vt Find v t
m
Answer: v t = 0.016 Re v t = 3.656
sec
Note that units have been included for all of the variables. The answer can be expressed in
any set of units desired. Some examples are given below.
ft mi mm in
v t = 0.052 v t = 0.035 v t = 15.782 v t = 37.279
sec hr sec min
Page MC-13 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
b) Mathcad has the gravitational acceleration predefined. For this case, g is redefined as 30g.
m
g 30 .g Guess: vt 1.
sec
Given
4 . g. ρ p ρ . D p
vt
3 . C D Re v t .ρ
vt Find v t
m
Answer: v t = 0.206 Re v t = 47.723
sec
Page MC-14 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Calculate the steady state temperature by setting derivatives to zero and solving remaining
equations using a Mathcad Solve Block.
Given
For the solution of multiple ODEs Mathcad requires that the functions of the right hand side be
defined in a vector of functions. The initial conditions are assigned to the vector variable to be
solved for.
20 W .C p . T 0 T1 UA . T steam T1
Initial conditions: T 20 M .C p
20 W .C p . T1 T2 UA . T steam T2
D( t , T )
Function vector: M .C p
W .C p . T2 T3 UA . T steam T3
M .C p
Set initial time, final time and size of time step in minutes. Calculate number of points calculated.
t final t0
t0 0 t final 100 ∆t 1 npoints 1
∆t
Solve the differential equations using the function Rkadapt.
Z Rkadapt T , 0 , t final , npoints , D
The solution is stored in an array. The first column represents the time at each step. The
remaining columns represent the solution vectors.
Assign columns of the solution array to vectors for clarity
64
99 .% .T3ss
50
T1
n
T2
n 40
T3n
30
20
0 20 40 60 80 100
time
n
99% of steady state value: 99 .% .T3ss = 50.804 Calculate value at 64 minutes: T3 64 = 50.777
∆t
The solution to this problem will use Mathcad's ability to solve two point boundary value
problems. The solution method has two parts. In the first part, Mathcad estimates the missing
boundary conditions at the first point. These estimated values are then used in the standard ODE
solvers to find the solution between the two boindary points. Check the Mathcad help files for
more details on using this method.
Assign values to the pysical properties and dimensions for the problem
1.2 . 10
9 3
Diffusivity D AB Reaction rate constant k 10
3
Initial concnetration: C A0 0.2 Slab depth: L 10
L
Set position of first and second point and step size: z1 0 z2 L ∆z
100
Mathcad uses the load and score functions in estimating the missing initial conditions
Initial guess for vector of unknown initial conditions: v0 1
C A0
Initial conditions (including guess vector): load( z1, v )
v0
Vector of functions representing the right hand side of the differential equations:
C1
D( z , C ) k .C
0
D AB
Score function is a measure of the difference between the computed and given values at the end
point.
score ( z2 , C ) C1
Function sbval calculates the missing initial conditions:
Now solve the differential equation using the estimated value of the inital conditions.
C0 C A0
L
z0 0 z end L npoints 1
∆z
Y Rkadapt C , z 0 , z end , npoints , D
Page MC-17 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
n 0 .. npoints zn Yn , 0 CA Yn, 1 dC A Yn , 2
n n
0.2
0.19
0.18
CA
n
z 0.17
cosh L . . 1
k n
D AB L
C A0 .
cosh L .
k 0.16
D AB
0.15
0.14
0.13
0 2 10 4 4 10 4 z 6 10 4 8 10 4
n
The differential equation that describes the unsteady state material balance includes the
k-value of component 2, k2. k2 depends implicitly on the mole fraction of component 2, x2. A
solve block will be used to define k2 as a function of x2. The first step in doing this is to write
the equilibrium temperature, Teq, as a function of x2. The vapor mole fraction can then be
defined as a function of x2 assuming the liquid behaves as an ideal solution and the vapor as
an ideal gas. k2 can then be defined as the ratio y2/x2.
atm
mole 1 mmHg C K
Coefficients for Antoine equation 760
B1 B2
A1 A2
T C1 T C2
P 1( T ) 10 . mmHg P 2( T ) 10 . mmHg
Given
1 x 2 .P 1( T ) x 2 .P 2( T ) P
Teq x 2 Find( T )
x 2 .P 2 Teq x 2
Define vapor mole fraction assuming ideal gas: y2 x2
P
y2 x2
Definition of k-value: k2 x2
x2
Page MC-19 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Now solve the unsteady state material balance equation using the adaptive Runge-Kutta method
Define the function on the right hand side of the differential equation:
L
D x 2, L
x 2. k 2 x 2 1
x 2f x 2i
Set initial and final values x 2i 0.4 x 2f 0.8 ∆x 2 0.01 npoints 1
∆x 2
i 0 .. npoints Li Zi , 1 x2 Zi , 0
i
80
60
L
i
40
20
0
0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75
x2
i
Page MC-20 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
J J
Heat of reaction: ∆H R 40000 . Activation energy: EA 41800 .
mole mole. K
6
dm
k 450 0.5 .
Arrhenius constant at 450 K: kg. min. mole
3
dm
Equilibrium constant at 450 K: K C450 25000 .
mole
J
Heat transfer coefficient: UA 0.8 . Coolant temperature: Ta 500. K
kg. min. K
mole mole
Initial flow rate, concentration and pressure: F A0 5.0 . C A0 0.271. P0 10. atm
min 3
dm
y A0 1.0
Initial temperature and gas mole fraction of A: T0 450. K
1
Constant used in calculating pressure drop: α 0.015. kg
EA
Kinetic rate expression: k( T ) k 450. exp . 1 1
R T0 T
∆H R
Equilibrium expression: K C( T ) K C450. exp . 1 1
R T0 T
1 X . .T 0 0.5 . X . . T 0
C A( X , y, T ) C A0. y C C ( X , y, T ) C A0. y
1 0.5 . X T 1 0.5 . X T
Page MC-21 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Reaction rate expressed as a function of conversion, vapor mole fraction and temperature
2
C C( X , y , T )
r A( X , y , T ) k( T ) . C A( X , y , T )
K C( T )
Mathcad requires the unknown variables to be expressed as a vector. We will define the variables
as follows: X = x0, y = x1 and T = x2
Express the right hand side of the three differential equations as a vector of functions
r A x0 , x1 , x2. T 0
F A0
1 0.5 . x0 x2. T 0
D( W , x ) α. .
2 . x1 T0
0
Initial conditions: x 1
1
Wf W0
Initial and final weight of catalyst: W0 0 Wf 20 ∆W 0.1 npoints 1
∆W
i 0 .. npoints Wi Zi , 0 Xi Zi , 1 yi Zi , 2 Ti Zi , 3. T 0
Page MC-22 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
1.5
X 1 y
i i
y
i
Ti Ti /(1000K) Xi
1000. K 0.5
0
0 2 4 6 8 10 12 14 16 18 20
W
i
b) The "knee" in the curve represents the acceleration in reaction rate due to the rapid increase in
temperature for the exothermic reaction.
c) Evaluate the concentration profiles using the calculated values of conversion, vapor mole
fraction and temperature
0.3
0.25
C A X ,y ,T CA
i i i 0.2
mole
3
dm
0.15
C C X ,y ,T
i i i
mole
3 0.1
dm
0.05
0
0 5 10 15 20
W
i
Page MC-23 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
KC
Define the heat input calculated by the controller: q T m, e .e
qs K C. T r Tm
τI
Mathcad requires the unknown variables to be expressed as a vector. We will define the variables
as follows: T = x0, T0 = x1, Tm = x2, and errsum = x3
The step change in inlet temperature is represented in Mathcad by defining the inlet temperature as
a function of time using an if function.
Ti( t ) if t < 10 , T is , T is 20
Define the vector of functions representing the right hand side of the ODEs
WC p . Ti( t ) x0 q x2 , x3
ρVC p
τ d WC p . Ti( t ) x0 q x2 , x3
x0 x1 . .2
D( t , x ) 2 ρVC p τd
x1 x2
τm
Tr x2
Page MC-24 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Tr Final time: tf 60
x
Tr Time step: ∆t 0.1
tf t0
0 npoints 1 i 1 .. npoints
∆t
Z Rkadapt x , t 0 , t f , npoints , D
ti Zi , 0 Ti Zi , 1 T0 Zi , 2 Tm Zi , 3 errsumi Zi , 4
i i
85
80
T
i 75
T0
i
T m 70
i
65
60
0 10 20 30 40 50 60
t
i
Page MC-25 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Define the vector of functions representing the right hand side of the ODEs
WC p . Ti( t ) x0 q x2 , x3
ρVC p
τ d WC p . Ti( t ) x0 q x2 , x3
x0 x1 . .2
D( t , x ) 2 ρVC p τd
x1 x2
τm
Tr x2
85
T 80
i
T0
i
75
Tm
i
Tr 70
65
0 20 40 60 80 100 120 140 160 180 200
t
i
Page MC-26 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Define the vector of functions representing the right hand side of the ODEs
WC p . Ti( t ) x0 q x2 , x3
ρVC p
τ d WC p . Ti( t ) x0 q x2 , x3
x0 x1 . .2
D( t , x ) 2 ρVC p τd
x1 x2
τm
Tr x2
100
T
i
T0
i
80
Tm
i
Tr
60
0 20 40 60 80 100 120 140 160 180 200
t
i
Page MC-27 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
Define the vector of functions representing the right hand side of the ODEs
WC p . Ti( t ) x0 q x2 , x3
ρVC p
τ d WC p . Ti( t ) x0 q x2 , x3
x0 x1 . .2
D( t , x ) 2 ρVC p τd
x1 x2
τm
Tr x2
Tr Final time: tf 60
x
Tr Time step: ∆t 0.1
tf t0
0 1 npoints i 1 .. npoints
∆t
Solve the system of ODEs using the adaptive Runge-Kutta method
Z Rkadapt x , t 0 , t f , npoints , D
85
T 80
i
T0
i
75
Tm
i
Tr 70
65
0 10 20 30 40 50 60
t
i
Page MC-28 MATHEMATICAL SOFTWARE PACKAGES IN CHEMICAL ENGINEERING
KC 5000 τI 2000000
Define the step increase in set point at time 10 using Mathcad if function.
Ti( t ) T is T r( t ) if t < 10 , T r0 , T r0 10
Define the limiting behavior of the heater using nested Mathcad if functions.
KC
q 0 T m, e, t qs K C. T r( t ) Tm .e
τI
Define the vector of functions representing the right hand side of the ODEs
WC p . T is x0 q x2 , x3 , t
ρVC p
τ d WC p . T is x0 q x2 , x3 , t
x0 x1 . .2
D( t , x ) 2 ρVC p τd
x1 x2
τm
T r( t ) x2
Solve the system of ODEs using the fixed interval Runge-Kutta method. The adaptive method was
too slow!
Z rkfixed x, t 0 , t f , npoints , D
100
95
Ti
90
T0
i
Tm
i
85
Tr t
i
80
75
0 20 40 60 80 100 120 140 160 180 200
t
i
8 104
4
6 10
0
4
q 0 T m , errsum , t 4 10
i i i
q T m , errsum i , ti
i
2 104
2.6 . q s
2 104
0 50 100 150 200
t
i