This section describes how to create and run a nested parameter sweep. We will demonstrate how to do this by finding the incident angle that results in minimum reflection from a 50 nm silver film on glass for 3 different wavelengths (for a more detailed description of this example, see Surface Plasmon Resonance 2D).
Creating the nested parameter sweep project
In the Optimization and Sweeps window, click the Add Sweep button to create a new parameter sweep task (see Parameter sweeps). Once the sweep is added, right click on the new sweep project and select Insert Parameter Sweep.
A nested parameter sweep will be created as a result. Open the edit window for the inner sweep object, change the name to "theta", add a parameter "source_angle" and browse the parameter pulldown menu to select the "angle" property of the source. Set the Start/Stop values to sweep from 40 to 60 degrees, and the Number of points 20. Finally, add a result "R" from the reflection analysis group (see Creating parameter sweep for step-by-step details). The edit window should look like the screenshot below.
In the edit window for the outer sweep, change the name to "wavelength", add a parameter "lambda" and browse the parameter pull down menu to select the "wavelength" property of the source. Set the Start/Stop values to sweep from 0.4 to 0.6 microns in 3 points. Add a result "R" and select R from the Result pull down menu, which contains all the results in the inner sweep that are already defined.
Running the nested parameter sweep
The nested parameter sweep can be run in the same manner as a single parameter sweep, as described in Parameter sweeps.
Viewing the results
Just like single parameter sweeps, the data from a nested parameter sweep can also be retrieved using getsweepresults. The following commands can be used to plot the data. It is also possible to plot this data with the visualizer.
reflection = getsweepresult("wavelength", "R");
R = -reflection.T;
lambda = reflection.lambda_sweep*1e9;
plot(reflection.source_angle, pinch(R,2,1), pinch(R,2,2), pinch(R,2,3),
"angle of incidence (degrees)","Reflection","Reflection vs angle");
legend('lambda = ' + num2str(lambda(1)),
'lambda = ' + num2str(lambda(2)),
'lambda = ' + num2str(lambda(3)));
We can see that shorter wavelengths correspond to larger incident angles where minimum reflection is obtained.
Note: Optimizations with nested sweeps This example file also contains an optimization task with a nested sweep. The optimization task is setup to find the optimal thickness of silver to minimize the reflected power for illumination by 500 nm light at angles between 45 and 50 degrees. The nested sweep is used to calculate the average reflection for angles between 45 and 50 degrees for each design (ie. thickness) in the optimization. |