-
-
December 5, 2023 at 12:51 amcrumbergerSubscriber
I am attempting to recreate the Lumerical RCWA portion of the small metalens tutorial using only Lumerical scripting rather than starting from the pre-built .fsp example file. When scripting Lumerical, I am having trouble with the command:
addrcwa;
Yet, this command appears in the online knowledge base here.Â
If I choose to use the command "addfdtd;" instead of "addrcwa;" the line executes, but I get an error further down the script when using the command:
addsweepresult("thickness_sweep_script", result_1);This seems strange to me because the code worked last week without errors when using the "addfdtd;" command.
A couple of notes:
1) I initially built this script with FDTD in mind but decided to try switching to RCWA since that is what appears in the online tutorial linked above. I realize that I may need to change some parts of my code accordingly. However, "addrcwa;" fails even when run as a lone command in the command window.
2) The screenshots above show the problematic lines being run alone in the command window. The errors are identical when running the full code. Only the line number in the error message changesI have included my code below. (I am still trying to work out how best to add sweeps and collect the results to get the phase response info, but that's another topic.) Thanks in advance for any advice!
SCRIPT:Âdeleteall;if(exist("cylinder_height_sweep")) {deletesweep("cylinder_height_sweep");}if(exist("cylinder_radius_sweep")) {deletesweep("cylinder_radius_sweep");}### VARIABLES #### Constants and Unitsnm = 1e-9;um = 1e-6;# Nanopillarheight_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";# Substrateperiod = 400*nm;thick_sub = 100*nm;material_sub = "SiO2 (Glass) - Palik";# FDTDlda_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 Nanopillaraddcircle;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);Â# Substrateaddrect;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 = 3Dset("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. customset("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 Regionaddmesh;set("dx",10*nm);set("dy",10*nm);set("dz",10*nm);set("based on a structure",true);set("structure","circle");Â### Sourceaddplane;set("injection axis","z");set("x",0);set("x span",period);set("y",0);set("y span",period);set("z",zmin_cell);# If Frequency Domainset("wavelength start",lda_min);set("wavelength stop",lda_max);# Else if Time Domainset("set time domain",true);Â### Monitoraddpower;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 heightpara_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 resultsresult_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 sweepaddsweepresult("thickness_sweep_script", result_1);addsweepresult("thickness_sweep_script", result_2);Â# create parameter sweep "radius"addsweep;setsweep("sweep","name","cylinder_radius_sweep");# define the parameter radiuspara_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 sweepaddsweepparameter("cylinder_height_sweep", para_r);# define resultsresult_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 sweepaddsweepresult("thickness_sweep_script", result_1);addsweepresult("thickness_sweep_script", result_2);Â
-
December 5, 2023 at 2:33 pmDimitris PolyzosAnsys Employee
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);
-
December 6, 2023 at 12:31 am
-
December 6, 2023 at 7:37 amDimitris PolyzosAnsys Employee
-
December 7, 2023 at 12:53 amcrumbergerSubscriber
Thanks for trying to help me with this. I see that I also cannot find an option to add an RCWA solver region under the Simulation button on the toolbar. I have just contacted someone on the server admin side to see if our organizational license is somehow set up with access to the FDTD solver but not the RCWA solver (not even sure if that's possible, but it could explain the issue if so).
Thanks again,
Charles
-
- The topic ‘Troubleshooting a couple of errors in Lumerical scripting’ is closed to new replies.
- Difference between answers in version 2024 and 2017 lumerical mode solution
- Errors Running Ring Modulator Example on Cluster
- INTERCONNECT – No results unless rerun simulation until it gives any
- Import material .txt file with script
- Help for qINTERCONNECT
- Trapezoidal ring
- Issues with getting result from interconnent analysis script
- Topology Optimization Error
- Edge Coupler EME Example Issue
- How to measure transmission coefficients on a given plane .
-
1231
-
543
-
523
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.