#FDTD 시뮬레이션 CODE#
In this case the code is literally a hundred times faster and uses a fraction of the memory. There is a special data structure in Matlab for sparse matricies, and using it speeds up calculation of inverses by orders of magnitude. However only 64 of those are nonzero, just 8% of the matrix is actually useful in computation! This drops to 4% if the resolution of our grid jumps by a factor of 10, and stays around 5% for another factor of 10. Here, so there are 784 elements in the matrix. We can visualise the structure of our matrix using the handy Matlab function spy – as plotted below it shows which elements of the matrix are nonzero. We will require or so then, which means the number of elements is around ! Storing each as a single precision number would require around 60 GB of RAM, and my poor battered laptop wouldn’t have a chance inverting that matrix even if it would fit in memory.įortunately this problem has crept up on people cleverer than I, and they invented the concept of the sparse matrix, or a matrix filled mostly with zeros. For this problem a room is approximately 5 m across, and the wavelength to resolve is around 5 cm. In fact, it is clear that the vast majority of the matrix is zero, which can help when considering the sheer size of the matrix. Where there are blank cells between the and cells. The row in the matrix equation corresponding to the th cell looks like I use the translation that so thatĪ pair of cells and are then separated by in this new labelling system, and a pair of cells and separated by 1. This is slightly tricky due to the fact that a 2D labelling system needs to be converted to a 1D labelling system, as the 2D simulation domain needs to be converted to a 1D vector. In particular we’ll have for some matrix, and we can compute. This motivates a linear algebraic approach to the problem – if all equations can be represented as one giant matrix equation, that matrix can be inverted and an exact solution for recovered.
Each cell has an equation describing the relationship with its neighbours, so there are equations in unknowns. This is a linear equation in the ‘current’ cell as a function of its 4 neighbours. Given this discretisation, the equation above becomes Here I chose to model a situation in 2D, and set up a computational grid of size with grid cells labelled for. Given a source of radiation and a geometry to propagate in, in principle the Helmholtz equation can be solved for the entire radiation field. More precisely, if the time-dependence of an electromagnetic wave can be assumed to be of the form and the dispersion relation given by for some refractive index distribution, then the electric field solves The Helmholtz equation is used in the modelling of the propagation of electromagnetic waves. UPDATE: Android app now available, see this post for details. Well, spurred on by a shocking amount of spare time, I’ve given it a go here. I casually mentioned that I really should be doing things more rigorously by solving the Helmholtz equation, but then didn’t.
For the propagation, we will use both BPM and BSP on the same metalens structures for cross-validation.A few posts back I was concerned with optimising the WiFi reception in my flat, and I chose a simple method for calculating the distribution of electromagnetic intensity. More efficient algorithms, such as Beam Propagation Method (BPM) or Beam Synthesis Propagation (BSP), are then used to simulate the propagation through the metalens.
A rigorous algorithm such as FDTD, or alternatively RCWA, is used to calculate the phase shift of the individual unit nano-cells, from which a phase mask for the complete metalens is constructed. In this paper, we demonstrate an approach that decomposes the metalens into simpler elements that can be solved individually. In practice, however, direct FDTD simulation of the entire metalens is fortunately not required. The largest metalens that can be directly simulated in most labs through FDTD is only tens of micrometers in diameter, much smaller than what is needed. However, FDTD is computationally expensive, requiring substantial computer resources. To simulate the nano-structures, a rigorous algorithm such as FDTD must be used.
A metalens is a difficult structure to design and simulate using photonic simulation algorithms, since its overall size is very large and contains many nano-structures.