Photonics

Photonics

Topics related to Lumerical and more

Script for group analysis and parameters

    • minusunny
      Subscriber

      Is there any reference to set parameters and add construction group using script?

    • Amrita Pati
      Ansys Employee

      Hello,

      Please refer to the following link and let me know if you have any questions:Structure Group.

      Regards,
      Amrita

    • minusunny
      Subscriber

      I tried this but it is giving me error the lines 45,46. 

    • Amrita Pati
      Ansys Employee

      Hello,

      Thanks for sharing more information. Would you be able to copy and paste the script (instead of screenshots) in your response? This would allow me to test the script much faster.

      Regards,
      Amrita

    • minusunny
      Subscriber
      addstructuregroup; adduserprop("coremat",5,"Si (Silicon) - Palik"); adduserprop("submat",5,"SiO2 (Glass) - Palik"); adduserprop("N_wg",0,60); adduserprop("W_1",2,6e-06); adduserprop("W_2",2,12e-06); adduserprop("wg_width",2,1.7e-06); adduserprop("T",2,0.22e-06); adduserprop("period",2,222e-09); adduserprop("dc",0,0.5); adduserprop("lambda",2,1.55e-06); simtime = 70000e-15; start = 0e-06; myscript = " for(i = 1:N) { stop = start + period; edge = stop - dc*period; addlen = (W_2-W_1)/N; addrect; set('name','seg_multimode'+num2str(i)); set('x max',stop); set('x min',edge); set('y',0); set('y span',W_1+addlen*i); set('z',0); set('z span',T); set('material',coremat); addtogroup('rect'); start = stop; } \n"; #myscript = myscript + "set(\"N"\",N);"; #myscript = myscript + "set(\"N_wg"\",N_wg);"; #myscript = myscript + "set(\"y span"\",W_1);"; #myscript = myscript + "set(\"W_2"\",W_2);"; myscript = myscript + "set(\"z span"\",T);"; myscript = myscript + "set(\"material"\",coremat);";
    • Amrita Pati
      Ansys Employee

      Hi,

      Thank you for sharing your code. Here is the modified version. Please let me know in case it does not work.

      addstructuregroup;

      adduserprop("coremat",5,"Si (Silicon) - Palik");

      adduserprop("submat",5,"SiO2 (Glass) - Palik");

      adduserprop("N_wg",0,60);

      adduserprop("W_1",2,6e-06);

      adduserprop("W_2",2,12e-06);

      adduserprop("wg_width",2,1.7e-06);

      adduserprop("T",2,0.22e-06);

      adduserprop("period",2,222e-09);

      adduserprop("dc",0,0.5);

      adduserprop("lambda",2,1.55e-06);

      simtime = 70000e-15; start = 0e-06;

       

      myscript = " for(i = 1:N)

      {

      stop = start + period;

      edge = stop - dc*period;

      addlen = (W_2-W_1)/N;

      addrect; set('name','seg_multimode'+num2str(i));

      set('x max',stop);

      set('x min',edge);

      set('y',0);

      set('y span',W_1+addlen*i);

      set('z',0);

      set('z span',T);

      set('material',coremat);

      addtogroup('rect'); start = stop; } \n";

       

       

      #myscript = myscript + "set(\"N"\",N);";

      #myscript = myscript + "set(\"N_wg"\",N_wg);";

      #myscript = myscript + "set(\"y span"\",W_1);";

      #myscript = myscript + "set(\"W_2"\",W_2);";

      myscript = myscript + "set(\"z span\",T);";

      myscript = myscript + "set(\"material\",coremat);";

       

       

      set('script',myscript);

      Regards,
      Amrita

    • minusunny
      Subscriber

      It didn't work unfortunately. It is setting up the properties as it did before, but not in the script part

       

    • Amrita Pati
      Ansys Employee

      That is a bit strange because I am able to set the script as well:

      Is the last line: set('script',myscript); executed successfully or is it throwing any error?

      Regards,
      Amrita

    • minusunny
      Subscriber

      N was not added as user property, now this is the error i am getting.

    • Amrita Pati
      Ansys Employee

      That is beacause you haven’t assigned any value to N before using it in the for loop. I also do not see N being input as a user property in the code.

      Regards,
      Amrita

       

    • minusunny
      Subscriber

      Yes I did.

       

    • minusunny
      Subscriber

      I figured it out. It was indentation error

Viewing 11 reply threads
  • You must be logged in to reply to this topic.