Photonics

Photonics

Topics related to Lumerical and more

Is it possible to access user-defined variables from other groups/containers?

    • hacha
      Subscriber

      I would like to define some of my variables in the Model scope, but if I create a construction script there it prevents me from manually adding things like monitors (sometimes it's nice to put an arbitrary monitor in after designing a simulation).

      The workaround is to create a structure group and use a separate analysis group, but sometimes I would like a monitor to rely on some variable that I specified for the construction group. Is there a way for me to access a variable stored in another group? Or can I define variables in the Model group and access them from the group's Structure or Analysis group children?


      Example: I want a monitor at the end of a waveguide while I run a parameter sweep on waveguide length, 'WG_length' . I can script this all in the model group, but then it will override any attempts to add more monitors via the GUI. I could script the waveguide in a structure group, and the monitor in the analysis group, but then the monitor will no longer have access to the 'WG_length' variable and will not move with the waveguide during the parameter sweep.

    • Guilin Sun
      Ansys Employee
      Structure groups can only be used to set up geometry, and analysis groups can be used to set up all objects, including geometry, source, monitors and simulation solvers (similar to MODEL). However, the scripts in those groups can only access the variables inside the groups and get them from MODEL (cannot be from group to MODEL). They cannot directly access other groups.
      In your case, you can include the structure group inside the analysis group, or simply setup the structure and the monitors in analysis group. You can refer some online examples, such as
      https://support.lumerical.com/hc/en-us/articles/360042097393




    • hacha
      Subscriber
      Thank you, that is super helpful! Could you share an example of a group script getting a variable from MODEL? Do you have to pass the variables to the group from the MODEL script, or can the groups pull the variables from MODEL? Hope this makes sense!
      -Brandon
    • Guilin Sun
      Ansys Employee
      any group cannot pull variables in MODEL. It is the MODEL that passes the variables/parameters to the groups. The same parameters can be passed from MODEL to different groups, if they are the same. IN band structure simulations the periodicity is passed to the analysis, structure and dipole groups: Photonic crystals - list of examples
    • hacha
      Subscriber
      Ah, now I understand. Thanks again!
Viewing 4 reply threads
  • The topic ‘Is it possible to access user-defined variables from other groups/containers?’ is closed to new replies.