Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ordinary differential equations

Similar presentations


Presentation on theme: "Ordinary differential equations"— Presentation transcript:

1 Ordinary differential equations

2

3 Finite element method Divide macroscopic object into small pieces
Can investigate real-size objects in real world time regimes Disregarding of atomic nature of matter and long-range interactions

4 Case study Reactor with reaction

5 More complicated problem Accumulation = inputs - outputs

6 More complicated problem Accumulation = inputs - outputs
𝑄 55 =2 𝑚 3 𝑚𝑖𝑛 inputs outputs 𝑄 15 =3 𝑚 3 𝑚𝑖𝑛 outputs 𝑐 5 𝑄 54 =2 𝑚 3 𝑚𝑖𝑛 outputs outputs 𝑄 25 =1 𝑚 3 𝑚𝑖𝑛 𝑄 44 =11 𝑚 3 𝑚𝑖𝑛 inputs outputs inputs outputs inputs outputs 𝑄 01 =5 𝑚 3 𝑚𝑖𝑛 𝑐 01 =20 𝑚𝑔/ 𝑚 3 𝑄 12 =3 𝑚 3 𝑚𝑖𝑛 𝑐 1 𝑐 2 𝑐 4 outputs 𝑄 23 =1 𝑚 3 𝑚𝑖𝑛 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛 inputs outputs inputs 𝑄 34 =8 𝑚 3 𝑚𝑖𝑛 𝑄 03 =8 𝑚 3 𝑚𝑖𝑛 𝑐 03 =20 𝑚𝑔/ 𝑚 3 𝑐 3

7 How to solve that problem? Accumulation = inputs - outputs So?
𝑄 15 =3 𝑚 3 𝑚𝑖𝑛 outputs 𝑉 1 𝑑 𝑐 1 𝑑𝑡 = 𝑐 01 𝑄 01 + 𝑐 3 𝑄 31 − 𝑐 1 𝑄 12 − 𝑐 1 𝑄 15 inputs outputs 𝑄 01 =5 𝑚 3 𝑚𝑖𝑛 𝑐 01 =20 𝑚𝑔/ 𝑚 3 𝑄 12 =3 𝑚 3 𝑚𝑖𝑛 Q01c01 = 50 mg/min, Q03c03 = 160 mg/min, V1 =50 m3, V2 = 20 m3, V3 = 40 m3, V4 = 80 m3, and V5 = 100 m3 𝑐 1 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛

8 How to solve that problem? Accumulation = inputs - outputs So?
𝑄 15 =3 𝑚 3 𝑚𝑖𝑛 outputs 𝑉 1 𝑑 𝑐 1 𝑑𝑡 = 𝑐 01 𝑄 01 + 𝑐 3 𝑄 31 − 𝑐 1 𝑄 12 − 𝑐 1 𝑄 15 inputs outputs 𝑄 01 =5 𝑚 3 𝑚𝑖𝑛 𝑐 01 =20 𝑚𝑔/ 𝑚 3 𝑄 12 =3 𝑚 3 𝑚𝑖𝑛 Q01c01 = 50 mg/min, Q03c03 = 160 mg/min, V1 =50 m3, V2 = 20 m3, V3 = 40 m3, V4 = 80 m3, and V5 = 100 m3 𝑐 1 𝑉 1 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 𝑐 3 +1 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛

9 How to solve that problem? Accumulation = inputs - outputs So?
𝑄 15 =3 𝑚 3 𝑚𝑖𝑛 outputs 𝑉 1 𝑑 𝑐 1 𝑑𝑡 = 𝑐 01 𝑄 01 + 𝑐 3 𝑄 31 − 𝑐 1 𝑄 12 − 𝑐 1 𝑄 15 inputs outputs 𝑄 01 =5 𝑚 3 𝑚𝑖𝑛 𝑐 01 =20 𝑚𝑔/ 𝑚 3 𝑄 12 =3 𝑚 3 𝑚𝑖𝑛 𝑄 01 𝑐 01 =50 𝑚𝑔 𝑚𝑖𝑛 , 𝑄 03 𝑐 03 =160 𝑚𝑔 𝑚𝑖𝑛 , 𝑉 1 =50 𝑚 3 , 𝑉 2 =20 𝑚 3 , 𝑉 3 =40 𝑚 3 , 𝑉 4 =80 𝑚 3 , 𝑉 5 =100 𝑚 3 𝑐 1 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 𝑐 3 +1 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛

