How to get the field distribution in S4

In this tutorial, we will calculate the field distribution for a photonic crystal slab, which consists of equally sized alternating regions of high index material (ɛ=12) and air, with lattice constant . The thickness of this slab is 0.5a.

The structure of the simulated photonic crystal slab and the mode profile at ω=0.64×2πc/a is shown below.

Figure 1. Mode profile of the 1D photonic crystal slab system which consists of an array of high index rods (ɛ=12) surrounded by air.

The Lua script for this case is shown below and can be downloaded here.

Run Example
S = S4.NewSimulation()
S:SetLattice({1,0}, {0,0})
--since the structure is uniform along the direction into the paper,
--we can reduce the 3D problem to a 2D problem
-- Material definition
S:AddMaterial("Silicon", {12,0}) -- real and imag parts
S:AddMaterial("Vacuum", {1,0})
'AirAbove', --name
0, --thickness
'Vacuum') --background material
S:AddLayer('Slab', 0.5, 'Vacuum')
S:SetLayerPatternRectangle('Slab', -- which layer to alter
'Silicon', -- material in rectangle
{0,0}, -- center
0, -- tilt angle (degrees)
{0.25, 0.5}) -- half-widths
S:AddLayerCopy('AirBelow', -- new layer name
0, -- thickness
'AirAbove') -- layer to copy
-- E polarized along the grating "rods"
{0,0}, -- incidence angles (spherical coordinates: phi in [0,180], theta in [0,360])
{1,0}, -- s-polarization amplitude and phase (in degrees)
{0,0}) -- p-polarization amplitude and phase
for x=-0.5,3.5,0.02 do
for z=0,1.5,0.02 do
Ex,Ey,Ez = S:GetEField({x,0,z}) –get filed profile