So, light is an intertesting thing. It’s absolutely fundamental to our lives in every possible way. Even so… understanding the true beauty of light took millenia, with some of the brightest human minds devoted to understanding it. Looking at light, though, it is not immediately obvious why.

Let’s think about light, then. What is it? Well, it might be easier to describe something it is not: a shadow. In fact, any toddler can tell you that when light hits something, it leaves a shadow on the other side. This interaction between light, objects, and shadows led many scientists to believe that light acted as a line of particles, all chained together. This wasn’t inherently wrong, but it wasn’t completely right either. It turns out that light can also act as a wave. How? Well, to answer this question, we need to talk a little more about what light is in the first place.

Light is something called an electromagnetic wave. What is that? Well, an electric field is the thing that causes like charges to repel and opposite charges to attract, and a magnetic field does the same thing except with magnets. These two fields follow particular equations known as Maxwell’s equations that can be written as:

What do these mean? Well, that depends on who you ask and what we are talking a bout, but for the most part, the mean the following:

- There are no Magnetic monopoles
- [Gauss’s Law] Charge is conserved unless something else acts on the system
- [Amphere’s Law] The magnetic field is related to the change in electric field over time
- [Faraday’s Law] The electric field is related to the change in magnetic field over time

For our purposes, we only care about the last two: Amphere’s Law and Faraday’s Law. These relate the electric and magnetic fields as they change in time. Basically, they mean that whenever the electric field changes in one direction, the magnetic field must change in another direction, and any time the magnetic field changes in some direction, the electric field must change in another direction. Because of these laws, the electric and magnetic fields must always be perpendicular.

In the case of light, this means that the electric field may move up and down, while the magnetic field moves in and out and the light itself moves forward. In this way, light is a truly 3-dimensional object.

But how does this related to the whole ray vs wave argument? Well, the electromagnetic wave that is light moves forward, but is made of two diffferent waveforms. This means that when we look at light from a distance, it acts as a ray. We don’t even notice the fact that it is a wave hidden in disguise; however, if we start looking closer… all of a sudden we realize that there are some wave-like properties to deal with like diffraction. Now, to be clear: these wave-like phenomenon are only noticeable when the distance in which we are interacting with the light is comparable to the wavelength of the light.

I believe this is a decent enough introduction to light, so let’s talk about an abject that light often interacts with: lenses.

When we consider light as a ray, it interacts with a lens via Snell’s Law:

This equation basically relates the angle of a wave entering a lens with the angle of a wave within the lens, itself. In this case, *n* is something known as an “Index of Refraction,” which is basically a ratio of how dens a medium is when compared to the outside air. If we draw a line perpendicular to the surface of the lens, and assume that the lens is denser than the air outside of it, then the ray will bend towards that line as it enters the lens. If it leaves the lens, it will bend back to the angle it was before.

Now here’s an interesting thought: what if the index of refraction inside the lens was not constant, but instead changed as the light moved through it? Well, in principle the ray would be entering consecutive layers of new lenses. In this way, we could arbitrarily force the ray of light to draw structures for us… or we could do something else.

We could make the lens, itself, invisible!

How? Well, all we need to do is match the rays of light on one side of the lens with the rays of light on the other side of the lens. In this way, an observer would not even notice a difference when looking through the lens. Well, that’s not completely true. An astute observer might recognize a small time delay, but why would that matter? I mean, the delay would be related to the time it took for light to weave it’s way through the lens and light is the fastest thing in the known universe! Surely the time delay would be negligible!

Well, yes. When we consider light to be a ray, it is totally negligible; however, if we consider light to be a wave… we now need to make sure that the time delay perfectly aligns with the light such that the wavefronts do not look disturbed.

In order to really do this system justice, we need to simulate it twice, once with time-dependent ray-tracing and another with one of the most useful physics algorithms out there: Finite-Difference Time Domain (FDTD). That’s exactly what we are going to do!

Remember from our discussion before, the ray approximation of light is only valid when the distance in which we are interacting with the light is much, much greater than the wavelength of the light. In math-speak, this is:

MORE COMING SOON

The Finite Difference Time Domain (FDTD) method is one of the most useful computational methods in the field of electricity and magnetism (which is a pretty active field, if you know the right people). What is it? It’s basically a simulation of the Electric and Magnetic fields in a typical electromagnetic wave. How does it work? Well, that might be a little complicated to explain, so let’s start with something simple-ish: Maxwell’s Equations.