10 Accumulation = inputs - outputs
How to solve that problem? Accumulation = inputs - outputs For other reactors 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 𝑐 3 +1 Initially the concentration in all reactors will be zero. What will be the evolution of concentrations in time? 𝑑 𝑐 2 𝑑𝑡 =0.15 𝑐 1 −0.15 𝑐 2 𝑑 𝑐 3 𝑑𝑡 =0.025 𝑐 2 −0.225 𝑐 3 +4 𝑑 𝑐 4 𝑑𝑡 =0.1 𝑐 3 − 𝑐 𝑐 5 How to solve this problem? 𝑑 𝑐 5 𝑑𝑡 =0.03 𝑐 𝑐 2 −0.04 𝑐 5

11 A really simple example Converstion of cyclopropane to propane
𝑘= −4 1 𝑠 , 𝑇= 500 𝑜 𝐶 1st order 𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕 If the initial concentration c(0) of cyclopropane is 0.05 M, what is the concentration after 30 min?

12 How to calculate c(t)? Differential equation
𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕

13 How to calculate c(t)? Differential equation
𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕 𝟎 𝒕 𝟏 𝒄 𝒅𝒄 𝒅𝒕 𝒅𝒕 =−𝒌 𝟎 𝒕 𝒅𝒕 𝒄(𝟎) 𝒄 𝒕 𝒅𝒄 𝒄 =−𝒌 𝟎 𝒕 𝒅𝒕

14 How to calculate c(t)? Differential equation
𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕 𝒄(𝟎) 𝒄 𝒕 𝒅𝒄 𝒄 =−𝒌 𝟎 𝒕 𝒅𝒕 𝐥𝐧 𝒄 𝒕 − 𝐥𝐧 𝒄 𝟎 =−𝒌𝒕

15 How to calculate c(t)? Differential equation
𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕 𝒄(𝟎) 𝒄 𝒕 𝒅𝒄 𝒄 =−𝒌 𝟎 𝒕 𝒅𝒕 𝐥𝐧 𝒄 𝒕 − 𝐥𝐧 𝒄 𝟎 =−𝒌𝒕 𝒄 𝒕 𝒄 𝟎 = 𝒆 −𝒌𝒕

16 How to calculate c(t)? Differential equation
𝒅𝒄 𝒅𝒕 =−𝒌𝒄 𝒕 𝒄(𝟎) 𝒄 𝒕 𝒅𝒄 𝒄 =−𝒌 𝟎 𝒕 𝒅𝒕 𝐥𝐧 𝒄 𝒕 − 𝐥𝐧 𝒄 𝟎 =−𝒌𝒕 𝒄 𝒕 𝒄 𝟎 = 𝒆 −𝒌𝒕 𝒄 𝒕 =𝒄 𝟎 ∗ 𝒆 −𝒌𝒕

17 Different approach Euler’s scheme

18 Instead of solving function analytically  step by step procedure
𝒇 𝒕+𝚫𝒕 =𝒇 𝒕 + 𝒇 ′ 𝒕 ∗𝚫𝒕 Analytical solution f t

19 Instead of solving function analytically  step by step procedure
𝒇 𝒕+𝚫𝒕 =𝒇 𝒕 + 𝒇 ′ 𝒕 ∗𝚫𝒕 Analytical solution Point-by-point solution f f t t

20 How does it works  we start from f(0)
1. Choose step 𝚫𝒕=𝟏 2. Compute next point using „chain rule” 𝒇 𝒕+𝚫𝒕 =𝒇 𝒕 + 𝒇 ′ 𝒕 ∗𝚫𝒕 Example 𝒇 𝒕 =𝟐∗𝒕  𝒇 ′ 𝒕 =𝟐

21 How does it works  we start from f(0)
𝒇 𝟎+𝚫𝒕=𝟏 =𝟎+𝟐∗𝟏 = 2 f f(1) t 1

