Photonics

Photonics

Programmatically selecting Frequency Monitor for Mode Expansion Monitor

    • Mateus Corato Zanarella
      Subscriber

      Hi,
      I cannot figure out how to programatically add a frequency monitor to an existing mode expansion monitor. This is particularly problematic when creating the mode expansion monitor using a construction script in model, because then we cannot manually alter the expansion monitor.
      Could someone please tell me how to do it?
      Thanks,
      Mateus

    • Amrita Pati
      Ansys Employee

      Hi Mateus,


      You can use the setexpansion script command to select a DFT monitor for expansion. For example, if the name of the DFT monitor is "dft", then you can use the following code:

      setexpansion("out","::model::dft");

      Please let me know if you have any further questions.

       

      Regards,
      Amrita

    • Mateus Corato Zanarella
      Subscriber

      Thank you for your answer, Amrita! That command worked.
      I have another question: now once the simulation is done and I want to calculate the expansion results to then grab them using getresult, how can I do it programmatically? Manually I can do it by right-clicking, but I'd like to to it programmatically in a loop. 
      Thanks again for your help!

    • Amrita Pati
      Ansys Employee

      Hi Mateus,

      You are welcome!

      Generally, if you have a mode expansion monitor called "Exp" and the expansion results are "out" then you use the following code:

      out = getresult("Exp","expansion for out");

      But if you are using loop, it could be a bit tricky since the expansion results are a dataset. I believe the simplest approach would be to save the individual results of the output (expansion results) in different arrays. And if you wish, you can combine these results to form a dataset after the loop ends.

      For example, if I am only interested in T_forward and T_backward results for 2 iterations and the data is collected at a single wavelength then I can use the following code:

      clear;

      T_forward = matrix(2);

      T_backward = matrix(2);

      for(i = 1:1:2){

      switchtolayout;
      run;

      out = getresult("Exp","expansion for out");

      T_forward(i) = out.T_forward;

      T_backward(i) = out.T_backward;

      }

       

      Here, I just have 2 reptitions and a single wavelength, which is why I initialize T_forward and T_backward as matrix(2).

      I believe you can also use the sweep utility instead of the loop. The sweep utility automatically reconstructs dataset so you can easily access all the results at one place. Please let me know if you have any further questions.

       

      Regards,

      Amrita

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