Ordinary differential equations

Slides:



Advertisements
Similar presentations
Request Dispatching for Cheap Energy Prices in Cloud Data Centers
Advertisements

SpringerLink Training Kit
Luminosity measurements at Hadron Colliders
From Word Embeddings To Document Distances
Choosing a Dental Plan Student Name
Virtual Environments and Computer Graphics
Chương 1: CÁC PHƯƠNG THỨC GIAO DỊCH TRÊN THỊ TRƯỜNG THẾ GIỚI
THỰC TIỄN KINH DOANH TRONG CỘNG ĐỒNG KINH TẾ ASEAN –
D. Phát triển thương hiệu
NHỮNG VẤN ĐỀ NỔI BẬT CỦA NỀN KINH TẾ VIỆT NAM GIAI ĐOẠN
Điều trị chống huyết khối trong tai biến mạch máu não
BÖnh Parkinson PGS.TS.BS NGUYỄN TRỌNG HƯNG BỆNH VIỆN LÃO KHOA TRUNG ƯƠNG TRƯỜNG ĐẠI HỌC Y HÀ NỘI Bác Ninh 2013.
Nasal Cannula X particulate mask
Evolving Architecture for Beyond the Standard Model
HF NOISE FILTERS PERFORMANCE
Electronics for Pedestrians – Passive Components –
Parameterization of Tabulated BRDFs Ian Mallett (me), Cem Yuksel
L-Systems and Affine Transformations
CMSC423: Bioinformatic Algorithms, Databases and Tools
Some aspect concerning the LMDZ dynamical core and its use
Bayesian Confidence Limits and Intervals
实习总结 (Internship Summary)
Current State of Japanese Economy under Negative Interest Rate and Proposed Remedies Naoyuki Yoshino Dean Asian Development Bank Institute Professor Emeritus,
Front End Electronics for SOI Monolithic Pixel Sensor
Face Recognition Monday, February 1, 2016.
Solving Rubik's Cube By: Etai Nativ.
CS284 Paper Presentation Arpad Kovacs
انتقال حرارت 2 خانم خسرویار.
Summer Student Program First results
Theoretical Results on Neutrinos
HERMESでのHard Exclusive生成過程による 核子内クォーク全角運動量についての研究
Wavelet Coherence & Cross-Wavelet Transform
yaSpMV: Yet Another SpMV Framework on GPUs
Creating Synthetic Microdata for Higher Educational Use in Japan: Reproduction of Distribution Type based on the Descriptive Statistics Kiyomi Shirakawa.
MOCLA02 Design of a Compact L-­band Transverse Deflecting Cavity with Arbitrary Polarizations for the SACLA Injector Sep. 14th, 2015 H. Maesaka, T. Asaka,
Hui Wang†*, Canturk Isci‡, Lavanya Subramanian*,
Fuel cell development program for electric vehicle
Overview of TST-2 Experiment
Optomechanics with atoms
داده کاوی سئوالات نمونه
Inter-system biases estimation in multi-GNSS relative positioning with GPS and Galileo Cecile Deprez and Rene Warnant University of Liege, Belgium  
ლექცია 4 - ფული და ინფლაცია
10. predavanje Novac i financijski sustav
Wissenschaftliche Aussprache zur Dissertation
FLUORECENCE MICROSCOPY SUPERRESOLUTION BLINK MICROSCOPY ON THE BASIS OF ENGINEERED DARK STATES* *Christian Steinhauer, Carsten Forthmann, Jan Vogelsang,
Particle acceleration during the gamma-ray flares of the Crab Nebular
Interpretations of the Derivative Gottfried Wilhelm Leibniz
Advisor: Chiuyuan Chen Student: Shao-Chun Lin
Widow Rockfish Assessment
SiW-ECAL Beam Test 2015 Kick-Off meeting
On Robust Neighbor Discovery in Mobile Wireless Networks
Chapter 6 并发:死锁和饥饿 Operating Systems: Internals and Design Principles
You NEED your book!!! Frequency Distribution
Y V =0 a V =V0 x b b V =0 z
Fairness-oriented Scheduling Support for Multicore Systems
Climate-Energy-Policy Interaction
Hui Wang†*, Canturk Isci‡, Lavanya Subramanian*,
Ch48 Statistics by Chtan FYHSKulai
The ABCD matrix for parabolic reflectors and its application to astigmatism free four-mirror cavities.
Measure Twice and Cut Once: Robust Dynamic Voltage Scaling for FPGAs
Online Learning: An Introduction
Factor Based Index of Systemic Stress (FISS)
What is Chemistry? Chemistry is: the study of matter & the changes it undergoes Composition Structure Properties Energy changes.
THE BERRY PHASE OF A BOGOLIUBOV QUASIPARTICLE IN AN ABRIKOSOV VORTEX*
Quantum-classical transition in optical twin beams and experimental applications to quantum metrology Ivano Ruo-Berchera Frascati.
The Toroidal Sporadic Source: Understanding Temporal Variations
FW 3.4: More Circle Practice
ارائه یک روش حل مبتنی بر استراتژی های تکاملی گروه بندی برای حل مسئله بسته بندی اقلام در ظروف
Decision Procedures Christoph M. Wintersteiger 9/11/2017 3:14 PM
Limits on Anomalous WWγ and WWZ Couplings from DØ
Presentation transcript:

Ordinary differential equations

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

Case study Reactor with reaction

More complicated problem Accumulation = inputs - outputs

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 𝑚𝑖𝑛 𝑄 24 =1 𝑚 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

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 𝑚𝑖𝑛

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 𝑐 1 +0.02 𝑐 3 +1 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛

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 𝑐 1 +0.02 𝑐 3 +1 outputs 𝑄 31 =1 𝑚 3 𝑚𝑖𝑛

Accumulation = inputs - outputs How to solve that problem? Accumulation = inputs - outputs For other reactors 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 1 +0.02 𝑐 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 −0.1375 𝑐 4 +0.025 𝑐 5 How to solve this problem? 𝑑 𝑐 5 𝑑𝑡 =0.03 𝑐 1 +0.01 𝑐 2 −0.04 𝑐 5

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

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

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

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

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

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

Different approach Euler’s scheme

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Problems? 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭

Problems? 𝒄 𝒕+𝚫𝐭 =𝒄 𝒕 −𝚫𝐭𝒄 𝒕 =𝒄 𝒕 𝟏−𝚫𝐭 Say 𝚫𝐭=𝟏 𝐭𝐡𝐞𝐧 𝒄 𝟏 =𝒄 𝟎 𝟏−𝟏 =𝟎 𝒄 𝟐 =𝒄 𝟏 𝟏−𝟏 =𝟎

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

Solution? Implicit scheme f 𝑓 𝑡 ∗ Δ𝑓 𝑓 𝑡 ∗ +Δ𝑡 Δ𝑡 𝛼 𝑡 ∗ 𝑡 ∗ +Δ𝑡 t 𝑡𝑔𝛼= Δ𝑓 Δ𝑡 Average slope on Δ𝑡 interval

Solution? Implicit scheme f 𝑓 𝑡 ∗ Δ𝑓 𝑓 𝑡 ∗ +Δ𝑡 Δ𝑡 𝛼 𝑡 ∗ 𝑡 ∗ +Δ𝑡 t 𝑡𝑔𝛼= Δ𝑓 Δ𝑡 Average slope on Δ𝑡 interval

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

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

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

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

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

But what about set of ODE? Same approach combined with linear equations 𝑑 𝑐 1 𝑑𝑡 =−0.12 𝑐 1 +0.02 𝑐 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 𝑐 5 + 1 0 4 0 0 𝑑 𝑐 3 𝑑𝑡 =0.025 𝑐 2 −0.225 𝑐 3 +4 𝑑 𝑐 4 𝑑𝑡 =0.1 𝑐 3 −0.1375 𝑐 4 +0.025 𝑐 5 𝑑 𝑐 5 𝑑𝑡 =0.03 𝑐 1 +0.01 𝑐 2 −0.04 𝑐 5

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 𝑐 5 + 1 0 4 0 0 -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 𝑐 5 + 1 0 4 0 0

𝒅 𝒄 𝒅𝒕 =𝑨 𝒄 + 𝒃 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 𝑐 5 + 1 0 4 0 0 𝒄 𝒄 𝒃 A 𝒅 𝒄 𝒅𝒕 =𝑨 𝒄 + 𝒃

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

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

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

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

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

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

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

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

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

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

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

Working example 3. Iterate n=2 𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 2 = 𝐵 −1 𝑐 1 = 0.5 0 0 0.25 0.5 0 0.25 0.5 1 0.5 0.25 0.25 = 0.25 0.25 0.5

Working example 3. Iterate n=3 𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 3 = 𝐵 −1 𝑐 2 = 0.5 0 0 0.25 0.5 0 0.25 0.5 1 0.25 0.25 0.5 = 0.125 0.1875 0.6875

Working example 3. Iterate n=4 𝑐 𝑛Δ𝑡 = 𝐵 −1 𝑐 𝑛−1 Δ𝑡 𝑐 4 = 𝐵 −1 𝑐 3 = 0.5 0 0 0.25 0.5 0 0.25 0.5 1 0.125 0.1875 0.6875 = 0.0625 0.125 0.8125

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

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

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

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?

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?

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?

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?

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?

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

Transformation of analytical problem into finite difference problem Boundary and initial conditions 𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 0,𝑡 =0 → 𝑐 0,𝑗 =0 𝑐 1,𝑡 =0→ 𝑐 𝑀,𝑗 =0 𝑐 𝑥,0 =𝜙 𝑥 → 𝑢 𝑛,0 =𝜙 𝑥 Boundary conditions Initial conditions

Finite difference equations for given differentials 𝑐 𝑚,𝑖+1 − 𝑐 𝑚,𝑖 Δ𝑡 =−𝐷 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 Δ 𝑥 2 𝑐 𝑚,𝑖+1 = 𝑐 𝑚,𝑖 − 𝐷Δ𝑡 Δ 𝑥 2 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 𝑐 𝑚,𝑖+1 = 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖 −2 𝑐 𝑚,𝑖 + 𝑐 𝑚−1,𝑖 𝑐 𝑚,𝑖+1 =−𝑟 𝑐 𝑚−1,𝑖 + 1+2𝑟 𝑐 𝑚,𝑖 −𝑟 𝑐 𝑚+1,𝑖

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

𝑐 𝑡 =−𝐷 𝑐 𝑥𝑥 𝑐 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,𝑖

𝑐 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,𝑖

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