22 How does it works  we start from f(0)
𝒇 𝟏+𝟏 =𝟐+𝟐∗𝟏 = 4 f f(2) f(1) t 2 2

23 And so on… point by point we reproduce solution
f(t) = 2t f f(2) f(1) t 2 2

24 Problems? - Accuracy Example – derivative varies (change of the function’s shape) Wrong value! f t

25 Solution? – More points, shorter interval
Example – derivative varies (change of the function’s shape) f Problem? Computing efficiency! t

26 Different approach – finite difference method
How to calculate c(t)? Different approach – finite difference method 𝚫𝒄 𝚫𝒕 =−𝒄 𝒕

27 Different approach – finite difference method
How to calculate c(t)? Different approach – finite difference method 𝚫𝒄 𝚫𝒕 =−𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 𝚫𝒕 =−𝒌𝒄 𝒕

28 Different approach – finite difference method
How to calculate c(t)? Different approach – finite difference method 𝚫𝒄 𝚫𝒕 =−𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 𝚫𝒕 =−𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 =−𝚫𝐭𝒌𝒄 𝒕

29 Different approach – finite difference method, explicit scheme
How to calculate c(t)? Different approach – finite difference method, explicit scheme 𝚫𝒄 𝚫𝒕 =−𝒄𝒌 𝒕 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 𝚫𝒕 =−𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 =−𝚫𝐭𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝐤𝒄 𝒕 =𝒄 𝒕 𝟏−𝐤𝚫𝐭

30 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝐤𝚫𝐭
𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝐤𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 c t

31 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏
𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏 c 1 t

32 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏
𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏 𝒄 𝟏 = 𝒄 𝟎 𝟏−𝚫𝐭 =𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟗 c 1 t 0.1

33 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏
𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏 𝒄 𝟏 = 𝒄 𝟎 𝟏−𝚫𝐭 =𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟗 𝒄 𝟐 = 𝒄 𝟏 𝟏−𝚫𝐭 =𝟎.𝟗∗ 𝟏−𝟎.𝟏 =𝟎.𝟖𝟏 c 1 0.1 0.2 t

34 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏
𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏 𝒄 𝟏 = 𝒄 𝟎 𝟏−𝚫𝐭 =𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟗 𝒄 𝟐 = 𝒄 𝟏 𝟏−𝚫𝐭 =𝟎.𝟗∗ 𝟏−𝟎.𝟏 =𝟎.𝟖𝟏 c 1 𝒄 𝟑 = 𝒄 𝟐 𝟏−𝚫𝐭 =𝟎.𝟖𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟕𝟐𝟗 0.1 0.2 0.3 t

35 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 𝐤=𝟏 𝒄 𝒏 = 𝒄 𝒏−𝟏 𝟏−𝚫𝐭 𝚫𝐭=𝟎.𝟏 𝒄 𝟎 = 𝒄 𝟎 =𝟏 𝒄 𝟏 = 𝒄 𝟎 𝟏−𝚫𝐭 =𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟗 𝒄 𝟐 = 𝒄 𝟏 𝟏−𝚫𝐭 =𝟎.𝟗∗ 𝟏−𝟎.𝟏 =𝟎.𝟖𝟏 𝒄 𝟑 = 𝒄 𝟐 𝟏−𝚫𝐭 =𝟎.𝟖𝟏∗ 𝟏−𝟎.𝟏 =𝟎.𝟕𝟐𝟗

36 Problems? 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝐤𝚫𝐭 𝐤=𝟏 Say 𝚫𝐭=𝟏 𝐭𝐡𝐞𝐧 𝒄 𝟏 =𝒄 𝟎 𝟏−𝟏 =𝟎 𝒄 𝟐 =𝒄 𝟏 𝟏−𝟏 =𝟎 Say 𝚫𝐭>𝟏 𝚫𝐭=𝟐 𝐭𝐡𝐞𝐧 𝒄 𝟏 =𝒄 𝟎 𝟏−𝟐 =−𝒄 𝟎 <𝟎 negative concentration. Unphysical!!! 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 𝟏−𝐤𝚫𝐭 →𝟏−𝐤𝚫𝐭>𝟎→𝚫𝐭<𝟏/𝐤

