## Total Internal Reflection in a Prism - iFDTD Tutorial

In this second tutorial we will show how to define a refractive index profile $$n\left(\mathbf{r}\right)$$ within the interactive FDTD toolbox. We will simulate the total internal reflection in a glass prism using a Gaussian shaped beam.

After we got to know the general handling of the iFDTD toolbox in the first tutorial, we advance now to interesting physics. Introducing a simple refractive index profile in the form of a prism will allow us to illustrates a lot of interesting electromagnetic effects like the Goos-Hänchen shift, evanescent coupling or simply the diffraction of a Gaussian beam with ease.

Before we can do anything, we have to start the toolbox in MATLAB executing "interactiveFDTD" in the folder of the iFDTD. Now we have to set the simulation parameters in the first popup.

After confirmation, click on "Define Refractive Index Profile" to define a dielectric structure - in our case a prism. Now a "structure" window appears and we can set different parameters:

$$\epsilon$$ and $$\mu$$ - Structure: set the relative permitivity and permeability of the structure.
Softened Structure: You can force a soft onset of the refractive index profile - 1 for yes and 0 for no.
Structure: which type of structure - there are 4 options you can choose from: three standard forms like a rectangular, circular or polygonic structure. Moreover, you can define a photonic crystal. If you choose photonic crystal, a second dialog will pop up where you can define the sizes of your primitive cell and the sizes of your included structure which we will discuss in the third tutorial.

To define the glass prism we have chosen a "Polygonic Structure" in the dialog. The structure is set by clicking at the positions where a polygon edge is desired. To close the polygon, the last point has to be identical with the first one. First set the polygon and confirm:

Defining the prism as a polygon (above). After confirmation, it should look like this:

In the next step we want to define the Gaussian shaped source. Therefore we click on "New Source" and the corresponding dialogue opens.

Now we have to confirm the setting and place the source in the computational domain. Let us put close to the right boundary.

Now we have everything ready to run the simulation. The only thing left to do is to set the visualization parameters. We do so by clicking on "Start Simulation". A new window opens and we can observe the field evolution. Since we have defined a quite fine grid we achieve a high accuracy, but the evolution will take a little bit more time. In the simulation we can observe several interesting optical phenomena like frustrated total internal reflection with the creation of evanescent waves at the glass-air interface. We also observe the diffraction of the beam if we compare the size of the beam entering and outgoing of the prism. Last but not least we see the partially reflection and refraction of light at the interfaces confirming snell's law. And since it's so easy, here is the video output of the situation:

Total internal reflection inside a prism. Direct movie output from the iFDTD simulation.