Finite Difference Time Domain Method (FDTD) FDTD: The Basic Algorithm • Maxwell’s Equations in the TIME Domain: H X E t E X H E t Equate Vector Components: Six E and H-Field Equations H x 1 E y E z t z y H y 1 E z E x t x z H z 1 E x E y t y x E x 1 H z H y E x t y z E y 1 H x H z E y t z x E z 1 H y H x E z t x y 2-D Equations: Assume that all fields are uniform in y direction (i.e. d/dy = 0) 2D - TE H y 1 E z E x t x z E x 1 H y E x t z E z 1 H y E z t x 2D - TM H x 1 E y t z H z 1 E y t x E y 1 H x H z E y t z x 1-D Equations: Assume that all fields are uniform in y and x directions (i.e. d/dy =d/dx= 0) 1D - TE H y 1 E x t z E x 1 H y E x t z 1D - TM H x 1 E y t z E y 1 H x E y t z Discretize Objects in Space using Cartesian Grid 3D Discretization 2D Discretization z x 1D Discretization Z z0 Ex ( z , t ) zZ Define Locations of Field Components: FDTD Cell called Yee Cell • Finite-Difference – Space is divided into small cells One Cell: (dx)(dy)(dz) – E and H components are distributed in space around the Yee cell (note: field components are not collocated) FDTD: Yee, K. S.: Numerical solution of initial boundary value problems involving Maxwell's equations in isotropic media. IEEE Transactions on Antennas Propagation, Vol. AP-14, pp. 302-307, 1966. Replace Continuous Derivatives with Differences • Derivatives in time and space are approximated as DIFFERENCES f f ' slope of curve x Central Difference Formula : f i ' f ' ( xi ) f i 1 f i 1 Error (h 2 ) 2h Solution then evolves by timemarching difference equations – Time is Discretized • One Time Step: dt – E and H fields are distributed in time – This is called a “leap-frog” scheme. Yee Algorithm Definitions of spatial meshing and time step Initialization Iteration n Calculation of En from Hn-1/2 and En-1 Calculation of Hn+1/2 from En and Hn-1/2 n=n+1 N=Nbiteration End 1-D FDTD Assuming that field values can only vary in the z-direction (i.e. all spatial derivatives in x and z direction are zero), Maxwell’s Equations reduce to: H y 1 E x t z Ex 1 H y Ex t z z Hy Ex (z), (z) 1-D FDTD – Staggered Grid in Space Interleaving of the Ex and Hy field components in space and time in the 1-D FDTD formulation Time plane Ex Hy Ex 1 n z 2 3 n z 2 ( nz 1 ( nz 2 3 nz 2 ( nz 1 ( nz 1 nz 2 3 n z 2 1 n z 2 1 nz 2 1 nt 2 ( nt 3 nz 2 1 n t 2 1-D FDTD H y 1 E x t z Ex 1 H y Ex t z Replace all continuous derivatives with central finite differences H yn (i) H yn1/ 2 (i) H yn1/ 2 (i) t t E (i) E t n x n 1/ 2 x (i) E t n 1/ 2 x (i) H yn (i) H yn (i 1 / 2) H yn (i 1 / 2) z z Exn (i) Exn (i 1 / 2) Exn (i 1 / 2) z z Exn1/ 2 (i) Exn 1/ 2 (i) E (i) 2 n x Note: finite differences are 2nd order in time and space 1-D FDTD Ex 1 H y Ex t z Replace all continuous derivatives with finite differences E xn (i) E xn 1/ 2 (i ) Exn 1/ 2 (i ) t t H yn (i) H yn (i 1 / 2) H yn (i 1 / 2) z z Exn 1/ 2 (i ) E xn 1/ 2 (i) E (i) 2 n x n n E xn 1/ 2 (i ) E xn 1/ 2 (i ) E xn 1/ 2 (i ) E xn 1/ 2 (i ) 1 H y (i 1 / 2) H y (i 1 / 2) t z 2 n 1 / 2 Solve for E x Exn 1/ 2 (i) (i ) 2 t n 1/ 2 2t Ex (i) H yn (i 1 / 2) H yn (i 1 / 2) 2 t z (2 t ( 1-D FDTD H y 1 E x t z Replace all continuous derivatives with finite differences and increment time by one half time step H yn1/ 2 (i) H yn1 (i) H yn (i) t t H yn1 (i) H yn (i) t H Exn1/ 2 (i 1 / 2) Exn1/ 2 (i 1 / 2) z 1 Solve for n 1 y Exn1/ 2 (i) Exn1/ 2 (i 1 / 2) Exn1/ 2 (i 1 / 2) z z H yn1 (i) t n 1/ 2 (i) H (i) Ex (i 1 / 2) E xn 1/ 2 (i 1 / 2) z n y ( 1-D FDTD H y 1 E x t z Ex 1 H y Ex t z After some simple algebra: E n 1/ 2 x 2 t n1/ 2 2t (i) Ex (i) H yn (i 1 / 2) H yn (i 1 / 2) 2 t z(2 t ( t n1/ 2 H (i) H (i) Ex (i 1 / 2) Exn1/ 2 (i 1 / 2) z n 1 y n y ( 1-D FDTD – Staggered Grid in Space Interleaving of the Ex and Hy field components in space and time in the 1-D FDTD formulation i=1 i=2 i=3 i=4 1 nt 2 Ex z=0 z=dz i=1 z=2*dz i=2 z=3*dz i=3 i=4 ( nt Hy z=dz/2 E n 1/ 2 x z=3dz/2 z=5*dz/2 z=7*dz/2 2 ( z ) t ( z ) n1/ 2 2t ( z) Ex ( z ) H yn ( z dz / 2) H yn ( z dz / 2) 2 ( z ) t ( z ) z (2 ( z ) t ( z ) ( E n 1/ 2 x 2 (i) t (i) n1/ 2 2t (i) Ex (i) H yn (i) H yn (i 1) 2 (i) t (i) z(2 (i) t (i) ( 1-D FDTD – Staggered Grid in Space Interleaving of the Ex and Hy field components in space and time in the 1-D FDTD formulation i=1 i=2 i=3 i=4 1 nt 2 Ex z=0 z=dz z=2*dz i=1 i=2 z=3*dz i=3 i=4 ( nt Hy z=dz/2 H yn 1 ( z ) H yn ( z ) z=3dz/2 z=5*dz/2 z=7*dz/2 t E xn 1/ 2 ( z dz / 2) E xn 1/ 2 ( z dz / 2) ( z )z H yn 1 (i ) H yn (i ) ( t E xn 1/ 2 (i 1) E xn 1/ 2 (i ) (i)z ( 1-D FDTD – Basic Core of Code Loop through all of the E -grid Loop through all of the H -grid Loop through all time steps for n=2:Nt % all time steps end for i=2:Nx-1 % all interior nodes Ex (i, n) 2 (i) t (i) 2t Ex (i, n 1) H y (i, n 1 ) H yn (i 1, n 1 ) 2 (i) t (i) z (2 (i) t (i) end ( Note: H uses the new values of E. This is Equivalent to incrementing by ½ a time step for i=2:Nx-1 % all interior nodes H y (i, n) H yn (i, n 1) end t E (i 1, n 1) E x (i, n 1) (i )z x ( SOME OPEN QUESTIONS?? • • • • How do we determine what t and z should be? How do we implement real sources? How do we simulate open boundaries? How accurate is the solution? Numerical Stability Like all iterative algorithms FDTD has the possibility of not converging on a solution. This usually results in the algorithm going unstable and producing ever increasing field values over time. When does this happen? 1-D 2-D 3-D x t c t t 1 1 1 c 2 x y 2 1 1 1 1 c 2 2 2 x y z Numerical Dispersion In real life plane waves traveling in a homogenous medium propagate at the speed of light in that medium independent of frequency or propagation direction. However, due to our approximation of continuous derivatives with finite differences if we launch a plane wave in FDTD it will actually propagate at a slightly different speed than that of light. Moreover, and more disturbing, the propagation velocity will depend on the frequency of the plane wave and its direction of propagation with respect to the FDTD grid. This effect is known as numerical dispersion. The effect has been well studied and mathematically quantified. Numerical Dispersion k c Continuous Plane Wave ct cos(t ) cos( kx) 1 1 x 2 1-D FDTD case I : t , x 0 k c case II : t k x c Magic time step! c x y z sin k x sin 2 k y sin 2 k z 2 2 2 2 0 2 2 2 c2 x y z 2 2 2 2 2 2 3-D FDTD At optimal time step 2 1 t c 1 1 1 2 2 x y z 2 Implementation of Boundary Conditions 1D Boundary condition for a perfectly electrically conducting (PEC) material Ex(1, nt ) 0 1 nt Nt ( N z , nt ) Ex 0 Absorbing/open boundary condition in 1-D Space-time-extrapolation of the first order For the magic time-step t x c a plane wave needs one time steps to travel over one grid cell with the size ∆z E xn (i 1) E xn1 (i 2) E xn (i N z ) E xn1 (i N z 1) Space-time-extrapolation of the first order (MATLAB DEMO) 2-D Equations: Assume that all fields are uniform in y direction (i.e. d/dy = 0) 2D - TM H y 1 E z E x t x z E x 1 H y E x t z E z 1 H y E z t x 2D - TE H x 1 E y t z H z 1 E y t x E y 1 H x H z E y t z x 2D - TM H y 1 E z E x t x z E x 1 H y E x t z E z 1 H y E z t x dx (i-1,j+1) E-GRID Ex dx Ex (i+1,j+1) H-GRID Ex Ex (i,j+1) Hy Ez Hy Hy Ez Ez Ez Hy Ez (i-1,j) Ex (i-1,j) (i,j) Ex (i+1,j) Ez (i,j) Ex (i-1,j) (i+1,j) Ex Hy Hy dz Ez Ez Ex (i-1,j-1) Ez Ez Ex (i,j-1) (i+1,j-1) Hy Hy dz Ez Ez (i-1,j-1) Ex (i,j-1) Ex 2D – TM: Derive FDTD Equations (i-1,j+1) H y 1 E z E x t x z E x 1 H y E x t z E z 1 H y E z t x n 1 2 H (i, j ) H y (i, j ) H t t n 1 2 E (i, j ) Ex (i, j ) E t t n x n 1 2 E (i, j ) Ez (i, j ) E t t n z n 1 2 y n 1 2 x (i, j ) (i, j ) Ez (i-1,j) Hy Ez Ex (i,j) Ez Ez Ex (i+1,j+1) Ez Ex (i+1,j) Hy Hy dz Ex Ez Ex (i,j-1) (i+1,j-1) H yn (i, j ) H yn (i, j 1 / 2) H yn (i, j 1 / 2) z z H yn (i, j ) H yn (i 1 / 2, j ) H yn (i 1 / 2, j ) x x Exn (i, j ) Exn (i, j 1 / 2) Exn (i, j 1 / 2) z z n 1 2 z (i, j ) Exn 1/ 2 (i, j ) Exn 1/ 2 (i, j ) E (i, j ) 2 n x (i,,j+1) Hy (i-1,j-1) n y Ex Ezn (i, j ) Exn (i 1 / 2, j ) Exn (i 1 / 2, j ) x x Ezn 1/ 2 (i, j ) Ezn 1/ 2 (i, j ) E (i, j ) 2 n z 2D – TM: Derive FDTD Equations dx H-GRID Ex H y 1 E z E x t x z Hy Ez Ezn (i, j ) Exn (i 1 / 2, j ) Exn (i 1 / 2, j ) x x Ez n 1 H y (i, j ) H y 2 (i, j ) t Ez (i,j) Ex (i-1,j) (i+1,j) Ex Hy Hy dz Ez Ez Ez (i-1,j-1) Ex 1 2 Hy (i-1,j) Exn (i, j ) Exn (i, j 1 / 2) Exn (i, j 1 / 2) z z n Ex (i,j-1) Ex 1 E zn (i 1 / 2, j ) E zn (i 1 / 2, j ) E xn (i, j 1 / 2) E xn (i, j 1 / 2) x z n 1 2 Solve for H y (i, j ) n 1 2 n H y (i, j ) H y 1 2 t Ezn (i 1 / 2, j ) Ezn (i 1 / 2, j ) Exn (i, j 1 / 2) Exn (i, j 1 / 2) (i, j ) x z 2D – TM: Derive FDTD Equations n 1 2 n H y (i, j ) H y 1 2 t Ezn (i 1 / 2, j ) Ezn (i 1 / 2, j ) Exn (i, j 1 / 2) Exn (i, j 1 / 2) (i, j ) x z t n 1/ 2 n 1/ 2 H ( i , j 1 / 2 ) H (i, j 1 / 2) t / y y n 1 n 2 Ex (i, j ) E (i, j ) t x t z 1 1 2 2 1 t n 1/ 2 n 1/ 2 H ( i 1 / 2 , j ) H (i 1 / 2, j ) t / y y n 1 n 2 Ez (i, j ) E (i, j ) t z t x 1 1 2 2 1 2-D FDTD – Basic Core of Code for n=2:Nt % all time steps Loop through all of the E -grid for i=2:Nx-1 % all interior nodes (i, j) t t /(i, j) H y (i, j,n 1) H y (i, j 1,n 1) 2(i, j) E x (i, j,n) E x (i, j,n 1) (i, j) t (i, j)t z 1 1 2(i, j) 2(i, j) 1 (i, j) t t /(i, j) H y (i, j,n 1) H y (i 1, j,n 1) 2(i, j) E z (i, j,n) E z (i, j,n 1) (i, j) t (i, j)t x 1 1 2(i, j) 2(i, j) 1 end Loop through all of the H -grid for i=2:Nx-1 % all interior nodes H y (i, j,n) H yn (i, j,n 1) end end t E z (i 1, j,n 1) E z (i, j,n 1) E x (i, j 1,n 1) E x (i, j,n 1) (i) x z 2D – TE: Derive FDTD Equations n 1 2 n H x (i, j) H x n Hz 1 2 1 2 t E zn (i, j 1/2) E zn (i, j 1/2) (i, j) z n n t E y (i 1/2, j) E y (i 1/2, j) (i, j) Hz (i, j) x n 1 2 t Hxn 1/ 2 (i, j 1/2) H xn 1/ 2 (i, j 1/2) H zn 1/ 2 (i 1/2, j) Hzn 1/ 2 (i 1/2, j) t / n 1 n 2 E (i, j) E y (i, j) t y t z x 1 1 2 2 1 Numerical Dispersion 2D case Using same procedure as for the 1D case we obtain: 2 2 ~ ~ 1 k x x 1 k z z 1 t ct sin 2 x sin 2 z sin 2 2 ~ ~ ~ ~ k x k cos( ), k z k sin( ) Source Modeling 1. We can implement a “hard” source by forcing the fields to predefined values at specific nodes in the FDTD grid. For example: (ntb )2 E z (io, jo,n) Ae cos( o (nt b)) Source Modeling: Soft Sources Scattered Field Formulation 1. We can implement a “soft” source by first reformulating Maxwell’s equations for only the scattered field. E tot (1) H tot t H tot E tot H inc t (2) E H inc o inc t E inc o E tot t (3) E tot E sc E inc Htot Hsc Hinc H tot H o inc t t E E (H tot H inc ) E tot tot o inc t t (E tot E inc ) (1)-(2): H sc H E sc ( o ) inc t t E E sc H sc E sc ( o ) inc E inc t t Use (3) in above and a little algebra: Six E and H-Field Equations Scattered Field sc H xsc 1 E y t z H ysc 1 E zsc t x E zsc o inc Hx y E xsc o inc Hy z sc H zsc 1 E xsc E y o inc Hz t y x H sc H E sc ( o ) inc t t E E sc H sc E sc ( o ) inc E inc t t sc E inc E xsc 1 H zsc H y sc o x E x E xinc t y z t inc E ysc 1 H xsc H zsc E y o E ysc E yinc t z x t sc E yinc E zsc 1 H y H xsc sc o E z E yinc t x y t 2D Scattered Field TM TE sc H xsc 1 E y o inc Hx t z sc H zsc 1 E y o inc Hz t x E yinc inc E ysc 1 H xsc H zsc sc o E y Ey t z x t sc E inc E xsc 1 H y sc o x E x E xinc t z t sc E yinc E zsc 1 H y sc o E z E yinc t x t H ysc 1 E zsc E xsc o H yinc t x z t 1D Scattered Field TM TE sc H xsc 1 E y o inc Hx t z inc E ysc 1 H xsc E inc y sc o E y Ey t z t sc E inc E xsc 1 H y sc o x E x E xinc t z t inc H ysc 1 E xsc o H y t z t 1-D FDTD Scattered Fields (TE) Hysc 1 E xsc o Hyinc t z t E sc n 1/ 2 x sc E inc E xsc 1 Hy sc o x E x E xinc t z t ( 2 t sc n1/ 2 2t sc n sc n (i) E x (i) H y (i 1/2) H y (i 1/2) 2 t z(2 t 2t( o ) E xinc 2t (t (n 1/2)t, z iz) E xinc (t (n 1/2)t, z iz) (2 t t (2 t H sc n 1 y ( t sc n 1/ 2 sc n 1/ 2 (i) H (i) Ex (i 1/2) E x (i 1/2) z sc n y inc H t( o ) y (t nt, z iz) t 1-D FDTD Scattered Fields (TE) EXAMPLE INCIDENT FIELD E xinc (z,t) Acos( o t kz z) Acos( o t o c E xinc (z,t) o Asin( o t o z) t c z let t c Acos( o ) 0 E xinc (z,t) 0 0 E xinc (z,t) A o sin( o ) 0 0 0 t In FDTD t z iz nt c c z) 1-D FDTD – Basic Core of 1D Scattered Field Code (non-magnetic) for n=2:Nt % all time steps for i=2:Nx-1 % all interior nodes Loop through all of the E -grid tau nt iz c If tau<0 2 (i ) t (i ) 2t E x (i, n) E x (i, n 1) H y (i, n 1 ) H yn (i 1, n 1 ) 2 (i ) t (i ) z (2 (i ) t (i ) ( else E x (i,n) 2(i) t (i) 2t E x (i,n 1) (H y (i,n 1 ) H yn (i 1, n 1 ) 2(i) t (i) z(2(i) t (i) 2t((i) o ) E xinc 2t (i) E xinc (2(i) t (i) t (2(i) t (i) Loop through all of the H -grid end end for i=2:Nx-1 % all interior nodes H y (i, n) H yn (i, n 1) end end t E (i 1, n 1) E x (i, n 1) (i ) z x ( 2-D FDTD Scattered Fields (TE) sc H xsc 1 E y o inc Hx t z sc H zsc 1 E y o inc Hz t x E yinc inc E ysc 1 H xsc H zsc o E ysc Ey t z x t H ysc n 1 n (i, j) H xsc (i, j) ( n 1/ 2 n 1/ 2 t E ysc (i, j 1/2) E ysc (i, j 1/2) z t( o ) H xinc (t nt, x ix,z jz) t H zsc E sc n 1/ 2 y n 1 n (i, j) H zsc (i, j) ( n 1/ 2 n 1/ 2 t E ysc (i 1/2, j) E ysc (i 1/2, j) x t( o ) H zinc (t nt, x ix,z jz) t H sc n (i, j 1/2) H sc n (i, j 1/2) H sc n (i 1/2, j) H sc n (i 1/2, j) 2 t sc n1/ 2 2t z z x x (i, j) Ey (i, j) 2 t 2 t z x ( 2t( o ) E y 2t (t (n 1/2)t, x ix, z jz) E yinc (t (n 1/2)t, x ix, z jz) (2 t t (2 t inc Implementation of Boundary Conditions 2D Boundary condition for a perfectly electrically conducting (PEC) material Ex(1, nt ) 0 1 nt Nt ( N z , nt ) Ex 0 Absorbing/open boundary condition in 1-D Many different methods • Interpolation/Extrapolation in time and space (Liaos) • One way way equation (Mur) • Artificial absorbing boundaries (PMLs) One Way Wave Equation 1 2 2 2 2 E 0 x c t y 2 2 2 2 2 Dt Dy Dx 2 2 2 Dy Dx Dt E L{E} 0 2 L{E} L L {E} 0 One Way Wave Equation L{E} L L {E} 0 2 2 D D Dx Dt 1 y Dx Dt 1 y E 0 D D t t L Dx Dt L Dx Dt Dy 1 Dt Dy 1 Dt 2 Dx Dt 1 (S 2 2 Dx Dt 1 (S 2 One Way Wave Equation L Dx Dt L Dx Dt Dy 1 Dt Dy 1 Dt 2 Dx Dt 1 (S 2 2 Dx Dt 1 (S 2 If we could implement the one way equations on a FDTD boundary we would have the perfect ABC (i.e. zero reflection. Unfortunately we can’t do that since we don’t know how to implement the square root operator. So we need to approximate. 1 (S 1 2 1 (S 1 2 First order Taylor series expansion One Way Wave Equation L Dx Dt L Dx Dt Dy 1 Dt Dy 1 Dt 2 Dx Dt 2 Dx Dt 1 L E 2 E 0 c t x 1 L E 2 E 0 c t x Absorbing Boundary Conditions 2D: Mur 1st order One-way Wave Equations: They approximately represent waves traveling in only one direction. y=h E 1 E 0 x c 2 t E 1 E 0 y c 2 t E 1 E 2 0 x c t E 1 E 0 y c 2 t y=0 x=0 x=w Absorbing Boundary Conditions 2D: Mur One-way Wave Equations: They approximately represent waves traveling in only one direction. y=h E 1 E E2n,j1 E1n, j 1 E2n, j E1n, j E 1 2 0 x c t x 2 x x n 1 n n 1 n E 1 E1, j E1, j E2, j E2, j t 2 t t n 1 1, j E ct x n1 n E E2, j E1, j ct x n 2, j y=0 x=0 x=w Absorbing Boundary Conditions 2D: 1st Order Mur 2D 1st Order Mur Equation y=h 1 Ein, Ny Ein, Ny 1 E1n, j 1 E2n, j ct x n 1 E2, j E1n, j ct x ct y n1 Ei , Ny 1 Ein, Ny ct y n 1 n E Nx , j E Nx 1, j Ein,11 Ein, 2 ct x n 1 n E Nx 1, j E Nx ,j ct x ct y n1 Ei , 2 Ein,1 ct y y=0 x=0 x=w Absorbing Boundary Conditions 2D: Mur 2nd Order One-way Wave Equations: They approximately represent waves traveling in only one direction. y=h 2E 1 2E c 2E 0 yt c t 2 2 x 2 2E 1 E n 1 E n1 1 E i,Ny E i,Ny1 E i,Ny E i,Ny1 yt 2t x x 2t y y n 1 n 1 n1 n1 2 n 2 n n 1 n n1 n 1 n n1 E 1 E i,Ny E i,Ny1 1 E i,Ny 2E i,Ny E i,Ny E i,Ny1 2E i,Ny1 E i,Ny1 t 2 2 t 2 t 2 2 t 2 t 2 2 y=0 x=0 2 n 2 n n n n n n n 2 E 1 E i,Ny E i,Ny1 1 E i1,Ny 2E i,Ny E i1,Ny E i1,Ny1 2E i,Ny1 E i1,Ny1 x 2 2 x 2 x 2 2 x 2 x 2 x=w (MATLAB DEMO)