Again, for FDTD simulations we only care about Amphere’s Law and Faraday’s Law because we are trying to find a way to relate the electric and magnetic field in a wave. I mean, for this purpose, who cares if charge is conserved or if there are no such things as magnetic monopoles?

From this information, it would look like we have equations and we know what electromagnetic waves should look like, so that should mean that we are set to start our simulation, right?

Well… Not exactly. Computers do not think like we do, so we need to discretize Maxwell’s Equations. What does that mean? Well, it means that we need to take a continuous system (nature) and split it into a bunch of little blocks that a computer can understand.

But let’s take a minute to think about what we know:

- The electric field is dependent on the variance of the magnetic field with time
- the magnetic field is dependent on the variance of the electric field with time

Let’s constrain ourselves to 1 dimension for now and a row of points. Each point will correspond to the electric field at some point in space. With only this one line, we could enforce an electric field distribution by setting all the points to appropriate values and waving our hands in the air like we just don’t care; however, this distribution would be stuck, unmoving for all eternity. How do we get it to move?

Well, we introduce a string of magnetic field points exactly halfway between each electric field point. In this case, though, we do not assign the magnetic field values. Instead, we allow the magnetic field to be calculated from the electric field – where each individual magnetic field point is related to the average of the two nearest electric field points.

So now we have a bit of a situation. The magnetic field is going to change in the very next time step! This is super exciting because it means that the magnetic field is changing with time. What else happens when the magnetic field changes with time?

Right! The electric field also changes! Of course, this is an endless cycle, because the moment the electric field changes, the magnetic field will also change. And then the electric field will change again! In this way, we have simulated Maxwell’s equations in distritized time and space with an incredibly intuitive method.

Now, I know what you are thinking, “Let’s just plug in this newfangled FDTD nonsense to our index of refraction profile and move on with our lives!” The truth is that life is not that simple.

Just because we can simulate a 1 dimensional wave does not mean we can simulate a lens in 2 dimensions. We need to make a few modifications, some of which are easier than others:

- Extend the code to 2 dimensions
- Force the wave to move in 1 direction only
- Stop the wave from moving at some point.

Now, all of these seem like they should be simple, right? In fact, the first one is. It’s just a matter of keepign track of your new 2-dimensional array. The latter two, though… they can be a little tricky. They require the introduction of two new devices: the total-field scattered-field boundary and absorbing boundary conditions.

What is a Total-Field Scattered-Field (TFSF) boundary? Well, I am glad you asked! It is a boundary that splits your electromagnetic wave into two parts:

- Total field
- Scattered Field

It’s literally in the name. But what does this mean? It means that when we create a wave at some point, we can split the wave into two sections – one that goes right and one that goes left. If we keep one of the sides from propagating, we have a TFSF bounday! This means that the wave is only moving in 1 direction!

Why is that cool? Well, think about what we are doing right now. We are trying to simulate an invisible lens. How can we do that without having a wave that moves in a single direction: towards the lens.

Now let’s talk about our ABC’s!

So, we have a problem. When the wave hits the edge of a box, it bounces back. Why? Well, it’s still trying to solve Maxwell’s equations, right? This means that the magnetic field changes based on the electric field and the electric field changes based on the magnetic field. In this case, if the electric field gets stuck on a wall, our algorithm will just resolve Maxwell’s equations and send the wave back where it came from. This can lead to some interesting physics, but it might not be what you want all the time.

Let’s say we want to pretend our wave is ongoing for all eternity. In this case, we need to do something to our very last elements in our row (or grid in 2 dimensions). What do we need to do? Well, we need to set up a little trap. Sure, we’ll allow the electric and magnetic field to move to the very last grid poing, but when they do, we do something nasty:

We set the very last element to be the value of the second-to-last element (or the very first element to be the second).

What does this mean? Well, it means that there is no longer a difference between the two electric field points, which means there is no magnetic field… and without a magnetic field, the electric field can no longer exist!

This is, in essence, an ABC. Sure. It might not sound too menacing, but it can be depending on the rules you have layed out for yourself. For example, in 2 dimensions, this simple case of setting the two final elements equal to each other will not longer work because you could have the wave moving in a way that is not directly perpendicular to the edge. What a shame that would be. What do you do in that case? Well, that is exactly what we are trying to figure out right now!