Docsity

mathcad-solutions-to-the-chemical-engineering-problem-set, Ejercicios de Métodos Numéricos

Toggle sidebar
bg1
MATHCAD SOLUTIONS TO THE CHEMICAL
ENGINEERING PROBLEM SET
Mathematical Software Session
John J. Hwalek, Department of Chemical Engineering
University of Maine, Orono, Me 04469-5737 ([email protected])
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.
Mathcad is a commercial software package developed by MathSoft, Inc. It is widely used by
engineers, scientists and mathematicians in universities as well as industry. Mathcad allows for the
integration of equations, text and graphics in a WYSIWYG interface. It has built into it a wide
variety of numerical routines to solve problems including simultaneous nonlinear equations,
systems of ordinary differential equations, numerical integration and differentiation, regression
and curve fitting as well as many other powerful features. Complete details of Mathcad's features,
system requirements and academic pricing can be found on the MathSoft Web site
(www.mathsoft.com). The solutions presented here are available at the Chemical Engineering
Mathcad Users' Group Web site
( ftp://ftp.umecheme.maine.edu/mathcad/asee).
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Vista previa parcial del texto

¡Descarga mathcad-solutions-to-the-chemical-engineering-problem-set y más Ejercicios en PDF de Métodos Numéricos solo en Docsity!

MATHCAD SOLUTIONS TO THE CHEMICAL

ENGINEERING PROBLEM SET

Mathematical Software Session

John J. Hwalek, Department of Chemical Engineering

University of Maine, Orono, Me 04469-5737 ([email protected])

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.

Mathcad is a commercial software package developed by MathSoft, Inc. It is widely used by

engineers, scientists and mathematicians in universities as well as industry. Mathcad allows for the

integration of equations, text and graphics in a WYSIWYG interface. It has built into it a wide

variety of numerical routines to solve problems including simultaneous nonlinear equations,

systems of ordinary differential equations, numerical integration and differentiation, regression

and curve fitting as well as many other powerful features. Complete details of Mathcad's features,

system requirements and academic pricing can be found on the MathSoft Web site

(www.mathsoft.com). The solutions presented here are available at the Chemical Engineering

Mathcad Users' Group Web site

( ftp://ftp.umecheme.maine.edu/mathcad/asee).

Mathcad Solution to Problem 1

Mathcad uses a structure called a solve block to solve non-linear equations. The solve block

starts with a Given statement and ends with a Find which includes the variables to be solved

for. Mathcad requires an initial guess of the solution before the start of the solve block. Note

that Mathcad allows for dimensional variables with automatic units conversion and the final

solution can be expressed in any desired units.

The equation to be solved is the van der Waals equation:

P

a

V

2

( V b)

R T

Define the constants to be used in the calculations (units included).

R 0.

atm liter

mole K

For ammonia: T c

405.5 K

P

c

111.3 atm

a

R

2 T c

2 .

P

c

a 4.

atm liter

2 .

mole

2

= b

R T

c

8 P

c

b 0.

liter

mole

a) Specify T and P: P 56 atm

T 450 K

Solve for the molar volume using a solve block

V

R T

P

V 0.

liter

mole

Initial guess of V using Ideal Gas Law:

Given Start of Solve Block

P

a

V

2

( V b)

R T

Equation to be solved

V Find V( ) V 0.

liter

mole

= End of Solve Block

Z

P V

R T

Z =0.

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).

Mathcad Solution to Problem 2

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.

First method solving all of the equations in a solve block

Defined feed rate and mole fractions.

F 70 x FX

0.15 x FS

0.25 x FT

0.4 x FB

x D1X

0.07 x D1S

0.04 x D1T

0.54 x D1B

x B1X

0.18 x B1S

0.24 x B1T

0.42 x B1B

x D2X

0.15 x D2S

0.10 x D2T

0.54 x D2B

x B2X

0.24 x B2S

0.65 x B2T

0.10 x B2B

Guess values of flow rates

and mole fractions:

D

F

D

D

B

D

B

F

D

B

B

B

x DX

0.25 x DS

0.25 x DT

0.25 x DB

x BX

0.25 x BS

0.25 x BT

0.25 x BB

Given

Component balances over entire system

x FX

F

x D1X

D

x B1X

B

x D2X

D

x B2X

B

x FS

F

x D1S

D

x B1S

B

x D2S

D

x B2S

B

x FT

F

x D1T

D

x B1T

B

x D2T

D

x B2T

B

x FB