37 Solution? Implicit scheme
Δ𝑡→0 f 𝑑𝑓 𝑑𝑡 𝑡 ∗ ≈ Δ𝑓 Δ𝑡 𝑡 ∗ 𝑜𝑟 Δ𝑓 Δ𝑡 𝑡 ∗ +Δ𝑡 or anywhere inbetween 𝑓 𝑡 ∗ Δ𝑓 Slope in point 𝑡 ∗ 𝑓 𝑡 ∗ +Δ𝑡 𝑡𝑔𝛽= lim Δ𝑡→0 Δ𝑓 Δ𝑡 = 𝑑𝑓 𝑑𝑡 Δ𝑡 𝛼 𝛽 𝑡 ∗ 𝑡 ∗ +Δ𝑡 t 𝑡𝑔𝛼= Δ𝑓 Δ𝑡 Average slope on Δ𝑡 interval

38 Solution? Implicit scheme
Before… Now… 𝚫𝒄 𝚫𝒕 =−𝒌𝒄 𝒕 𝚫𝒄 𝚫𝒕 =−𝒌𝒄 𝒕+𝚫𝐭 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 𝚫𝒕 =−𝒌𝒄 𝒕+𝚫𝐭 𝒄 𝒕+𝚫𝐭 −𝐜 𝐭 𝚫𝒕 =−𝒌𝒄 𝒕 𝒄 𝒕+𝚫𝐭 =𝐜 𝐭 −𝚫𝐭𝒌𝒄 𝒕+𝚫𝐭 𝒄 𝒕+𝚫𝐭 =𝐜 𝐭 −𝚫𝐭𝒌𝒄 𝒕

39 Solution? Implicit scheme
𝒄 𝒕+𝚫𝐭 =𝐜 𝐭 −𝚫𝐭𝐤𝒄 𝒕+𝚫𝐭 𝒄 𝒕+𝚫𝐭 +𝚫𝐭𝐤𝒄 𝒕+𝚫𝐭 =𝐜 𝐭 𝒄 𝒕+𝚫𝐭 𝟏+𝐤𝚫𝐭 =𝐜 𝐭 𝒄 𝒕+𝚫𝐭 = 𝐜 𝐭 𝟏+𝐤𝚫𝐭 Always positive

40 Solutions, comparison 𝒅𝒄 𝒅𝒕 =−𝒄 𝒕 𝐤=𝟏 𝒄 𝒕+𝚫𝐭 = 𝐜 𝐭 𝟏+𝚫𝐭
𝒄 𝒕+𝚫𝐭 = 𝐜 𝐭 𝟏+𝚫𝐭 𝒄 𝒕+𝚫𝐭 =𝐜 𝐭 −𝚫𝐭𝒄 𝒕 𝒄 𝒕 =𝒄 𝟎 𝒆 −𝒕 𝚫𝐭=𝟎.𝟏 𝚫𝐭=𝟐

41 Problems? - Accuracy Example – derivative varies (change of the function’s shape) Wrong value! f t

42 But what about set of ODE?
Same approach combined with linear equations 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 𝑐 3 +1 𝑑 𝑐 1 𝑑𝑡 𝑑 𝑐 2 𝑑𝑡 𝑑 𝑐 3 𝑑𝑡 𝑑 𝑐 4 𝑑𝑡 𝑑 𝑐 5 𝑑𝑡 = 𝑑 𝑐 2 𝑑𝑡 =0.15 𝑐 1 −0.15 𝑐 2 -0.12 0.02 0.15 -0.15 0.025 -0.225 0.1 0.1375 0.03 0.01 -0.05 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐 𝑑 𝑐 3 𝑑𝑡 =0.025 𝑐 2 −0.225 𝑐 3 +4 𝑑 𝑐 4 𝑑𝑡 =0.1 𝑐 3 − 𝑐 𝑐 5 𝑑 𝑐 5 𝑑𝑡 =0.03 𝑐 𝑐 2 −0.04 𝑐 5

