Sie sind auf Seite 1von 35

CHEE 222: CHEMICAL PROCESS DYNAMICS AND

NUMERICAL METHODS

[Module 3: Dynamic Lumped Parameter System]


Topics to be covered in this module
• Origin of Ordinary Differential Equations
– Transient balance for lumped parameter systems
– Steady state balance for distributed parameter system

Numerical Methods
• Numerical Integration of Ordinary Differential Equation
– Euler’s Method
• Explicit and Implicit Methods + Numerical Stability of Explicit Method
– Runge-Kutta Method
• Second- and Fourth-Order Runge-Kutta Methods
– Computer-Based ODE Solution Techniques
• Matlab Integration Routines
– Ode23 and Ode45Study of transient behavior

Process Dynamics
• Case study: CSTR with first-order reaction kinetics
Types of System and Resulting Equations

Lumped Parameter System Distributed Parameter System

Steady State Dynamic Steady State Dynamic

X
Algebraic
Differential Differential Partial
Equations
Equations Equations Differential
Equations

Linear Non-Linear

Single Multi-
Variable Variable
Transient Lumped Parameter System
• For a constant density (ρ ) fluid of
density being flowed in and out of a
storage tank of uniform cross-
section area (A), the transient mass
balance (derived earlier in the class)
takes the following form: Fin

dh Fin Fout
= − Fout
dt A A

Note: The density parameter does not appear because it cancels out
Steady State Distributed Parameter System

Consider viscous flow in a pipe.

The differential equation to describe the local pressure


drop takes the following form (you’ll learn more in
CHEE 223):

dP 4 f ρv 2
=− ( )
dz D 2
Numerical Methods for Solving
Ordinary Differential Equations
Euler’s Method
Numerical Solutions for ODEs: The Euler Method
Let us consider a single-variable ODE by the following equation
x = f (x ) with the initial condition x(0) = x0

Objective: To find the solution x(t).


Strategy: Approximate x or dx over a finite time length or
time-step (∆ t) dt
dx
The basic idea is to approximate by a difference scheme
dt
dx x(t + ∆t ) − x(t )

dt t (t + ∆t ) − t

The value of expression f(x) is evaluated and is then used to estimate


the value of x (t+∆ t)
Graphical illustration will be provided in class
Explicit Euler Methods
In this method, the value of f(x) is evaluated at known value of x
or at xk. The term dx/dt is represented by the following difference
scheme
dx xk +1 − xk

dt tk ∆t
The derivative is then equated to f(x)
xk +1 − xk
= f ( xk )
∆t
The value of x at t=t+∆ t is then calculated by the following
equation:
xk +1 = xk + ∆t ⋅ f ( xk )
Note that the RHS of the above equation contains all known
values, therefore, the equation can be solved explicitly
Euler’s IMPLICIT Method
Implicit Euler Methods
This method differs from the implicit method in that the value of f(x) is
evaluated at unknown value of x or at xk+1 . The dx/dt is represented by a
difference scheme
dx xk +1 − xk

dt tk ∆t
The derivative is equated to f(xk+1 ) and we get:
xk +1 − xk
= f ( xk +1 )
∆t
The equation can be rearranged as follows:

xk +1 = xk + ∆t ⋅ f ( xk +1 )
Clearly, the equation is implicit in the unknown xk+1 . Depending on the
non-linearity of f(x), an iterative solution may be required
Stability of Explicit Method
Explicit Euler’s Method: Stability
• Tutorial#5 problem illustrates that explicit Euler’s Method may result in a
solution that generates oscillatory solution.

• The oscillatory behavior is due to “numerical approximation”.

• The solution can also be unstable.

• For Euler’s explicit method, both the instability and oscillation are the result
of step-size chosen for integration.

• From mathematical theory, the conditions for stability can be found. Here,
we provide you with that condition (the derivation is beyond the scope of
this course).
Explicit Euler’s Method: Stability
The general form of solution for Explicit Euler Method is as follows:

x k +1 = x k + ∆t ⋅ f ( x k )

Let us denote the RHS of the above equation as a function g(xk). The
requirement for stable solution is as follows:

g ' ( xk ) < 1

where, g΄(xk) is the derivative of g(xk) with respect to xk

In lecture, we will apply this criterion to the Tutorial#6 problem


Euler’s Method: Closing Remarks

• Euler’s method is rarely used in advanced computational routines. Nonetheless,


it is very useful in demonstrating the general concept on numerical integration

• Explicit Euler Method is easy to implement due to explicit nature of the equation
but numerical stability can be a problem

• Stability problems can be overcome with an appropriate choice of step-size.

