Photonics

Photonics

Topics related to Lumerical and more.

Can’t add frequency domain field profile into structure group using script

    • Joshua Worrall
      Subscriber

      I'm trying to add a frequency domain field profile to a structure group using the addprofile; command, however I get the following error when testing:

      Error: prompt line 99: addprofile is not a valid function or variable name

      I've tried adding other simulation monitors and they don't seem to work either, does any have any advice on how to fix this? Have I missed a step in order to be able to add monitors within a script?

      I'm using Lumerical 2023 R2.1 Mode

    • Dev
      Ansys Employee

      Hello, Can you share the whole script? 

      For me, addprofile command is working fine and there is no error.. 

      Note: addprofile only works for Mode and FDTD. addprofile - Script command – Ansys Optics

      Regards

      Devika

      • Joshua Worrall
        Subscriber

        Hi Devika,

        I've added a copy of the script along with an image of the parameters I've set in the structure group below. I've also attached an image of the produced structure.

        The script is just a modified version of the included script to produce a photonic crystal with a square lattice. I've added extra functionality to add input and output waveguides and change the structure of the crystal. Now I want to add a frequency domain field profile to the output waveguide. I've used the example script for the "addprofile" command but it seems to be not valid in my case. 

        I'm new to scripting in Lumerical Mode so please let me know if I've missed anything thank you.

        deleteall;
        ####################################################
        # Rectangular lattice PC array
        # A periodic array of photonic crystals in a rectangular lattice.
        #
        # Input properties
        # z span: height of crystals
        # nx, ny: the number of columns and rows
        # a: lattice constant
        # index: index of refraction
        # material
        # alength, blength, ylength: length of input and output waveguides
        #
        # Tags: square rectangular lattice pc photonic crystal array
        #
        # Copyright 2012 Lumerical Solutions Inc
        #####################################################

        # simplify variable names by removing spaces
        z_span = %z span%;
        n_rows = ny-1;
        n_cols = nx-1;
        even_flag = 0;
        radius1 = 0.36*a;
        radius2 = 0.24*a;

        for(i=-n_rows/2:n_rows/2) {
          for(j=-n_cols/2:n_cols/2) {
              if( (j<=i+nx/2) and (-j>=i-nx/2) and ((-round(j+2) != round(i)) or (j <= -1 and j >= -4))) {
                 addcircle;    
                 set("radius",radius1);
                 set("x",(j)*a);
                 set("y",(i)*a);  
                 set("z span",z_span);
                 set("material",material);
                 if(get("material")=="")
                 { set("index",index); }
              }
              else if((i != 5 or j <= -5) and (i != -5 or j <= 3)){
                 addcircle;    
                 set("radius",radius2);
                 set("x",(j)*a);
                 set("y",(i)*a);  
                 set("z span",z_span);
                 set("material",material);
                 if(get("material")=="")
                 { set("index",index); }
              }
          }
        }

        # Input A
        addrect;
        set("name","input_A");
        set("x",-((nx/2)*a)-alength/2);
        set("x span",alength);
        set("y",5*a);
        set("y span",2*a);
        set("z",0);
        set("z span",z_span);
        set("material","Si (Silicon) - Palik");

        # Input B
        addrect;
        set("name","input_B");
        set("x",-((nx/2)*a)-blength/2);
        set("x span",blength);
        set("y",-5*a);
        set("y span",2*a);
        set("z",0);
        set("z span",z_span);
        set("material","Si (Silicon) - Palik");

        # Output Y
        addrect;
        set("name","output_Y");
        set("x",((nx/2)*a)+ylength/2);
        set("x span",ylength);
        set("y",5*a);
        set("y span",4*a);
        set("z",0);
        set("z span",z_span);
        set("material","Si (Silicon) - Palik");

        # Silicon
        addrect;
        set("name","Silicon");
        set("x",0);
        set("x span",(nx+1)*a);
        set("y",0);
        set("y span",(ny+1)*a);
        set("z",0);
        set("z span",z_span);
        set("material","Si (Silicon) - Palik");

        # Output Monitor
        addprofile;
        set("name","field_profile");
        set("monitor type",7);  # 2D z-normal
        set("x",0);
        set("x span",5e-6);
        set("y",0);
        set("y span",5e-6);
        set("z",0);

        • Dev
          Ansys Employee

           

          Thanks for shairing more details: 

          Are you adding

          ”addprofile” in

          Structure group? That could be the reason of error. 

           

          You won’t be able to add the profile monitor there. Its only for the structure . You can add monitors in analysis group. Or you can use any of the following options. 

           

          Option 1:

          You can create an lsf file from Script file Editor on the right side of window and add profile monitor

          Option 2: 

          add the monitor inside the model script.

           

          I will recommend this course material: Ansys Lumerical Scripting – Learning Track | Ansys Innovation Courses

          Please let me know this solve the problem.

          Thanks and regards

          Devika

           

           

        • lixing
          Subscriber

          Actually you can not add any monitor into structure group,you can try analysis group.

      • Joshua Worrall
        Subscriber

        Thank you both Devika and Chris for the replies, I realise now that I can't add the monitors using a structure group. I tried again using an analysis group as suggested by Chris and I can now get the monitors placed with the scripts.

      • Viewing 2 reply threads
        • The topic ‘Can’t add frequency domain field profile into structure group using script’ is closed to new replies.