This page describes how to create single frequency (CW, steady state) movies of a simulation, as opposed to the broadband time domain movies from created by Movie monitors. The field data for a CW movie can be obtained from a frequency monitor.
This example uses MATLAB (the movie2avi function) to create the CW movie because Lumerical's software does not provide a 'create movie' script function. If you don't have MATLAB, see the Tip at the end of page for an alternate solution.
Step 1: Copy the 'CW movie with MATLAB' analysis object into your simulation
After the simulation has been run, set the wavelength of interest in the CW movie object, then run the analysis script. Running the analysis script will export the appropriate data to a .mat file.
setnamed("CW movie with MATLAB","wavelength",1.52e-6);
runanalysis("CW movie with MATLAB");
Step 2: Generate the movie file with MATLAB
Open MATLAB, and run usr_cw_movie_matlab.m. This will load the data into Matlab and generate the AVI movies seen below (converted to Flash).
The real valued, instantaneous steady state field profiles are obtained by multiplying the complex field data from the monitor by an appropriate phase, then taking the real part. By repeating this process for phase values between 0 and 2Pi, we can see how the fields oscillate over an optical cycle. Finally, we create a structure outline on the figure with the contour function and index monitor data. See usr_cw_movie_matlab.m for more details. The following videos show the steady state fields real(Ey(w)) and |E(w)|^2 at the drop frequency.
For comparison, the movies created by the standard Movie monitors in the simulation are shown below. These movies show how the fields evolve during the actual FDTD simulation, including the initial broadband source pulse and all transients that occur as the field propagate through the simulation volume. These movies are inherently broadband. You can see that some fields leave the simulation through the Through channel and some leaves through the Drop channel.
Note: Matlab imaging conventions
Note that in the Matlab m-file, usr_cw_movie_matlab.m, we must:
1) apply an unconjugated transpose operation followed by a flip up-down operation to the matrix containing the field data
2) interpolate the data from FDTD onto a uniform grid
The first step is necessary to get the orientation correct (the image() command in FDTD interprets rows and columns differently than the imagesc() command in MATLAB). The second step is necessary because the imagesc() command in MATLAB assumes that matrix data is uniformly sampled, even when you provide the x,y position vectors. See the Matlab->Tips section for more information.
TIP: Creating a CW movie without MATLAB
To create a CW movie without MATLAB, use the 'CW movie with FDTD' analysis object. It is similar to the Matlab technique, but without the final functions to output the results as an avi movie. Instead, the movie frames exported to a series of numbered jpg image files.
This is not as convenient as a proper movie file, but there are many programs available that convert jpeg files to movies. Alternatively, placing the images in a folder and scrolling through them with an image viewing program will give a good idea of what the movie would look like.
TIP: Movies of the Poynting vector as a function of time
The technique described on this page to create CW movies of the electric (or magnetic) fields can not be directly applied to the Poynting vector, since the Poynting vector data recorded by the frequency monitors is the time averaged value. For this reason, it is not correct to define P(t) as P(t) = exp(i*phase)*P(w). Instead, it is necessary to first calculate E(t)=exp(i*phase)*E(w) and Ht)=exp(i*phase)*H(w), then calculate the cross product: P(t) = E(t) X H(t).
TIP:Using other data visualization functions
The above examples use the imagesc function to plot the field data. It is equally possible other data visualization functions. For example, the third movie created by the example file uses the quiver3 function to create an animated vector plot.
It is worth noting that the X and Y span of this video is much smaller than the other videos. Rather than showing the entire ring resonator, this video shows a small region around the injection plane of the source. It is certainly possible to create a vector movie of the entire simulation region, but some additional processing of the field data will be required. For example, it may be necessary to plot the data on a coarser mesh, to reduce the number of vector arrows drawn. Plotting the Poynting vector, rather the the electric field, is also likely to result in a more intuitive looking movie.