• Smaller steps sizes are always desirable because they lead to increased accuracy.
However, small step-size come at the cost of increased computation time.

• Implicit methods are inherently stable.

• Implicit Euler Method for non-linear equations require an iterative solution such
as Newton’s method.

• Finally, stable does not mean accurate.


Runge-Kutta Method
Runge-Kutta Methods

• Runge-Kutta methods are variations of explicit methods.

• Runge-Kutta methods are used extensively in computational


packages.
– MATLAB uses 2nd and 4th order methods – “ode23” and “ode45”
solvers

• The basic idea is to estimate an improved guess for the


derivative and, in turn, a better estimate for the integrated
variable.
2nd Order Runge-Kutta (RK2) Method
Objective: To numerically integrate the following ordinary differential equation.
dx
Integration Procedure: x = = f (x )
dt the slope or derivative at xk
• Apply Euler’s method to estimate

m1 = f ( xk )
• Estimate the value of state variable at a mid-point, i.e. x(t+∆ t/2).
∆t ∆t
xk +1/ 2 = xk +
m1 xk +1/ 2 = xk + f ( xk )
2 2
• Calculate the slope or derivative at this mid-point
m2 = f ( xk +1/ 2 )

• Estimate the value of state variable at next time step, i.e. xk+1 using slope at
mid-point:

xk +1 = xk + ∆t ⋅ m2

Illustrative examples to be discussed in lecture


4th Order Runge-Kutta Method (RK4 Method)
Integration Procedure:
• Apply Euler’s method to estimate the slope (m1) or derivative at xk
m1 = f ( xk )

• Estimate the value of state variable∆tat a mid-point, i.e. x(t+∆ t/2).


xk +1/ 2 = xk + m1
2

• Calculate the slope or derivative (m2) at this mid-point to estimate new mid-
point state variable x΄k+1/2 ∆t
k +1 / 2 = xk +
'
m2 = f ( xk +1/ 2 ) x m2
2

• Find “corrected” mid-point slope (m3) at this new mid-point x΄k+1/2


m3 = f ( x k +1/ 2 )
'
x k +1 = xk + ∆t ⋅ m3
'

