Instructor Dr. Ramon Rumpf (915) 747 6958 rcrumpf@utep.eu EE 5337 Computational Electromagnetics (CEM) Lecture #14 Implementation of Finite Difference Frequenc Domain Lecture 14 These notes ma contain coprighte material obtaine uner fair use rules. Distribution of these materials is strictl prohibite Slie 1 Outline Basic flow of FDFD 2 gri technique Calculating gri parameters Constructing our evice on the gri Walkthrough of the FDFD algorithm Eamples for benchmarking Lecture 14 Slie 2 1
Basic Flow of FDFD Lecture 14 Slie 3 Block Diagram of FDFD Implementation Dashboar Source, evice, learn, an gri Calculate Gri N, N,,, a, a Buil Device on Gri Incorporate PML All har coe numbers. No work. No har coe numbers. All work. Calculate Wave Vector Components k, k, k m, k m, k m,inc,inc,ref,trn Buil Wave Matri A E jh A H j E Compute Source bqaaq f Solve A = b src FDFD Post Process RDE, TDE, REF, TRN, CON Lecture 14 Slie 4 2
Detaile FDFD Algorithm 1. Construct FDFD Problem a. Define our problem b. Calculate the gri parameters c. Assign materials to the gri to buil ER2 an UR2 arras 2. Hanle PML an Materials a. Compute s an s b. Incorporate into r an r c. Overla onto 1 gris 3. Compute Wave Vector Components a. Ientif materials in reflecte an transmitte regions: ref, trn, ref, trn, n ref, n trn b. Compute incient wave vector: k inc c. Compute transverse wave vector epansion: k,m. Compute k,ref an k,trn 4. Construct A a. Construct iagonal materials matrices b. Compute erivative matrices c. Compute A 5. Compute Source Vector, b a. compute source fiel f src b. compute Q c. compute source vector b 6. Solve Matri Problem: e = A 1 b; 7. Post Process Data a. Etract E ref an E trn b. Remove phase tilt c. FFT the fiels. Compute iffraction efficiencies e. Compute reflectance & transmittance f. Compute conservation of power Lecture 14 Slie 5 2 Gri Technique Lecture 14 Slie 6 3
What is the 2 Gri Technique? (1 of 2) This is the traitional approach for builing evices on a Yee gri. It is ver teious an cumbersome to etermine which fiel components resie in which material. Device on 1 Gri Device 1 Gri N N VERY DIFFICULT STEP!! Lecture 14 Slie 7 What is the 2 Gri Technique? (2 of 2) The 2 gri technique simplifies how evices are built into the permittivit an permeabilit arras. Device N2 = 2*N N2 = 2*N 2 = /2 2 = /2 2 Gri Device on 2 Gri eas 1 Gri N N eas eas Device on 1 Gri Lecture 14 Slie 8 4
Block Diagram of FDFD With 2 Gri 2 Gri Onl Use Here Dashboar Source, evice, learn, an gri Calculate Gri N, N,,, a, a Buil Device on 2 Gri ER2 UR2 Incorporate PML on 2 Gri Parse to 1 Gri All har coe numbers. No work. No har coe numbers. All work. FDFD Calculate Wave Vector Components k, k, k m, k m, k m,inc,inc,ref,trn Buil Derivate Matrices e e h h D, D, D an D Buil Wave Matri A h 1 e h 1 e A D μ D D μ D ε e 1 h e 1 h A D ε D D ε D μ E zz H zz Compute Source bqaaq f Solve A = b src Diagonalize Materials Post Process RDE, TDE, REF, TRN, CON Lecture 14 Slie 9 Recall the Yee Gri 1D Yee Gri E 2D Yee Gris E z 3D Yee Gri z H E Moe z H H Ez Moe H E z H E E H E Moe z E H z Hz Moe E E H z Lecture 14 Slie 1 5
4 4 Yee Gris E Moe H Moe Lecture 14 Slie 11 Simplifie Representation of E Fiel Components The fiel components are phsicall positione at the eges of the cell. The simplifie representation shows the fiels insie the cells to conve more clearl which cell the are in. Lecture 14 Slie 12 6
Simplifie Representation of E Fiel Components The fiel components are phsicall positione at the eges of the cell. The simplifie representation shows the fiels insie the cells to conve more clearl which cell the are in. Lecture 14 Slie 13 The 2 Gri The Conventional 1 Gri Due to the staggere nature of the Yee gri, we are effectivel getting twice the resolution. It now makes sense to talk about a gri that is at twice the resolution, the 2 gri. j j j i i i The 2 gri concept is useful because we can create evices (or PMLs) on the 2 gri without having to think about where the ifferent fiel components are locate. In a secon step, we can easil pull off the values from the 2 gri where the eist for a particular fiel component. Lecture 14 Slie 14 7
2 1 (1 of 4): Define Gris Suppose we wish to a a circle to our Yee gri. First, we efine the stanar 1 gri. Secon, we efine a corresponing 2 gri. Note: the 2 gri represents the same phsical space, but with twice the number of points. Lecture 14 Slie 15 2 1 (2 of 4): Buil Device Thir, we construct a cliner on the 2 gri without having to consier anthing about the Yee gri. Fourth, if esire we coul perform ielectric averaging on the 2 gri at this point. Note: This is iscusse more in Lecture 14 FDFD Etras. Lecture 14 Slie 16 8
2 1 (3 of 4): Recall Fiel Staggering Recall the relation between the 2 an 1 gris as well as the location of the fiel components. Lecture 14 Slie 17 2 1 (4 of 4): Parse to 1 Gri Lecture 14 Slie 18 9
Etract ER from ER2 ER = ER2(2:2:N2,1:2:N2) Lecture 14 Slie 19 Etract ER from ER2 ER = ER2(1:2:N2,2:2:N2) Lecture 14 Slie 2 1
Etract ERzz from ER2 ERzz = ER2(1:2:N2,1:2:N2) Lecture 14 Slie 21 Etract UR from UR2 UR = UR2(1:2:N2,2:2:N2) Lecture 14 Slie 22 11
Etract UR from UR2 UR = UR2(2:2:N2,1:2:N2) Lecture 14 Slie 23 Etract URzz from UR2 URzz = UR2(2:2:N2,2:2:N2) Lecture 14 Slie 24 12
MATLAB Coe for Parsing Onto 1 Gri ER = ER2(2:2:N2,1:2:N2,1:2:Nz2); ER = ER2(1:2:N2,2:2:N2,1:2:Nz2); ERzz = ER2(1:2:N2,1:2:N2,2:2:Nz2); UR = UR2(1:2:N2,2:2:N2,2:2:Nz2); UR = UR2(2:2:N2,1:2:N2,2:2:Nz2); URzz = UR2(2:2:N2,2:2:N2,1:2:Nz2); E z Moe ERzz = ER2(1:2:N2,1:2:N2); UR = UR2(1:2:N2,2:2:N2); UR = UR2(2:2:N2,1:2:N2); H z Moe ER = ER2(2:2:N2,1:2:N2); ER = ER2(1:2:N2,2:2:N2); URzz = UR2(2:2:N2,2:2:N2); Lecture 14 Slie 25 Calculating the Gri Parameters Lecture 14 Slie 26 13
Moel Construction Dirichlet bounar PML 2 cells perioic bounar perioic bounar PML Dirichlet bounar 2 cells Lecture 14 Slie 27 Consieration #1: Wavelength The gri resolution must be sufficient to resolve the shortest wavelength. 1 point First, ou must etermine the smallest wavelength: min min ma n, N min N 1 N Comments 1 to 2 Low contrast ielectrics 2 to 3 High contrast ielectrics 4 to 6 Most metallic structures 1 to 2 Plasmonic evices min[ ] is the shortest wavelength of interest in our simulation. ma[n(,)] is the largest refractive ine foun anwhere in the gri. Secon, ou resolve the wave with at least 1 cells. Lecture 6 Slie 28 14
Consieration #2: Mechanical Features The gri resolution must be sufficient to resolve the smallest mechanical features of the evice. First, ou must etermine the smallest feature: min min Secon, ou must ivie this b 1 to 4. N min N 1 Unit cell of a iamon lattice N 1 N 1 N 1 N 4 Lecture 6 Slie 29 Calculating the Initial Gri Resolution 1. We must resolve the minimum wavelength. min ma n, N 1 N Note: If ou are performing a parameter sweep over frequenc or wavelength, min( ) is the shortest wavelength in the sweep. 2. We must resolve the minimum structural imension. min N 1 N We procee with the smallest of the above quantities to be our initial gri resolution min, Lecture 14 Slie 3 15
Resolving Critical Dimensions (1 of 3) We have not et consiere the actual imensions of the evice we wish to simulate. This means we likel cannot resolve the eact imensions of a evice. Suppose we wish to place a evice of length onto a gri. Not an eact fit. We cannot fill a fraction of a cell. Lecture 14 Slie 31 Resolving Critical Dimensions (2 of 3) To fi this, we first calculate how man cells N are neee to resolve the most important imension. In this case, let this be. N N 1.5 cells Secon, we etermine how man cells we wish to eactl resolve. We o this b rouning N up to the nearest integer. N ceil N 11 cells Lecture 14 Slie 32 16
Resolving Critical Dimensions (3 of 3) Thir, we ajust the value of to represent the imension eactl. N N 11 cells We call this step snapping the gri to a critical imension. Unfortunatel, using a uniform gri, we can onl o this for one imension per ais. Lecture 14 Slie 33 Snap Gri to Critical Dimensions Decie what imensions along each ais are critical. Tpicall this is a lattice constant or grating perio along Tpicall this is a film thickness or grating epth along Compute how man gri cells comprise an an roun UP. M M an ceil ceil Ajust gri resolution to fit these critical imensions in gri EXACTLY. M We will rop the prime smbol from an. M initial gri ajuste gri critical imension critical imension Lecture 14 Slie 34 17
Compute Total Gri Size Don t forget to a cells for PML! Must often a space between PML an evice. Note: This is particularl important when moeling evices with large evanescent fiels. PML Spacer Region Easiest to make N o. N Reason iscusse later. N 2NPML 2NSPACE N ma SPACE ceil nbuff Problem Space Spacer Region PML N N Lecture 14 Slie 35 Compute 2 Gri Parameters 1 Gri 2 Gri N2 = 2*N; N2 = 2*N; 2 = /2; 2 = /2; Lecture 14 Slie 36 18
Constructing a Device on the Gri Lecture 14 Slie 37 Reucing 3D Problems to 2D z Representation on a Cartesian gri Lecture 14 Slie 38 19
Averaging At the Eges Direct Smoothe Lecture 14 Slie 39 Builing Rectangular Structures For rectangular structures, consiering calculating start an stop inices. Be ver careful with how man n1 points on the gri ou fill in! r1 r r 2 n1 n2 n3 n4 n5 n2 n3 n4 n6 n2 = n1 + roun(/2) 1; Without subtracting 1 here, filling in n1 to n2 woul inclue an etra cell. This can introuce error into our results. % BUILD DEVICE ER2 = er1*ones(n2,n2); %fill everwhere with er1 ER2(n1:n2,n1:n2) = er; %a tooth 1 ER2(n5:n6,n1:n2) = er; %a tooth 2 ER2(:,n3:n4) = er; %a substrate ER2(:,n4+1:N2) = er2; %fill transmission region Lecture 14 Slie 4 2
Oh Yeah, Metals! Perfect Electric Conuctors 1 r or E1 f1 1 Em EM fm Em Inclue Tangential Fiels at Bounar (TM moes!) Ba placement of metals Goo placement of metals E Hz Moe Hz E Lecture 14 Slie 41 Walkthrough of the FDFD Algorithm Lecture 14 Slie 42 21
Input to the FDFD Algorithm The FDFD algorithm requires the following information: The materials on the 2 gri: ER2(n,n) an UR2(n,n) The gri resolution: an The size of the PML on the 1 gri: NYLO an NYHI The source wavelength, Angle of incience, Moe/polarization: E or H Lecture 14 Slie 43 (1) Determine the Material Properties in the Reflecte an Transmitte Regions If these parameters are not provie in the ashboar, or a ashboar oes not eist, the can be pulle irectl off of the gri. ref r ref r ER2(n,n) UR2(n,n) trn r trn r Lecture 14 Slie 44 22
(2) Compute the PML Parameters on 2 Gri 2 cells on Yee gri. 4 cells on 2 gri. s, s, 2 cells on Yee gri. 4 cells on 2 gri. Lecture 14 Slie 45 (3) Incorporate the PML We can incorporate the PML parameters into [μ] an [ε] as follows E k r H H k E r ss z s ss z r s ss zz sz ss z s ss z r s ss zz s z For 2D simulations, s z = 1 an we have s r s s r s s s zz r s s s s s s r r zz r Note: the PML is incorporate into the 2 gri. % INCORPORATE PML UR = UR2./s.*s; UR = UR2.*s./s; URzz = UR2.*s.*s; ER = ER2./s.*s; ER = ER2.*s./s; ERzz = ER2.*s.*s; Lecture 14 Slie 46 23
(4) Overla Materials Onto 1 Gris Fiel an materials assignments I E z zz III H, E, II H, E, IV H z zz I 1 Gris II E z 2X Gri H Ez Moe H E Hz Moe Hz E III IV % OVERLAY MATERIALS ONTO 1X GRID UR = UR(1:2:N2,2:2:N2); UR = UR(2:2:N2,1:2:N2); URzz = URzz(2:2:N2,2:2:N2); ER = ER(2:2:N2,1:2:N2); ER = ER(1:2:N2,2:2:N2); ERzz = ERzz(1:2:N2,1:2:N2); Lecture 14 Slie 47 (5) Compute the Wave Vector Terms k 2 sin kinc knref cos 2 kmk,inc m 2 2 k m k n k m,ref ref 2 2 k m k n k m,trn trn This is a vector quantit m, 2, 1,,1,2, N points total. For proper smmetr, N shoul be o. m = [-floor(n/2):floor(n/2)]'; These equations come from the ispersion equation for the reflecte an transmitte regions. Recall that there use to be a negative sign here. We are able to rop it as long as we also rop the negative sign when calculating iffraction efficienc. Lecture 14 Slie 48 24
(6) Construct Diagonal Materials Matrices ε ε ε zz 1 2 1 2 zz 1 zz 2 zz N N N μ μ μ zz 1 2 N 1 2 N zz 1 zz 2 zz N ER = iag(sparse(er(:))); Lecture 14 Slie 49 (7) Construct the Derivative Matrices D, D, D, an D e e h h Frequenc (or wavelength) information is incorporate into FDFD here [DEX,DEY,DHX,DHY] = eeer(ngrid,k*res,bc,kinc/k); Don t forget that we have normalize our parameters so ou shoul use eeer() as follows: [DEX,DEY,DHX,DHY] = eeer(ngrid,k*res,bc,kinc/k); Be sure this function uses sparse matrices from the ver beginning. A = sparse(m,m) creates a sparse MM matri of zeros. A = spiags(b,,a) As arra b to iagonal in matri A. Lecture 14 Slie 5 25
(8) Compute the Wave Matri A Moe A D μ D D μ D ε h 1 e h 1 e E zz Moe A D ε D D ε D μ e 1 h e 1 h H zz Lecture 14 Slie 51 (9) Compute the Source Fiel The source has an amplitue of 1. f jk r src, ep inc ep j k,inc k,inc k inc Don t forget to make f src a column vector. 1 gri Lecture 14 Slie 52 26
(1) Compute the Scattere Fiel Masking Matri, Q total fiel scattere fiel 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Reshape gri to 1D arra an then iagonalize. 1 Q 1 Q = iag(sparse(q(:))); It is goo practice to make the scattere fiel region at least one cell larger than the low PML. Lecture 14 Slie 53 (11) Compute the source vector, b src Af = b b QA AQ f Lecture 14 Slie 54 27
(12) Compute the Fiel f 1 f=a b Asie In MATLAB, f = A\b emplos a irect LU ecomposition to calculate f. This is ver stable an robust, but a half full matri is create so memor can eploe for large problems. Iterative solutions can be faster an require much less memor, but the are less stable an ma never converge to a solution. Correcting these problems requires significant moification to the FDFD algorithm taught here. Don t forget to reshape() f from a column vector to a 2D gri after the calculation. Lecture 14 Slie 55 (13) Etract Transmitte an Reflecte Fiels SF E ref The reflecte fiel is etracte from insie the scattere fiel, but outsie the PML. TF E trn The transmitte fiel is etracte from the gri after the evice, but outsie the PML. Lecture 14 Slie 56 28
(14) Remove the Phase Tilt Recall Bloch s theorem, jk r E r A r e inc kinc This implies the transmitte an reflecte fiels have the following form E A A ref trn ref trn jk i ref jk,i A e E A e trn jk i Eref e jk,i E e trn,nc nc We remove the phase tilt to calculate the amplitue terms.,nc nc Lecture 14 Slie 57 (15) Calculate the Comple Amplitues of the Spatial Harmonics Recall that the plane wave spectrum is the Fourier transform of the fiel. We calculate the FFT of the fiel amplitue arras. ref trn FFT S m A ref FFT S m A trn Some FFT algorithms (like MATLAB) require that ou ivie b the number of points an shift after calculation. Sref = flipu(fftshift(fft(aref)))/n; Strn = flipu(fftshift(fft(atrn)))/n; Lecture 14 Slie 58 29
(16) Calculate Diffraction Efficiencies The source wave was given unit amplitue so 2 Sinc 1 The iffraction efficiencies of the reflecte moes are then ref 2 Re k m r,inc Rm Sref m E Moe Re k R m U m ref inc r,inc ref 2 Re k m r,inc Re k inc r,inc H Moe The iffraction efficiencies of the transmitte moes are then trn 2 Re k r,trn Tm Strn m inc Re k r,inc E Moe trn 2 Re k r,trn Tm Utrn m inc Re k r,inc H Moe Recall that there use to be a negative sign here. We roppe it because we also roppe the sign when calculating k m. Note: these equations assume that Sinc 1. Lecture 14 Slie 59,ref S m amplitues of E moe spatial harmonics Um amplitues of H moe spatial harmonics (17) Calculate Reflectance, Transmittance, an Conservation of Power The overall reflectance is REF R m m The overall transmittance is TRN T m m Conservation of power is compute as REFTRNABS 1 If no loss or gain is incorporate, then ABS = an we will have REFTRN 1 REF + TRN < 1 loss REF + TRN = 1 no loss or gain REF + TRN > 1 gain Lecture 14 Slie 6 3
Remember the Thir Dimension! We grabbe a unit cell of a 3D evice. We represente it on a 2D gri. We simulate it on a 2D gri. The fiel is interprete as infinitel etrue along the thir imension. Lecture 14 Slie 61 Eamples for Benchmarking Lecture 14 Slie 62 31
Air Simulation 1. r 1. r -3 L = 1. h = 1. m -4-3 -2-1 1 2 3 4 E Moe R T 1 R H Moe T 1 E an H Moe Lecture 14 Slie 63 Dielectric Slab Grating 1. r 9. r -6-25 15 45 8 E Moe R T 49.5% 5.6% 28.5% 71.7% 25.1% 75. 26.3% 73.8% 37.2% 62.9% 77.7% 21.8% R 5. 21.8% 25.1% 24. 13.9% 8.3% H Moe T 95.4% 78.4% 75.1% 76.3% 86.4% 91.9% Note: ou can come up with our own benchmarking eamples using the transfer matri metho! = 45 Lecture 14 Slie 64 32
Binar Diffraction Grating 1. 1. r1 r1 w =.5L -3 h =.25 1. r 9. r m -4-3 -2-1 1 2 3 4 E Moe R T 4.6% 5.3% 2.6% 6.9% 22.1% 12.7% 7.8% 17.7% 16.4% 3.9% R 14.1%.9% H Moe T 2.4% 7.5% 3.1% 38.8% 5.4% 17.7% 7.6% 2.4% L = 1.25 Lecture 14 Slie 65 Sawtooth Diffraction Grating 1. 1. r1 r1 L = 1.25-2 h =.85 1.5 r 3. r m -4-3 -2-1 1 2 3 4 E Moe R T 5.6% 39.2%.8% 44.2% 1.1% R H Moe T.4% 53.1% 3.4% 29.5% 13.6% H Moe Lecture 14 Slie 66 33