43 But what about set of ODE?
Same approach combined with linear equations 𝑑 𝑐 1 𝑑𝑡 𝑑 𝑐 2 𝑑𝑡 𝑑 𝑐 3 𝑑𝑡 𝑑 𝑐 4 𝑑𝑡 𝑑 𝑐 5 𝑑𝑡 = -0.12 0.02 0.15 -0.15 0.025 -0.225 0.1 0.1375 0.03 0.01 -0.05 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐 -0.12 0.02 0.15 -0.15 0.025 -0.225 0.1 0.1375 0.03 0.01 -0.05 𝑑 𝑑𝑡 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐 5 = 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐

44 𝒅 𝒄 𝒅𝒕 =𝑨 𝒄 + 𝒃 But what about set of ODE?
Same approach combined with linear equations -0.12 0.02 0.15 -0.15 0.025 -0.225 0.1 0.1375 0.03 0.01 -0.05 𝑑 𝑑𝑡 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐 5 = 𝑐 1 𝑐 2 𝑐 3 𝑐 4 𝑐 𝒄 𝒄 𝒃 A 𝒅 𝒄 𝒅𝒕 =𝑨 𝒄 + 𝒃

45 What next? Finite difference approach but on vectors!
𝒅 𝒄 𝒅𝒕 =𝑨 𝒄 𝚫 𝒄 𝚫𝒕 =𝑨 𝒄

46 What next? Finite difference approach but with vectors!
𝚫 𝒄 𝚫𝒕 =𝑨 𝒄 𝒄 𝒕+𝚫𝐭 − 𝐜 (𝐭) 𝚫𝒕 =𝑨 𝒄 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 +𝚫𝐭𝑨 𝒄

47 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 +𝚫𝐭𝑨 𝒄 (𝒕) 𝒄 𝒕+𝚫𝐭 = 𝑰+𝚫𝐭𝑨 𝐜 𝒕 𝒄 𝒕+𝚫𝐭 =𝑩 𝐜 𝒕
What next? Finite difference approach but with vectors! Explicit scheme 𝒄 = 𝒄 (𝒕) 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 +𝚫𝐭𝑨 𝒄 (𝒕) 𝒄 𝒕+𝚫𝐭 = 𝑰+𝚫𝐭𝑨 𝐜 𝒕 𝒄 𝒕+𝚫𝐭 =𝑩 𝐜 𝒕 𝑩=𝑰+𝚫𝐭𝑨

48 𝒄 𝒕+𝚫𝐭 =𝑩 𝐜 𝒕 What next? Finite difference approach but with vectors!
Explicit scheme 𝒄 = 𝒄 (𝒕) Define c(0) 𝒄 𝒕+𝚫𝐭 =𝑩 𝐜 𝒕 𝑩=𝑰+𝚫𝐭𝑨 Compute 𝑩=𝑰+𝚫𝐭𝐀 Problem? Unstable! Compute c in the next time frame 𝒄 𝒏𝚫𝐭 =𝐁𝐜( 𝐧−𝟏 𝚫𝐭)) 𝒏+𝟏

49 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 +𝚫𝐭𝑨 𝒄 (𝒕+𝚫𝐭) 𝒄 𝒕+𝚫𝐭 −𝚫𝐭𝑨 𝒄 (𝒕+𝚫𝐭)= 𝒄 𝒕
What next? Finite difference approach but on vectors! Implicit scheme 𝒄 = 𝒄 (𝒕+𝚫𝐭) 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 +𝚫𝐭𝑨 𝒄 (𝒕+𝚫𝐭) 𝒄 𝒕+𝚫𝐭 −𝚫𝐭𝑨 𝒄 (𝒕+𝚫𝐭)= 𝒄 𝒕 𝑰−𝚫𝐭𝑨 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕

50 𝑰−𝚫𝐭𝑨 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 𝑩 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 𝒄 𝒕+𝚫𝐭 = 𝑩 −𝟏 𝒄 𝒕 𝑩=𝑰−𝚫𝐭𝑨
What next? Finite difference approach but on vectors! Implicit scheme 𝒄 = 𝒄 (𝒕+𝚫𝐭) 𝑰−𝚫𝐭𝑨 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 𝑩 𝒄 𝒕+𝚫𝐭 = 𝒄 𝒕 𝒄 𝒕+𝚫𝐭 = 𝑩 −𝟏 𝒄 𝒕 𝑩=𝑰−𝚫𝐭𝑨