m4 = f ( x ' k +1 )
• A final slope (m4)is evaluated at the end of the step
4th Order Runge-Kutta Method (Cont.)

The new state variable at the integration step is calculated by a


weighted average of three slopes:

m1 m2 m3 m4
xk +1 = xk + [ + + + ] ⋅ ∆t
6 3 3 6
Multi-variable RK method
RK Methods: Closing Remarks

• 2nd order Runge-Kutta Method is more accurate than Euler’s


explicit method

• 4th order Runge-Kutta Method is preferred when higher


accuracy is required.

• Selection of step-size is crucial for accuracy and usually class


problems are solved using a fixed step-size. However, Most of
the integration routines use a variable step-size.
Numerical Integration in Matlab

• So far, we have learned about Runge-Kutta methods for


integration of ordinary differential equation.

• Runge-Kutta methods are used extensively in computational


packages.
– MATLAB uses 2nd and 4th order methods – “ode23” and “ode45”
solvers
Study of Transient Behavior of a Chemical Process:
CSTR with 1st -order Rate Kinetics
CSTR: Steady State and Transient Behavior
C STR Beha v io r a nd Tra ns ien ce
CSTRs ar e d es ig ned to o perate at s teady -s tate and , as su ch , trans ien t ef fects ar ise fr om th e fo llo wing situ atio n s:
star t-u p s o r s hu t- do wn o f r eacto r
u ps ets o r d istu rb a nces (f luctu atio n s) of state an d/o r desig n variables d ur in g op er atio n
tr an sien ce fro m o ne stead y- state to the o ther.



R ole o f a p ro cess eng in eer o p era tin g a C STR .


The pr imary interest is to an alyze the stead y state con ditio ns . A s well, to p redict h o w the sy stem b eh aves d u rin g trans ien t p er io d.

How d o we u nd erta ke th is st ud y o f stea dy st at e a nd t ra ns ien t b eh a vior?


Deri vat ion of Tota l M a ss Ba lance
Deri vat ion of Mole B a lance on Rea cta nt A
C alc ula tion of Ste ady-Stat e C oncentrat ion
Dete rmina tion of ana lytica l s olution for the problem, i.e . C (t) = ?





Case Study: CSTR Transient Behavior
Study of SS & Transient Behavior of a CSTR
• Objective: Apply differential mass and mole balance to a CSTR to study
transient effects, i.e. to investigate the process dynamics of the system.
• Problem description: Consider the following CSTR system wherein a
chemical reaction following first-order rate kinetics is being carried out.

Reaction: A → B Initial Condition:


Rate Kinetics: (-rA) = k⋅ CA at t=0, CA = CA,initial = 2 mol/L

where, k=0.005 s-1

Fin = 0.15( L / s)
C A0 = 10(m ol/ L)

Fout = 0.15( L / s)
C A = ?(m ol/ L)

V =10 (L)
Fundamental Balance Equations for a CSTR
1. Differential Mass Balance Equation
Accumulation = Input Rate – Output Rate
d ( ρV )
= ρ ⋅ Fin − ρ ⋅ Fout
dt
d (V )
⇒ for constant density system (e.g. liquids) = Fin − Fout
dt

2. Differential Mole Balance on Reactant A


Accumulation = Input Rate – Output Rate + Gen. Rate – Cons.Rate

d (VC A )
= Fin ⋅ C A0 − Fout ⋅ C A + 0 − (k ⋅ C A ) ⋅ V
dt

Rate of consumption is given by a constitutive relationship – reaction kinetics.


Reaction kinetics describes how reaction rate is related to CA via a reaction rate constant
Fundamental Balance Equations for a CSTR (cont.)
2. Differential Mole Balance on Reactant A (Cont.)
For constant volume system, the following equation
d (VC A )
= Fin ⋅ C A0 − Fout ⋅ C A + 0 − (k ⋅ C A ) ⋅ V
dt
reduces to
dC A Fin F
= ⋅ C A0 − out ⋅ C A − (k ⋅ C A )
dt V V
and can be rearranged as follows:
dC A Fin Fout
+ ( + k ) ⋅ CA = ⋅ C A0
dt V V
Introducing a new variable (τ p,) below, the above equation can be re-
written as: 1
dC A C A Fout τ p =
+ = ⋅ C A0 F
( in + k )
dt τp V V
Steady State Behavior of the CSTR
3. Calculation of the Steady-State Concentration
The steady-state (SS) concentration (CA,s) can be calculated by setting dCA/dt
term equal to zero in the following equation

dC A C A Fin
+ = ⋅ C A0
dt τp V

Thus, we have

C A, s Fin Fin
0+ = ⋅ C A0 ⇒ C A, s = τ p ( ) ⋅ C A0
τp V V

τ p = 1/(0.15/10 +.005)-1 seconds = 50 s

CA,s = 50 s × (.15/10) s-1× 10 mol/L = 7.5 mol/L


Transient Behavior of the CSTR
4. Analytical Solution for Transient Mole Balance Equation
The mole balance equation below represents a first-order ordinary
differential equation.
dC A CA Fin dC A Fin
⇒ = − + ( ) ⋅ C A0 τp⋅ = −C A + τ p ⋅ ( ) ⋅ C A0
dt τp V dt V
The equation can be re-written as follows
C A, s
dC
⇒ τ p ⋅ A = −C A + C A, s
dt
The above equation can be solved to yield CA (t) by simple integration

− τ p ⋅ ln( −C A + C A,s ) = t + C1

Applying the initial condition (at t=0, CA= CA,initial ) to the above equation, we
get
− τ p ⋅ ln( −C A,initial + C A,s ) = C1
Transient Behavior of the CSTR
The solution can therefore can be derived as follows:
− τ p ⋅ ln( −C A + C A, s ) = t − τ p ⋅ ln( −C A,initial + C A, s )

Dividing by -τ p

t
ln( −C A + C A, s ) = −( ) + ln( −C A,initial + C A, s )
τp

Rearranging, we get
(C A − C A , s ) t (C A − C A, s ) t
ln[ ] = −( ) = exp (− )
(C A,initial − C A, s ) τp (C A,initial − C A, s ) τp

Finally, ∆ CA

t
C A (t ) = C A, s + (C A,initial − C A, s ) ⋅ exp(− )
τp
Case Study: Graphical Representation of the
Solution
8

5
CA (mol/L)

0.993 ∆ CA
0.865 ∆ CA
0.633 ∆ CA

∆ CA
3

1
t=τ p
t = 2τ p t = 5τ p
0
0 50 100 150 200 250 300 350 400

t (seconds)

Can you see the relevance and utility of τ p ?


Where do we go from here ?
Transient Effects of a CSTR
• Let us explore the dynamic behavior of the CSTR subjected to
the following WHAT IF scenarios:

– What if the initial concentration was varied.


– What if there was upset in feed concentration after SS operation was
established.
– What if there was upset in feed volumetric rate after SS operation was
established.

• The above scenarios will be explored via MATLAB


simulations (to be demonstrated in class)

This exercise aims to demonstrate application of


computer-aided balance equations.

Das könnte Ihnen auch gefallen