ordinary differential equations (ode). differential equations heat transfer mass transfer...

43
ORDINARY DIFFERENTIAL ORDINARY DIFFERENTIAL EQUATIONS EQUATIONS (ODE) (ODE)

Upload: audrey-coleson

Post on 14-Dec-2015

258 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

ORDINARY DIFFERENTIAL ORDINARY DIFFERENTIAL EQUATIONSEQUATIONS

(ODE)(ODE)

Page 2: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Differential EquationsDifferential Equations

Heat transfer

Mass transfer

Conservation of momentum, thermal energy or mass

dz

TCd

A

q pz)(

dz

dCDJ AABAZ

Rzt

2

2

(4.1)

(4.2)

(4.3)

ODEODE

PDEPDE

Page 3: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

ODEODE

Definition

Example

A 3rd order differential equation for = (t)

Solution

independent

dependent

0)(),...,('),(, )( ttttf n (4.4)

4'''''' 2 tet (4.5)

kQdt

dQ (4.6)

tcetQ kt ,)( (4.7)

Page 4: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Important IssuesImportant Issues

1. Existence of a solution

2. Uniqueness of the solution

3. How to determine a solution

Page 5: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Linear Equation (1)Linear Equation (1)

1. Rewrite 4.9

2. Determine

where (t) is called an integrating factorintegrating factor

)()()()(...)()( 0)0(

1'

2)1(

1)( tgtatatatata n

nn

n (4.8)

)()()(')( 012 tgtatata (4.9)

0)(;)(

)()(

)(

)(' 2

2

0

2

1

tata

tatg

ta

ta for all t (4.10)

dt

ta

tat

)(

)(exp)(

2

1 (4.11)

Page 6: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Linear Equation (2)Linear Equation (2)

3. Multiply both sides of equation 4.10 by (t)

Observe that the left-hand side of eqn 4.12 can be written as

or

)(tdt

d

)()(

)()()(

)(

)('

2

0

2

1 tta

tatgt

ta

ta

(4.12)

)()(

)(exp

)(

)(

)(

)(exp'

2

1

2

1

2

1 tdt

ddt

ta

ta

ta

tadt

ta

ta

(4.13)

Page 7: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Linear Equation (3)Linear Equation (3)

Equation (4.12) can be rephrase as:

4. Integrate both sides of Equation (4.14) with respect to the independent variable:

dt

ta

ta

ta

tatgdt

ta

ta

dt

d

)(

)(exp

)(

)()(

)(

)(exp

2

1

2

0

2

1

cdtdtta

ta

ta

tatgdt

ta

ta

)(

)(exp

)(

)()(

)(

)(exp

2

1

2

0

2

1

(4.14)

dt

ta

tacdtdt

ta

ta

ta

tatgdt

ta

tat

)(

)(exp

)(

)(exp

)(

)()(

)(

)(exp)(

2

1

2

1

2

0

2

1 (4.15)

where cc is the constant of integrationconstant of integration

Page 8: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example 1Example 1

Water containing 0.5 kg of salt per liter is poured into a tank at a rate of 2 l/min, and the well-stirred mixture leaves at the same rate. After 10 minutes, the process is stopped and fresh water is poured into the tank at a rate of 2 l/min, with the new mixture leaving at 2 l/min. Determine the amount (kg) of salt in the tank at the end of 20 minutes if there were 100 liters of pure water initially in the tank.

2 l/min

2 l/min, CA (l/min)CA

½ kg salt/l

Page 9: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

SolutionSolution

Page 10: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example 2Example 2

Consider a tank with a 500 l capacity that initially contains 200 l of water with 100 kg of salt in solution. Water containing 1 kg of salt/l is entering at a rate of 3 l/min, and the mixture is allowed to flow out of the tank at a rate of 2 l/min. Determine the amount (kg) of salt in the tank at any time prior to the instant when the solution begins to overflow. Determine the concentration (kg/l) of salt in the tank when it is at the point of overflowing. Compare this concentration with the theoretical limiting concentration if the tank had infinite capacity.

Page 11: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

SolutionSolution

Page 12: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

THEOREMTHEOREM

If the functions p and g are continuous on an open interval < x < containing the point x = x0, then there exists a unique function y = (x) that satisfies the differential equation

y’ + p(x)y = g(x)

for < x < , and that also satisfies the initial condition

y(x0) = y0

where y0 is an arbitrary prescribed initial value.

Page 13: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Higher ODE Reduces to 1Higher ODE Reduces to 1stst Order Order

2

2( ) ( )

Define , we have

( ) ( )

d y dyq x r x

dx dxdy

zdx

dyz

dxdz

r x q x zdx

2

1 2 3

12

23

231 3 2 1

'''( ) ( ) ''( ) 2( '( )) ( ) 0

Define , ', '', we have

2( )

y x y x y x y x y x

y y y y y y

dyy

dxdy

ydxdy

y y y ydx

In general, it is sufficient to solve first-order ordinary differential equations of the form

1( , , , ), 1, 2, ,ii N

dyf x y y i N

dx

Page 14: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Nonlinear equations can be reduced to linear ones by a substitution. Example:

y’ + p(x)y = q(x)yn

and if n 0,1 then

(x) = y1-n(x)

reduces the above equation to a linear equation.

(4.16)

(4.17)

Page 15: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example 3Example 3

Suppose that in a certain autocatalytic chemical reaction a compound A reacts to form a compound B. Further, suppose that the initial concentration of A is CA0 and that CB(t) is the concentration of B at time t. Then CA0 – CB (t) is the concentration of A at time t. Determine CB(t) if CB(0) = CB0.

Page 16: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Solution Solution

Page 17: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

NONLINEAR ORDINARY NONLINEAR ORDINARY DIFFERENTIAL EQUATIONSDIFFERENTIAL EQUATIONS

Page 18: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

NONLINEAR EQUATIONSNONLINEAR EQUATIONS

Rewrite as

0),(),( dt

dtNtM

),( tf

dt

d

If M is a function of t only, and N is a function of only, then

0)()( dt

dNtM

dttMdN )()( Separable

Page 19: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

NONLINEAR EQUATIONSNONLINEAR EQUATIONS

Consider

)( 0 BABB CCkC

dt

dC

0)0( BB CC

kdtCCC

dC

BAB

B )( 0

subject to

Then, it is separable and results in:

(4.16)

Page 20: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Simplifying left-hand side; 1st consider the fraction

BABBAB CCCCCC

00 )(

1

1)( 0 BBA CCC

1:0 0 AB CC

0

1

AC

where and are constants to be determined. Then:

If we put

then

(4.17)

Page 21: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Rewrite equation 4.17

1: 00 AAB CCC If we put

0

1

AC

then

BA

A

B

A

BAB CC

C

C

C

CCC

0

00

0

11

)(

1

Page 22: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

And equation 4.16 becomes

which integrates to:

kdtdCCCCC BBABA

00

111

)exp(1

1

0

0

ktmCC

C AC

BA

B

where m1 is an arbitrary constant to be determined with the given initial condition. @ t = 0, CB = CB0, then

1

1

0

0

mCC

C AC

BA

B

0000

00

)exp()()(

BABA

ABB CtkCCC

CCtC

Page 23: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example of Problem SetupExample of Problem Setup

Consider the continuous extraction of benzoic acid from a mixture of benzoic acid and toluene, using water as the extracting solvent. Both streams are fed into a tank where they are stirred efficiently and the mixture is then pumped into a second tank where it is allowed to settle into two layers. The upper organic phase and the lower aqueous phase are removed separately, and the problem is to determine what proportion of the acid has passed into the solvent phase.

Page 24: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example (cont…)Example (cont…)

List of assumptions1. Combine the two tanks into a single stage2. Express stream-flow rates on solute-free basis3. Steady flowrate for each phase4. Toluene and water are immiscible5. Feed concentration is constant6. Mixing is efficient, the two streams leaving the stage are in

equilibrium with each other given by y = mx7. Composition stream leaving is the same with the composition

in the stage8. The stage initially contains V1 liter toluene, V2 liter water and

no benzoic acid

Page 25: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Problem 1Problem 1

Consider an engine that generates heat at a rate of 8,530 Btu/min. Suppose this engine is cooled with air, and the air in the engine housing is circulated rapidly enough so that the air temperature can be assumed uniform and is the same as that of the outlet air. The air is fed to the housing at 6lb-mole/min and 65oF. Also, an average of 0.20 lb-mole of air is contained within the engine housing and its temperature variation can be neglected. If heat is lost from the housing to its surroundings at a rate of Q(Btu/min) = 33.0(T-65oF) and the engine is started with the inside air temperature equal to 65oF.

1. Derive a differential equation for the variation of the outlet temperature with time.

2. Calculate the steady state air temperature if the engine runs continuously for indefinite period of time, using Cv = 5.00 Btu/lb-mole oF.

Page 26: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Problem 2Problem 2

A liquid-phase chemical reaction with stoichiometry A B takes place in a semi-batch reactor. The rate of consumption of A per unit volume of the reactor is given by the first order rate expression

rA (mol/liter.s) = kCA

where CA (mol/liter) is the reactant concentration. The tank is initially empty. At time t=0, a solution containing A at a concentration CA0(mol/liter) is fed to the tank at a steady rate (liters/s). Develop differential balances on the total volume of the tank contents, V, and on the moles of A in the tank, nA .

Page 27: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Solving ODEs using Numerical MethodsSolving ODEs using Numerical Methods

Initial Value Problem (IVP)y’’ = -yx

y(0) = 2, y’(0) = 1

Boundary Value Problem (BVP)y” = -yx

y(0) = 2, y’(1) = 1

Page 28: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

General ProcedureGeneral Procedure

Re-write the dy and dx terms as Δy and Δx and multiply by Δx

Literally doing this is Euler’s method

Niyyyxfdx

xdyNi

i ,...,1),...,,()(

21 equations for

xyxfyy

yxfx

xy

yxfdx

xdy

iiii

),(

),()(

),()(

1

Page 29: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Tank mixing problemTank mixing problem

tccV

Vcc

ccV

V

dt

dc

iinii

in

)(

)(

1tank

tank

Page 30: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Mixing tankMixing tank

t Error Et

at t=600

300 1.4

150 0.61

100 0.39

50 0.19

30 0.11

15 0.055

10 0.036

5 0.018

3 0.011

Page 31: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Improvements to Euler’s MethodImprovements to Euler’s Method

EulerEuler

Heun’s methodHeun’s method (predictor-corrector)

Procedure

calc yi+1 with Euler (predictor)

calc slope at yi+1

calc average slope

use this slope to calc new yi+1 (corrector)

xyxfyy

yxfdx

xdy

iiii

),(

),()(

1

Page 32: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Heun exampleHeun example

xyy

yx

y

xyxfyy

yx

y

x

eyeyxy

.xyydx

dy

ii

ii

x

1

1

1

0

10

),(

)5.0(

1

36.15.0)1()(

105.0)0(

location updated

slope average

location predicted at slope :corrector

location predicted

slope (Euler) predictor

Δ withNumerical

so Analytical

at Solve

0

0.5

1

1.5

0 1x

y

Page 33: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Midpoint MethodMidpoint Method

Use Euler to calculate a midpoint location

evaluate slope y’ at the midpoint

use that to calculate full step location

0

0.5

1

1.5

0 1x

y

xyxfyy

xyxfyy

yxfy

iiii

iiii

),(2

),(

),(

2/12/11

2/1

Page 34: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Runge-KuttaRunge-Kutta

slope) a (aka function increment is

form General

integral the evaluate to quadrature Gaussian use Or

between locations at evaluated f of values on based

integral for fit l)(polynomia order higher use Could

hyy

hxx

dxyxfxyhxyyxfdx

dy

ii

hx

x

1

),()()(),(

Page 35: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

R-K – General formR-K – General form

)...,(

),(

),(

),(

,,,

11,122,111,11

22212123

11112

1

21

2211

1

hkqhkqhkqyhpxfk

hkqhkqyhpxfk

hkqyhpxfk

yxfk

aaa

where

kakaka

hyy

nnnnninin

ii

ii

ii

n

nn

ii

constants

:as Write

form General

Page 36: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

R-K – 1st Order FormR-K – 1st Order Form

hyxfyy

yxfk

a

ka

hyy

iiii

ii

ii

),(1

),(

constant 1

where

form General

1

1

1

11

1

Page 37: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

R-K – 2R-K – 2ndnd Order Form Order Form

11212

21

11121

11112

1

22111

2

1

1

constants

),(

),(

qapa

aa

,q,p,aa

hkqyhpxfk

yxfk

hkakayy

ii

ii

ii

y(x)

xi xi+1 x

Page 38: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

RK2 – OptionsRK2 – Options

0

0

2

1;1

),(;),(

1

2

1121221

111121

22111

a

a

qapaaa

hkqyhpxfkyxfk

hkakayy

iiii

ii

y(x)

xi xi+1

x

Page 39: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

RK2 – OptionsRK2 – Options

3

2

2

1

2

1;1

),(;),(

2

2

1121221

111121

22111

a

a

qapaaa

hkqyhpxfkyxfk

hkakayy

iiii

ii

y(x)

xi xi+1 x

y(x)

xi xi+1 x

Page 40: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

R-K – 2R-K – 2ndnd Order Form Order Form

constants

)(),(

),(

1121

212

1

22111

,q,p,aa

hOy

fqfh

x

fphfhqkyphxfk

yxfk

hkakayy

ii

ii

ii

Page 41: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

RK – 3rd Order FormRK – 3rd Order Form

)2,(

)2

1,

2

1(

),(

46

1

213

12

1

3211

hkhkyhxfk

hkyhxfk

yxfk

hkkkyy

ii

ii

ii

ii

y(x)

xi xi+1 x

Page 42: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

RK – 4th OrderRK – 4th Order

),(

)2

1,

2

1(

)2

1,

2

1(

),(

226

1

33

23

12

1

43211

hkyhxfk

hkyhxfk

hkyhxfk

yxfk

hkkkkyy

ii

ii

ii

ii

ii

y(x)

xi xi+1 x

Page 43: ORDINARY DIFFERENTIAL EQUATIONS (ODE). Differential Equations Heat transfer Mass transfer Conservation of momentum, thermal energy or mass (4.1) (4.2)

Example Example yy΄́=x+y, y(0)=0=x+y, y(0)=0

x yo k1=fik2=f(x+h/

2,y+h/2k1)k3=f(x+h/

2,y+h/2k2)k4=f(x+h,y

+hk3)yn=yo+1/6(k1+2k2+2k

3+k4)h

0 0 0 0.1 0.11 0.222 0.02140

0.20.021

4 0.221 0.344 0.356 0.493 0.0918

0.4 0.092 0.492 0.641 0.656 0.823 0.2221

0.6 0.222 0.822 1.004 1.023 1.227 0.4255

0.8 0.426 1.226 1.448 1.470 1.720 0.718

1 0.718 1.718 1.990 2.017 2.322 1.120

1.2 1.120 2.320 2.652 2.685 3.057 1.655

1.4 1.655 3.055 3.461 3.501 3.955 2.353

1.6 2.353 3.953 4.448 4.498 5.052 3.250

1.8 3.250 5.050 5.654 5.715 6.393 4.389

0

0.5

1

1.5

2

2.5

3

3.5

0 0.5 1 1.5 2

x

y

Euler

analytical

RK4