**Electromagnetic and Photonic Simulation for the Beginner: Finite Difference Frequency Domain in MATLAB**

Written by Dr. Raymond C. Rumpf, the EMProfessor, this book teaches the art of computational electromagnetics using the finite-difference frequency-domain (FDFD). The books starts from the simplest concepts and works up to advanced three-dimensional simulations. It uses plain language and plenty of high-quality graphics to allow the complete beginner to grasp all of the concepts quickly and visually. This single resource includes everything needed to simulate a wide variety of different electromagnetic and photonic devices (see below). The book is packed with helpful guidance and computational wisdom that will aid the reader to easily simulate their own devices and more easily learn and implement other methods in computational electromagnetics.

Special techniques in MATLAB® are presented that will allow readers to simulate their own device ideas using FDFD. Key concepts in electromagnetics are reviewed so the reader can fully understand the calculations happening in FDFD. A powerful method for implementing the finite-difference method is taught that will enable the reader to solve entirely new differential equations, and sets of differential equations, in mere minutes.

Separate chapters are included that describe how Maxwell’s equations are handled using this finite-difference method and how outgoing waves can be absorbed using a perfectly matched layer absorbing boundary. With this background, a chapter describes how to calculate full vector guided modes in channel waveguides and slab waveguides, rigorously analyze transmission lines, and calculate surface plasmon polaritons supported at the interface between a metal and a dielectric.

The effective index method based on slab waveguide analysis is taught as way to model many three-dimensional devices using just a two-dimensional simulation. Another chapter describes how to calculate photonic band diagrams and isofrequency contours to quickly estimate the properties of periodic structures like photonic crystals. Next, a chapter presents how to analyze diffraction gratings and calculate the power coupled into each diffraction order.

This book shows that many periodic devices can be simulated as if they were diffraction gratings including guided-mode resonance filters, photonic crystals, polarizers, metamaterials, frequency selective surfaces, and metasurfaces. Plane wave sources, Gaussian beam sources, and guided-mode sources are all described in detail, allowing different types of devices to be simulated in different ways. An optical integrated circuit is reduced to two dimensions using the effective index method and then simulated using FDFD by launching a guided-mode source into the circuit.

A chapter is included to describe how FDFD should be modified to easily perform parameter sweeps, such as plotting reflection and transmission as a function of frequency, wavelength, angle of incidence, or a parameter describing a device. The last chapter is advanced and teaches FDFD for three-dimensional devices and anisotropic materials. It includes simulations of a crossed grating, a doubly-periodic guided-mode resonance filter, a frequency selective surface, and an invisibility cloak. The chapter also includes parameter retrieval from a left-handed metamaterial.

The book includes a line-by-line explanation of all of the programs that can be downloaded from this website. This will allow readers to fully understand the codes so they can easily modify the codes to simulate their own ideas and devices. All of the MATLAB codes can be downloaded from this website and other learning resources can be accessed from EMPossible. This is an ideal book for an undergraduate elective course as well as a graduate course in computational electromagnetics because the book covers the background material so well and includes full examples of many different types of devices that will be of interest to a wide audience.

## Table of Contents

### Chapter 1 – MATLAB Preliminaries

Special skills and techniques for implementing FDFD in MATLAB are described. Topics include matrices, linear algebra, building devices into arrays, and visualizing data in arrays.

### Chapter 2 – Electromagnetic Preliminaries

All of the background in electromagnetics and device theory is presented that is needed to fully understand how FDFD is implemented. Topics include Maxwell’s equations, tensors, waves, polarization, scattering at an interface, diffraction from gratings, waveguides, transmission lines, and scalability of Maxwell’s equations.

### Chapter 3 – The Finite-Difference Method

A unique and very powerful method of implementing the finite-difference method is presented that allows entirely new differential equations to be solved in mere seconds to minutes. Concepts such as boundary conditions, derivative matrices, multiple variables, staggered grids, and solving matrix equations is discussed.

### Chapter 4 – Finite-Difference Approximation of Maxwell’s Equations

Numerical approximation of Maxwell’s equations using the finite-difference method is described. Field components are spatially staggered following the Yee grid scheme. Matrix representations of Maxwell’s equations are derived that include boundary conditions.

### Chapter 5 – The Perfectly Matched Layer Absorbing Boundary

The perfectly matched layer (PML) absorbing boundary is presented as a way of absorbing waves at the boundaries of a simulation. Both a uniaxial PML and a stretched-coordinate PML are described.

### Chapter 6 – FDFD for Calculating Guided Modes

FDFD is formulated and implemented for calculating guided modes. This includes rigorous hybrid mode analysis, slab waveguide analysis, surface wave analysis, and analysis of transmission lines. The effective index method is presented as a way of using slab waveguide analysis to model many three-dimensional problems in just two dimensions.

### Chapter 7 – FDFD for Calculating Photonic Bands

FDFD is formulated and implemented for calculating photonic band diagrams and isofrequency contours of periodic structures. A self-collimating photonic crystal is analyzed. Both calculations and creating the diagrams are explained in detail.

### Chapter 8 – FDFD for Scattering Analysis

Two-dimensional FDFD for scattering analysis is formulated and implemented, including how to incorporate different types of sources and how to calculate transmission and reflection from periodic structures. Devices examples include a sawtooth diffraction grating, a photonic crystal, and an optical integrated circuit.

### Chapter 9 – Parameter Sweeps with FDFD

FDFD is modified to perform different types of parameter sweeps including frequency sweeps, wavelength sweeps, dimension sweeps, and convergence sweeps. Device examples include a guided-mode resonance filter and a terahertz polarizer.

### Chapter 10 – FDFD Analysis of Three-Dimensional and Anisotropic Devices

Three-dimensional and anisotropic FDFD is formulated and implemented including sources, iterative solution, and iterative solution on a GPU. Device examples include a crossed grating guided-mode resonance filter, a frequency selective surface, parameter retrieval of a left-handed metamaterial, and an invisibility cloak designed by transformation optics

### Appendices

Best practices for building devices onto Yee grids is covered in Appendix A.1. The discussion includes placing metals onto the grid as well as dielectric averaging to better resolve curved dielectric structures. The remaining appendices are summaries that allow the reader to quickly and conveniently access the key equations to implement the methods. Summaries include the discrete form of Maxwell’s equations, the perfectly matched layer absorbing boundary, waveguide analysis, three-dimensional and anisotropic FDFD, and construction of photonic band diagrams.

## FDFD Codes for the Book

Download all of the codes for each chapter of the book at the links below. All of the codes are described in detail in the book.

(Zip) (PDF) MATLAB Codes (updated Updated 1 April 2023)

(Zip) OCTAVE Codes (updated Updated 1 April 2023)

Note: I have not yet been able to get all of Chapter 10 codes to run correctly in Octave.

## Errata

Errata Document (Updated 1 April 2023)

## Other Learning Resources

Are you interested in other learning resources for electromagnetics and computation offered by Dr. Raymond C. Rumpf?