MEEP modelling: Square Cavity – Part 2

Posted on Tue 25 July 2017 in MEEP

If we inspect the output from meep that we saved in file square.ctl:

-----------
Initializing structure...
Working in 2D dimensions.
Computational cell is 1 x 1 x 0 with resolution 21
     block, center = (0,0,0)
          size (1,1,1e-20)
          axes (1,0,0), (0,1,0), (0,0,1)
          dielectric constant epsilon diagonal = (1,1,1)
time for set_epsilon = 0.00246215 s
-----------
Meep progress: 1265.7857142857142/2005.0 = 63.1% done in 4.0s, 2.3s to go
on time step 53163 (time=1265.79), 7.52429e-05 s/step
harminv0:, frequency, imag. freq., Q, |amp|, amplitude, error
harminv0:, 0.49965027602074025, 6.962901950688442e-8, -3587945.6551254354, 0.07777794402701167, 0.0024368236485488148+0.07773976117518522i, 2.1971119199697203e-8+0.0i
harminv0:, 0.7067768851898223, -7.597594046763396e-8, 4651320.410379862, 0.03547170560103376, -0.00560172786233135-0.03502659765382288i, 1.6310167415083462e-8+0.0i
harminv0:, 0.997198615390459, -2.2874161068410783e-8, 21797490.46113849, 0.30571523921562116, 0.30557359296981657-0.009305201135996685i, 4.379556711147102e-9+0.0i
harminv0:, 1.1157886868016782, -7.198145589973213e-9, 77505287.4976533, 0.18504732775678, -0.06019929248036505-0.17498159530301646i, 2.0145105671454234e-9+0.0i
harminv0:, 1.4115657086248123, 9.691822540596569e-8, -7282251.107632874, 0.09323703957434044, 0.08941825563599501-0.02641062489989536i, 1.2346770754915476e-8+0.0i
harminv0:, 1.490528739827691, 1.4909785346550363e-7, -4998491.611995442, 0.04358290725731711, 0.001576775048424593-0.043554375043691876i, 2.8521991089171737e-8+0.0i
harminv0:, 1.572707606509909, -8.635811826769853e-8, 9105731.100084461, 0.03510133186423594, -0.03341229909079056-0.01075740526850139i, 1.1398999164323018e-8+0.0i
harminv0:, 1.7956590548227003, 2.713483475275414e-7, -3308770.941824962, 0.0173063963599404, 0.017267776387618082-0.0011555317367245932i, 3.265935897573454e-8+0.0i
harminv0:, 1.9774955614133072, -3.2803139027426844e-7, 3014186.4773366884, 0.01085226263124576, -0.010634565235754036-0.002162782112008712i, 9.627394698484882e-8+0.0i
run 0 finished at t = 2005.0 (84210 timesteps)

Elapsed run time = 12.9194 s

we see that some resonant frequencies have been generated (look for lines beginning with harminv0) Let's extract the frequencies with the unix command grep harminv0 square.out | sed 's/,//g' | gawk '{printf "%.4f\n", $2}', which looks for lines containing the text harminv, removes commas and then takes the second column and prints the value to 4 decimal places:

0.4997
0.7068
0.9972
1.1158
1.4116
1.4905
1.5727
1.7957
1.9775

We ignore the first entry 0.000 since it is the result of printing the second column of the legend harminv0:, frequency, imag. freq., Q, |amp|, amplitude, error. Due to the simple geometry we can also calculate the frequency of the modes analytically using the expression

$$ f = \tfrac{1}{2} \sqrt{n_x^2 + n_y^2} $$

where \(n_x\) and \(n_y\) are the number of half-waves in the \(x\) and \(y\) directions. This can be derived from the wavenumber \(k^2 = k_x^2 + k_y^2 = \pi^2(n_x^2+n_y^2)\) and \(f = \omega/2\pi = ck/2\pi\). Since \(c=1\) in meep, then

$$ f = \frac{ck}{2\pi} = \frac{\pi\sqrt{n_x^2+n_y^2}}{2\pi} = \tfrac{1}{2} \sqrt{n_x^2 + n_y^2} $$
meep \(n_x\) \(n_y\) \(f\) \(f\) \(\Delta f\)
0.4996 0 1 \(\tfrac{1}{2}\sqrt{0^2 + 1^2} = \tfrac{1}{2}\) 0.500 0.0004
0.7068 1 1 \(\tfrac{1}{2}\sqrt{1^2 + 1^2} = \tfrac{\sqrt{2}}{2}\) 0.707 0.0002
0.9972 0 2 \(\tfrac{1}{2}\sqrt{0^2 + 2^2} = 1\) 1.000 0.0028
1.1158 1 2 \(\tfrac{1}{2}\sqrt{1^2 + 2^2} = \tfrac{\sqrt{5}}{2}\) 1.118 0.0022
1.4116 2 2 \(\tfrac{1}{2}\sqrt{2^2 + 2^2} = \sqrt{2}\) 1.414 0.0024
1.4905 0 3 \(\tfrac{1}{2}\sqrt{0^2 + 3^2} = \tfrac{3}{2}\) 1.500 0.0095
1.5727 1 3 \(\tfrac{1}{2}\sqrt{1^2 + 3^2} = \tfrac{\sqrt{10}}{2}\) 1.581 0.0083
1.7957 2 3 \(\tfrac{1}{2}\sqrt{2^2 + 3^2} = \tfrac{\sqrt{13}}{2}\) 1.803 0.0073
1.9775 0 4 \(\tfrac{1}{2}\sqrt{0^2 + 4^2} = 2\) 2.000 0.0225

If we set the excitation to \(E_z\) then we do not excite as many modes. This is because the boundary conditions do not permit either \(n_x = 0\) or \(n_y\) = 0.

meep \(n_x\) \(n_y\) \(f\) \(f\) \(\Delta f\)
0.7068 1 1 \(\tfrac{1}{2}\sqrt{1^2 + 1^2} = \tfrac{\sqrt{2}}{2}\) 0.707 0.0002
1.1158 1,2 2,1 \(\tfrac{1}{2}\sqrt{1^2 + 2^2} = \tfrac{\sqrt{5}}{2}\) 1.118 0.0022
1.4116 2 2 \(\tfrac{1}{2}\sqrt{2^2 + 2^2} = \sqrt{2}\) 1.414 0.0024
1.5727 1,3 3,1 \(\tfrac{1}{2}\sqrt{1^2 + 3^2} = \tfrac{\sqrt{10}}{2}\) 1.581 0.0083
1.7957 2,3 3,2 \(\tfrac{1}{2}\sqrt{2^2 + 3^2} = \tfrac{\sqrt{13}}{2}\) 1.803 0.0073