scieee AI-readable full text Open interactive document viewer

Integral Equation MEI (IE-MEI) analysis of 2D homogeneous lossy dielectric and plasmonic scatterers

Planes Conangla, Gerard

Abstract

This work revisits the IE-MEI method, previously only applied to perfect conductors, and proposes a new formulation for high-loss dielectric piecewise-homogeneous media. The aim is to assess if the fast attenuation of elds in highly lossy media helps in improving the previously not successful performance of the IE-MEI for lossless dielectric scatterers, with the goal of re- ducing the memory requirements to store the matrix of the system of equations, obtained after discretization with the method of moments of the integral equations of electromagnetism. The results show promise and the obtained sparsi cation is usually excellent, but the problem of ill-conditioned matrices is common and has yet to be solved.

Full text

ESCOLA T` ECNICA SUPERIOR D’ENGINYERS DE TELECOMUNICACI´ O DE BARCELONA PROJECTE FINAL DE CARRERA Integral Equation MEI (IE-MEI) analysis of 2D homogeneous lossy dielectric and plasmonic scatterers AUTHOR: Gerard Planes Conangla DIRECTOR: Juan Manuel Rius Casals Departament de Teoria de Senyal i Comunicacions AntennaLab - Grup d’Antenes i Sistemes R`adio Barcelona, 2015 Acknowledgements To Juan Manuel Rius, for his help and guidance and for introducing me to research with this project. Resum Aquest treball revisita el m`etode IE-MEI, aplicat fins ara ´unicament a conductors perfectes, i proposa una nova formulaci´o per a diel`ectrics d’altes p`erdues en medis homogenis a trossos. L’objectiu ´es determinar si la r`apida atenuaci´o dels camps en medis amb p`erdues ajuda a millorar el rendiment del IE-MEI, problem`atic en diel`ectrics sense p`erdues, amb l’objectiu de reduir els requeriments de mem`oria per a emmagatzemar la matriu del sistema d’equacions, resultant de la discretitzaci´o de les equacions integrals de l’electromagnetisme amb el m`etode dels moments. Els resultats s´on prometedors i la dispersi´o en les matrius obtingudes ´es excel·lent, si b´e el problema d’obtenci´o de matrius mal condicionades ´es com´u i resta per solucionar. Resumen Este trabajo revisita el m´etodo IE-MEI, aplicado hasta ahora ´unicamente en conductores perfectos, y propone una nueva formulaci´on para diel´ectricos de altas p´erdidas en medios homog´eneos a trozos. El objetivo es determinar si la r´apida atenuaci´on de los campos en medios con altas p´erdidas ayuda a mejorar el rendimiento del IE-MEI, problem´atico en diel´ectricos sin p´erdidas, con el objetivo de reducir los requerimientos de memoria para almacenar la matriz del sistema de ecuaciones, resultante de discretizar las ecuaciones integrales del electromagnetismo con el m´etodo de los momentos. Los resultados son prometedores y la dispersi´on en las matrices obtenidas es excelente, si bien el problema de obtenci´on de matrices mal condicionadas es com´un y todav´ıa no se ha solucionado. Abstract This work revisits the IE-MEI method, previously only applied to perfect conductors, and proposes a new formulation for high-loss dielectric piecewise-homogeneous media. The aim is to assess if the fast attenuation of fields in highly lossy media helps in improving the previously not successful performance of the IE-MEI for lossless dielectric scatterers, with the goal of reducing the memory requirements to store the matrix of the system of equations, obtained after discretization with the method of moments of the integral equations of electromagnetism. The results show promise and the obtained sparsification is usually excellent, but the problem of ill-conditioned matrices is common and has yet to be solved. Contents 1 Introduction 5 1.1 Motivation.................................... 5 1.2 Overview of the methods for electromagnetic problems . . . . . . . . . . . 7 1.2.1 Numerical approach to the solution . . . . . . . . . . . . . . . . . . 7 1.2.2 Classification of the numerical methods . . . . . . . . . . . . . . . . 8 1.3 Goals....................................... 9 2 Method of moments 12 2.1 Surfaceequivalence............................... 12 2.2 Integro-differential equations . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3 Boundaryconditions .............................. 14 2.4 Equations for a penetrable dielectric scatterer . . . . . . . . . . . . . . . . 15 2.5 Discretization with the MoM . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3 The MEI method 19 3.1 Finitedifferences ................................ 19 3.2 DifferentialMEI................................. 21 3.2.1 Thepostulates ............................. 21 3.2.2 Metrons ................................. 22 3.2.3 Consequences and correctness of the postulates . . . . . . . . . . . 23 4 Integral formulation of the MEI (IE-MEI) 24 4.1 Derivation from the reciprocity theorem . . . . . . . . . . . . . . . . . . . 24 4.2 Derivation as a CFIE from the MoM . . . . . . . . . . . . . . . . . . . . . 26 4.2.1 EFIE and MFIE for PEC . . . . . . . . . . . . . . . . . . . . . . . 26 4.2.2 Linear combination and equivalence . . . . . . . . . . . . . . . . . . 27 4.3 Coefficient computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2 4.4 Metrons ..................................... 29 4.4.1 Coefficient computation . . . . . . . . . . . . . . . . . . . . . . . . 29 4.4.2 Typesofmetrons............................ 30 5 Implementation of the code in the 2D case 32 5.1 Development and routines . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 5.1.1 MoM for 2D dielectric scatterer . . . . . . . . . . . . . . . . . . . . 33 5.1.2 MoM in 2Nx2N and NxN form . . . . . . . . . . . . . . . . . . . . 35 5.1.3 IE-MEI implementation . . . . . . . . . . . . . . . . . . . . . . . . 36 5.1.4 Reduced zero forcing for the IE-MEI . . . . . . . . . . . . . . . . . 39 5.1.5 Green’s function integral in field computation . . . . . . . . . . . . 41 5.1.6 2D Geometry section . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.2 Outlineofthecode............................... 43 6 Graphical user interface 45 6.1 2D Scattering simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.1.1 Description of the GUI . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.1.2 Aguidedexample............................ 48 6.2 IE-MEINxNGUI................................ 49 6.2.1 Description of the GUI . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.2.2 Aguidedexample............................ 51 7 Results 53 7.1 Generalconsiderations ............................. 53 7.2 2Nx2NIE-MEI ................................. 56 7.3 NxNIE-MEI .................................. 57 7.4 Zero-forcing schemes figures . . . . . . . . . . . . . . . . . . . . . . . . . . 59 7.5 MoMvsIE-MEIfigures ............................ 66 8 Conclusions 78 9 Annexes 81 9.1 Listofpublications............................... 81 9.2 Review of electromagnetism . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.2.1 Maxwell’s equations . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.2.2 Waveequation ............................. 82 3 9.2.3 Boundary conditions between media . . . . . . . . . . . . . . . . . 83 9.2.4 Green’sfunctions............................ 83 9.3 Code....................................... 85 9.3.1 Main MATLAB routines . . . . . . . . . . . . . . . . . . . . . . . . 85 9.3.2 Geometry routines . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 9.3.3 Others..................................133 4 Chapter 1 Introduction 1.1 Motivation Numerical analysis, as opposed to general symbolic manipulations, is the design and analysis of techniques to give approximate but accurate solutions to mathematical problems. Algebraic and symbolic manipulations, and thus exact solutions to problems, were insufficient with the advent of hard problems (usually physical models via ordinary and partial differential equations), and in broad terms the study of these equations subdivided in qualitative and numerical analysis: the goal of the first was to obtain global, regularity and convergence results for a given equation; numerical analysis, on the other hand, served as a means to obtain particular solutions, if approximate, to specific problems, and hence became a fundamental tool in applied mathematics and engineering. With the advent of computing and the automatization of calculations that were traditionally performed manually, the field of numerical methods experienced an authentic revolution, specially from the second half of the twentieth century on. Fields as diverse as weather forecasting, finances and investment, internet queueing, chemical reactions in the farmaceutical industry or antenna and radar theory have benefited immensely from numerical methods. Scattering problems (scattering of incident light by and object) are a subfield of the latter, and can be modelled with Maxwell’s equations (therefore forming a system of partial differential equations). Electromagnetic waves are one of the best known and most commonly encountered forms of radiation that undergo scattering, so the study of light and radio waves behaviour is of fundamental importance in telecommunications. Major forms of elastic light scattering (involving negligible energy transfer) are Rayleigh 5 Chapter 1. Introduction 1.1. Motivation and Mie scattering. This models are used to explain, for instance, the atmospheric and cloud scattering. For modelling of scattering in cases where the Rayleigh and Mie models do not apply (such as irregularly shaped particles), there are many numerical methods that can be used. Recently, surface plasmon polaritons (SPPs) have been brought into light for the possibility of innovative technological implementations. SPPs are electromagnetic waves confined to a metal-dielectric interface, so they are excitations that can be explained, essentially, from a classical point of view, and therefore analysed with Maxwell’s equations. As shown in recent experiments, SPPs can be manipulated using waveguides and resonators, and hence hold promise for very diverse applications (sensing, photovoltaics, telecommunications, opto-electronic circuit integration. . . ), due to their ability to concentrate and guide electromagnetic energy at the nanoscale. As such, there is a huge interest in the performance of the simulations involving plasmonic resonances. As will be explained later in more detail, a problem of interest is the simulation of colloidal depositions of a huge number of small “particles”, each of which acting as a plasmonic resonator. These particles can be spheres, nanorods or have other, more exotic, geometries, and the general scattering problem is solved by the method of moments (MoM) in conjunction with the multilevel fast multipole method (MLFMM). The MoM is a numerical computational method for solving linear partial differential equations which have been formulated as integral equations, via discretization in a mesh of boundary elements; the MLFMM is also based on the MoM, but reduces the scaling with respect to memory and run-time from O(n3) to O(nlog n), where nrepresents the number of unknowns. This method subdivides the boundary element mesh into different clusters and if two clusters are in each other’s far field, all calculations that would have to be made for every pair of nodes can be reduced to the midpoints of the clusters with almost no loss of accuracy. Thus, MLFMM introduces different levels of clustering (clusters made out of smaller clusters) to additionally enhance computation speed. However, for clusters not in the far field, the traditional MoM has to be applied. Although for conventional scatterers the MLFMM can solve large problems of more than one billion (109) unknowns, for plasmonic scatterers the discretization must be much finer, thus increasing the size of near field matrices and leading to a possible collapse of the available storage memory. This is why obtaining a solution for the near field, if nis big enough, can increase the time and memory requirements to a point where the problem is not solvable in practice. And this is precisely where the IE-MEI (Integral equation 6 Chapter 1. Introduction 1.2. Overview of the methods for electromagnetic problems of the Measured Equation of Invariance) can make a difference, because it is aimed at sparsifying the near field matrices. The main goal of the project has been the application and analysis of the IE-MEI to homogeneous dielectric scatterers with complex relative permittivities r, thus being able to represent a broad class of materials (metals, lossy dielectrics and plasmonic materials). 1.2 Overview of the methods for electromagnetic problems 1.2.1 Numerical approach to the solution Some of the most common numerical methods for electromagnetic problems are finiteelement methods and the method of moments, which solve Maxwell’s equations to find the distribution of the scattered electromagnetic field by discretizing the geometry of the scatterer (meshing all the scatterer, in the former, or only the boundary, in the latter). To apply any numerical method, the sequence of actions is always the following: 1. Formulation of the problem: the starting point are the Maxwell’s equations, the wave equation or some derived integro-differential equations. 2. Discretization of the mathematical formulation: computations can only be performed with numbers, so the functions have to be discretized to vectors in some (finite) basis, to which the integro-differential operators will be applied. This way, a system of functional equations is transformed into a system of algebraic equations of finite dimension, which can be solved with a computer. Usually, as in Maxwell’s equations case, the operators are linear and the resulting system is of the matrix form. 3. Discretization of the boundary conditions: the surface must be discretized except in a few canonical geometries. Then, boundary conditions in the elements must be imposed. This can be performed in several ways: (a) Imposing boundary conditions in exactly a finite number of points (pointmatching). 7 Chapter 2. Method of moments 2.2. Integro-differential equations The Lij in the previous equations are the integro-differential operators that relate the scattered field with the equivalent currents, and ~n is the vector normal to the surface pointing outwards (towards the embedding medium). From this point on we will drop the “eq” sub-index from the currents. 2.2 Integro-differential equations At any point r, the total field of an electromagnetic scattering problem defined by Vis given by the integral equations ~ E(r) = θ(r)( ~ Ei(r)−Λ~ J+ Ω ~ M) (2.5) ~ H(r) = θ(r)( ~ Hi(r)−Ω~ J−1 η2Λ~ M) (2.6) where θ(r)1is a constant with different values depending on if r∈V,Eiand Hithe incident electromagnetic field, Jand M(unknown) surface current densities, η=pµ is the impedance of the medium and Λ and Ω linear integro-differential operators. Given a surface field ~ X(r), Λ and Ω are defined by Λ~ X(r) = Z∂V jωµ ~ X(r0) + j ω∇(∇0~ X(r0)))G(r−r0)ds0(2.7) and Ω~ X(r) = Z∂V ~ X(r)×∇G(r−r0)ds0(2.8) where G(r−r0) is the corresponding Green function (that varies depending on the problem). Thus, the previous Lij are easily identified. 2.3 Boundary conditions Working with the equivalence theorem requires the use of operators 2.7 and 2.8, thus evaluating the radiation integrals in the points of ∂V . When the source point and the field point are coincident, r0=r, the Green function is singular and the integrals become improper. To calculate the correct value, the integral is divided between Cauchy principal value (coincident with numerical integration) and the singularity value, calculated 1See next subsection. 14 Chapter 2. Method of moments 2.4. Equations for a penetrable dielectric scatterer analytically ZS ds= lim a→0ZSa ds+ZSvp ds(2.9) To account for the singularity, the value of θ(r) can be given as follows θ(r) = (4π Ω0if r∈V 0 otherwise (2.10) where Ω0is the solid angle covered by the exterior of the surface at r. If the surface presents no discontinuities, Ω0= 2πand thus θ(r) = 2. 2.4 Equations for a penetrable dielectric scatterer Applying the equivalent currents for an arbitrary dielectric scatterer, we get in the embedding medium V: ~ J1=~n1×~ H1(2.11) ~ M1=−~n1×~ E1(2.12) where n1is normal to ∂V pointing to V, and in the object V ~ J2=~n2×~ H2(2.13) ~ M2=−~n2×~ E2(2.14) where ~n2is the normal pointing inwards. Therefore, ~n2=−~n1, so we can define ~n1≡~n, and imposing the boundary conditions2we get ~ J2=−~n ×~ H2=−~n ×~ H1=−~ J1(2.15) ~ M2=~n ×~ E2=−~n ×~ E1=−~ M1(2.16) so we can rename ~ J1≡~ Jand ~ M1≡~ M. Performing the cross product by ~n on 2.5 both in Vand in Vand substituting with ~n ×~ E=−~ Mwe obtain the EFIE equations ~n ×~ Ei=~n ×Λ1~ J−~n ×Ω1~ M−~ M 2(2.17) 0 = ~n ×Λ2~ J−~n ×Ω2~ M+~ M 2(2.18) 2~n ×(~ E1−~ E2) = 0 and ~n ×(~ H1−~ H2)=0 15 Chapter 2. Method of moments 2.5. Discretization with the MoM where in V~ Ei= 0. Analogously, on 2.6 we get the MFIE equations ~n ×~ Hi=~n ×Ω1~ J+1 η2 1 ~n ×Λ1~ M+~ J 2(2.19) 0 = ~n ×Ω2~ J+1 η2 2 ~n ×Λ2~ M−~ J 2(2.20) Finally, operating again with −~n × ·, we get the tangential vectors to ∂V and the equations that will be used for discretization: 1. EFIE: ~ Etan i= Λtan 1~ J−Ωtan 1~ M+~n ×~ M 2(2.21) 0 = Λtan 2~ J−Ωtan 2~ M−~n ×~ M 2(2.22) 2. MFIE: ~ Htan i= Ωtan 1~ J+1 η2 1 Λtan 1~ M−~n ×~ J 2(2.23) 0=Ωtan 2~ J+1 η2 2 Λtan 2~ M+~n ×~ J 2(2.24) It is worth noting that these equations permit solving the equivalent currents, Jand M, in terms of the incident fields. This won’t be, in general, possible analytically, but its discretization is simple. Because of the given derivation of the EFIE and MFIE, these equations are valid, in general, only for closed surfaces. However, the EFIE can also be applied to open PEC surfaces. 2.5 Discretization with the MoM Because of the linearity of equations 2.21 to 2.24, the equations can be represented by the general form LX =Y(2.25) where Lis one of the linear operators, Xis the unknown (the equivalent currents) and Ythe independent term (the incident field). To solve 2.25 numerically, it’s necessary to 16 Chapter 2. Method of moments 2.5. Discretization with the MoM discretize the functions and operators and convert the functional equation to a matrix equation3. The first step is to approximate the unknown Xby a linear combination of base functions xj: X≃XN= N X j ajxj(2.26) where ajare the elements of the discretization of Xand constitute the unknowns of the numerical problem. Thus, its approximation XNwill be a vector of Nelements. For XN to be a good approximation of X(which, in general, will be infinite dimensional), the basis functions must belong to the operator domain. By replacing 2.26 into 2.25 we get L N X j ajxj= N X j ajLxj=YN≃Y(2.27) which is a functional equation with Nunknowns aj. Again, it is necessary that a linear combination of Lxjfunctions be a good approximation of Y, so Lxjmust be a basis of the field. The error in the boundary conditions, or residual, is R=Y−YN=Y− N X j ajLxj(2.28) This residual is made zero by weighting it with Mweight functions wi, so hwi, Ri= 0 i= 1 . . . M (2.29) with the inner product defined in the Hilbert space sense hf, gi=ZΩ f∗·g(2.30) Hence, the system of Mlinear equations with Nunknowns becomes N X j ajhwi, Lxji=hwi, Y ii= 1 . . . M (2.31) that in matrix form becomes Ma =b(2.32) 3Because of the linearity of the differential operator. 17 Chapter 2. Method of moments 2.5. Discretization with the MoM where Mis a M×Nmatrix with Mij =hwi, Lxji,ais the unknowns vector formed by the ajcoefficients and bis the field vector, with bi=hwi, Y i. To solve the system a matrix inversion (or equivalent procedure) is performed if Mis square, not singular a=M−1b(2.33) If the system is overdetermined, usually a least squares method (or other similar criteria) is used. However, in the rest of this work, M=Nand the obtained matrices will all be square. 18 Chapter 3 The MEI method Finite difference methods (FD) discretize directly the Maxwell’s equations, representing derivatives by an appropriate use of finite differences that lead to sparse linear systems that can be efficiently solved. In scattering problems, FD methods raise the necessity of approximating the boundary conditions in the infinite, for the fields to verify Sommerfelds’ condition, by imposing some specific constraints, and therefore have a volume mesh between the scatterer surface and the mesh truncation boundary. In this chapter some basic concepts of differential methods are introduced, and the differential MEI method (original idea for the IE-MEI method) is also discussed. 3.1 Finite differences In finite differences methods, direct discrete approximations on partial derivatives are made, with different orders of finite differences used according to particular needs. Finite differences, therefore, can be used in Maxwell’s equations, the wave equation or any other partial differential equation of interest. Assuming the function whose derivatives are to be approximated is properly-behaved, by Taylor’s theorem, we can create a Taylor Series expansion f(x0+h) = f(x0) + f0(x0) 1! h+f(2)(x0) 2! h2+···+f(n)(x0) n!hn+Rn(x) (3.1) where Rn(x) is a remainder term, denoting the difference between the Taylor polynomial of degree nand the original function. We will derive an approximation for the first derivative of the function fby first truncating the Taylor polynomial f(x0+h) = f(x0) + f0(x0)h+R1(x) (3.2) 19 Chapter 3. The MEI method 3.1. Finite differences Setting x0=awe have f(a+h) = f(a) + f0(a)h+R1(x) (3.3) Dividing across by hgives: f(a+h) h=f(a) h+f0(a) + R1(x) h(3.4) Solving for f0(a): f0(a) = f(a+h)−f(a) h−R1(x) h(3.5) Assuming that R1(x) is sufficiently small, the approximation of the first derivative of f is: f0(a)≈f(a+h)−f(a) h(3.6) Of course, approximations of higher order can be made by following the same scheme. Using the 2D wave equation for the scattering problem (the incident field in TM or TE polarisation) (∇2+k2)φ(r) = 0 (3.7) in the frequency domain, where φ(r) is the scattered field and kis the wavenumber. The numerical solution can be found by approximating with the finite difference method. A grid mesh (see 3.1) with constant distance hbetween nodes must be used, and thus we obtain the finite differences equation φ1+φ2−(4 −k2h2)φ0+φ3+φ4= 0 (3.8) The resolution of a boundary problem like 3.8 requires the following previous steps 1. Defining the domain, or space that contains to object to be analysed: this is the domain that will be meshed. Ideally this domain would be infinitely large but, of course, this is impossible in numerical methods. Boundary conditions verifying the Sommerfeld radiation condition are set. 2. Stating the equation in each point in the mesh, as defined previously. 3. Solving the obtained system. In finite differences, the system matrix is of big dimensions (every point of the mesh is an unknown φi, and a lot of mesh points must be used outside the scatterer in order to get a good solution), but as a differential equation, each point is only related to the points in a neighbourhood, and the matrix is very sparse. 20 Chapter 3. The MEI method 3.2. Differential MEI Figure 3.1: A typical finite difference mesh point and local numbering 3.2 Differential MEI The main problem in terms of quality of the solution in the finite difference method is the proximity of the object to analyse to the ending of the mesh. Logically, the farther away this is, the better the boundary constraint will be and the obtained solution. However, as the mesh grows bigger in volume, the number of points increases as O(n3), therefore increasing dramatically the memory and computing time. There is, thus, a trade-off –as often in engineering problems– between the accuracy and the practical implementation of the method. 3.2.1 The postulates K. Mei introduced the concept of Measured Equation of Invariance (MEI) in [8] as a series of “postulates” to sort out this problem. He advanced that there existed a set of equations for every point in the mesh, analogous as the equations in the finite difference method, that were 1. Location dependent. 2. Geometry specific 3. Invariant to the field of excitation 21 Chapter 3. The MEI method 3.2. Differential MEI Therefore, in this case and in contrast with the FDM, the equations at every node wouldn’t be the same, as they would depend on the point and geometry of the scatterer. However, the solution would be the same. This idea could be used to terminate the mesh almost anywhere and, in particular, close to the scatterer, hence dramatically reducing the size of the system. “Postulate” 3 suggests that the coefficients of the equations (that will be used later to solve the problem) can be found by introducing n−1 linearly independent solutions of the problem and solving n−1 X i=0 aiφ1= 0 (3.9) for every solution. Mei uses the example of complex plane waves of the form ejkh as a set of linearly independent solutions. It is worth noting that Mei didn’t provide any proof of the existence and correctness of his postulates. 3.2.2 Metrons However, a more general method of finding “solutions” is required, as plane waves are clearly not geometry specific. This is where Mei introduced the concept of metrons: a set of current densities on the surface of the scatterer, Jk(r) for k= 1,2...,n−1, from which the solutions to be introduced in the previous systems (this solutions are also called measures) are derived via the integral with the corresponding Green function φk(~r) = Z∂V G(~r|~r0)Jk(~r)ds(3.10) where G(~r|~r0) is the Green’s function of the wave function, kare the nodal points of the n−1 neighbours, ∂V is the contour of the scatterer, ~r is the coordinate location of the node and ~r0is the coordinate location of the metron. It should be emphasized that the metrons are not basis functions, so there is no requirement for metrons to resemble the actual current density. Two immediate sets of metrons are •Delta metrons: rectangular shaped current densities, with constant current inside the rectangle and zero current outside. •Harmonic metrons: complex exponential current distributions (only in 2D). 22 Chapter 3. The MEI method 3.2. Differential MEI If the third postulate was correct, it should be possible to terminate a finite difference mesh almost anywhere, and in particular, much closer to the object than before. Nonetheless, it is in theory more advantageous to use it in conjunction with the finite difference method, using the MEI method where needed. 3.2.3 Consequences and correctness of the postulates The interest of the MEI method is evident: it is, in one hand, a differential method, so the resultant matrix is going to be very sparse; also, as the meshing can be terminated very soon, a very reasonable number of nodes and, therefore, unknowns, can be used. Both things contribute to a decrease in computing time and memory requirements. It would seem, hence, that the MEI method has all the advantages of the differential methods (locality) and all the advantages of integral methods (few unknowns). However, as it turned out, the third postulate was false (see [11]), and no exact MEI method exists. A different formulation of the MEI, by JM Rius et al, was introduced soon after, and is the method used in this work (it is discussed in the next chapter). Although the method could not provide the same solutions as the finite difference method, the question of whether a good enough approximation could be provided with all the previous advantages remained. 23 Chapter 4. Integral formulation of the MEI (IE-MEI) 4.4. Metrons then, to approximate [ZC] by [ZCS] in 4.34 it is enough that [ZCZ][C]≃0 (4.36) which is a less restrictive condition that [ZCZ]≃0. When the coefficient matrices [A] and [B] are obtained by a least squares procedure, clearly the minimization of k[ZCZ][C]k produces an error smaller than the minimization of k[ZCZ]kwhen we approximate [ZC][C] by [ZCS][C]. Unfortunately, this cannot be used to compute the IE-MEI matrices [A], [B], because [C] is precisely the discretization coefficients of the induced current, which is unknown. Determining [C] is the goal of solving the problem: once solved, there is no point in using it again to calculate [A] and [B], because [A] and [B] are part of the determination of [C]. However, we can force for a set of Pcolumn vectors [σp] that expand [C] as closely as possible. As has been seen before, these are called the metrons of the method [C]≃ P X p=1 [σp] (4.37) The system of equations to solve in order to obtain the coefficients anm,bnm in row n of [A] and [B] is now [ZniE][σip] = Anm Bnm  ZE mi ZH mi ![σip]=0 i∈zZ n, m ∈zAB n, p = 1, . . . , P (4.38) 4.4.2 Types of metrons Different sets of metrons can be used in the system of equations 4.38. The more immediate are •Harmonic metrons: the set of harmonic metrons for two dimensional scatterers is σip =ej2πip/N |p|< kRmax (4.39) where Rmax is the radius of the minimum circumference that encloses the scatterer, pis the order of the metron and iincreases along the scatterer boundary. This set approximately expands the induced current vector. However, for electrically large scatterers the number of metrons is much larger than the number of unknowns in the system of equations 4.38. If the system of equations is solved in the least squares 30 Chapter 4. Integral formulation of the MEI (IE-MEI) 4.4. Metrons sense, the minimum k[ZCZ][C]kwill be obtained and, since [C]≃Ppσp, the 2-norm of the term to be neglected in equation is approximately the minimum possible. The main advantage of this set of metrons is that it allows the computation of the measures with the FFT with an operation count proportional to Nlog N. The main problem is that it only works in 2D problems. •Delta metrons: if the metrons are Kronecker delta functions [σip] = (1 if 1 = p 0 if 1 6=p(4.40) the matrix of the metrons [σ] is the identity matrix, and equation 4.38 becomes the same as before after setting ann = 1. Accordingly, the procedure to find the coefficients is an implementation of the MEI method using a set of delta metrons. If the equation is solved in the least squares sense, we have the minimum k[ZCZ]k but not the minimum k[ZCZ][C]kas before. The main advantage of this metron set is that it is easily applicable to 3D scatterers. 31 Chapter 5 Implementation of the code in the 2D case In this chapter, the code specifically developed for the project is discussed. An adaptation of the IE-MEI method, which had only been used for PEC scatterers, is derived from the MoM equations from chapter 2 in the case of dielectric homogeneous media, in the manner seen in the last chapter. As previously remarked, in this work there is a specific interest for complex relative permittivity: this allows the simulation of plasmonic and lossy dielectric media when the imaginary part of the permittivity is negative and, thus, the propagation of the field decreases exponentially. This fact is fundamental in the possibility of making the equations more local, as the decrease of the field as it advances in space has immediate consequences in the mutual dependence of nearby points (more dependent) and distant points (almost no relation at all). This notion will be made more precise in the following sections. 32 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines 5.1 Development and routines 5.1.1 MoM for 2D dielectric scatterer It was seen in the second chapter that for a homogeneous, oriented and closed dielectric scatterer, the EFIE and MFIE equations are, respectively ~ Etan i= Λtan 1~ J−Ωtan 1~ M+~n ×~ M 2 0 = Λtan 2~ J−Ωtan 2~ M−~n ×~ M 2 and ~ Htan i= Ωtan 1~ J+1 η2 1 Λtan 1~ M−~n ×~ J 2 0 = Ωtan 2~ J+1 η2 2 Λtan 2~ M+~n ×~ J 2 If we discretize all the currents and incident fields in terms of Kronecker deltas (i.e. rectangle functions), the linear operators Λ and Ω can be expressed in terms of matrices. Figure 5.1: Pulse basis functions in 2D and 3D. These operators had been developed in Cfor PEC back in 1996 by J.M. Rius. Now they have been updated to C++ for homogeneous dielectric media with complex permittivity constants. These routines are the only not developed in MATLAB language (as well as a complex Bessel’s functions library, not written by the authors 1) for performance reasons. They take the following form, with some apparently strange signs maintained for programming convenience and coherence: 1See the code section in Annexes 33 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines •EFIE: –Λtan i, : referred as Zeji in the code, implemented as -oper_die_2d(...,TM,1,...) –−Ωtan iM−n×M 2: referred as Zemi in the code, implemented as oper_die_2d(...,TE,0,...). so we have to add Id to get −Ωtan iM+n×M 2 Thus, discretizing the equations using the method of moments with Nelements, we obtain the system ~ Ei= [Zej1]~ J+ ([Zem1] + Id)~ M(5.1) 0=[Zej2]~ J+ [Zem2]~ M(5.2) •MFIE: –Λtan i, : referred as Zhmi in the code, implemented as -oper die 2d(...,TE,1,...)/η2 i –Ωtan iJ+n×J 2: referred as Zhji in the code, implemented as -oper_die_2d(...,TM,0,...) so we have to substract Id to get Ωtan iM+n×M 2 Again, discretizing the equations using the method of moments with Nelements, we obtain the system ~ Hi= [Zhm2]~ M+ ([Zhj2] + Id)~ J(5.3) 0 = [Zhj1]~ J+ [Zhm1]~ M(5.4) 34 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines 5.1.2 MoM in 2Nx2N and NxN form There are two ways to approach the solution of the obtained systems: the first is to treat it as a singular 2N×2Nsystem, with matrices EFIE: Ei 0!= ZEJ 1ZEM 1+Id ZEJ 2ZEM 2! J M!(5.5) MFIE: Hi 0!= ZHJ 1ZHM 1+Id ZHJ 2ZHM 2! J M!(5.6) This matrices can be inverted and solved, or a combination of the two systems can be used (CFIE) and later solved. The other is to see the relations as different equations, and isolating and substituting we get 1. EFIE: ~ M=−[Zem2]−1[Zej2]~ J(5.7) ~ Ei=[Zej1]−([Zem1] + Id)[Zem2]−1[Zej2]~ J(5.8) 2. MFIE: ~ J=−[Zhj1]−1[Zhm1]~ M(5.9) ~ Hi=[Zhm2]−([Zhj2]−Id)[Zhj1]−1[Zhm1]~ M(5.10) This approach has the disadvantage that a matrix must be inverted to use it, and with that all the interest in the IE-MEI method vanishes: if the main objective is to reduce the memory requirements to a minimum, with a matrix inversion we will likely get a full matrix. However, if the relative permittivity has negative imaginary part, empiric results show that the inverted matrices relating the electric and magnetic currents will be almost diagonal. Hence, its inversion is trivial and the memory needs negligibles. Also, an N×N formulation uses 1/4 of the memory used in a 2N×2Nformulation. Both formulations have been implemented and tested. 35 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines 5.1.3 IE-MEI implementation Circulant 2Nx2N matrix version For the first formulation described, the IE-MEI is a linear combination of the two such that the matrix to be inverted is almost diagonal, [A][EFIE]+[B][MFIE] If we call [ZE] and [ZH] the two EFIE and MFIE matrices (relating the current to the incident fields) we obtain (5.11) where the condition ≃0 has been added, which is the main goal of multiplying by the IE-MEI and adding the result. From this condition the coefficients anm and bnm of [A] and [B] will be derived. This last expression can be rewritten as A B  ZE ZH!≃0 (5.12) Matrices [A] and [B] will be of the form [M] =                  m m m 0. . . 0m m m m m m 0. . . 0m m m m m m 0. . . 0 0m m m m ...0 . . .............. . . 0. . . m .......... . . m0. . . 0m m m m m m 0. . . 0m m m                  (5.13) where the subindices of the melements have been avoided for the sake of simplicity and presentation, and the number of non null elements in each row can be set to any <2N number. Essentially, therefore, [A] and [B] are diagonal matrices where the diagonal has been expanded circularly to both sides to a number of BW elements, adding to a total of 2BW+1 elements per row. Thus, for every row of [A] and [B], we’ll have to solve the system a b  ZE ZH!≃0 (5.14) 36 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines where (a, b) is just one concatenated row of the matrices. There is a trivial solution of this system, a b = 0 (5.15) that we want to avoid. For this reason, the first elements of vector a(that is, the elements that are BW elements to left, counting from the diagonal) is set to 1, as any solution of the system will still be a solution after multiplication by a constant. Hence, the system will be equivalent to a b  ZE ZH!=ZEZH a b!= (5.16) =Z0 EZH a0 b!=−zE(5.17) where zEis the first vector of the [ZE] matrix and Z0 Eand a0are the modified matrix/vector after the extraction of its first element. Defining M≡Z0 EZH(5.18) we can solve 5.17 in the least squares sense, obtaining a0 b!= (M∗M)−1M∗·(−zE) (5.19) where ∗is the Hermitian transpose (conjugate transpose). Without further modifications, this method would lead to [Z] = [A][ZE]+[B][ZH]≃0 However, [Z] must be inverted to solve the problem and isolate the currents. Consequently a last refinement is necessary: the requirement of [Z] to be one of the following: •Circulant diagonal band matrix, as with [A] and [B]. •Circulant tridiagonal band matrix, of the form seen in figure This is in principle a more sensible choice, as in the first case the incident fields would only depend of one of the two currents, whether electric or magnetic. The performance of each is discussed in the Results section, as well as the use of circulant tridiagonal [A] and [B] matrices too. 37 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines Figure 5.2: Example of a circulant tridiagonal band matrix. In black, non-zero elements In whichever case, the size of the diagonals doesn’t necessarily have to be the same as in [A],[B]. The number of constraints and number of variables available as coefficients in [A] and [B] must be taken into account. These modifications can be easily achieved by only forcing zeros in the white sections (as in figure LIU FIGURA), outside of the circulant diagonals. This is accomplished by including in [M] only the rows such that the corresponding column of [Z] vanishes (this calculation will be performed for every row of [Z]). Because of the minimisation of the 2-norm error in an overdetermined system, the elements forced to be zero won’t be, in general, zero, but only small. As a last step, then, once the IE-MEI matrices have been applied, a truncation of the matrices to liberate memory will be performed, effectively transforming these matrices into sparse matrices. This can be done by making all elements smaller than a threshold zero. NxN version In the second formulation, by substituting and using N×Nmatrices we obtained •EFIE: ~ M=−[Zem2]−1[Zej2]~ J ~ Ei=[Zej1]−([Zem1] + Id)[Zem2]−1[Zej2]~ J 38 Chapter 5. Implementation of the code in the 2D case 5.1. Development and routines •MFIE: ~ J=−[Zhj1]−1[Zhm1]~ M ~ Hi=[Zhm2]−([Zhj2]−Id)[Zhj1]−1[Zhm1]~ M If we substitute ~ Mby ~ Jin the MFIE equations, or viceversa in the EFIE, we get equations ~ Ei=[Zej1]−([Zem1] + Id)[Zem2]−1[Zej2]~ J(5.20) ~ Hi=[Zhm2][Zhm1]−1[Zhj1]−([Zhj2]−Id)~ J(5.21) These two equations can be linearly combined by multipliying by two [A], [B] equations as before, following the same method to obtain circular band diagonal matrices after. Now, though, the matrices will be of size N×N, and only electrical (r. magnetic) current will be involved. For this reason, only single diagonal bands are considered, instead of tridiagonal bands as before. The IE-MEI resultant system will be [A]~ Ei+ [B]~ Hi= ([A][ZE]+[B][ZH]) ~ J(5.22) where [ZE]≡[Zej1]−([Zem1] + Id)[Zem2]−1[Zej2](5.23) [ZH]≡[Zhm2][Zhm1]−1[Zhj1]−([Zhj2]−Id)(5.24) For the magnetic current, the development of the system is completely analogous. From a memory point of view, it is in general a bad idea to invert matrices as in 5.21. Nonetheless, as indicated earlier, if the complex permittivity has negative imaginary part and the object is electrically big enough (usually not specially big for the tested values of plasmonic media), the matrix to be inverted is almost diagonal, hence very sparse and not memory intensive. 5.1.4 Reduced zero forcing for the IE-MEI It has been seen that a least squares problem must be solved for every row of the IE-MEI matrices, to obtain its coefficients. This is easily seen to be too many operations to be worth it: it is usually best to solve the problem directly, instead of finding [A] and [B] matrices, multiplying, adding the two systems and solving. The IE-MEI, in this case, is not justified. 39 Chapter 6. Graphical user interface 6.1. 2D Scattering simulator Figure 6.1: Clean GUI after executing from the command line where kscat is the wavenumber inside the scatterer and k0is the wavenumber in vacuum. Here, |√r| ≃ 3 for the values commonly encountered in plasmonic materials, but this could change to more strict conditions in materials with higher permittivity. 2. r: the relative permittivity of the scatterer (ratio of permittivity to the permittivity of vacuum). This parameter controls “the material” of which the scatterer is made, and can be complex. In non magnetic materials such as this, n=√r, where n is the refractive index. A permittivity of 1 means the scatterer will be made of thin air and there will be no scattering at all (this can be tested to prove the code is correct), a permittivity of around 3 will simulate a glass and a permittivity of negative real and imaginary part (e.g. −1000 −400j) will simulate a metal, where there is no penetration of the fields inside the scatterer. 3. 2D scatterer: the geometry of the scatterer can be chosen: •Elliptical (including circular case) •Rectangular •Pill: this geometry is strictly a superellipse (transition case between the other geometries). 4. Geometry parameters: a vector input of the form (a, b). The first parameter, ais 46 Chapter 6. Graphical user interface 6.1. 2D Scattering simulator k0rin the Xaxis: the value of k·r. If the selected geometry is elliptical, it will be the semiaxis of the circle in this direction; if the selected geometry is rectangular, it will be half the side in the xaxis. The second parameter, b, acts exactly the same but in the Yaxis. The GUI also excepts only one parameter (the second will be assumed to be the same). 5. Show near field: the option to calculate the near field or only the currents in the surface. The convolution integrals involved in the calculation of the near field is the most time consuming of all the operations. 6. Method: EFIE or MFIE equations can be chosen. The solutions with either method should be almost the same except in extreme cases (like resonances). 7. Run: initiate the simulation once the rest of the parameters have been set. 8. About Scattering Simulator: shows help, sources and other diverse information in the log section. Figure 6.2: GUI after a simulation (elliptic metallic scatterer) Tooltips have been included to give advice when passing by over a field with the mouse. The other two sections are “Log” (in the lower left section of the gui), where information regarding the simulation is printed once the calculations are finished, and the right 47 Chapter 6. Graphical user interface 6.1. 2D Scattering simulator section of the gui, where the plotting is performed and six figures are shown. From left to right and from top to bottom these are: 1. Amplitude of the Efield (inside and outside the scatterer). The silhouette of the scatterer is shown in pink dashed lines. 2. Intensity of the field, which shows an animation of the permanent sinusoidal regime and the scattering for 5 complete periods. 3. Modulus of the electric current around the scatterer. 4. Modulus of the magnetic current around the scatterer. 5. Phase of the electric current around the scatterer. 6. Phase of the magnetic current around the scatterer. A picture of the gui after a simulation is shown in figure 6.2 6.1.2 A guided example Fill the parameter boxes with the following numbers: •Put ‘300’ in the number of elements box. •Put ‘3’ in the relative permittivity box (glass material). •Write ‘[3,3]’ in the k0rsection (radius of size R≃λ). •Select ‘Rectangular’ geometry option. •Mark ‘yes’ option in the Show near field rectangle. •Select EFIE equations. •Click on ‘Run Simulation’ Once the simulation is done, the times spent in each step and the values used will appear in the ’Log’ section. Graphs of the modulus of electric and magnetic current, its complex value and the total field (incident plus scattered) will be plotted at the right side of the GUI. The result should look like figure 6.3. 48 Chapter 6. Graphical user interface 6.2. IE-MEI NxN GUI Figure 6.3: GUI after a simulation (square glass scatterer) 6.2 IE-MEI NxN GUI 6.2.1 Description of the GUI As in the previous case, the GUI is composed of three sections; on the upper left, the parameters of the problem are specified. The ones for the ‘PROBLEM’ section are the same, and the IE-MEI parameters are set in the ‘IEMEI’ rectangle: 1. N: the number of elements in which the scatterer is going to be discretized. 2. r: the relative permittivity of the scatterer (ratio of permittivity to the permittivity of vacuum). 3. 2D scatterer: geometry of the scatterer: •Elliptical •Rectangular •Pill 4. Geometry parameters: a vector input of the form (a, b). The first parameter, ais k0rin the Xaxis; bis kr in the Yaxis. In the rectangle case, both aand bare half the sides of the rectangle. 49 Chapter 6. Graphical user interface 6.2. IE-MEI NxN GUI Figure 6.4: Clean GUI after executing from the command line 5. Plot near field: the option to calculate the near field or only the currents in the surface. Otherwise, it will plot the error in the elements. 6. IEMEI: single EFIE or MFIE IEMEI method or combined IEMEI method. In the first or second case, only [A] or [B] matrices, with the EFIE or the MFIE equations, are used. With the combined IEMEI both are used, and thus also both the EFIE and MFIE equations are calculated. 7. [A][B] BW(%): percentage of the number of elements that will be used in the [A], [B] matrices. The rest will be set to zero. 8. Zc forced zeros (%): percentage of elements of the [ZC] matrix that will be set to zero, outside of the diagonal. The zeros will be distributed to best minimize the effect of the elements without constraints. 9. Zc threshold: threshold below which all elements will be forced to zero after multiplication by [A] and [B]. 10. J →M threshold: threshold below which all elements will be forced to zero in the transformation matrix from ~ Jto ~ M. In lossy dielectrics, this transformation matrix is almost diagonal. 11. Run: initiate the simulation once the rest of the parameters have been set. 50 Chapter 6. Graphical user interface 6.2. IE-MEI NxN GUI 12. Help: shows help and diverse information in the log section. Here, tooltips have also been included to give advice when passing by over a field with the mouse. The other two sections are “Log” (lower left section of the gui), where information regarding the simulation is printed once the calculations are finished, and the right section of the gui, where the plotting is performed and six figures are shown. From left to right and from top to bottom these are: 1. Near field/Error per element in the geometry 2. Resultant [ZC] matrix. Useful to see the performance of the IE-MEI method. 3. Modulus of the electric current around the scatterer. 4. Modulus of the magnetic current around the scatterer. 5. Phase of the electric current around the scatterer. 6. Phase of the magnetic current around the scatterer. 6.2.2 A guided example Fill the parameter boxes with the following numbers: •Write ‘300’ in the number of elements box. •Put ‘-3-4j’ in the relative permittivity box (plasmonic material). •Write ‘[5,5]’ in the Geometry parameters section. •Select ‘Elliptical’ geometry option. •Mark ‘Show error’ option in the Show near field rectangle. •Select ‘Combined IEMEI’ equations. •Put ‘4’ in [A][B] BW(%). •Put ‘9’ in Zc forced zeros. •Write ‘1e-6’ in the Zc threshold area. 51 Chapter 6. Graphical user interface 6.2. IE-MEI NxN GUI •Write ‘5e-2’ in the J→M area. •Click on ‘Run Simulation’ Once the simulation is done, the times spent in each step and the values used will appear in the ’Log’ section. Graphs of the modulus of electric and magnetic current, its complex value and the total field (incident plus scattered) will be plotted at the right side of the GUI. The result should look like figure 6.5. Figure 6.5: IE-MEI GUI after a simulation (square glass scatterer) 52 Chapter 7 Results In this chapter the results of the studies and implemented methods are presented. The performance of the methods is compared with its equivalent pure MoM simulations and generally refer to results of the equivalent current in modulus and phase form, with some added figures and comments about the behaviour of the field. All the incident fields have been set with TM polarisation, and this fact will be taken for granted in the whole section. 7.1 General considerations The results of the MoM show that for dielectric simulations, the discretization step often used for boundary element methods for PEC scatterers of about λ0/10 is not enough. Generally, a minimum of half this discretization size, λ/20 is required, and usually even more. In extreme cases, like with plasmonic resonances, a specially thin meshing is of maximum importance. Usual discretization sizes used throughout the work belong in the range of λ0/20 to λ0/40. No IE-MEI method proved able for general real positive permittivities. In any of the formulations used, after setting the number of not forced to zero elements per row in the resulting [A][ZE] + [B][ZH] matrix (i.e., the sparsity of the matrix), the results were reasonable only for sparsities in the range of 30% - 40% and higher, not justifying the application of the method. For smaller sparsities, spurious oscillations and noise appeared on the results. This explains the lack of publications on the sparsification of the MEI or IE-MEI methods to dielectric scatterers. 53 Chapter 7. Results 7.1. General considerations Hence, the study has focused on complex permittivites with negative imaginary part1; that is to say, media with exponential decay on the fields. If the real part of this permittivity is smaller than 1 (generally negative values), these materials can be classified as plasmonic. They can have a big negative imaginary part and therefore rapidly decaying interior fields; the limit case is a perfect conductor, in which no fields at all exists inside the scatterer. If the imaginary part is higher than 1, they can model lossy dielectrics, or real dielectrics, such as water or glass, and they tend to have small absolute values of imaginary part, usually negligible. This can be seen in figures 7.1, 7.2 and 7.3. Figure 7.1: Complete penetration in a dielectric without decay, r= 6 In permittivites with negative imaginary part, the mutual dependence decays approximately as a negative exponential (this depends, of course, of the exact geometry of the scatterer), so a good sparsification, followed by a truncation appears plausible. The application of the IE-MEI in this case has been more succesful, with high sparsities obtained. 1See [9] 54 Chapter 7. Results 7.1. General considerations Figure 7.2: Simulation of a plasmonic material, r=−3−5j. There is some field penetration Figure 7.3: Simulation of a PEC scatterer. There is no field penetration 55 Chapter 7. Results 7.4. Zero-forcing schemes figures elements. More zeros5could be used in this case. Figure 7.8: Forced zeros in an elliptical scatterer, N= 300, sparsity 5%, r=−3−5j Figure 7.9: Forced zeros in an elliptical scatterer, N= 300, sparsity 5%, r=−3−5j. Superior view 5As in a variable number of zeros strategy 62 Chapter 7. Results 7.4. Zero-forcing schemes figures Figure 7.10: Forced zeros in a rectangular scatterer, N= 300, sparsity 5%, r=−3−5j Figure 7.11: Forced zeros in a rectangular scatterer, N= 300, sparsity 5%, r=−3−5j. Superior view 63 Chapter 7. Results 7.4. Zero-forcing schemes figures Figure 7.12: Forced zeros in a superelliptical scatterer, N= 400, sparsity 5%, r=−3−3j, kR semiaxis of (3,9) Figure 7.13: Forced zeros in a superelliptical scatterer, N= 400, sparsity 5%, r=−3−3j. Superior view 64 Chapter 7. Results 7.4. Zero-forcing schemes figures Figure 7.14: Forced zeros in a circular scatterer, N= 900, sparsity 2.33%, r=−5.84 − 2.11j(gold λ0= 546 nm) 65 Chapter 7. Results 7.5. MoM vs IE-MEI figures 7.5 MoM vs IE-MEI figures In table 7.2, a comparison of the obtained quadratic error in ~ Jand ~ Mbetween the MoM and IE-MEI for different thresholds is displayed. The scatterer is circular and a permittivity of −3−3j, corresponding to a plasmonic material, is used. The table shows that after a certain threshold is exceeded, the relative error stops decreasing. This is due to the comparison between the MoM results and the IE-MEI method: to calculate the error, one of the two equations (EFIE or MFIE) have to be chosen, whereas the IEMEI uses both. Because the EFIE and MFIE are different equations, a certain distance between them always exist and can’t be overcome. Once the IE-MEI produces errors of the same order, the solution can’t be further improved. The forced and obtained sparsity values6are included. The threshold in the currents transformation has been taken at 10−3in the whole section, whereas truncation of the [ZC] matrix is performed at 10−4. All the incident fields are 0◦with TM polarization. Modulus of electric current 0 20 40 60 80 100 120 140 160 180 200 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 IEMEI solution EFIE solution MFIE solution Figure 7.15: Modulus of ~ Jin circular scatterer, N= 200, kR = 4, sparsity 3%, r= −3−5j 6Once a wanted sparsity is set, least squares are applied, so the zeros are not exactly zeros. A truncation threshold is applied, which will give a slightly different sparsity. 66 Chapter 7. Results 7.5. MoM vs IE-MEI figures k0r N rDesired [ZC] sp. (%) zeros (%) Obt. [ZC] sp. (%) ethr δr 10 300 -3 - 3j 35 52 27,43 10−44,40513 27,63 10−50,261416 27,67 10−60,008002 27,67 10−70,008002 27,67 10−80,008002 10 300 -3 - 3j 35 36 27,63 10−40,820586 27,66 10−50,127847 27,67 10−60,008711 27,67 10−70,008711 39,05 10−80,008153 10 300 -3 - 3j 25 37,5 19,42 10−41,278478 19,66 10−50,054065 19,67 10−60,008006 19,67 10−70,008006 19,67 10−80,008006 10 300 -3 - 3j 25 18,75 19,5 10−40,64752 19,67 10−50,020954 19,67 10−60,020954 28,79 10−70,016806 56,88 10−80,00808 10 300 -3 - 3j 15 12,75 11,55 10−40,474551 11,66 10−50,008734 11,67 10−60,008251 12,9 10−70,008248 46,17 10−80,008066 10 300 -3 - 3j 15 12,75 11,64 10−40,244069 11,67 10−50,020197 11,7 10−60,020153 43,16 10−70,008584 Table 7.2: Obtained sparsities (sp.) for a circular scatterer in three-band zero distribution. After the problem parameters are set, a different truncation threshold is applied, which can modify the sparsity of the matrix. In the last column, δr, relative error between MoM and IE-MEI formulation. The best results are obtained for a desired sparsity of 15% and thresholds of 10−5or 10−6 67 Chapter 7. Results 7.5. MoM vs IE-MEI figures Phase of electric current 0 20 40 60 80 100 120 140 160 180 200 -4 -3 -2 -1 0 1 2 3 4 IEMEI solution EFIE solution MFIE solution Figure 7.16: Phase of ~ Jin circular scatterer, N= 200, kR = 4, sparsity 3%, r=−3−5j Modulus of magnetic current 0 20 40 60 80 100 120 140 160 180 200 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 IEMEI solution EFIE solution MFIE solution Figure 7.17: Modulus of ~ Min circular scatterer, N= 200, kR = 4, sparsity 3%, r= −3−5j 68 Chapter 7. Results 7.5. MoM vs IE-MEI figures Phase of magnetic current 0 20 40 60 80 100 120 140 160 180 200 -4 -3 -2 -1 0 1 2 3 4 IEMEI solution EFIE solution MFIE solution Figure 7.18: Phase of ~ Min circular scatterer, N= 200, kR = 4, sparsity 3%, r=−3−5j Modulus of electric current 0 50 100 150 200 250 300 350 400 450 500 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 IEMEI solution EFIE solution MFIE solution Figure 7.19: Modulus of ~ Jin circular scatterer, N= 500, kR = 12, sparsity 3%, r= −3−5j. Some slight oscillations appear at the sides. 69 Chapter 7. Results 7.5. MoM vs IE-MEI figures Phase of electric current 0 50 100 150 200 250 300 350 400 450 500 -4 -3 -2 -1 0 1 2 3 4 IEMEI solution EFIE solution MFIE solution Figure 7.20: Phase of ~ Jin circular scatterer, N= 500, kR = 12, sparsity 3%, r=−3−5j Modulus of magnetic current 0 50 100 150 200 250 300 350 400 450 500 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 IEMEI solution EFIE solution MFIE solution Figure 7.21: Modulus of ~ Min circular scatterer, N= 500, kR = 12, sparsity 3%, r=−3−5j. Some slight oscillations appear at the sides, product of the increase in the condition number. 70 Chapter 7. Results 7.5. MoM vs IE-MEI figures Phase of magnetic current 0 50 100 150 200 250 300 350 400 450 500 -4 -3 -2 -1 0 1 2 3 4 IEMEI solution EFIE solution MFIE solution Figure 7.22: Phase of ~ Min circular scatterer, N= 500, kR = 12, sparsity 3%, r=−3−5j Modulus of electric current 0 50 100 150 200 250 300 350 400 450 500 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2IEMEI solution EFIE solution MFIE solution Figure 7.23: Modulus of ~ Jin superelliptical scatterer, N= 500, kR = (4,12), sparsity 5%, r=−3−5j. The results appear contaminated, product of too many variables in the least squares matrices and bad condition number. For smaller but big enough sparsity numbers, the results are good 71 Chapter 8 Conclusions The IE-MEI method has been formulated and implemented for 2D dielectric objects. Preliminar results for high-loss complex dielectric constants having negative real part, like those of plasmonic materials, show good linear system matrix sparsification and excellent agreement with the Method of Moments reference results, and have been presented at the IX Iberian Meeting on Computational Electromagnetics(EIEC 2015), Baeza, and the International Conference on Electromagnetics in Advanced Applications (ICEAA 2015), Torino (the latter to take place at the beginning of September). In the N×Nformulation used, the matrices relating ~ Jand ~ Mare almost diagonal, or at least extremely sparse, and this is independent of the IE-MEI method and can be used as a first small approximation of the MoM. The most important findings of this work are summarized below: •In the calculation of the IE-MEI matrices [A] and [B], the increase of the number of unknowns, which is itself of interest in the simulation of plasmonic resonances (which require a very thin and smooth discretization), results in a steep growth of the condition number of the system and, particularly, of the least squares matrices, which is in itself considerably big. Specially prone to ill conditioned matrices are the very elongated objects, where elements in the center of the bar are highly dependent on all the rest of elements (in particular to the ones at the other side of the bar). This elements contributed the most part of the error in the solution. •Although having big condition numbers, the problems in the N×Nformulation provide better results than in the 2N×2Nformulation, where the condition numbers were much worse. The latter was abandoned in favour of the former. •It has been shown, too, that the distribution of imposed zeros has a considerable 78 Chapter 8. Conclusions effect on the accuracy, although no theoretical work has been done to support the claims. This is of particular interest in non canonical geometries, although discontinuities in the derivative of the boundary, such as in the rectangle case, present problems. Using a reduced numbers of zeros is also of tremendous help in reducing the computation time. If well distributed, only a few percent (2-5%) of the zeros had to be forced to obtain matrices with a big band diagonal and the rest of the elements (forced zeros and elements without constraints but close to the zeros) several orders of magnitude below. As stated, though, when increasing the size of the scatterer and, therefore, using a higher number of elements, ill conditioned matrices appeared in the least squares method. •Harmonic metrons (which had been used successfully before in 2D scatterers) were also tested here with dielectrics. In contrast with delta metrons, they didn’t produce sparse enough matrices. The “limited” zero forcing strategy gave very poor results, to the point where truncation was not applicable, and the use of delta metrons was resumed. Some suggestions are also given, if this or a similar line of research is to be followed in the future: •Combination of the IE-MEI with multilevel decomposition interative fast solvers like MLFMM (in PEC, lossless or lossy dielectrics) to sparsify near field matrices. •Work in the reduction of the condition number, by using preconditioners or even by using other different error minimisation techniques. Least squares was the option used in the work, but some shallow attempts (without much success) were made at using L1minimisation (of which there is plenty of material and bibliography to be found, in the domain of linear programming and simplex-like algorithms). Some form of Compressed Sensing or Orthogonal Matching Pursuit could be of use. •Implementation of a variable number of zeros forced per row (instead of the constant number used in this work in all the rows of the matrix); in this case, some elements would “receive” more zeros than others. •Exportation of the IE-MEI to 3D plasmonic objects, with the zero forcing scheme described. A possible way to do it (in geometries homeomorphic to a 2-sphere) 79 Chapter 8. Conclusions would be to order the elements as in the peeling of an apple. Another way would be to set a probability of an element (column index) to be a forced zero depending on the geometrical distance to the source (row index). In any case, sparsification of electrically small geometries is working successfully in the current implementation, and is useful to reduce storage requirements of the near field matrix in multilevel decomposition fast solvers. In bigger geometries, further guarantees on the quality of the solution are required. 80 Chapter 9 Annexes 9.1 List of publications The results of this work have been presented at the following conferences: 1. “Integral Equation MEI (IE-MEI) analysis of homogeneus dielectric and plasmonic media in 2D”, Juan M. Rius, G. Planes, E. Ubeda and A. Heldring, IX Iberian Meeting on Computational Electromagnetics(EIEC 2015), Baeza, Spain, 6-8 May 2015. 2. “Efficient analysis of homogeneous dielectric and plasmonic media with integral equation MEI (IE-MEI)”, Juan M. Rius, G. Planes, E. Ubeda and A. Heldring, International Conference on Electromagnetics in Advanced Applications (ICEAA 2015), Torino, Italy, September 7-11, 2015. A paper is also in preparation: 1. “Sparsification of the MLFMA near field matrix with IE-MEI for high-loss dielectric objects”, in preparation for IEEE Trans. on Antennas and Propag. 9.2 Review of electromagnetism 9.2.1 Maxwell’s equations Maxwell’s equations are a set of partial differential equations that, together with the Lorentz force law, form the foundation of classical electrodynamics, classical optics, and 81 Chapter 9. Annexes 9.2. Review of electromagnetism electric circuits. These fields in turn underlie modern electrical and communications technologies. Maxwell’s equations describe how electric and magnetic fields are generated and altered by each other and by charges and currents. They are named after the physicist and mathematician James Clerk Maxwell, who published an early form of those equations between 1861 and 1862. The powerful and most widely familiar form of Maxwell’s equations, whose formulation is due to Oliver Heaviside, in the vector calculus formalism, is used throughout. The equations introduce the electric field E, a vector field, and the magnetic field B, a pseudovector field, where each generally have time-dependence. The sources of these fields are electric charges and electric currents, which can be expressed as local densities namely charge density ρand current density J. A separate law of nature, the Lorentz force law, describes how the electric and magnetic field act on charged particles and currents. A version of this law was included in the original equations by Maxwell but, by convention, is no longer. In differential terms, this equations take the form ∇·D=ρ(9.1) ∇·B= 0 (9.2) ∇×E=−∂B ∂t (9.3) ∇×H=J+ε0 ∂E ∂t (9.4) Here, Hand Dare also used: in order to apply Maxwell’s macroscopic equations, it is necessary to specify the relations between displacement field Dand the electric field E, as well as the magnetizing field Hand the magnetic field B. The equations specifying this response are called constitutive relations, and are usually taken in the form D=εE,H=1 µB(9.5) Thus, Maxwell’s equations are usually expressed in engineering in terms of Eand H. 9.2.2 Wave equation By solving in terms of Ethe Maxwell’s equation (there are several ways to do it, see the Annexes of [4]), we obtain the classical wave equation c2∇2−∂2 ∂t2E=0(9.6) 82 Chapter 9. Annexes 9.2. Review of electromagnetism Furthermore, if we can express the field as a product of the space depending field and a time varying harmonic function ejwt, this equation simplifies to the Helmholtz equation (∇2+k2)E= 0 (9.7) where k=ω c=2π λis the wavenumber in vacuum. It is worth noting that in both equations 9.6 and 9.7, the differential linear operator is perfectly visible at the left side of the equation, as a “product” with E. 9.2.3 Boundary conditions between media Maxwell’s equations describe the behaviour of electromagnetic fields; electric field, electric displacement field, magnetic field and magnetic field strength. The differential forms of these equations require that there is always an open neighbourhood around the point to which they are applied, otherwise the vector fields E,D,Band Hare not differentiable. In other words, the medium must be continuous. On the interface of two different medium with different values for electrical permittivity and magnetic permeability that does not apply. However the interface conditions for the electromagnetic field vectors can be derived from the integral forms of Maxwell’s equations. These are, for the electric field n12 ×(E2−E1) = M(9.8) where n12 is normal vector from medium 1 to medium 2, and for the magnetic field −n12 ×(H2−H1) = J(9.9) Here, Jand Mare the electric and magnetic currents. Normally, Mis zero because actual magnetic currents and charges never exist in a physical situation. However, for calculation purposes Mcan appear (and in this work, in fact, does) several times if the scattering medium is a dielectric. In PEC cases, M= 0. 9.2.4 Green’s functions Definition and uses AGreen’s function,G(x, s), of a linear differential operator L=L(f) acting on distributions over a subset of the Euclidean space Rnat a point s, is any solution of LG(x, s) = δ(x−s) (9.10) 83 Chapter 9. Annexes 9.2. Review of electromagnetism where δis the Dirac delta function. This property of a Green’s function can be exploited to solve differential equations of the form Lu(x) = f(x) (9.11) If the kernel Lis non-trivial, then the Green’s function is not unique. However, in practice, some combination of symmetry, boundary conditions and/or other externally imposed criteria will give a unique Green’s function. Also, Green’s functions in general are distributions, not necessarily proper functions (as in the Dirac delta function case). Green’s functions are useful tools in solving wave equations and diffusion equations, among others. If the operator is translation invariant, that is, when Lhas constant coefficients with respect to x, then the Green’s function can be taken to be a convolution operator, that is G(x, s) = G(x−s) (9.12) In this case, the Green’s function is the same as the impulse response of linear timeinvariant system theory, and this is exactly the case in the wave equation in electromagnetism. Motivation Loosely speaking, if such a function Gcan be found for the operator L, then if we multiply the equation 9.10 for the Green’s function by f(s), and then perform an integration in the svariable, we obtain ZLG(x, s)f(s)ds =Zδ(x−s)f(s) ds=f(x) (9.13) The right-hand side is now given by the equation 9.11 to be equal to Lu(x), thus: Lu(x) = ZLG(x, s)f(s) ds(9.14) Because the operator L=L(x) is linear and acts on the variable xalone (not on the variable of integration s), we can take the operator Loutside of the integration on the right-hand side, obtaining Lu(x) = LZG(x, s)f(s) ds(9.15) 84 Chapter 9. Annexes 9.3. Code which suggests u(x) = ZG(x, s)f(s) ds=ZG(x−s)f(s) ds(9.16) Thus, we can obtain the function u(x) through knowledge of the Green’s function in equation 9.10 and the source term on the right-hand side in equation 9.11. This process relies upon the linearity of the operator L. In other words, the solution of equation 9.11, u(x), can be determined by the integration given in equation 9.16. Although f(x) is known, this integration cannot be performed unless Gis also known. The problem now lies in finding the Green’s function Gthat satisfies equation 9.10. For this reason, the Green’s function is also sometimes called the fundamental solution associated to the operator L. Not every operator Ladmits a Green’s function. A Green’s function can also be thought of as a right inverse of L. Aside from the difficulties of finding a Green’s function for a particular operator, the integral in equation 9.16 may be quite difficult to evaluate. However the method gives a theoretically exact result. 9.3 Code In this annex the realized programs for this project are displayed. Most of them are MATLAB routines, with the exception of a few Cand C++ routines in which a more low-level language was preferred: the routines oper die 2d and oper die 2d complex, which have been developed jointly by J.M. Rius and the author. Complex Bessel functions in C++ have also been used from a mathematical library developed by CR Bond. The rest of the code has been written by the author. 9.3.1 Main MATLAB routines die scat nn.m Main function. Performs all the operations described in 5.2 for a general 2D dielectric scatterer. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % MoM for a dielectric scatterer, surrounded by dielectric medium % Includes EFIE, MFIE equations and IEMEI method, with N x N matrices % 85 Chapter 9. Annexes 9.3. Code % equations: ’efie’, ’mfie’ or ’iemei’ % N: number of elements in scatterer surface % Z_tot_spars: wanted sparsity in final impedance matrix (the one reduced % by least squares) % Z_hm_spars: wanted sparsity in inverted matrix % BW: number of non zero elements in every of the bands of matrices A, B % pc1: preconditioner. Best value around 200-300 usually % e_r2, mu_r2: relative permittivity and permeability in dielectric scatterer % kr: value of k*r (size of object to lambda) % % NOTES % - The permittivity and permeability can be complex % - There is one version of get_iemei_matrices. % get_iemei_matrices: A of the form: single circular band so that % AZe is also single circular band %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % G. Planes Conangla, 3/2015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function[str] = die_scat_nn(equations, N, Z_tot_spars, force_zero_frac, JM_threshold, trunc_bound, e_r2, mu_r2, k_geo_parameters, geometry, green, varargin) %% Start timer tic; %% constants/static variables % dielectric material constants % outside dielectric e_r1 = 1; mu_r1 = 1; % inside dielectric % e_r2 and mu_r2 are called as input to the function % impedance eta_0 = 119.9169*pi;% in the void eta_r1 = sqrt(mu_r1/e_r1); eta_r2 = sqrt(mu_r2/e_r2); 86 Chapter 9. Annexes 9.3. Code eta_1 = eta_0*eta_r1; eta_2 = eta_0*eta_r2; % incident field; lambda = 1; k_0 = 2*pi/lambda; k_1 = k_0*sqrt(mu_r1*e_r1); k_2 = k_0*sqrt(mu_r2*e_r2); ang_i = 0; % angle in degrees k_i = k_1*exp(1i*ang_i*pi/180); % SCATTERER kr = k_geo_parameters(1); geo_parameters = k_geo_parameters/k_1; %% gui or command line if ~isempty(varargin) % gui fig_1 = varargin{1}; fig_2 = varargin{2}; fig_3 = varargin{3}; fig_4 = varargin{4}; fig_5 = varargin{5}; fig_6 = varargin{6}; fig_7 = varargin{7}; else fig_1 = 1; fig_2 = 2; fig_3 = 3; fig_4 = 4; fig_5 = 5; fig_6 = 6; fig_7 = 7; end %% IEMEI: only for IEMEI method. % BW: number of non zero elements in every of the bands of matrices A, B % Called as input of the function. 87 Chapter 9. Annexes 9.3. Code % get current vectors M = Z_iemei\(A*Inc_h); J = (-Z_trunc\Z_hm1)*M; % time after matrix inversion t3=toc; %% compare with exact system Z_efie = (Z_ej1 + (Z_em1 + eye(N))*(-Z_em2\Z_ej2)); Z_mfie = (Z_hm2 + (Z_hj2 + eye(N))*(-Z_hj1\Z_hm1)); J_e_efie = Z_efie\(Inc_e); M_e_efie = (-Z_em2\Z_ej2)*J_e_efie; M_e_mfie = Z_mfie\(Inc_h); J_e_mfie = (-Z_hj1\Z_hm1)*M_e_mfie; cond_current = condest(Z_hj1); % L2 error % error between MFIE & EFIE er_J_fie = norm(J_e_efie - J_e_mfie)/norm(J_e_mfie); er_M_fie = norm(M_e_efie - M_e_mfie)/norm(M_e_mfie); % error between MFIE & IEMEI er_J = norm(J_e_mfie - J)/norm(J_e_mfie); er_M = norm(M_e_mfie - M)/norm(M_e_mfie); % calc. sparsity sp_iemei = sparsity(Z_iemei); case ’iemei’ Z_iemei = A*Z_efie_aprox + B*Z_mfie_aprox; draw_matrix(Z_iemei,’iemei AZ_e + BZ_h’,fig_1); cond_prob = condest(Z_iemei + A); % draw_matrix(Z_iemei,’iemei AZ_e + BZ_h’,1); Z_iemei = trunc_matrix(Z_iemei,trunc_bound); % get current vectors // amb M (millor) M = (Z_iemei + A)\(A*Inc_e + B*Inc_h); J = (-Z_trunc2\Z_hm1)*M; % time after matrix inversion t3=toc; %% compare with exact system Z_efie = (Z_ej1 + (Z_em1 + eye(N))*(-Z_em2\Z_ej2)); 94 Chapter 9. Annexes 9.3. Code Z_mfie = (Z_hm2 + (Z_hj2 + eye(N))*(-Z_hj1\Z_hm1)); J_e_efie = Z_efie\(Inc_e); M_e_efie = (-Z_em2\Z_ej2)*J_e_efie; M_e_mfie = Z_mfie\(Inc_h); J_e_mfie = (-Z_hj1\Z_hm1)*M_e_mfie; cond_current = condest(Z_em2); % L2 error % error between MFIE & EFIE er_J_fie = norm(J_e_efie - J_e_mfie)/norm(J_e_mfie); er_M_fie = norm(M_e_efie - M_e_mfie)/norm(M_e_mfie); % error between MFIE & IEMEI er_J = norm(J_e_mfie - J)/norm(J_e_mfie); er_M = norm(M_e_mfie - M)/norm(M_e_mfie); % calc. sparsity sp_iemei = sparsity(Z_iemei); end % Display calculation times/values used and plot results if green [E, x, y] = get_electric_field(J, M, N, dl, geometry, geo_parameters, deg, zl, un, rad*k_1, k_1, k_2, eta_0, eta_2); plot_field(E, x, y, zl, fig_2); else plot_error_geo(zl, er_vec, fig_2); end str = print_results(N,kr,e_r2,mu_r2,BW,BW_ext,En_bw,cond_vec,cond_prob,cond_current,er_vec,t1,t2,t3,t_iemei,er_J,er_M,er_J_fie,er_M_fie,sp_iemei,sp_Z_trunc,equations); plot_results_modphase(equations, eta_0, J, M, fig_4, fig_5, fig_6, fig_7, J_e_efie, M_e_efie, J_e_mfie, M_e_mfie); end 95 Chapter 9. Annexes 9.3. Code pec.m Method of moments for a PEC scatterer. % MoM for PEC scatterer, surrounded by dielectric % with variable e_r, mu_r. % % M_i: impedance matrix % % GP Conangla 2/2015 function[] = pec %% constants % incident field; lambda = 100; TM = 1; % dielectric material constants e_r = 1; mu_r = 1; eta_0 = 119.9169*pi; eta = eta_0*sqrt(mu_r/e_r); % wavevector k_0 = 2*pi/lambda; k = k_0*sqrt(mu_r*e_r); ang_i = 0; %angle in degrees k_i = k*exp(1i*ang_i*pi/180); % scatterer rad = 20/k; %radius N = 1000; %number of elements in scatterer %% MoM % scatterer and boundary zl = circular(N,rad); [un,dl,z] = normals(zl); h = dl(1); % incident field 96 Chapter 9. Annexes 9.3. Code Ei=exp(-1i*dot(k_i,z)); Hi = -dot(un,k_i/k).*exp(1i*dot(-k_i,z))/eta; % impedance matrix M1 = oper_die_2d(z,un,z.’,un,dl,k_0,TM,1,e_r,mu_r); M2 = oper_die_2d(z,un,z.’,un,dl,k_0,TM,0,e_r,mu_r); %% Solution % EFIE J1 = -inv(M1)*Ei; % MFIE J2 = -inv(M2-eye(N,N))*Hi; %% Field in space % Number of points in x and y Npun = 200; % Small shift to avoid singularity of G(r-rn) eps = 1e-3; x=linspace(-4*6/k+eps,4*6/k+eps,Npun); % 6/k can be changed by rad, it’s just some random number y = x; [rx,ry] = meshgrid(x,y); % make the mesh r = rx + 1j*ry; % Scattered field Es=zeros(Npun,Npun); for n=1:N, R=abs(r-zl(n)); % Distance from points of boundary to r G = besselh(0,2,k*R)/(4*1j); % Green’s function Es = Es - 1j*k*eta*h*J2(n)*G; end Ei=exp(-1j*k*real(r)); E=Ei+Es;% total field = scattered + incident %% plot % current 97 Chapter 9. Annexes 9.3. Code figure(1); clf; hold on; plot(eta_0*abs(J1),’r’); plot(eta_0*abs(J2),’b’); legend(’EFIE’,’MFIE’); title(’Absolut value of Electric current’); % field figure(2); clf; pcolor(x,y,abs(E)); colormap(jet); shading(’interp’); colorbar; title(’Total field’); xlabel(’x’), ylabel(’y’); axis(’equal’); axis(’square’); end oper die 2d complex.cpp C++ function that implements the basic linear operators. // // JM Rius 1996 // GP Conangla 2015 (added e_r and mu_r, complex arguments) #define _USE_MATH_DEFINES #include <complex> #include <cmath> #include "complex_bessel.h" #include "mex.h" 98 Chapter 9. Annexes 9.3. Code using namespace std; typedef complex<double> dcomp; //complex double #define _PI 3.141592653589 /* Arguments */ #define IN_ARG 12 #define p_r prhs[0] /* r = field points (column vector) */ #define p_un prhs[1] /* un = normal to boundary at FIELD points */ #define p_ri prhs[2] /* ri = source points (row vector) */ #define p_uni prhs[3] /* uni = normal to boundary at SOURCE points */ #define p_dl prhs[4] /* dl = length of basis functions */ #define p_k prhs[5] /* k = 2*pi/lam */ #define p_TM prhs[6] /* Polarization, 1->TM, 0->TE */ #define p_Es prhs[7] /* Field, 1-> Es, 0-> Hs */ #define p_e_r_re prhs[8] /* e_r = relative permittivity, real part */ #define p_e_r_im prhs[9] /* e_r = relative permittivity, imaginary part */ #define p_mu_r_re prhs[10] /* mu_r = relative permeability, real part */ #define p_mu_r_im prhs[11] /* mu_r = relative permeability, imaginary part */ #define OUT_ARG 1 #define p_field plhs[0] /* Field */ static complex<double> ij(0.0,1.0); // imag unit void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {double *rx, *ry, *rix, *riy, *dl, k_0, *Er, *Ei, *Hr, *Hi, *unx, *uny, *unix, *uniy; double R, Rmry, Rmrx, Rmlx, Rmly, Rmr, Rml, lx2, ly2; dcomp e_real, e_im, e_r, mu_real, mu_im, mu_r, eta, k, kR, tmp, var, kRmr, kRml; int N,M,Ni,Mi,i,j,p,TM,Es; if (nrhs != IN_ARG) mexErrMsgTxt("Input argument number"); Mi = mxGetM(p_ri); Ni = mxGetN(p_ri); if(Mi != 1) mexErrMsgTxt("ri must be 99 Chapter 9. Annexes 9.3. Code row vector"); M = mxGetM(p_r); N = mxGetN(p_r); if(N != 1) mexErrMsgTxt("r must be column vector"); p_field = mxCreateDoubleMatrix(M, Ni, mxCOMPLEX); k_0 = *mxGetPr(p_k); TM = *mxGetPr(p_TM); Es = *mxGetPr(p_Es); // complex permit., permeab. e_real = *mxGetPr(p_e_r_re); e_im = *mxGetPr(p_e_r_im); e_r = e_real + e_im*ij; mu_real = *mxGetPr(p_mu_r_re); mu_im = *mxGetPr(p_mu_r_im); mu_r = mu_real + mu_im*ij; // Change k_0 to k k = k_0*sqrt(e_r*mu_r); // define eta eta = 119.9169*_PI*sqrt(mu_r/e_r); // distance rx = mxGetPr(p_r); if(mxIsComplex(p_r)) ry = mxGetPi(p_r); else ry = (double*) mxCalloc(M,sizeof(double)); unx = mxGetPr(p_un); if(mxIsComplex(p_un)) uny = mxGetPi(p_un); else uny = (double*) mxCalloc(M,sizeof(double)); rix = mxGetPr(p_ri); if(mxIsComplex(p_ri)) riy = mxGetPi(p_ri); else riy = (double*) mxCalloc(Ni,sizeof(double)); unix = mxGetPr(p_uni); 100 Chapter 9. Annexes 9.3. Code if(mxIsComplex(p_uni)) uniy = mxGetPi(p_uni); else uniy = (double*) mxCalloc(Ni,sizeof(double)); dl = mxGetPr(p_dl); if(Es) { Er = mxGetPr(p_field); Ei = mxGetPi(p_field); } else { Hr = mxGetPr(p_field); Hi = mxGetPi(p_field); } dcomp z, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p, cj0_2, cj1_2, cy0_2, cy1_2, cj0p_2, cj1p_2, cy0p_2, cy1p_2; // operators if(TM && Es) for(j=0, p=0; j<Ni; j++) for(i=0; i<M; i++, p++) { R = hypot(rx[i]-rix[j],ry[i]-riy[j]); //distance if(R != 0) { tmp = eta/4.0*k*dl[j]; z = k*R; cbessjy01(z, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p); var = -tmp*cj0 + tmp*cy0*ij; Er[p] = var.real(); Ei[p] = var.imag(); } else { tmp = eta/4.0/_PI*k*dl[j]; var = -_PI*tmp + 2.0*tmp*log(tmp*5.460166e-3)*ij; Er[p] = var.real(); Ei[p] = var.imag(); } } if(TM && !Es) for(j=0, p=0; j<Ni; j++) for(i=0; i<M; i++, p++) { R = hypot(rx[i]-rix[j],ry[i]-riy[j]); if(R != 0) { tmp = -0.25*k*dl[j]*(unx[i]*(rx[i]-rix[j]) + uny[i]*(ry[i]-riy[j]))/R; z = k*R; cbessjy01(z, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p); var = tmp*cy1 + tmp*cj1*ij; Hr[p] = var.real(); 101 Chapter 9. Annexes 9.3. Code Hi[p] = var.imag(); } else { Hr[p] = 0.5; Hi[p] = 0; } } if(!TM && Es) for(j=0, p=0; j<Ni; j++) for(i=0; i<M; i++, p++) { R = hypot(rx[i]-rix[j],ry[i]-riy[j]); if(R != 0) { tmp = -eta/4.0*k*dl[j]*(unx[i]*unix[j] + uny[i]*uniy[j]); z = k*R; cbessjy01(z, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p); var = tmp*cj0 + -tmp*cy0*ij; Er[p] = var.real(); Ei[p] = var.imag(); } else { tmp = eta/4.0/_PI*k*dl[j]; var = -_PI*tmp + 2.0*tmp*log(tmp*5.460166e-3)*ij; Er[p] = var.real(); Ei[p] = var.imag(); } lx2 = -uniy[j]*dl[j]/2; ly2 = unix[j]*dl[j]/2; Rmrx = rx[i]-rix[j]-lx2; Rmry = ry[i]-riy[j]-ly2; Rmlx = rx[i]-rix[j]+lx2; Rmly = ry[i]-riy[j]+ly2; Rmr = hypot(Rmrx,Rmry); Rml = hypot(Rmlx,Rmly); kRmr = k*Rmr; kRml = k*Rml; 102 Chapter 9. Annexes 9.3. Code cbessjy01(kRmr, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p); cbessjy01(kRml, cj0_2, cj1_2, cy0_2, cy1_2, cj0p_2, cj1p_2, cy0p_2, cy1p_2); var = -(eta/4.0*((-uny[i]*Rmrx + unx[i]*Rmry)*cj1/Rmr + (uny[i]*Rmlx - unx[i]*Rmly)*cj1_2/Rml)) + (eta/4.0*((-uny[i]*Rmrx + unx[i]*Rmry)*cy1/Rmr + (uny[i]*Rmlx - unx[i]*Rmly)*cy1_2/Rml))*ij; Er[p] = Er[p] + var.real(); Ei[p] = Ei[p] + var.imag(); } if(!TM && !Es) for(j=0, p=0; j<Ni; j++) for(i=0; i<M; i++, p++) { R = hypot(rx[i]-rix[j],ry[i]-riy[j]); if(R != 0) { tmp = 0.25*k*dl[j]*(unix[j]*(rx[i]-rix[j]) + uniy[j]*(ry[i]-riy[j]))/R; z = k*R; cbessjy01(z, cj0, cj1, cy0, cy1, cj0p, cj1p, cy0p, cy1p); var = tmp*cy1 + tmp*cj1*ij; Hr[p] = var.real(); Hi[p] = var.imag(); } else { Hr[p] = -0.5; Hi[p] = 0; } } } get iemei matrices.m Calculate the IE-MEI matrices, version 1. This and the following pieces of code are different versions of the matrices calculation (not successive versions). % Calculate A and B matrices for IEMEI method in dielectrics % % Z_h: magnetic impedance matrix 103 Chapter 9. Annexes 9.3. Code zeros_in_band = floor(x/2*total_zeros); zero_one_1 = ones(1, zeros_in_band); distributed_zeros = floor((1-x)*total_zeros); X=linspace(-3, 3, distributed_zeros); Y = 1/2*(1+erf(X/(sqrt(2)*sigma))); Y = (Y - Y(1))/(Y(end) - Y(1)); % make sure it starts at zero and ends at 1 zeros_here = Y*(N - (2*Band_ext + 1) - 2*zeros_in_band - 1) + 1; zero_one_2 = zeros(1, N - (2*Band_ext + 1) - 2*zeros_in_band); for i = 1:length(zeros_here) zero_one_2(floor(zeros_here(i))) = 1; end zero_one = [zero_one_1, zero_one_2, zero_one_1]; vec = logical([zeros(1,Band_ext + 1), zero_one, zeros(1,Band_ext)]); % other vec2 vec2 = logical([zeros(1,Band_ext + 1) ,ones(1, N-(2*Band_ext + 1)), zeros(1,Band_ext)]); else vec = logical([zeros(1,Band_ext + 1) ,ones(1, N-(2*Band_ext + 1)), zeros(1,Band_ext)]); end calc_error = zeros(N,N); calc_error(1,:) = vec; where_zeros = vec; % vec = sparse(vec); band_M = zeros(N, N); % A_B will be the matrix of coefficients. To be transformed later, after % rearranging, to matrices A and B A_B = zeros(N, 2*(1+2*Band)); cond_vec = zeros(N,1); % time before A, B for i=1:N% rows of matrix A, B force_zero = repmat(vec,2*(1+2*Band),1); % a_b will be the vector of unkowns. The first parameter, a_{-Band}, % is forced to be 1 (to supress trivial solution) % temp_z is the matrix to construct the overdetermined system. 110 Chapter 9. Annexes 9.3. Code temp_ze = Z_e(i: i + 2*Band,:); temp_zh = Z_h(i: i + 2*Band,:); ZeZh = [temp_ze; temp_zh]; % convert column to zero in case there is no constraint for this % variable (it doesn’t have to be zero). Only for elements in band % diagonals. % Same effect as removing column, but faster. ZeZh = force_zero.*ZeZh; % calculate and solve system: a = (M^t*M)^{-1}*k k = -ZeZh(1,:).’; M = ZeZh(2:end,:).’; % calculate a with good condition number if issparse(M) R=qr(M); else R=triu(qr(M)); end a_b = R\(R’\(M’*k)); % otherwise: normal solution cond_vec(i) = cond(((M’ * M))); % a = (M’ * M )\M’*k; % least squares for overdetermined system A_B(i,:) = [1, a_b.’]; %first coef. forced to 1 if use_bfz band_M(i,:) = vec2; vec2 = circshift(vec2, [0 1]); else band_M(i,:) = vec; end where_zeros = [where_zeros; circshift(vec’, i-1)’]; vec = circshift(vec, [0 1]); calc_error(i,:) = vec; end %% construct A,B matrix from A_B % number of non_zero elements in sparse matrix A A_temp = A_B(:,1:(1+2*Band)); A_temp = [A_temp, zeros(N, N-(2*Band + 1))]; 111 Chapter 9. Annexes 9.3. Code B_temp = A_B(:,(1+2*Band)+1:end); B_temp = [B_temp, zeros(N, N-(2*Band + 1))]; % shift A_temp and B_temp A=zeros(N); B=zeros(N); for i=0:N-1 A(i + 1, :) = circshift(A_temp(i + 1,:),[0 i]); B(i + 1, :) = circshift(B_temp(i + 1,:),[0 i]); end % calc. mean error of overdetermined system % figure(1); % spy(calc_error); % return er_matrix = calc_error.*(A*Z_e_orig + B*Z_h_orig); er_vec = sum(abs(er_matrix),2); % total error total_zeros = B_force_zero*2; er_vec = er_vec/total_zeros; % mean error A = circshift(A,[0 -Band]); B = circshift(B,[0 -Band]); band_M = ~band_M; return get iemei matrices3.m Calculate the IE-MEI matrices, version 3. % Calculate A and B matrices for IEMEI method in dielectrics % % Z_h: magnetic impedance matrix % Z_e: electric impedance matrix % Band = Bandwidth. -> BW + 1 (diag) + BW % % G. P. Conangla 2/2015 112 Chapter 9. Annexes 9.3. Code function[A, B, band_M, cond_vec, er_vec] = get_iemei_matrices3(Z_e_orig, Z_h_orig, ef_dist, N, Band, Band_ext, B_force_zero) %% preliminary checks % determine if the band where zeros are forced (considering forcing zeros % in only a band around the non-zero coefficients of A and B is enough) is % too big to be used if Band <= 0 disp(’Choose a positive "Band"’); disp(’Changed to Band = 1’); Band = 1; end % return A, B identity matrices in case Band is too big if Band >= (N-1)/2 A=sparse(1:N, 1:N, 1); return elseif Band_ext >= (N-1)/2 A=sparse(1:N, 1:N, 1); return end %% A, B calculation % adapt matrices Z_e, Z_h to multiply by circular matrix Z_e_sup = Z_e_orig((N - Band +1):N, :); Z_e_inf = Z_e_orig(1:Band, :); Z_e = [Z_e_sup; Z_e_orig; Z_e_inf]; Z_h_sup = Z_h_orig((N - Band +1):N, :); Z_h_inf = Z_h_orig(1:Band, :); Z_h = [Z_h_sup; Z_h_orig; Z_h_inf]; % vec points which elements from the first row A*Z_e+B*Z_h must be forced to be zero. % shifting the vector we can determine the same for any row vec = make_vec(B_force_zero, Band_ext, N, Z_e_orig, 1); %first row of Z_e calc_error = zeros(N,N); calc_error(1,:) = vec; 113 Chapter 9. Annexes 9.3. Code where_zeros = vec; % other vec2 vec2 = logical([zeros(1,Band_ext + 1) ,ones(1, N-(2*Band_ext + 1)), zeros(1,Band_ext)]); band_M = zeros(N, N); % A_B will be the matrix of coefficients. To be transformed later, after % rearranging, to matrices A and B A_B = zeros(N, 2*(1+2*Band)); cond_vec = zeros(N,1); % time before A, B for i=1:N% rows of matrix A, B force_zero = repmat(vec,2*(1+2*Band),1); % a_b will be the vector of unkowns. The first parameter, a_{-Band}, % is forced to be 1 (to supress trivial solution) % temp_z is the matrix to construct the overdetermined system. temp_ze = Z_e(i: i + 2*Band,:); temp_zh = Z_h(i: i + 2*Band,:); ZeZh = [temp_ze; temp_zh]; % convert column to zero in case there is no constraint for this % variable (it doesn’t have to be zero). Only for elements in band % diagonals. % Same effect as removing column, but faster. ZeZh = force_zero.*ZeZh; ZeZh = ZeZh(:,any(ZeZh)); % draw_matrix(force_zero,’force_zero’,1); % calculate and solve system: M*a = k by minimising |Ma - k| k = -ZeZh(1,:).’; M = ZeZh(2:end,:).’; % % calculate L1 min % Tried but not working (it has good possibilities though) % preconditioner 114 Chapter 9. Annexes 9.3. Code X=M’*M; b=max(X.’).’; B=diag(b); % solve cond_vec(i) = cond((B*(M’ * M))); % vector of condition numbers for every % least squares matrix a_b = (B*(M’ * M))\B*M’*k; % least squares for overdetermined system A_B(i,:) = [1, a_b.’]; %first coef. forced to 1 band_M(i,:) = vec2; vec2 = circshift(vec2, [0 1]); if i~= N vec = make_vec(B_force_zero, Band_ext, N, Z_e_orig, i + 1); where_zeros = [where_zeros; circshift(vec’, i-1)’]; vec = circshift(vec, [0 i]); calc_error(i,:) = vec; end end %% construct A,B matrix from A_B % number of non_zero elements in sparse matrix A A_temp = A_B(:,1:(1+2*Band)); A_temp = [A_temp, zeros(N, N-(2*Band + 1))]; B_temp = A_B(:,(1+2*Band)+1:end); B_temp = [B_temp, zeros(N, N-(2*Band + 1))]; % shift A_temp and B_temp A=zeros(N); B=zeros(N); for i=0:N-1 A(i + 1, :) = circshift(A_temp(i + 1,:),[0 i]); B(i + 1, :) = circshift(B_temp(i + 1,:),[0 i]); end % calc. mean error of overdetermined system % figure(1); % spy(calc_error); % return 115 Chapter 9. Annexes 9.3. Code er_matrix = calc_error.*(A*Z_e_orig + B*Z_h_orig); er_vec = sum(abs(er_matrix),2); % total error total_zeros = B_force_zero*2; er_vec = er_vec/total_zeros; % mean error % finish A, B matrices A = circshift(A,[0 -Band]); B = circshift(B,[0 -Band]); band_M = ~band_M; % matrix with ones where A, B are different from zero % figure(5); % spy(where_zeros); return get iemei matrices4.m Calculate the IE-MEI matrices, version 4. This version includes the inverse method for the forced zeros distribution. % Calculate A and B matrices for IEMEI method in dielectrics % % Z_h: magnetic impedance matrix % Z_e: electric impedance matrix % Band = Bandwidth. -> BW + 1 (diag) + BW % % G. P. Conangla 2/2015 function[A, B, band_M] = get_iemei_matrices4(Z_e_orig, Z_h_orig, ef_dist, N, Band, Band_ext, B_force_zero) %% preliminary checks % determine if the band where zeros are forced (considering forcing zeros % in only a band around the non-zero coefficients of A and B is enough) is % too big to be used if Band <= 0 116 Chapter 9. Annexes 9.3. Code disp(’Choose a positive "Band"’); disp(’Changed to Band = 1’); Band = 1; end % return A, B identity matrices in case Band is too big if Band >= (N-1)/2 A=sparse(1:N, 1:N, 1); return elseif Band_ext >= (N-1)/2 A=sparse(1:N, 1:N, 1); return end %% A, B calculation % adapt matrices Z_e, Z_h to multiply by circular matrix Z_e_sup = Z_e_orig((N - Band +1):N, :); Z_e_inf = Z_e_orig(1:Band, :); Z_e = [Z_e_sup; Z_e_orig; Z_e_inf]; Z_h_sup = Z_h_orig((N - Band +1):N, :); Z_h_inf = Z_h_orig(1:Band, :); Z_h = [Z_h_sup; Z_h_orig; Z_h_inf]; % vec points which elements from the first row A*Z_e+B*Z_h must be forced to be zero. % shifting the vector we can determine the same for any row % vec = make_vec(B_force_zero, Band_ext, N, Z_e_orig, 1); %first row of Z_e % other vec2 vec2 = logical([zeros(1,Band_ext + 1) ,ones(1, N-(2*Band_ext + 1)), zeros(1,Band_ext)]); % vec = sparse(vec); band_M = zeros(N, N); % A_B will be the matrix of coefficients. To be transformed later, after % rearranging, to matrices A and B A_B = zeros(N, 2*(1+2*Band)); % time before A, B 117 Chapter 9. Annexes 9.3. Code for i=1:N% rows of matrix A, B % force_zero = repmat(vec,2*(1+2*Band),1); % a_b will be the vector of unkowns. The first parameter, a_{-Band}, % is forced to be 1 (to supress trivial solution) % temp_z is the matrix to construct the overdetermined system. temp_ze = Z_e(i: i + 2*Band,:); temp_zh = Z_h(i: i + 2*Band,:); ZeZh = [temp_ze; temp_zh]; ZeZh = fft(ZeZh.’).’; % fftshift for columns % ZeZh = fftshift(ZeZh, 2); % draw_matrix(ZeZh, ’’,1); % return % ZeZh(:, floor(N/4):floor(3*N/4)) = 0; % convert column to zero in case there is no constraint for this % variable (it doesn’t have to be zero). Only for elements in band % diagonals. % Same effect as removing column, but faster. % ZeZh = force_zero.*ZeZh; TO BE UPDATED, FORCE ZERO MUST REMOVE % LIMITS % calculate and solve system: M*a = k by minimising |Ma - k| k = -ZeZh(1,:).’; M = ZeZh(2:end,:).’; % % calculate L1 min % [~, lg] = size(M); % x0 = ones(lg,1); % a_b = l1eq_pd(x0, M’ * M, 1, M’*k, 1e-3, 50, 1e-8, 200); % % calculate a with good condition number % % if issparse(M) % R = qr(M); % else % R = triu(qr(M)); % end % a_b = R\(R’\(M’*k)); 118 Chapter 9. Annexes 9.3. Code % otherwise: normal solution % preconditioner X=M’*M; b=max(X.’).’; B=diag(b); % [l,~] = size(X); % B = dftmtx(l); % solve a_b = (B*(M’ * M))\B*M’*k; % least squares for overdetermined system A_B(i,:) = [1, a_b.’]; %first coef. forced to 1 band_M(i,:) = vec2; vec2 = circshift(vec2, [0 1]); % if i~= N % vec = make_vec(B_force_zero, Band_ext, N, Z_e_orig, i + 1); % vec = circshift(vec, [0 i]); % end end %% construct A,B matrix from A_B % number of non_zero elements in sparse matrix A A_temp = A_B(:,1:(1+2*Band)); A_temp = [A_temp, zeros(N, N-(2*Band + 1))]; B_temp = A_B(:,(1+2*Band)+1:end); B_temp = [B_temp, zeros(N, N-(2*Band + 1))]; % shift A_temp and B_temp A=zeros(N); B=zeros(N); for i=0:N-1 A(i + 1, :) = circshift(A_temp(i + 1,:),[0 i]); B(i + 1, :) = circshift(B_temp(i + 1,:),[0 i]); end A = circshift(A,[0 -Band]); B = circshift(B,[0 -Band]); X = A*fft(Z_e_orig,[],2) + B*fft(Z_h_orig,[],2); draw_matrix(X,’AZe + BZh’,3); 119 Chapter 9. Annexes 9.3. Code % MFIE dielectric equations % 1st box Z_hj_1 = operator(z,un,z.’,un,dl,’Omega’,’J’,k_0,e_r2,mu_r2,N); % 2nd box Z_hm_1 = operator(z,un,z.’,un,dl,’Lambda’,’M’,k_0,e_r2,mu_r2,N)/eta_2^2; % 3rd box Z_hj_2 = operator(z,un,z.’,un,dl,’Omega’,’J’,k_0,e_r1,mu_r1,N); % 4th box Z_hm_2 = operator(z,un,z.’,un,dl,’Lambda’,’M’,k_0,e_r1,mu_r1,N)/eta_1^2; end get electric field.m Calculate the convolution integral with the currents and Green’s function to find the near field. % Calculate Green integrals: get E field from electric & magnetic current % ref: Integral Equation Methods for Electromagnetics, Morita et al (pg 156, 3.115, 3.116); % % Inputs: % J: electric current % M: magnetic current % N: discretization number % dl: distance between disc. points -> h: step size % geometry: geometry of object % geo_parameters: semiaxis in x, y % deg: degree of superellipse (only in pill geometry case) % zl: disc. points % normal: normals in disc. points % kr: k* bigger semiaxis % k_1: k of medium (usually free space) % k_2: k in object 126 Chapter 9. Annexes 9.3. Code % eta_0: impedance in free space % eta_2: impedance of object % % Outputs: % E: electric field % x: x coordinates mesh % y: y coordinates mesh % % G. Planes Conangla 5/2015 function[E, x, y] = get_electric_field(J, M, N, dl, geometry, geo_parameters, deg, zl, normal, kr, k_1, k_2, eta_0, eta_2) % Number of points in x and y Npun = 160; % must be multiple of 4 eps = 1e-3; % Small shift to avoid singularity of G(r-rn) x=linspace(-kr/2 - eps, kr/2 + eps, Npun); y = x; [rx,ry] = meshgrid(x,y); % make the mesh r = rx + 1j*ry; % Scattered field outside Es=zeros(Npun, Npun); for n = 1:N h = dl(n); R=abs(r - zl(n)); % Distance from points of boundary to r G = besselh(0, 2, k_1*R)/(4*1j); % Green’s function % now calculate diff in normal direction of G (for M current part) delta = normal(n)/(abs(normal(n))*1000); % increment for differentiation R_up_delta = abs(r - (zl(n) + delta)); G_up_delta = besselh(0, 2, k_1*R_up_delta)/(4*1j); R_down_delta = abs(r - (zl(n) - delta)); G_down_delta = besselh(0, 2, k_1*R_down_delta)/(4*1j); dif_n_G = (G_up_delta - G_down_delta)/(2*abs(delta)); % central finite diff. 127 Chapter 9. Annexes 9.3. Code Es = Es + (M(n)*dif_n_G)*h - (1j*k_1*eta_0*J(n)*G)*h; % integrate end Ei=exp(-1j*k_1*real(r)); E=Es+Ei;% total field outside = scattered + incident % Scattered field inside scatterer r_small = r(Npun/4 + 1: 3/4*Npun, Npun/4 + 1: 3/4*Npun); % extract submatrix from r Es=zeros(Npun/2, Npun/2); for n = 1:N h = dl(n); R=abs(r_small - zl(n)); % Distance from points of boundary to r G = besselh(0, 2, k_2*R)/(4*1j); % Green’s function % now calculate diff in normal direction of G (for M current part) delta = normal(n)/(abs(normal(n))*1000); % increment for differentiation R_up_delta = abs(r_small - (zl(n) + delta)); G_up_delta = besselh(0, 2, k_2*R_up_delta)/(4*1j); R_down_delta = abs(r_small - (zl(n) - delta)); G_down_delta = besselh(0, 2, k_2*R_down_delta)/(4*1j); dif_n_G = (G_up_delta - G_down_delta)/(2*abs(delta)); % central finite diff. Es = Es + (M(n)*dif_n_G)*h - (1j*k_1*eta_2*J(n)*G)*h; % integrate end Es = -Es; % inside: opposite sign % insert inside of scatterer in E matrix big_Es = zeros(Npun, Npun); big_Es(Npun/4 + 1: 3/4*Npun, Npun/4 + 1: 3/4*Npun) = Es; % detect interior of scatterer and put right field inside switch geometry case ’elliptical’ ind = find((abs(real(r))/geo_parameters(1)).^2 + (abs(imag(r))/geo_parameters(2)).^2 < 1); case ’pill’ 128 Chapter 9. Annexes 9.3. Code ind = find((abs(real(r))/geo_parameters(1)).^deg + (abs(imag(r))/geo_parameters(2)).^deg < 1); case ’rectangular’ ind = find(abs(real(r)) < geo_parameters(1) & abs(imag(r)) < geo_parameters(2)); end E(ind) = big_Es(ind); % change field inside of scatterer end 9.3.2 Geometry routines circular.m Circular geometry boundary generator. % z = circular(N,param) % Circular boundary % % N : number of basis functions % param : radius % % z : sampling points, left end of basis functions % z(N+1) = z(1) % 2-D vectors are represented by complex numbers z = x + j*y % % MEI v3.0, Juan M. Rius, Sept. 1996 function z=circular(N,param) R = param(1); t=linspace(0,2*pi,N+1)’; z=R*exp(1i*t); 129 Chapter 9. Annexes 9.3. Code elliptical.m Elliptical geometry boundary generator % z = elliptical(N, param) % Elliptical boundary % % N : number of basis functions % param : semiaxis in x and in y % % z : sampling points, left end of basis functions % z(N+1) = z(1) % 2-D vectors are represented by complex numbers z = x + j*y % % Juan M. Rius, Sept. 1996 % G Planes Conangla 5/2015 function z = elliptical(N, param) a = param(1); b = param(2); t=linspace(0,2*pi,N+1)’; z = a*cos(t) + 1j*b*sin(t); rectang geometry.m Rectangular geometry boundary generator. % z = rectang_geometry(N,param) % Rectangular boundary % % N : number of basis functions % geo_parameters: half the sides in x, y % z : sampling points, left end of basis functions % % Returns column vector with N+1 elements: z(N+1)=z(1) % 2-D vectors are represented by complex numbers z = x + 1j*y 130 Chapter 9. Annexes 9.3. Code % % Gerard Planes Conangla, May 2015 function z = rectang_geometry(N, geo_parameters) lx = 2*geo_parameters(1); % width of rectangle in x ly = 2*geo_parameters(2); % width of rectangle in y L2 = lx + ly; N12 = floor(N/2); N34 = N-N12; p1=round(N12*lx/L2); % Points in x direction p2 = N12 - p1; % Points in y direction p3=round(N34*lx/L2); p4 = N34 - p3; i1 = lx/p1; i3 = lx/p3; % Step in x direction i2 = ly/p2; i4 = ly/p4; % Step in y direction z1=linspace(-lx/2 - 1j*ly/2, lx/2 - i1 - 1j*ly/2, p1); % bottom z2=linspace( lx/2 - 1j*ly/2, lx/2 + 1j*(ly/2-i2), p2); % rigth z3=linspace( lx/2 + 1j*ly/2, -lx/2 + i3 + 1j*ly/2, p3); % upper z4=linspace(-lx/2 + 1j*ly/2, -lx/2 - 1j*(ly/2-i4), p4); % left z=[z1 z2 z3 z4 z1(1)].’; pill.m Superelliptical geometry boundary generator. % z = pill(N, param) % "Pill" boundary (rectangular boundary with smooth vertices (specifically % a superellipse)) % % N : number of basis functions % param : semiaxis in x, y % % z : sampling points, left end of basis functions 131 Chapter 9. Annexes 9.3. Code % z(N+1) = z(1) % deg: degree of superellipse used % 2-D vectors are represented by complex numbers z = x + j*y % % G Planes Conangla 5/2015 function [z, deg] = pill(N, param) a = param(1); b = param(2); deg = 4; % this number can be changed: the bigger the number, the closer % to a rectangle. deg = 2 gives an ellipse as result t=linspace(0,2*pi,N+1)’; % equispaced angles for circle k_equi = zeros(N + 1, 1); % equispaced in superellipse for i = 1:length(t) cos_x = cos(t(i)); sin_x = sin(t(i)); angle_fun = @(k) (k*cos_x/a).^deg + (k*sin_x/b).^deg - 1; k_equi(i) = fzero(angle_fun, 1); end z_circ = exp(1i*t); z = z_circ.*k_equi; dot.m Dot product in the 2D complex sense used in the project. % Dot product of 2-D vectors represented by complex numbers % % p = dot(a,b) % % If a and b are vectors, p is a vector p(n) = dot(a(n),b(n)) function p=dot(a,b) 132 Chapter 9. Annexes 9.3. Code p=real(a.*conj(b)); normals.m Return normals to the surface from a given geometry. % Obtain unit normals and length of basis functions % % [un,dl,zc] = normals(zl) % % zl = sampling points, left of pulse basis functions. % For closed objects, z(N+1) = z(1) % For open objects z(N+1) is right end of last basis function % un = exterior unit normals % dl = length of basis functions % 2-D vectors are represented by complex numbers z = x + j*y % % IE-MEI, version 3.0, Juan M. Rius, sept. 1996 function [un,dl,zc]=normals(zl) N = length(zl)-1; t = zl(2:N+1) - zl(1:N); un = -1i*sign(t); dl=abs(t); zc = (zl(1:N)+zl(2:N+1))/2; 9.3.3 Others band matrix.m Generate a circulant band matrix. % Obtain matrix with ones in the three diagonal bands % % G. P. Conangla 2/2015 133 Chapter 9. Annexes 9.3. Code function[tri_band] = band_matrix(N, Band) if Band >= (N - 1)/2 tri_band = ones(2*N,2*N); return end tri_band = zeros(2*N,2*N); vec = [zeros(1,Band + 1), ones(1, N-(2*Band + 1)), zeros(1,2*Band + 1), ones(1, N-(2*Band + 1)), zeros(1,Band)]; for i = 1:2*N % rows of matrix A, B for j = 1:2*N % columns of Z_e, Z_h if j>=i% col >= row include = vec(1 + j - i); else include = vec(2*N + 1 - (i - j)); end if include == false tri_band(i,j) = 1; end end end return draw matrix.m Plot adequately a matrix. % draw matrix with good orientation, axis and title % function[] = draw_matrix(M,name,h_1) if issparse(M) M=full(M); 134 Chapter 9. Annexes 9.3. Code end if h_1 == 1 || h_1 == 2 || h_1 == 3 figure(h_1); else axes(h_1); end cla reset; A=log10(abs(M.’)); A=A-max(max(A)); % fprintf(’Biggest element of figure %f is %f\n’,h_1,max(max(abs(M)))); surf(A); shading interp; text = strcat({’Matrix ’}, name, {’ in log_{10} scale’}); title(text); dim1 = size(M,1); dim2 = size(M,2); axis([1 dim1 1 dim2]); xlabel(’Rows’); ylabel(’Columns’); colorbar; end make sparse.m % make M sparse by truncating M % the statistics of sparsity are taken from just one row to increase speed % spars is the wanted sparsity function[M, k] = make_sparse(M, spars) % return if operation is redundant if sparsity(M(1,:)) < spars k = 0; return end top = abs(max(max(M))); 135 Chapter 9. Annexes 9.3. Code % Magnetic current axes(h_5); % figure(5); hold on; plot(abs(M_e_efie),’b.-’); plot(abs(M_e_mfie),’g.-’); legend(’IEMEI solution’,’EFIE solution’,’MFIE solution’); axes(h_6); % figure(6); hold on; plot(angle(M_e_efie),’b.-’); plot(angle(M_e_mfie),’g.-’); legend(’IEMEI solution’,’EFIE solution’,’MFIE solution’); end end print results.m Print the results of the simulation in txt format. % Display calculation times, values used and results % (on command line or gui) % % function[str] = print_results(N,kr,e_r2,mu_r2,BW,BW_ext,En_bw,cond_vec,cond_prob,cond_current,er_vec,t1,t2,t3,t_iemei,er1,er2,order_erj, order_erm, sp_AZ,sp_Z_trunc,equations) % str = sprintf(’\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n’); str = sprintf(’--SCATTERER--\n’); str = sprintf(’%sNumber of elements in scatterer: %d\n’,str, N); str = sprintf(’%sValue of r/lambda: %.1f/2pi\n’,str, kr); if imag(e_r2) < 0 str = sprintf(’%se_r: %.2f - %.2fj mu_r: %.2f\n\n’,str, e_r2, abs(imag(e_r2)/1j), mu_r2); else 142 Chapter 9. Annexes 9.3. Code str = sprintf(’%se_r: %.2f + %.2fj mu_r: %.2f\n\n’,str, e_r2, e_r2/1j, mu_r2); end switch equations case {’iemei_efie’,’iemei_mfie’,’iemei’} str = sprintf(’%s--BANDWIDTH and SPARSITY--\n’,str); str = sprintf(’%sA bandwidth: %d\n’,str, BW); str = sprintf(’%sCalculated BW in En: %d\n’,str, BW_ext); str = sprintf(’%sActual BW used: %d\n’,str,En_bw); str = sprintf(’%sSparsity of: Zc: %.2f%%\n’,str,sp_AZ*100); str = sprintf(’%s Z_J->M: %.2f%%\n\n’,str,sp_Z_trunc*100); str = sprintf(’%s--TIME--\n’,str); str = sprintf(’%sPre-calculation steps: %f s\n’,str, t1); str = sprintf(’%sZ matrices calculation: %f s\n’,str, t_iemei - t1); str = sprintf(’%sIEMEI matrix calculation: %f s\n’,str, t2 - t_iemei); str = sprintf(’%sSystem solving: %f s\n’,str, t3 - t2); str = sprintf(’%sTotal time: %f s\n\n’,str, t3); str = sprintf(’%s--ERROR--\n’,str); str = sprintf(’%sCond. num. of: Current matrix (before trunc): %.2g IEMEI matrix (before trunc): %.2g\n’,str,cond_prob,cond_current); str = sprintf(’%sCond. num. of IEMEI least squares matrices: min: %.2g max: %.2g mean: %.2g\n’,str,min(cond_vec), max(cond_vec), mean(cond_vec)); str = sprintf(’%sError per element in least squares: min: %.2g max: %.2g mean: %.2g\n\n’,str,min(er_vec), max(er_vec), mean(er_vec)); str = sprintf(’%sRelative L2 error in J between MFIE/EFIE: %f\n’,str, order_erj); str = sprintf(’%sRelative L2 error in M between MFIE/EFIE: %f\n’,str, order_erm); str = sprintf(’%sRelative L2 error in J (with MFIE): %f\n’,str, er1); str = sprintf(’%sRelative L2 error in M (with MFIE): %f\n\n’,str, er2); 143 Chapter 9. Annexes 9.3. Code str = sprintf(’%sMean L2 error: %f\n\n’,str, (er1 + er2)/2); otherwise % EFIE or MFIE str = sprintf(’%s--TIME--\n’,str); str = sprintf(’%sPre-calculation steps: %f s\n’,str, t1); str = sprintf(’%sZ matrices calculation: %f s\n’,str, t2 - t1); str = sprintf(’%sSystem solving: %f s\n’,str, t3 - t2); str = sprintf(’%sTotal time: %f s\n\n’,str, t3); end end sparsity.m Determine the sparsity of a given matrix. function[sp] = sparsity(M) sp=nnz(M)/(size(M,1)*size(M,2)); end trunc matrix.m Truncate a matrix for a given threshold. % truncate matrix M. All elements < k*max_element % set to zero function[M] = trunc_matrix(M, k, varargin) if nargin > 2 M(abs(M) < k*varargin{1}) = 0; else % M(abs(M) < k*abs(max(max(M)))) = 0; for i = 1:length(M(1,:)) E = M(i,:); E(abs(E) < k*abs(max(E))) = 0; 144 Chapter 9. Annexes 9.3. Code M(i,:) = E; end end end 145 Bibliography [1] N. Morita, N. Kumagai, J.R. Mautz, INTEGRAL EQUATION METHODS FOR ELECTROMAGNETICS, Artech House, 1990 [2] J.M. Rius, R. Pous, A. Cardama, INTEGRAL FORMULATION OF THE MEASURED EQUATION OF INVARIANCE: A NOVEL SPARSE MATRIX BOUNDARY ELEMENT METHOD. IEEE Transactions on Antennas and Propagation, vol. 32 No. 3, May 1996 [3] Juan M. Rius, NUMERICAL ADAPTIVE TESTING FUNCTIONS FOR APPROXIMATE SPARSE MATRIX METHOD OF MOMENTS. PART 1: PERFECTLY CONDUCTING SCATTERER. October 1996 [4] A. Cardama, L. Jofre, J.M. Rius et al., ANTENAS (2nd edition). Edicions UPC, Barcelona 2002 [5] Korada Umashankar, Allen Taflove, COMPUTATIONAL ELECTROMAGNETICS, Artech House, 1993 [6] R.F. Harrington. FIELD COMPUTATION BY MOMENT METHOD, McGraw-Hill, New York 1968 [7] C.A. P´erez Carpintero, J.M Rius Casals, DESARROLLO Y APLICACIONES DEL MEI EN OBJETOS CONDUCTORES DE DOS DIMENSIONES (PFC). Departament de teoria de senyal i comunicacions, ETSETB, UPC, Barcelona 1996 [8] K.K. Mei, R.Pous et al., MEASURED EQUATION OF INVARIANCE: A NEW CONCEPT IN FIELD COMPUTATIONS. IEEE Transactions on Antennas and Propagation, vol. 42, no. 3, March 1994 [9] Stefan A. Maier, PLASMONICS: FUNDAMENTALS AND APPLICATIONS. Springer Science+Business Media LLC 2007. 146 Bibliography Bibliography [10] J.M. Rius, C.P Carpintero, A. Cardama, J.R. Mosig, THE THEORETICAL ERROR IN THE INTEGRAL EQUATION MEI. IEEE Electronic Letters 1996. [11] Jovan O. Jevtic, Robert Lee, A THEORETICAL AND NUMERICAL ANALYSIS OF THE MEASURED EQUATION OF INVARIANCE. IEEE Transactions on Antennas and Propagation, vol 42. No. 8, August 1994. [12] Joel A. Tropp, Anna C. Gilbert, SIGNAL RECOVERY FROM RANDOM MEASUREMENTS VIA ORTHOGONAL MATCHING PURSUIT. IEEE Transactions on Information Theory, vol. 53, no. 12, December 2007 [13] D.M. Sol´ıs, M.G. Ara´ujo, L. Landesa et al, MLFMA-MOM FOR SOLVING THE SCATTERING OF DENSELY PACKED PLASMONIC NANOPARTICLE ASSEMBLIES. IEEE Photonics Journal, vol. 7, n. 3, June 2015. [14] C.A. Balanis, ADVANCED ENGINEERING ELECTROMAGNETICS. Ed. Wiley, May 1989 [15] J.M. Rius, E. ´ Ubeda, J. Parr´on, THE INTEGRAL EQUATION MEI APPLIED TO THREE-DIMENSIONAL ARBITRARY SURFACES. Electronic Letters, vol. 33, Issue 24, November 1997. [16] J.M Rius, C.P. Carpintero, A. Cardama, K.A. Michalski. ANALYSIS OF ELECTRICALLY LARGE CONCAVE SCATTERERS WITH THE INTEGRAL EQUATION MEI. Microwave and Optical Technology Letters, 14(5), pp. 287-289, 5th April 1997 [17] J. Song, C. C. Lu, and W. C. Chew, MULTILEVEL FAST MULTIPOLE ALGORITHM FOR ELECTROMAGNETIC SCATTERING BY LARGE COMPLEX OBJECTS. Antennas and Propagation, IEEE Transactions vol. 45, no. 10, pp. 1488–1493, Oct 1997. 147