File:Cavity Mode Formation.gif

Summary

Description
English: If you put light in a cavity (even just two mirrors facing each other) it will diffract , and the part of it that hits the mirror will be reflected. After a few bounces it will settle into a stable pattern with minimal losses. Visualization obtained letting the (scalar) field diffract, then setting to zero everything that doesn't hit the mirror, and let the remaining field diffract again.
Date
Source https://twitter.com/j_bertolotti/status/1405117966539268103
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 12.0 code

\[Lambda] = 0.1;
k0 = (2 \[Pi])/\[Lambda] // N;
z = 10 \[Lambda];
dim = 2^10 + 1
mirrordim = 200;
mirror = BoxMatrix[mirrordim, dim];
U0 = mirror;
fU0 = RotateRight[InverseFourier[U0], {(dim - 1)/2, (dim - 1)/2}];

z = 100 \[Lambda];
H = Table[
   Chop[E^(I Sqrt[k0^2 - (kx - ((dim + 1)/2))^2 - (ky - ((dim + 1)/2))^2] z)], {kx, 1, dim}, {ky, 1, dim}];
U = U0;
fields = Reap[Table[
     U = U*mirror;
     U = Fourier[ RotateLeft[(RotateRight[ InverseFourier[U], {(dim - 1)/2, (dim - 1)/2}])*H, {(dim - 1)/2, (dim - 1)/2}] ];
     Sow[U];
     , {9}] ][[2, 1]];
fields = Prepend[fields, U0];

evo = Table[
   A0 = RotateRight[ InverseFourier[ fields[[j]]*mirror ], {(dim - 1)/2, (dim - 1)/2}];
   H = Table[
     Chop[E^(I Sqrt[k0^2 - (kx - ((dim + 1)/2))^2 - (ky - ((dim + 1)/2))^2] z)], {kx, 1, dim}, {ky, 1, dim}];
   U = Fourier[RotateLeft[A0*H, {(dim - 1)/2, (dim - 1)/2}] ];
   ArrayPlot[Abs[U]^2, ColorFunction -> Function[a, RGBColor[1, 0, 0, a]], Axes -> False, Frame -> False, ColorFunctionScaling -> True]
   , {j, 1, Evaluate@Dimensions[fields][[1]] }
   , {z, 0, 100 \[Lambda], 5 \[Lambda]}];

l = 2*mirrordim/dim // N;
nframes = Dimensions[evo][[2]]
frames = Table[
   Graphics3D[{Thick, 
     Line[{{-l, -1, -l}, {-l, -1, l}, {l, -1, l}, {l, -1, -l}, {-l, -1, -l}}], EdgeForm[], 
     Texture[evo[[k, j + 1]] ], 
     If[OddQ[k], Polygon[{{-1, (2 j)/(nframes - 1) - 1, -1}, {-1, (2 j)/(nframes - 1) - 1, 1}, {1, (2 j)/(nframes - 1) - 1, 1}, {1, (2 j)/(nframes - 1) - 1, -1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]
      , Polygon[{{-1, 1 - (2 j)/(nframes - 1), -1}, {-1, 1 - (2 j)/(nframes - 1), 1}, {1, 1 - (2 j)/(nframes - 1), 1}, {1, 1 - (2 j)/(nframes - 1), -1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]]
     , Line[{{-l, 1, -l}, {-l, 1, l}, {l, 1, l}, {l, 1, -l}, {-l, 1, -l}}]
     }, Lighting -> "Neutral", Boxed -> True, ImageSize -> Large]
   , {k, 1, Evaluate@Dimensions[fields][[1]] }
   , {j, 0, nframes - 1}];

ListAnimate[Join[Flatten@Table[{Table[frames[[j, 1]], 5], frames[[j]]}, {j, 1, Evaluate@Dimensions[fields][[1]]}] ]]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Cavity%20Mode%20Formation.gifCategory:Self-published work
Category:Animated GIF files Category:Optical cavity Category:Animations of diffraction Category:Images with Mathematica source code
Category:Animated GIF files Category:Animations of diffraction Category:CC-Zero Category:Images with Mathematica source code Category:Optical cavity Category:Self-published work