51 Implicit scheme 𝒄 = 𝒄 (𝒕) Compute c in the next time frame
Define c(0) 𝒄 𝒕+𝚫𝐭 = 𝑩 −𝟏 𝐜 𝒕 𝑩=𝑰−𝚫𝐭𝑨 Compute 𝑩=𝑰+𝚫𝐭𝐀 Problem? Computing 𝑩 −𝟏 Compute 𝑩 −𝟏 Compute c in the next time frame 𝒄 𝒏𝚫𝐭 = 𝐁 −𝟏 𝐜( 𝐧−𝟏 𝚫𝐭)) 𝒏+𝟏

52 Working example implicite scheme
𝑨 k 𝟏 =𝟏 𝑩 k 𝟐 =𝟏 𝑪 𝒅𝑨 𝒅𝒕 =−𝑨 Initially A = 1, B = 0, C = 0 𝒅𝑩 𝒅𝒕 =𝑨−𝑩 𝑑 𝑑𝑡 𝐴 𝐵 𝐶 = − − 𝐴 𝐵 𝐶 𝒅𝑪 𝒅𝒕 =𝑩 𝑐 0 =

53 Working example 1. Initiate, calculate B
𝑨 k 𝟏 =𝟏 𝑩 k 𝟐 =𝟏 𝑪 𝑑 𝑑𝑡 𝐴 𝐵 𝐶 = − − 𝐴 𝐵 𝐶 𝑐 0 = 𝑩=𝑰−𝚫𝐭𝑨 𝜟𝒕=1 𝑐 0 = 𝐵= −1 − − = − −1 1

54 Working example 2. Calculate 𝑩 −𝟏 𝐵= 2 0 0 −1 2 0 0 −1 1
𝐵= − −1 1 𝐵 −1 =

55 Working example 3. Iterate n=1
𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 1 = 𝐵 −1 𝑐 0 = =

56 Working example 3. Iterate n=2
𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 2 = 𝐵 −1 𝑐 1 = =

57 Working example 3. Iterate n=3
𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 3 = 𝐵 −1 𝑐 2 = =

58 Working example 3. Iterate n=4
𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 4 = 𝐵 −1 𝑐 3 = =

59 Partial ODE Diffusion equation 𝜕𝑐 𝜕𝑡 =−𝐷 𝜕 2 𝑐 𝜕 𝑥 2

60 „Building blocks” for differentials
𝜕𝑐 𝜕𝑥 = 𝑐 𝑖+1 − 𝑐 𝑖−1 Δ𝑥 +𝑂 Δ 𝑥 2 𝜕𝑐 𝜕𝑥 = 𝑐 𝑖 − 𝑐 𝑖−1 Δ𝑥 +𝑂 Δ𝑥 𝜕 2 𝑐 𝜕 𝑥 2 = 𝑐 𝑖+1 −2 𝑐 𝑖 + 𝑐 𝑖−1 Δ 𝑥 2 +𝑂 Δ 𝑥 2

61 𝜕𝑐 𝜕𝑡 =−𝐷 𝜕 2 𝑐 𝜕 𝑥 2 𝜕𝑐 𝜕𝑡 = 𝑐 𝑚,𝑖+1 − 𝑐 𝑚,𝑖 Δ𝑡 𝜕 2 𝑐 𝜕 𝑥 2 = 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 Δ 𝑥 2

62 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) Instantaneous outtake Instantaneous outtake 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 Drug 1 Question: How the profile changes in time?

63 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) Instantaneous outtake Instantaneous outtake 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 Drug 1 Question: How the profile changes in time?

64 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) Instantaneous outtake Instantaneous outtake 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 Drug 1 Question: How the profile changes in time?

65 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) Instantaneous outtake Instantaneous outtake 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 Drug 1 Question: How the profile changes in time?

66 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) Instantaneous outtake Instantaneous outtake 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 Drug 1 Question: How the profile changes in time?

