Ansys Learning Forum › Forums › Discuss Simulation › Photonics › Troubleshooting a couple of errors in Lumerical scripting › Reply To: Troubleshooting a couple of errors in Lumerical scripting
Hello,Â
Regarding the addrcwa; command it runs OK on my PC. Could you please let me know what version of Lumerical do you use? In the script you shared, I commented the addfdtd; command line and uncommented the addrcwa; and it works fine.
It seems that your script needs a slight modification in order to work. After loading it in script file editor please change at line 120 and 121.
addsweepresult("cylinder_height_sweep", result_1);
addsweepresult("cylinder_height_sweep", result_2);
Similarly do the same for lines 146Â and 147 for the name :
addsweepresult("cylinder_radius_sweep", result_1);
addsweepresult("cylinder_radius_sweep", result_2);
Otherwise, you can use the corrected script directly below:
deleteall;
if(exist("cylinder_height_sweep")) {deletesweep("cylinder_height_sweep");}
if(exist("cylinder_radius_sweep")) {deletesweep("cylinder_radius_sweep");}
### VARIABLES ###
# Constants and Units
nm = 1e-9;
um = 1e-6;
# Nanopillar
height_np_min = 600*nm;
height_np_max = 1.2*um;
radius_np_min = 75*nm;
radius_np_max = 125*nm;
material_np = "Si (Silicon) - Palik";
# Substrate
period = 400*nm;
thick_sub = 100*nm;
material_sub = "SiO2 (Glass) - Palik";
# FDTD
lda_min = 400*nm;
lda_max = 800*nm;
airgap = lda_max/2;
#height_cell = height_np_max+thick_sub+2*airgap;
zmin_cell = -1*(thick_sub + airgap);
zmax_cell = height_np_max + airgap;
Â
# Cylindrical Nanopillar
addcircle;
set("x",0);
set("y",0);
set("radius",radius_np_min);
set("z min",0);
set("z max",height_np_min);
set("material",material_np);
Â
# Substrate
addrect;
set("x",0);
set("x span",period);
set("y",0);
set("y span",period);
set("z min",-1*thick_sub);
set("z max",0);
set("material",material_sub);
Â
# FDTD Region
addrcwa;
#addfdtd;
set("dimension",2); # 1 = 2D, 2 = 3D
set("x",0);
set("x span",period);
set("y",0);
set("y span",period);
set("z min",zmin_cell);
set("z max",zmax_cell);
set("x min bc","Periodic");
set("y min bc","Periodic");
set("pml profile",3); # 1. standard, 2. stabilized
# 3. steep angle, 4. custom
set("allow symmetry on all boundaries",true);
set("set simulation bandwidth",true);
set("simulation wavelength min",lda_min);
set("simulation wavelength max",lda_max);
set("always use complex fields",true);
Â
### Mesh Override Region
addmesh;
set("dx",10*nm);
set("dy",10*nm);
set("dz",10*nm);
set("based on a structure",true);
set("structure","circle");
Â
### Source
addplane;
set("injection axis","z");
set("x",0);
set("x span",period);
set("y",0);
set("y span",period);
set("z",zmin_cell);
# If Frequency Domain
set("wavelength start",lda_min);
set("wavelength stop",lda_max);
# Else if Time Domain
set("set time domain",true);
Â
### Monitor
addpower;
set("name","Transmission");
set("monitor type","2D Z-normal");
set("x",0);
set("x span",period);
set("y",0);
set("y span",period);
set("z",zmax_cell-airgap/2);
Â
### Parameter Sweep
# create parameter sweep "height"
addsweep;
setsweep("sweep", "name", "cylinder_height_sweep");
setsweep("cylinder_height_sweep", "type", "Ranges");
setsweep("cylinder_height_sweep", "number of points", 10);
# define the parameter height
para_h = struct;
para_h.Name = "height";
para_h.Parameter = "::model::height";
para_h.Type = "Length";
para_h.Start = height_np_min;
para_h.Stop = height_np_max;
para_h.Units = "microns";
addsweepparameter("cylinder_height_sweep", para_h);
# define results
result_1 = struct;
result_1.Name = "S";
result_1.Result = "S";
result_2 = struct;
result_2.Name = "T";
result_2.Result = "T";
# add the results R & T to the sweep
addsweepresult("cylinder_height_sweep", result_1);
addsweepresult("cylinder_height_sweep", result_2);
Â
# create parameter sweep "radius"
addsweep;
setsweep("sweep","name","cylinder_radius_sweep");
# define the parameter radius
para_r = struct;
para_r.Name = "radius";
para_r.Parameter = "::model::radius";
para_r.Type = "Length";
para_r.Start = radius_np_min;
para_r.Stop = radius_np_max;
para_r.Units = "microns";
# add the parameters to the sweep
addsweepparameter("cylinder_radius_sweep", para_r);
# define results
result_1 = struct;
result_1.Name = "R";
result_1.Result = "::model::R::T";
Â
result_2 = struct;
result_2.Name = "T";
result_2.Result = "::model::T::T";
Â
# add the results R & T to the sweep
addsweepresult("cylinder_radius_sweep", result_1);
addsweepresult("cylinder_radius_sweep", result_2);