A simple plane wave implementation method for photonic crystal calculations Shangping Guo and Sacharia Albin Department of Electrical & Computer Engineering, Old Dominion University, Norfolk, VA 23529 sguox002@lions.odu.edu, salbin@odu.edu Abstract: A simple implementation of the full-vectorial plane wave method is presented for modeling photonic crystals with regular ‘atoms’ using MATLAB. We calculate the analytical Fourier transform for an atom and use the shift property to obtain the Fourier transform for any arbitrary supercell consisting of a finite number of atoms, including the quasiperiodic case. MATLAB source code for the implementation requires approximately one hundred statements. It converges quickly and yields accurate results using a small number of plane waves. The source code is freely available at http://www.lions.odu.edu/~sguox002. © 2001 Optical Society of America OCIS codes: (000.4430) Numerical approximation and analysis; (350.3950) Micro-optics ______________________________________________________________________________________________________________________________ References and links 1. S. G. Johnson and J. D. Joannopoulos, “Block iterative frequency-domain methods for Maxwell's equations in a planewave basis.” Optics Express 8, 173-190 (2001). 2. D. Hermann et al., “Photonic band structure computations.” Optics Express 8, 167-172 (2001). 3. F. J. Brechet et al., “Complete analysis of the characteristics of propagation into photonic crystal fibers by the finite element methods.” Optical Fiber Technology 6, 181-191 (2000). 4. K. M. Ho, C. T. Chan, and C. M. Soukoulis, “Existence of a photonic gap in periodic dielectric structures.” Phys. Rev. Lett. 65, 3152-3155 (1990). 5. K. M. Leung, "Plane wave calculation of photonic band structures" in Photonic band gaps and localizations, C. M. Soukoulis. ed. (Plenum Press NY 1993). 6. K. M. Leung and Y. F. Liu, “Full vector wave calculation of photonic band structures in FCC dielectric media.” Phys. Rev. Lett. 65, 2646-2649 (1990). 7. D. C. Champeney, Fourier transforms and their physical applications, (Academic Press, 1973) Chap. 3. 8. J. D..Joannopoulos et al., Photonic crystals - Molding the flow of light ( Princeton University Press 1995). 9. R. D. Meade, A. M. Rappe et al., “Accurate theoretical analysis of photonic band gap materials.” Phys. Rev. B 48, 8434-8437 (1993). 10. P. R. Villeneuve, S. Fan et al., “Microcavities in photonic crystals: mode symmetry, tunability, and coupling efficiency.” Phys. Rev. B 54, 7837-7842 (1996). 11. A Brandt, S McCormick and J. Ruge, "Multigrid methods for differential eigenproblems," SIAM J. Sci. Stat. Comput. 4, 244-260 (1983). ______________________________________________________________________________________________________________________________ 1. Introduction The plane wave method (PWM) is often used for photonic crystal modeling. Generally, it involves intensive computations, using thousands of plane waves. Its implementation is complicated and involves a huge number of statements in C or Fortran, similar to those given in the well-known MPB package from MIT [1]. In this paper, we present a simple and fast implementation method using MATLAB. MATLAB provides many functions required for numerical analysis and graphics, also operations are optimized for matrix, so it is ideal for scientific analysis with little programming effort, especially those calculations involving intensive matrix operations. In fact, our program is so tiny that it has only 100 statements for performing the calculations and graphic output, which makes the algorithm much clearer and more understandable, imaging how difficult it is to debug and maintain a program with ~10,000 statements. Our implementation treats those most commonly used ‘atoms’ with regular shapes, such as the square, rectangular, circular cylinders, cubes and spheres. Analytical Fourier transform exists for these atoms and there is no need to do numerical Fast Fourier Transform (FFT), thus avoiding the cumbersome step of dividing the space into small grids. Generally, these grids should be carefully arranged to get good convergence [2], or fine grid mesh needs to be used in some region to reflect the finest features, such as the finite element method [3]. Errors in plane wave method include: the error of Fourier coefficient for each reciprocal grid vector used, the truncation error of using a finite number of plane waves and the error by the eigensolver. Since we use analytical Fourier transform, there is no error in these coefficients, therefore the method is stable and always converges quickly, requiring only a moderate number of plane waves. This approach may not necessarily speed up the calculation, since one may have a powerful FFT algorithm. Since the number of plane waves is not necessary to be the same as the number of the grids in the mesh, very fine mesh can be used to obtain accurate Fourier coefficients using FFT. However, programming effort is largely reduced when the FFT is skipped, especially when we consider those non-orthogonal cases, like the triangular lattice. Since the computation is not so intensive, the program can easily run on a desktop PC and could be a convenient tool for engineering analysis of photonic crystals. 2. Theory of PWM The PWM is illustrated in several papers [4, 5]. Here, we summarize the theory very briefly. Maxwell’s equations in a transparent, time-invariant, source free and non-permeable (µ=µ0 ) space can be rewritten as Helmholz’s equation: r 1 ω2 r (1) ∇× ∇ × H (r ) = 2 H (r ) ε (r ) c r with the transverse condition being: (2) ∇ • H (r ) = 0 . In a photonic crystal, we assume infinite periodic medium, and using Bloch’s theorem, a mode in a periodic structure can be expanded as a sum of infinite number of plane waves: r r r r r (3) H (r ) = h G , λ eˆ ei (k +Gi )⋅r ∑ ( r Gi ,λ ) i λ r r where λ=1, 2, k is the wave vector in vacuum, G is the reciprocal lattice vector. Using the Fourier transform, the dielectric function can be written as: r rr ε (r ) = ∑ ε Gi e iGi ⋅r r ( ) (4) Gi where G is any reciprocal lattice vector. Using equations (3) and (4), and applying the transverse condition, Helmholz’s equation can be transformed to an algebraic form [6]: ˆ2 ˆ2′ e e ∑ k + G k + G ′ ε (G − G ′ )− eˆ eˆ ′ −1 G′ 1 2 − eˆ2 eˆ′1 h1′ w 2 h1 . = eˆ1eˆ1′ h′2 c 2 h2 (5) This is a standard eigenvalue problem. If N plane waves are used, this will be 2N linear equations. Simplifications exist for 2D and 1D PBGs. For in-plane propagation in a 2D photonic crystal, equation (5) is decomposed into TE and TM modes: r r r r −1 r r r r ω2 TM: (6) ′ ′ ′ k + G k + G ε G − G h G = h1 G ∑ 1 2 c G′ r r r r −1 r r r r ω2 TE: (7) ′ ′ ′ k + G • k + G ε G − G h G = h2 G . ∑ 2 2 c G′ ( )( ( ) ( ) ) ( ) ( ) () () Each of them is a group of N linear equations if N plane waves are used, and the problem complexity is reduced half. For 1D normal incidence, TE and TM behave the same, so only one equation is needed. Off-plane 1D and 2D problems can be treated as 2D and 3D problems, respectively. For each specific k, the frequency ω for the eigenmode is the eigenvalue of the above equations. Using N plane waves, we will get 2N (for TE & TM is N) discrete frequencies for each k-point. These frequencies are sorted ascendantly and labeled as 1 to 2N. One band is formed by all the eigen-frequencies with the same order for all k-vectors in First Irreducible Brillouin zone (IBZ). We can calculate only the eigen-frequencies for those k-vectors along the edge of the IBZ, since those frequencies for the k-vectors falling inside the IBZ will fall inside the band. r r The eigenvectors can be used to form the H and D field according to equation (3) and the relation: r r −i D (r ) = ∇ × H (r ) k (8) where k is the magnitude of the vacuum wave vector. 3. Implementation We illustrate the implementation in the case of 2D photonic crystals with the most commonly used circular cylinder. Other shapes can follow the same procedure and the Fourier transform for them can refer to reference [7]. Assuming the radius of the cylinder is R, the dielectric constant for the cylinder is εa, the background dielectric constant is εb , the lattice structure can be represented by the two lattice r r r r basis vector a1 and a 2 . The cell area is calculated as A = a1 × a 2 , the Fourier transform of the unit cell is: 2πR 2 J 1 (GR) J (GR ) (9) ε (G ) = ε bδ (G ) + (ε a − ε b ) = ε bδ (G ) + 2(ε a − ε b ) f 1 A GR GR (10) ε (G = 0 ) = ε b + f (ε a − ε b ) where J1 is the 1st order Bessel function, f is a fraction parameter and (11) f = Volatom Volcell . For a supercell with several atoms in periodic or random positions, the Fourier transform can be obtained using the shift property [7]: r r (12) ε (r + r0 ) ↔ e iG •r ε (G ) . Note that the fraction parameter for a supercell is now f = ∑ Volatom Volsupercell . Therefore, the Fourier transform for any arbitrary supercell with a finite number of atoms can be easily obtained using: r (13) ε (r + r ) ⇔ eiG • ri ε (G ) , ∑ ri i ∑ ri where ri is the location of an ‘atom’ in the supercell. Application of the shift property to get the Fourier transform of a supercell has an important advantage: we can easily obtain the Fourier coefficients of the supercell at the required G grid points by doing simple additions, requiring only the Fourier coefficients of a single atom. This provides an important flexibility such that photonic crystals with different geometries can be treated in the same way, with the only difference being the set of the G grid points and k-vectors. This shift property can even be used when FFT instead of analytical Fourier transform is used. Supposing we have a 2D supercell containing m x m unit cells, and the number of plane waves to be used is Npw, the supercell is divided into a N x N mesh to perform FFT. To ensure accurate Fourier coefficient, the mesh should be fine enough, i.e., N 2 >> N pw . If FFT is done on a unit cell, [N/m] x [N/m] mesh is sufficient to achieve the same accuracy, provided [N m] >> N pw . This saves both memory and computation largely. As an example, the source code for calculating the TM/TE band structure for a 2D square lattice using a 5x5 supercell is placed on the website for free downloading. The program has approximately 100 lines and requires no extra work for installation. The procedure for the band structure calculation is given below: 1) Define the base lattice vector and the base reciprocal lattice vector of the structure in Cartesian system. Also, the primitive unit cell and first Brillouin zone (1BZ) should be found. 2) Specify how many grid points in the reciprocal space are to be used, in other words, how many plane waves to be used. The set of plane waves is selected by the following procedure: along each reciprocal lattice base vector direction from the 2 3) origin, choose the n closest grid points, and also the n closest grid points along the reverse direction. So the total grid points or plane waves used would be NPW =(2n+1), NPW =(2n+1) 2 , and NPW =(2n+1)3 for 1D, 2D, and 3D PBG’s respectively. Note, there may be also other ways of choosing G vectors, our approach can just simplify the process. Form the G vector array using the grids selected according to some sequence. Figure 1 shows how we arrange these grid points into an array in a 2D triangular lattice with 49 grid points in the reciprocal space, resulting in 49 plane waves. Fig.1. Selection of grid points in the reciprocal space: A 2D triangular lattice is used in this example Form the Fourier transform matrix ε(G) according to its analytical form, this matrix contains the Fourier coefficients for a grid matrix which is twice as large as the G grid matrix in step 2), that is the matrix ε(G) is (4n+1) by (4n+1) for 2D PBG. This matrix contains all the required coefficients for ε(G-G’), which is (2n+1)2 by (2n+1)2 for 2D PBG. 5) Use the shift property in equation (13) to get the Fourier transform for the supercell. 6) Select all the coefficients needed to form the matrix ε(G-G’). It is easy to find all the coefficients in the matrix obtained in step 4) by following our method of selection of the grid points. By doing this way, the computation for ε(G-G’) is largely reduced, since a lot of elements in the matrix ε(G-G’) are identical and we only calculate ε(G). 7) Calculate the inverse matrix of ε(G-G’). 8) Form the k-points array to be calculated, using only points along the edge of the irreducible first Brillouin zone. 9) Form the eigen-matrix according to the problem to be solved. The equation (5) (6) (7) can be easily expressed as matrix form in MATLAB. 10) Find all the eigenvalues and/or the eigenvectors of interest. 11) Output the final results by graph or file. The source file can easily be modified for all kinds of 2D geometry, by changing the base vectors for the primitive unit cell, the two reciprocal lattice vectors, and other related parameters. Extension to 3D cases or quasi-3D cases needs some modifications, which can also be downloaded from our site. Since MATLAB is designed to work best with matrices, the code is vectorized so that it is simple and efficient. As an example, we show how the 3D diamond lattice is worked out: The diamond lattice is a complex FCC lattice with two spherical atoms in the unit cell. Assuming the length of the simple cubic side is a, the primitive lattice vector basis are: r r r a1 = [0,1,1] a 2 , a2 = [1,0,1]a 2 , a3 = [1,1, 0]a 2 . The locations of the two atoms in the r r primitive cell are: r0 = [− 1, −1, −1] a 4 and r1 = [1,1,1]a 4 . The basis vector in the reciprocal lattice is calculated according to: r r r r r r r r r a ×a a ×a a ×a b1 = 2π r 2 r 3 r , b2 = 2π r 3r 1 r , b3 = 2π r 1 r 2 r a1 • a2 × a3 a1 • a2 × a3 a1 • a 2 × a3 4) Assuming the radius of the sphere is R, the Fourier coefficient at the reciprocal lattice grid is expressed as: r r r sin GR − GR cos GR cos G • r0 ε G = 3 f (ε a − ε b ) 3 (GR ) () ( ) using the shift property and Fourier transform for a sphere, where f =2 r r r V = a1 • a2 × a3 . 4π R 3 3 and V We show the band gap for R = 3 8 a using our simple program with 73 = 343 plane waves. The graph shows excellent agreement with the result in PRL 65-25, 3152 even that we used a very small amount of plane waves. 4. Convergence, accuracy and stability 4.1 Ideal photonic crystal We performed the TM/TE band calculation for an ideal square lattice with alumina rods in air chosen from reference [8]. To find the bandgap, 31 k-points are used and all eigenvalues are calculated. The dielectric constants are 8.9 for the dielectric rods and 1.0 for air, rod radius is 0.2a, where a is the lattice constant, and supercell size is 1x1, i.e., an ideal PBG. Table 1 shows the minimum of band 2 for TM/TE mode using different number of plane waves. All data is obtained using a Unix machine at Old Dominion University as a telnet user, on a Sun UltraSparc 400 MHz processor, with Soloris 7.0 and MATLAB 6.0R12 for Unix. Table 1.Convergence of TM/TE modes in a 2D square lattice using 1X1 super cell N # of PW’s 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 9=3X3 25=5X5 49=7X7 81=9X9 121=11X11 169=13X13 225=15X15 289=17X17 361=19X19 441=21X21 529=23X23 625=25X25 729=27X27 841=29X29 961=31X31 Min. of band 2 for TE 0.463564 0.461277 0.460242 0.460598 0.460726 0.460866 0.460973 0.461048 0.461118 0.461167 0.461213 0.461250 0.461281 0.461310 0.461332 Calculation time (s) 0.11 0.23 0.82 2.16 5.74 14.64 26.34 54.64 107.80 195.28 353.18 634.07 1092.57 1729.19 2732.66 Min. of band 2 for TM 0.453323 0.445268 0.443014 0.442765 0.442648 0.442590 0.442569 0.442550 0.442542 0.442536 0.442532 0.442529 0.442527 0.442525 0.442524 Calculation time (s) 0.10 0.22 0.65 2.07 5.18 12.16 26.33 55.58 106.54 199.28 359.50 626.36 1059.36 1737.20 2731.44 Fig.2. Convergence of TM/TE mode for the bottom of band 2 for an ideal 2D square lattice with alumina rods in air. The left figure corresponds to TM mode, and the right figure corresponds to TE mode. In both figures, the time used to get the band bottom is illustrated as the right y-axes in log-scale. Figure 2 shows how quickly the result converges using our method with both TE and TM mode in 2D structures. The method converges well for both TE and TM mode when the number of plane waves is increased, however, the TE is worse than TM mode. This is due to the Gibbs’ phenomenon in Fourier series expansion. Also, the time increases exponentially, which is the biggest weakness for plane wave method, the complexity for PWM is O(N 3 ) . When a large number of plane waves need be used, time and memory required is so large that only supercomputers can handle it and some optimization methods need be used to alleviate the computation. Since the Fourier transform and matrix inversion is done only once, most time is spent on the eigen-solver when a band is calculated. Thus, the efficiency of the eigensolver affects the performance the most. Figure 3 shows the calculated TM/TE mode band structure for the PBG structure, which is identical to the graph in reference [8]. For an accuracy of approximately 1%, only 50 plane waves are sufficient for a 1x1 supercell for an ideal photonic crystal. Figure 3: Band structure of TM/TE mode for an ideal square lattice, with alumina rods in the air, the solid line represents the TM mode, the dotted line represents the TE mode, 121 plane waves are used. 4.2 Photonic crystal with a point defect Using the same parameters in the previous example of a square lattice with Al rods in air, a 5x5 super cell with the center rod absent is analyzed. The defect frequency in the band gap at one k-point (0,0) was calculated using different number of plane waves. The results are listed in Table 2. Table 2: Defect frequency of TM mode in a 2D square lattice using a 5X5 supercell n # of PWs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 9=3X3 25=5X5 49=7X7 81=9X9 121=11X11 169=13X13 225=15X15 289=17X17 361=19X19 441=21X21 529=23X23 625=25X25 729=27X27 841=29X29 961=31X31 Matrix size 9X9 25X25 49X49 81X81 121X121 169X169 225X225 289X289 361X361 441X441 529X529 625X625 729X729 841X841 961X961 Defect frequency (band 25) X 0.445011 0.415112 0.409213 0.404646 0.403069 0.397684 0.396170 0.394902 0.394326 0.394169 0.393472 0.393313 0.393191 0.393173 Iteration Errors X X -7.20E-02 -1.44E-02 -1.13E-02 -3.91E-03 -1.35E-02 -3.82E-03 -3.21E-03 -1.46E-03 -3.98E-04 -1.77E-03 -4.04E-04 -3.10E-04 -4.58E-05 Relative error Calculation Time(s) X 1.32E-01 5.58E-02 4.08E-02 2.92E-02 2.52E-02 1.15E-02 7.62E-03 4.40E-03 2.93E-03 2.53E-03 7.60E-04 3.56E-04 4.58E-05 X X 0.40 0.41 0.85 2.20 3.95 7.10 12.08 20.21 36.21 60.00 89.49 105.46 230.30 229.78 Figure 4 shows the convergence property for the defect frequency using a 5x5 supercell. We need to use more number of plane waves than that for the 1x1 supercell for the same accuracy. This is because the band will be folded by N2 times, where N is the supercell size, so we need at least N2 times as many plane waves to get the same information as for a 1x1 supercell. Also, the Fourier matrix for a supercell with small perturbation will have many values near zero, which will increase numerical errors and slow down the convergence. It is clearly seen that for an accuracy of approximately 1%, 289 plane waves are enough for calculating the defect frequency in a 5x5 supercell. Figure 4: Convergence of the defect frequency of TM mode in a 2D square lattice using a 5x5 supercell, containing alumina rods in air with the center rod absent. The defect frequency also converges with the supercell size as illustrated in Table 3 in the case of results having the accuracy of 0.1%. The defect frequency is calculated with k=0 (in the 1BZ). We only used odd number since such supercell is inversion-symmetric and the Fourier coefficient is pure real. Table 3: Defect frequency vs. super cell size Supercell size 3X3 Defect frequency 0.381242 Supercell size 13X13 Defect frequency 0.396406 5X5 7X7 9X9 11X11 0.394169 0.395736 0.396130 0.396191 15X15 17X17 19X19 21X21 0.396438 0.397023 0.398405 0.398512 The convergence curve of the defect frequency using different supercell size is shown in the figure below: freq 0.42 5X5 0.415 7X7 0.41 9X9 11X11 0.405 13X13 0.4 15X15 0.395 17X17 19X19 0.39 12 22 32 42 sqrt(Npw) 52 62 Figure 1: Convergence of defect frequency for TM mode using different supercell size in a square lattice with the center rod being removed The defect frequency for a point defect should be independent of k-vectors for an infinitely large supercell; however for small supercells, coupling between neighboring defects will lead to a finite width of the defect frequency. For large supercells, the interaction between neighboring defects becomes smaller. The convergence shows that a finite photonic crystal with a large enough size can act as an infinite photonic crystal. Figure 5: Mode field of defect modes in a 2D square lattice using a 5X5 supercell. (a), the dielectric function (b) mode field for band 28: a quadrupole mode (c) Mode field for band 29: a quadrupole mode (4) Mode field for band 30: a second order monopole mode. Eigenvectors resulting from our implementation can be used to get the mode field patterns. As an example, we show in Fig.5 the field pattern for the defect mode created by increasing the radius of the center rod from 0.20a to 0.55a, using a 5x5 supercell. This structure supports 3 defect modes in the band gap for band 28, 29 and 30. The field pattern are quadrupoles for band 28 and 29, and second order monopole for band 30. These results are comparable to those obtained by Villeneuve et al. [10]. The source code for mode field calculation is also placed on our website. The field obtained contains both real and imaginary parts, and each of them is the solution but with a random phase with it. We need to fix this phase to get the eigenmode field so that the modes in a PBG can satisfy the orthogonality condition [8]. In addition, we use the same program to compare our results with those recently published by Hermann et al. [2], as shown in Table 4. One is worth to point out that the number of plane waves for them are unknown, since the number of plane waves is not necessarily the same as the mesh dimension. Also the time for their methods is measured on other computer and is only listed as it is. Table 4: Comparison of several methods Method Grid Our method Our method Our method Our method Our method Our method Our method Our method Our method PWM[2] Multigrid[11] 3X3 5X5 7X7 9X9 11X11 13X13 15X15 17X17 19X19 40X40 256X256 # of PWs 9 25 49 81 121 169 225 289 361 X X Band 1 at X 0.15097 0.15076 0.15073 0.15072 0.15071 0.15071 0.15071 0.15071 0.15071 0.15163 0.15071 Band 2 at X 0.18942 0.18805 0.18786 0.18781 0.18779 0.18778 0.18778 0.18778 0.18778 0.19066 0.18778 Band 3 at X 0.31988 0.31875 0.31859 0.31854 0.31853 0.31852 0.31851 0.31851 0.31851 0.31962 0.31851 Band 4 at X 0.37733 0.36433 0.36290 0.36250 0.36236 0.36231 0.36229 0.36228 0.36228 0.36678 0.36219 CPUtime(s) 0.07 0.11 0.25 0.57 1.22 2.60 5.06 8.10 13.15 99.80 47.60 The advantages of our method are evident from Table 4. It requires a small number of plane waves, but produces accurate results and converges quickly. Optimization is not so important in our method since our program can get the same results using a small number of plane waves. For systems without inversion symmetry, the Fourier transform matrix will be complex and must be calculated as a complex matrix, however, the eigenvalue will be purely real[8]. The eigenvector will be complex and needs to be used as complex. Though plane wave method proves successful in PBG calculations, it has several limitations. The computation grows exponentially when problem size increases. Some 3D problems needs powerful supercomputers and parallel computing. And PWM needs also modifications when dealing with dispersive and lossy materials such as the metal in optical region. When dynamics in PBG is considered such as coupling, transmission and reflection, time-domain method and transfer matrix method are more suitable. 5. Conclusions In conclusion, our implementation, though very simple and tiny, yields good convergence and the programming effort is minimized. We minimize the errors induced by discretizing the space and performing numerical FFT’s subsequently by using analytical Fourier coefficients, so that we can use fewer plane waves to obtain accurate results quickly on a desktop PC. By using the shift property to get the Fourier transform of a supercell, computation can be reduced significantly. It can be applied to many different PBG geometries such as triangular and honeycomb, and structures with many kinds of defects such as waveguide and bends, by making minor modifications to the source code. The main drawback of this method is apparent that it can only deal with those atoms with regular shapes. However, the shift property can still be used if we know the Fourier coefficients at a grid point for a single atom using FFT. In majority of cases the atoms covered are regular and our program can perform most of these calculations. This also suggests that in a pure FFT approach, further improvements can be made by adopting the shift property and analytical Fourier coefficients when available. Acknowledgment We acknowledge with thanks many fruitful discussions with Dr. Arnel Lavarias. Shangping Guo acknowledges the award of a Dominion Scholar Research Assistantship by Old Dominion University.