Photonics

Photonics

nesting or dependent structure groups

    • chetherington
      Subscriber

      Hi,

      In Lumerical, I'm trying to use scripts to create a structure group (group B) the values of whose user parameters depend on structures created in a separate structure group A. I see two ways of doing this and neither are working so I am asking for recommendations:

      One would be to nest B inside of A, so that variables in the A build script can be passed to the B build as user parameters. However, this fails because the software can't parse nested scripts. e.g. set('script', ' ... addstructuregroup; set('script', '...'); ');

      Another method is to use the same script to create A first, then read out the values from A, then pass those values to B as user parameters. For example,

      newproject(3); clear;

      addstructuregroup; set("name","A");

      adduserprop("A_z", 2, 1e-6);

      set('script', '

      addrect;

      set("name","Arectangle");

      set("z", A_z);

      runsetup;

      ');

      select("A::Arectangle");

      zvalue=get("z");

      #I will then pass zvalue to structuregroup B.

      If I run this by pasting into the prompt, it runs fine. The problem is this: When I run this as a script, I invariably get the error:  line 11: no objects matching that name were found.

      What am I doing wrong? Can you suggest a different way of doing this dependency? B must be a structure group of its own, because I need to make an array of B's later on.

      Thanks,

      Craig

    • chetherington
      Subscriber
      The object "Arectangle" is selectable by script ONLY if it is in a layout group, not if it is in a structure group.
    • chetherington
      Subscriber
      I am pretty sure this is a bug in the software. Lumerical staff, do you have any comment as to what I'm doing wrong, or as to how to make a structure array of structure groups whose properties depend on a different structure group? Thanks.
    • Guilin Sun
      Ansys Employee
      In general, Lumerical has two methods to create nested structures groups:
      1: manually create the groups in GUI, write the script to create structures, and pass the parameters from root to branches. Eg, "model" is the basic root, and it can pass all the parameters to its children (groups and objects);
      2: using script: before you assign any thing to the inner group, you have to first create it.
      In your illustration script:
      newproject(3); clear;
      addstructuregroup; set("name","A");
      adduserprop("A_z", 2, 1e-6);
      set('script', '
      addrect;
      set("name","Arectangle");
      set("z", A_z);
      runsetup;
      ');
      select("A::Arectangle");
      zvalue=get("z");
      there is no "z" beforehand, so you have first get it from Arectangle.

      Actually you should first define all parameters, and then assign them to the specific object inside that group.

      I would say that, although the scripting seems efficient, if you do not check the geometry and the material properties, it has higher chance to have some mistakes. I personally prefer to use group and its script inside instead of using an independent script to create the whole simulation file.
    • Stealthbird97
      Subscriber
      Not sure how this can be used in conjunction with other objects such as dipoles, or monitors.
      For example, If I need to place a dipole relative to a object inside a structure group.
      Last time I checked, structure group scripting can not access variables outside of the structure group. How would I be able to access a user variable, or a parameter of an object in the "model" inside a structure group script?

    • chetherington
      Subscriber
      This is the practical problem I'm encountering. I am trying to use the LSF script to 'read out' the value from inside the structure group but it doesn't work if the structure group is built by an internal script. How can I do that readout?
    • Guilin Sun
      Ansys Employee
      Structure group cannot access other objects outside its scope.
      To do so, you have two options:
      1: use analysis group. it can access its member structure group, source and monitors. Please refer this example:
      Metamaterial parameter extraction - Smith
      2: through "model" to access. Please refer band structure examples: Bandstructure of planar photonic crystal with a square lattice

      Please read the example instructions, open the files and check related objects and scripts to see how the parameters are assigned and passed.
    • mohamed.elshorbagy
      Subscriber

      As others have stated, the line:

      select("A::Arectangle");

      does not work when called from a script file, but works when entered into the script prompt. Is there a solution to this?

    • mohamed.elshorbagy
      Subscriber

      Selecting an object inside a structure group from script works when the group is created by the addtogroup command, but not when the object is created using the setup script.

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