Itroductio of Numerical Aalysis #03 TAGAMI, Daisuke (IMI, Kyushu Uiversity) web page of the lecture: http://www2.imi.kyushu-u.ac.jp/~tagami/lec/
Strategy of Numerical Simulatios Pheomea Error modelize Nostatioary temperature distributio i uiform metal bar heat coservatio Fourier s law Mathematical Model Error discretizatio Approximate Problem Nostatioary heat equatio I time: forward/backward Euler Crak-Nicolso I space: cetral differece Liear Systems
Heat equatio Heat equatio (1-D i space) u t 2 u = 0, x2 x, t 0, 1 0, T, t u 0, t = u 1, t = 0, t 0, T, u x, 0 = si πx, x 0, 1, has the uique solutio u u x, t = e π2t si πx x
Space-Time grid t T t N =N Δt t = Δt Δt u i t 1 t 1 =Δt t 0 =0 O 1 x 0 =0 x 1 =h x h i 1 x i =ih x M 1 x x M =Mh=1
Cotiuous problem (1H) Heat equatio (cotiuous problem; 1H): u t 2 u x 2 = f, x, t 0, 1 0, T, u = 0, x = 0, t 0, T, u = 0, x = 1, t 0, T, u, 0 = a, x 0, 1, t = 0. We focus ourselves o time variatio u t t = F t, u t ; f t f t + 2 u t. x2
Time discretizatio [1/5] Time discretizatio with the same argumet i ODE: 1. Set N equal divisio of time iterval 0, T, ad time icremet Δt is defied by Δt T/N. 2. Itroduce the fuctio Φ from the temperature at t = t N to oe at t = t N+1. u u N u u 0 Φ Φ 2 u u 1 Φ u t u t N u t u t 2 0 u t 1 u t Δt Δt Δt t t 0 = 0 t 1 t 2 t t N = T t
Time discretizatio [2/5] How to decide? u t Φ t = F t, u t ; f t Itegrate o t, t u t = u t + t t F s, u s ; f s ds Itroduce umerical itegratio forward/backward Euler method; Crak-Nicolso method, etc. have bee itroduced correspodig to the type of umerical itegratios. u = u + Φ t, t ; u, u ; f, f u u t, f f t
Time discretizatio [3/5] u t = u t + t t F s, u s ; f s ds u = u + Δt F t, u ; f piecewise costat as the value at t = t. Forward Euler method: Set u 0 = a; For = 0,, N 1, compute u s.t. D Δt u 2 u x 2 = f, x 0, 1, u = 0, x = 0, u Here = 0, x = 1. D Δt u u u Δt
Time discretizatio [4/5] u t = u t + t t F s, u s ; f s ds u = u + Δt F t, u ; f piecewise costat as the value at t = t. Backward Euler method: Set u 0 = a; For = 0,, N 1, fid u s.t. D Δt u 2 u x 2 = f, x 0, 1, u = 0, x = 0, u Here = 0, x = 1. D Δt u u u Δt
Time discretizatio [5/5] u t = u t + t u = u + 1 2 Δt k=0 t F s, u s ; f s 1 ds piecewise 1st order polyomial as the value at t = t ad t = t (trapezoidal formula). F t +k, u +k ; f +k Crak Nicolso method: Set u 0 = a; For = 0,, N 1, fid u s.t. D Δt u 2 u /2 x 2 = f /2, x 0, 1, u /2 Here = 0, x = 0, u /2 = 0, x = 1. D Δt u u u Δt v /2 v + v 2
Space discretizatio [1/2] Set M equal divisio of iterval 0,1, ad apply the 2d order cetral differece ito the approximatio of the Laplace operator for grid poit fuctio u u j : Discrete Laplace operator: L h u i u i+1 2 u i + u i 1 h 2 d2 u dx 2 x i x i ih h 1/M u i u x i u 2 u 3 u 4 u 0 h u 1 h h h x x 0 =0h=0 x 1 =h x 2 =2h x 3 =3h x 4 =4h=1
Space discretizatio [2/2] How to realize the homogeeous Neuma boudary coditio? 1. Set virtual grid poit x = x M+1 = 1 + h ad virtual approximate value u M+1. 2. Approximate u/ x at x = x M = 1 by the cetral differece with u M 1 ad u M+1 : 0 = u x 1 u M+1 u M 1 2h 3. Impose the followigs: u M+1 = u M 1 v x = u x 0 x 1 u 2 x 1 < x 2 v i = u i i = 0, 1,, M u 2M i i = M + 1,, 2M x=1
Fiite differece equatio [1/4] Forward Euler method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, compute u i s.t. D Δt u i + L h u i = f i, u 0 u M+1 = 0, = u M 1. i = 1,, M, Here D Δt u u u Δt, L h u i u i+1 2 u i + u i 1 h u i u x i, t, f i f x i, t, a i a x i
Fiite differece equatio [2/4] Backward Euler method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i s.t. D Δt u i + L h u i = f i, u i = 1,, M, 0 = 0, u M+1 = u M 1. Here D Δt u u u Δt, L h u i u i+1 2 u i + u i 1 h u i u x i, t, f i f x i, t, a i a x i
Fiite differece equatio [3/4] Crak Nicolso method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i s.t. D Δt u /2 /2 i + L h u i = fi, u i = 1,, M, 0 = 0, u M+1 = u M 1. Here D Δt u u u Δt, L h u i u i+1 2 u i + u i 1 h u i u x i, t, f i f x i, t, a i a x i v /2 v + v 2
Fiite differece equatio [4/4] θ method θ 0, 1 : Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i s.t. D Δt u i + L h u +θ i = f +θ i, u i = 1,, M, 0 = 0, u M+1 = u M 1. θ = 0: forward Euler θ = 1: backward Euler θ = 1/2: Crak-Nicolso Here D Δt u u u Δt, L h u i u i+1 2 u i + u i 1 h u i u x i, t, f i f x i, t, a i a x i v +θ θv + 1 θ v
Discretized equatio [1/4] Forward Euler method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, compute u i u i u 0 = t h 2 u i+1 + 1 2 t h 2 u i = 0, s.t. + t h 2 u i 1 + t f i, i = 1,, M, u M+1 = u M 1. u i Explicit scheme: Do ot require to solve the liear system at eqch time step. Require the stability coditios betwee Δt ad h to satisfy. u i 1 u i u i+1
Discretized equatio [2/4] Backward Euler method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i t h 2 u i+1 + 1 + 2 t h 2 u i u 0 = 0, s.t. t h 2 u i 1 = u i + t f i, i = 1,, M, u M+1 = u M 1. u i Implicit scheme: Require to solve the liear system at eqch time step. Do ot require the stability coditios betwee Δt ad h to satisfy. u i 1 u i u i+1
Discretized equatio [3/4] Crak Nicolso method: Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i s.t. 1 t 2 h 2 u i+1 + 1 + t h 2 ui 1 t 2 h 2 u i 1 = 1 t 2 h 2 u i+1 + 1 t h 2 ui + 1 t 2 h 2 u i 1 + t f +θ i, i = 1,, M, u 0 = 0, u M+1 = u M 1. u i Implicit scheme: Require to solve the liear system at eqch time step. Do ot require the stability coditios betwee Δt ad h to satisfy. u i 1 u i 1 u i u i+1 u i+1
Discretized equatio [4/4] θ method θ 0, 1 : Set u i 0 = a i i = 0,, M + 1 ; For = 0,, N 1, fid u i θ t h 2 u i+1 + 1 + 2θ t h 2 u i θ t = 1 θ t h 2 u i+1 + 1 2 1 θ t h 2 u i + t f +θ i, = 0, u 0 u M+1 s.t. i = 1,, M, = u M 1. θ = 0: forward Euler θ = 1: backward Euler θ = 1/2: Crak-Nicolso h 2 u i 1 + 1 θ t h 2 u i 1 u i u i 1 u i+1 Hereafter we call the above equatio (1H) h. u i 1 u i u i+1
Mathematical justificatios Cosistecy of D t ad L h Stability of (1H) h Covergece of (1H) h
Extetio u ito R [1/3] u = u x u = 0 u = 0 v x = u x 0 x 1 u 2 x 1 < x 2 x=0 x=1 x= 2 x= 1 x=0 x=1 x=2 w x = v x v x 0 x 2 2 x < 0
Extetio u ito R [2/3] l u x l k u x k 0 = 0, l = 0, 2,, 2m; 1 = 0, k = 1, 3,, 2m 1 v x = u x 0 x 1 u 2 x 1 < x 2 u C 2m 2, 2 Replace w ito the same otatio u. x= 2 x= 1 x=0 x=1 x=2 w x = v x v x 0 x 2 2 x < 0
Extetio u ito R [3/3] x= 2 x= 1 x=0 x=1 x=2 Defiitio: u is L periodic fuctio u x + L = u x, x R u is exteded ito R to become 4 periodic fuctio. u x = u x 4 x + 2 4 x= 6 x= 2 x=0 x=2 x=6 l u x l 0 = 0, l = 0, 2,, 2m; u C 2m R k u x k 1 = 0, k = 1, 3,, 2m 1
Cotiuous problem i R Heat equatio (cotiuous problem i R): Fid 4 periodic fuctio u: R 0, T R s.t. u t 2 u x 2 = f, x, t R 0, T, u, 0 = a, x R, t = 0.
Extetio u ito R [1/2] u = u i u M+1 = u M 1 u 0 = 0 x=0 x=1 v i = u i i = 0, 1,, M u 2M i i = M + 1,, 2M x= 2 x= 1 x=0 x=1 x=2 w i = v i v i i = 0, 1,, 2M i = 2M, 2M + 1,, 1
Extetio u ito R [2/2] x= 2 x= 1 x=0 x=1 x=2 u is exteded ito the all grid poits i R to become 4M periodic grid poit fuctio. Defiitio: u is L periodic grid poit fuctio u i+l = u i, i Z u j = u j 4M j+2m 4M x= 6 x= 2 x=0 x=2 x=6
Discretized equatio i R [1/3] θ method θ 0, 1 : Give M periodic grid poit fuctio a = a i i Z ; Set u i 0 = a i i Z ; For = 0,, N 1, fid M periodic grid poit fuctio u = u i i Z s.t. θ t h 2 u i+1 + 1 + 2θ t h 2 u i θ t h 2 u i 1 = 1 θ t h 2 u i+1 + 1 2 1 θ t h 2 u i + 1 θ t h 2 u i 1 + t f i +θ, i = 1,, M. NOTE: I the previous sheet, the periodic of u is equal to 4M. However, to avoid cumbersomes, we replace the period with M.
Discretized equatio i R [2/3] u i p1 u i 1 u i u i+1 u i+q1 t = t Δt u i p0 u i 1 u i u i+1 u i+q0 t = t Fiite differece operator: B L t q L b m L t S m Summatio of the +L, coefficiets of u i+m which ifluece u i m= p L L = 0, 1; p L, q L N 0 : costat; t R + : time icremet; b L m t R: coefficiet correspodig to u +L i+m ; S m : v i S m v i v i+m : shifted operator i space for the grid poit fuctios
Discretized equatio i R [3/3] Whe a exteral heat source f = 0, the discretize equatio ca be writte geerally as follows: Give M periodic grid poit fuctio a = a i i Z ; Set u i 0 = a i i Z ; For = 0,, N 1, fid M periodic grid poit fuctio u = u i i Z s.t. B 1 t u i = B 0 t u i, i Z. (FD) EX) θ method: For p 0, q 0 = 1 b 1 t = b 1 1 t = θ t p 1, q 1 = 1, 1 h 2, b L 1 t = 1 + 2θ t h 2 0 b 1 t = b 0 1 t = 1 θ t h 2, b 1 L t = 1 2 1 θ t h 2
Stability [1/4] Discretized equatio i geeral form: Set u 0 i = a i i Z ; For = 0,, N 1, fid u = u i B 1 t u i = B 0 t u i, i Z. i Z s.t. (FD) Here B L t q L b m L t S m m= p L Amplitude factor of (FD) g k; t q 0 bm 0 t e 2πi m= p 0 q 1 bm 1 t e 2πi m= p 1 mk M mk M k = 0, 1,, M
Stability [2/4] Defiitio (FD) is stable def c > 0 s.t. u 0, t 0, 1, = 0,, N T u h c a h M 1 Here v h 1 M j=0 v j 2 1/2
Stability [3/4] vo Neuma coditio (FD) is stable c 0 > 0 s.t. g k; t 1 + c 0 t k Z, t 0, 1. EX) I case of θ method, g k; t = if g k; t 1 1 2θ t πk 2 si2 h t 1 4 1 θ h2 si2πk M 1+4θ t h2 si2πk M M < 1 2. Therefore,, (FD) is stable. That is, θ 1, 1 : without ay coditios betwee t ad h 2 θ 0, 1 t : with the stability coditios < 1 2 h 2 2 1 2θ
Stability [4/4] Stability of (1H) h u: the solutio of (1H) h Assume t < 1 h 2 2 1 2θ u h a h 1 + t t 1 θ f 0 2 h + t k=1 f k 2 + tθ f h 2 h 1 2 = 0, 1,, N Here v h 1 M 1 2 v 2 0 + M 1 j=1 v j 2 + 1 2 v M 2 1 2
Cosistecy of differece operator u: the solutio of (1H) l u x l C 0, 1 0, T, l = 0, 1, 2, 3, 4; k u = 0, k = 0, 1, 2, 3 tk l u x l 0, t = 0, l = 0, 2, 4; k u x k 1, t = 0, k = 1, 3 g i θ 1 2 tm 0,2 u + 1 12 t2 M 0,3 u + 1 12 h2 M 4,0 u i = 1, 2,, M, = 0, 1,, N 1 Here l+k u M l,k v max x l x, t ; x, t 0, 1 0, T tk g i D Δt u i + L h u +θ +θ i f i u i u x i, t, f i f x i, t, v +θ θv + 1 θ v
Covergece u: the solutio of (1H) u: the solutio of (1H) h Assumptios of Stability ad Cosistecy max u x i, t u i ; i = 0, 1,, M, = 0, 1,, N θ 1 2 tm 0,2 u + 1 12 t2 M 0,3 u + 1 12 h2 M 4,0 u θ 1 2 O t + h2 θ = 1 2 O t2 + h 2