67 Example – 1 D Diffusion equation (drug release)
Initial concentration profile 𝜙(𝑥) 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 𝑐 1,𝑡 =0 𝑐 𝑥,0 =𝜙 𝑥 𝑐 𝑛,𝑖 concentration in position 𝑛Δ𝑥 and time 𝑖Δ𝑡 𝑇 Δ𝑡 1 Δ𝑥 𝐿 𝑥 𝑖 =𝑛Δ𝑥, Δ𝑥= 𝐿 𝑀 𝑡 𝑛 =𝑖Δ𝑡, Δ𝑡= 𝑇 𝑁

68 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 → 𝑐 0,𝑗 =0 𝑐 1,𝑡 =0→ 𝑐 𝑀,𝑗 =0 𝑐 𝑥,0 =𝜙 𝑥 → 𝑢 𝑖,0 =𝜙 𝑥

69 𝑥 𝑖 =𝑛Δ𝑥, Δ𝑥= 𝐿 𝑀 𝑡 𝑛 =𝑖Δ𝑡, Δ𝑡= 𝑇 𝑁

70 𝑐 𝑚,𝑖+1 − 𝑐 𝑚,𝑖 Δ𝑡 =−𝐷 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 Δ 𝑥 2 𝑐 𝑚,𝑖+1 = 𝑐 𝑚,𝑖 − 𝐷Δ𝑡 Δ 𝑥 2 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 𝑐 𝑚,𝑖+1 = 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖

71 𝑐 𝑚,𝑖+1 = 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 𝑐 𝑚,𝑖+1 =−𝑟 𝑐 𝑚−1,𝑖 + 1+2𝑟 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖

72 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 → 𝑐 0,𝑗 =0 𝑐 1,𝑡 =0→ 𝑐 𝑀,𝑗 =0 𝑐 𝑥,0 =𝜙 𝑥 → 𝑢 𝑖,0 =𝜙 𝑥 𝑐 1,𝑖+1 =−𝑟 𝑐 0,𝑖 + 1+2𝑟 𝑐 1,𝑖 −𝑟 𝑐 2,𝑖 𝑐 1,𝑖+1 = 1+2𝑟 𝑐 1,𝑖 −𝑟 𝑐 2,𝑖 𝑐 𝑀−1,𝑖+1 =−𝑟 𝑐 𝑀−2,𝑖 + 1+2𝑟 𝑐 𝑀−1,𝑖 −𝑟 𝑐 𝑀,𝑖 𝑐 𝑀−1,𝑖+1 =−𝑟 𝑐 𝑀−2,𝑖 + 1+2𝑟 𝑐 𝑀−1,𝑖

73 𝑐 1,𝑖+1 = 1+2𝑟 𝑐 1,𝑖 −𝑟 𝑐 2,𝑖 𝑐 𝑚,𝑖+1 =−𝑟 𝑐 𝑚−1,𝑖 + 1+2𝑟 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖 𝑐 𝑀−1,𝑖+1 =−𝑟 𝑐 𝑀−2,𝑖 + 1+2𝑟 𝑐 𝑀−1,𝑖 𝑐 1,𝑖+1 𝑐 2,𝑖+1 ⋮ 𝑐 𝑀−1,𝑖+1 = 1+2𝑟 −𝑟 0 ⋯ 0 −𝑟 1+2𝑟 −𝑟 ⋯ 0 0 ⋮ 0 ⋱ 0 ⋱ ⋯ ⋱ −𝑟 0 ⋮ 1+2𝑟 𝑐 1,𝑖 𝑐 2,𝑖 ⋮ 𝑐 𝑀−1,𝑖

74 𝑐 1,𝑖+1 𝑐 2,𝑖+1 ⋮ 𝑐 𝑀−1,𝑖+1 = 1+2𝑟 −𝑟 0 ⋯ 0 −𝑟 1+2𝑟 −𝑟 ⋯ 0 0 ⋮ 0 ⋱ 0 ⋱ ⋯ ⋱ −𝑟 0 ⋮ 1+2𝑟 𝑐 1,𝑖 𝑐 2,𝑖 ⋮ 𝑐 𝑀−1,𝑖 𝑐 𝑖+1 =𝐴 𝑐 𝑖


Download ppt "Ordinary differential equations"

Similar presentations


Ads by Google