Photonics

Photonics

Topics related to Lumerical and more.

Lumerical optimization for multiple parameters

    • minusunny
      Subscriber

      Hi,

           I am trying to optimize multiple parameters using the PSO algorithm as given in the lumerical for a multimode interference device with four outputs.  Is there any other method to optimize multiple parameters, like using MATLAB?

       I tried to modify the script given on the website as an example:

      Grating coupler - Matlab-driven optimization (2D) – Ansys Optics  

      But have a doubt regarding the parameter optimization:

      I want to optimize the output at four ports, so what should i change here?

       

      Thank you

       

    • Amrita Pati
      Ansys Employee

      Hello,

      Lumerical uses PSO algorithm whereby it only optimizes a single objective function. So, you won't be able to optimize multiple results. There are a few approaches to how multi-objective optimization can be incorportated. I answered a similar post this morning, please refer to this for information: ALF Post on Optimization.

      Please let me know if you have any further questions.

      Regards,
      Amrita

    • minusunny
      Subscriber

      Is there any example for  the script to apply user defined figure of merit? How about the MATLAB part?

       

    • Amrita Pati
      Ansys Employee

      As far as I know there is no published example script. Also, it is hard to have a general script to create such a single objective function from multiple ones. How you frame the function would be very specific to the simulation you are looking at. And sometimes in my experience you might have to reformulate the function depending upon the how the optimization behaves. I will check internally to see if we have some examples.

      I will look into the MATLAB optimization and also see if there are any other options.

      Regards,
      Amrita

    • minusunny
      Subscriber

      That would be great., Thanks

    • minusunny
      Subscriber

      Hi, 

      I am trying to optimize with MATLAB with this example : https://optics.ansys.com/hc/en-us/articles/360042304834-Grating-coupler-Matlab-driven-optimization-2D-

      I am trying to extract the Transmission from the ports of FDTD. Is this the right way ? Do i need to use a transmission monitor separately for that?

    • Amrita Pati
      Ansys Employee

      Hi,

      Sorry I didn't get back to you earlier. I looked at a few optimization options on the Python end but didn't have time to look into MATLAB. 
      The answer to your question is no. The ports are a combination of Mode source, mode expansion monitor, and DFT monitor and returns the transmission "T" by default. So, you don't need to setup additional monitors.

      Regards,
      Amrita

    • minusunny
      Subscriber

      So, may i know how can i correct the code   given in the screenshot? Apparently, it is not reading the results from the ports and the program gets halted because of this?

    • Amrita Pati
      Ansys Employee

      Please copy and paste the code here. And also share a screenshot of the Lumerical objects tree with atleast one of the ports fully expanded.

      Regards,
      Amrita

    • minusunny
      Subscriber

       

      code=strcat('switchtolayout;',... 
      'groupscope("::model");',...
      'set("N",',num2str(N,16),');',...
      'set("W_2",',num2str(W2*1e-6,16),');',...
      'set("factor",',num2str(factor,16),');',...
      'for(0;layoutmode>0; 0) {run;}');
      appevalscript(h,code);

      %Get the coupled power from T monitor to
      %FDTD workspace as variable 'T_avg_FDTD'
      code=strcat(['T_1_FDTD=getresult("FDTD","ports","Out1,"T"");' ...
          'T_2_FDTD=getresult("FDTD","ports","Out2,"T"");' ...
          'T_3_FDTD=getresult("FDTD","ports","Out3,"T"");' ...
          'T_4_FDTD=getresult("FDTD","ports","Out4,"T"");']);
      appevalscript(h,code);

      %Get the average transmission(figure of merit) from FDTD workspace to
      %Matlab workspace
      T_MatlabFun_1=appgetvar(h,'T_1_FDTD');
      T_MatlabFun_2=appgetvar(h,'T_2_FDTD');
      T_MatlabFun_3=appgetvar(h,'T_3_FDTD');
      T_MatlabFun_4=appgetvar(h,'T_4_FDTD');

       

       

       

    • Amrita Pati
      Ansys Employee

      The syntax for getresult is incorrect. Try using this instead and let me know what hapens:

      code=strcat('T_1_FDTD=getresult("FDTD::ports::Out1","T");',...
          'T_2_FDTD=getresult("FDTD::ports::Out2","T");',...
          'T_3_FDTD=getresult("FDTD::ports::Out3","T");',...
          'T_4_FDTD=getresult("FDTD::ports::Out4","T");');

      Also, since I won't be able to test the whole script as I don't have the simulation file I recommend you to look at the syntax in the file "Coupler_Optimization_Main_Script.m' in the MATALB driven optimization link you shared earlier.

      Regards,
      Amrita

    • minusunny
      Subscriber

       

      That works.  Thank you. The extraction of results is showing some error

    • Amrita Pati
      Ansys Employee

      Can you look at the T results from all the ports (if you click on the ports one by one) on the Lumerical side? For. ex:

      Regards,
      Amrita

    • minusunny
      Subscriber

      The port reads the transmission, seems like the not able to assign it to the MATLAB variable

    • Amrita Pati
      Ansys Employee

      Does it mean you are not able to see the variables T_MatlabFun_1, T_MatlabFun_2, T_MatlabFun_3, and T_MatlabFun_4 in the MATLAB workspace?

      Regards,
      Amrita

Viewing 14 reply threads
  • The topic ‘Lumerical optimization for multiple parameters’ is closed to new replies.