This script command reruns a previous RCWA simulation with new layer interface positions. This computation can be performed quickly as the modes in the layers don't need to be recomputed, so this command is faster than using the rcwa command again. Similar to the EME propagation sweep, this command will extend or shrink the geometry inside each layer according to the specified layer interface positions.

The same results returned by the rcwa command are returned by this command as a function of the layer thickness. This command requires data provided by rcwa while the option `report_raw_data`

is set to `true`

, so the rcwa command must be run once before running this command.

Syntax | Description |
---|---|

Result = rcwasweeppropagation (rawdata, interface_positions) |
Returns the results of the RCWA simulation as a function of the layer interface positions. The The The |

Result = rcwasweeppropagation (rawdata, interface_positions, options) |
The additional argument, `options` , is the same as the `options` argument of the rcwa command. It replaces the `options` struct used by the RCWA simulation used to obtain the `rawdata` for the new simulation. |

## Example

This example will run an RCWA simulation, rerun the simulation with new layer interface positions.

a = 1e-6;

# set RCWA solver properties

geometry = struct;

geometry.injection_axis = "z-axis";

geometry.x_min = -a/2;

geometry.x_max = a/2;

geometry.y_min = -a/2;

geometry.y_max = a/2;

geometry.z_min = -a/2;

geometry.z_max = a/2;

geometry.layer_positions = [-a/4,a/4];

excitation = struct;

excitation.f =0.5*c/a;

excitation.phi = 0;

excitation.theta = 15;

options={"max_N":10 , "report_raw_data":true};

# create geometry

addrect;

set("x min",geometry.x_min);

set("x max",geometry.x_max );

set("y min",geometry.y_min);

set("y max",geometry.y_max);

set("z min",geometry.layer_positions(1));

set("z max",geometry.layer_positions(2));

set("index",sqrt(12));

addcircle;

set("z min",geometry.layer_positions(1));

set("z max",geometry.layer_positions(2));

set("radius",0.2*a);

set("index",1);

# add FDTD solver region

addfdtd;

set("x min",geometry.x_min);

set("x max",geometry.x_max);

set("y min",geometry.y_min);

set("y max",geometry.y_max);

set("z min",geometry.z_min);

set("z max",geometry.z_max);

# run RCWA solver and plot results

result = rcwa(geometry, excitation, options);

TE = result.TotalEnergy;

plot(excitation.f,TE.Rs,TE.Ts,TE.Rp,TE.Tp,"frequency (Hz)","Power", "layer_positions = [-a/4,a/4]");

legend("Rs","Ts","Rp","Tp");

# run rcwasweeppropagation

rawdata=result.raw_data; # get rawdata from rcwa script

interface_positions = [-a/3,a/3];

options2={"report_total_energy":true};

results_rcwasweep = rcwasweeppropagation (rawdata, interface_positions, options2);

TE_sweep = results_rcwasweep.TotalEnergy;

plot(excitation.f,TE_sweep.Rs,TE_sweep.Ts,TE_sweep.Rp,TE_sweep.Tp,"frequency (Hz)","Power", "layer_positions = [-a/3,a/3]");

legend("Rs","Ts","Rp","Tp");