F

x D1B

D

x B1B

B

x D2B

D

x B2B

B

Overall Balances on columns #2 and #

D D

B

B D

B

Component balances over column #2 Component balances over column #

x DX

D

x D1X

D

x B1X

B

x BX

B

x D2X

D

x B2X

B

x DS

D

x D1S

D

x B1S

B

x BS

B

x D2S

D

x B2S

B

x DT

D

x D1T

D

x B1T

B

x BT

B

x D2T

D

x B2T

B

x DB

D

x D1B

D

x B1B

B

x BB

B

x D2B

D

x B2B

B

D

B

D

B

D

B

x DX

x DS

x DXT

x DXB

x BX

x BS

x BT

x BB

Find D B, D 1

, B

, D

, B

, x DX

, x DS

, x DT

, x DB

, x BX

, x BS

, x BT

, x BB

Mathcad Solution to Problem 3

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 = a 0

  • a 1 *f 1 (x) + a 2 f 2 (x) + ... + anf n (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 n th 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.

Define vectors T and P containing the data:

Define the vector of functions, F(x), to be fit:

T

P

F x( )

x

x

2

x

3

x

4

x

5

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( ( ))

Results:

Order Variance

c linfit T P( , ,F)

c

Calculate the errors

and then the variance

error i

P

i

n

j

c j

T

i

j .

var error( ) =0.

Plot the results for the polynomial fit

P i

0

n

j

c j

T i

j .

=

T i

40 20 0 20 40 60 80 100

0

200

400

600

800

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:

Clausius-Clapeyron: log(P) = A - B/(T+273.15)

Antoine: Tlog(P) = AT - Clog(P) + [AC - B]

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.

b) Fitting the Clausius-Clapeyron equation.

x i

T

i

y i

log P i

A intercept x y( , ) A =8.

B slope x y( , ) B 2.035 10

Calculate the errors

and then the variance

error i

log P i

A

B

T

i

var error( ) 6.073244 10

Mathcad Solution to Problem 4

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 A

1.5 C

B

K

C

1.06 K

C

2.63 K

C

a) First set of initial guesses: C D

0 C

X

C

D

C

Z

C

D

C

A

C

A

C

B

C

B

C

C

C

A

C

Y

Given

K

C

C

A

C

B

C

C

C

D

K

C

C

B

C

C

C

X

C

Y

K

C

C

A

C

X

C

Z

C

A

C

A

C

D

C

Z

C

B

C

B

C

D

C

Y

C

C

C

D

C

Y

C

Y

C

X

C

Z

Find C A

C

B

, C

C

, C

D

, C

X

, C

Y

, C

Z

b) Second set of initial guesses: C D

1 C

X

C

D

C

Z

C

D

Given

K

C

C

A

C

B

C

C

C

D

K

C

C

B

C

C

C

X

C

Y

K

C

C

A

C

X

C

Z

C

A

C

A

C

D

C

Z

C

B

C

B

C

D

C

Y

C

C

C

D

C

Y

C

Y

C

X

C

Z

Find C A

C

B

, C

C

, C

D

, C

X

, C

Y

, C

Z

c) Third set of initial guesses: C D

10 C

X

C

D

C

Z

C

D

Given

K

C

C

A

C

B

.. C

C

C

D

. K

C

C

B

C

C

.. C

X

C

Y

. K

C

C

A

C

X

.. C

Z

C

A

C

A

C

D

C

Z

C

B

C

B

C

D

C

Y

C

C

C

D

C

Y

C

Y

C

X

C

Z

Find C A

C

B

, C

C

, C

D

, C

X

, C

Y

, C

Z

Mathcad gives the same results for all sets of starting values.

b) Mathcad has the gravitational acceleration predefined. For this case, g is redefined as 30g.

g 30 g.^ Guess: v t

m

sec

Given

v t

4 g

ρ p

ρ

D

p

3 C

D

Re v t

ρ

v t

Find v t

Answer: v t

m

sec

= Re v t

Mathcad Solution to Problem 6

Mathcad has built-in a variety of differential equation solvers. In this case, an adaptive

Runge-Kutta method will be used since the solution varies slowly with time and all of the

functions vary on the same time scale (i.e., they are not stiff).

System physical constants and properties kg 1 min 1 kJ 1 C 1

Mass of oil in each tank: M 1000 kg

Oil mass flow rate: W 100

kg

min

Oil heat capacity: C p

kJ

kg C

Temperature of entering oil: T 0

