Ansys Learning Forum Forums Discuss Simulation Photonics Shifting structure along z-axis by scripting Reply To: Shifting structure along z-axis by scripting

Guilin Sun
Ansys Employee
If you are sweeping the structure, the best way is to layer the structure. suppose you have thickness parameters d1,d2,d3, and begins from z0, then you know that
for layer 1, zmin1=z0, zmax1=zmin1+d1;
for layer 2, zmin2=zmax1,zmax2=zmin2+d2
for layer 3, zmin3=zmax2, zmax3=amin3+d3
therefore, you can use "setnamed" to set their parameters:
setnamed("layer1","z min",zmin1);
setnamed("layer1","z max"zmax1)
setnamed("layer2","z min",zmin2);
setnamed("layer2","z max"zmax2);
setnamed("layer3","z min",zmin3);
setnamed("layer3","z max"zmax3);

So what you need to define is d1,d2,and d3 in structure group, and then you can sweep di so the structure will change automatically since the thicknesses are built-in for the layers. You can do a simple test by sweep 2 points.
In this way, you can simultaneously sweep all of them, or nested sweep them without any issue.
If the script is broken, you will need to check what line it breaks and what is the cause, for example by use questions mark:
?d1;
?zmax2
etc to find which is wrong .

If you want to break the script, you should be able to use "break". break - Script command