20 C

Steam temperature: T steam

250 C

Heat transfer coefficient: UA 10

kJ

min C

Calculate the steady state temperature by setting derivatives to zero and solving remaining

equations using a Mathcad Solve Block.

Initial guess for temperatures: T1ss 20 T2ss 20 T3ss 30

Given

W C

p

T

T1ss

UA T

steam

T1ss

M C

p

W C

p

( T1ss T2ss)

UA T

steam

T2ss

M C

p

W C

p

( T2ss T3ss)

UA T

steam

T3ss

M C

p

T1ss

T2ss

T3ss

Find T1ss T2ss( , ,T3ss)

Steady state temperatures: T1ss = 30.952 C T2ss = 41.383 C T3ss =51.317 C

Mathcad Solution to Problem 7

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

Diffusivity D AB

9 . Reaction rate constant k 10

3

Initial concnetration: C A

0.2 Slab depth: L 10

3

Set position of first and second point and step size: z1 0 z2 L ∆z

L

Mathcad uses the load and score functions in estimating the missing initial conditions

Initial guess for vector of unknown initial conditions: v 0

Initial conditions (including guess vector): load z1 v( , )

C

A

v 0

Vector of functions representing the right hand side of the differential equations:

D z C( , )

C

1

k

D

AB

C

0

Score function is a measure of the difference between the computed and given values at the end

point.

score z2 C( , ) C 1

Function sbval calculates the missing initial conditions:

C

1

sbval v 0( , , L, D, load,score) C 1

Now solve the differential equation using the estimated value of the inital conditions.

C

0

C

A

z 0

0 z end

L npoints

L

∆z

Y Rkadapt C z 0

, z end

, , npoints,D

Assign columns of the solution array to vectors for clarity

n 0 .. npoints z n

Y

n 0,^

C

A

n

Y

n 1,^

dC A n

Y

n 2,

Verify boundary value at endpoint (dC A /dz = 0)

dC A npoints

= Close enough!

Plot solution and compare with analytical solution

C A n

C A

cosh L

k

D AB

. 1

z n

L

.

cosh L

k

D AB

.

.

z n

0 2 10

4 4 10

4 6 10

4 8 10

4

Numerical solution matches analytical solution very closely.

Now solve the unsteady state material balance equation using the adaptive Runge-Kutta method

Initial condition: L 0

100 mole

Define the function on the right hand side of the differential equation:

D x 2

, L

L

x 2

k 2

x 2

Set initial and final values x 2i

0.4 x 2f

0.8 ∆x 2

0.01 npoints

x 2f

x 2i

∆x 2

Solve the differential equation: Z Rkadapt L x 2i

, x 2f

, , npoints,D

i 0 .. npoints L i

Z

i 1,^

x 2 i

Z

i 0,

Teq x 2i

= 95.585 C y 2

x 2i

= 0.213 k 2

x 2i

Initial values: L 0

Final conditions :L npoints

= 14.042 Teq x 2f

= 108.572 C y 2

x 2f

= 0.629 k 2

x 2f

Plot of mass of liquid remaining

L i

x 2 i

0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.

0

20

40

60

80

100

Mathcad Solution to Problem 9

This problem involves the solution of 3 simultaneous ODEs and uses the adaptive

Runge-Kutta Method built into Mathcad.

Define auxiliary units: J^ joule^ dm^

m

R

J

mole K

Physical properties and other parameters as given in the problem statement

Heat capacities: C PA

J

mole K

C

PB

J

mole K

Heat of reaction: ∆H R

J

mole

Activation energy: E A

J

mole K

k 450

dm

6

kg min mole Arrhenius constant at 450 K:

Equilibrium constant at 450 K: K C

dm

3

mole

Heat transfer coefficient: UA^

J

kg min K

Coolant temperature: T a

500 K

Initial flow rate, concentration and pressure: F A

mole

min

C

A

mole

dm

3

P

10 atm

y A

Initial temperature and gas mole fraction of A: T 0

450 K

Constant used in calculating pressure drop: α^

0.015 kg

1

Kinetic rate expression: k(^ T^ )

k 450

exp

E

A

R

T

T

Equilibrium expression: K C

( T)

K

C

exp

∆H

R

R

T

T

Concentrations expressed as a function of conversion, vapor mole fraction and temperature

C

A

( X y T, , )

C

A

1 X

0.5 X

y

T

T

C

C

( X y T, , )

C

A

0.5 X

0.5 X

y

T

T