Photonics

Photonics

Topics related to Lumerical and more.

Importing data from files into scripted element [Interconnect]

    • Badrul
      Subscriber

      I have often used FDTD module in the past, and scripting seems to be one of the best features of Lumerical.

      In Interconnect, it seems similar, although with some differences.

      I would like to import some data into the "Scripted" element in Interconnect, which I would like to use with the script inside.

      If I understand correctly, we need to create a new property (inside "Property Editor" of that element), and use it as the mediation. I did something like this:

      addproperty("SCRIPTED_1","new_property","scripted","FileOpen",0,100,"Dimensionless");


      And subsequently I loaded a file.

      Unfortunately, I have not been able to import the data stored inside, as the command " ?new_property " outputs me the just the name of the parameter, while I would like to read the content.


      I have also tried to import the data by creating a matrix with 3 columns, and then creating the property:

      addproperty("SCRIPTED_1","imported_Pin_vs_PGain","general","Matrix",0,100,"NonQuantity");


      Thus, I would like a suggestion about the best way to approach this issue about importing data inside Scripted elements. I am pretty sure that there are many ways to approach it, but I guess I am missing something.

      Also, what may be the best practice? Ideally, just like I used to do in FDTD, I would like to create fully automated scripts, where no clicking is involved for the simulations.


      Thanks in advance for your answers

    • GWANG
      Ansys Employee
      Hi Badrul
      The "addproperty" command adds the property into the Scripted element, but not setting this property. You can use the "setnamed" or "set" command to set the property once you add it to the correspongding value. In your case, once you add the file open property, you can set the property to the path of the file, then the file will be loaded.
    • Badrul
      Subscriber
      Ok, thank you very much. This helped a lot.

      Can I ask you another thing? I am not sure if it is better to create a new discussion.
      About the script inside "scripted element", I would like to access to the signals in the ports and use them as variables (e.g. take the electrical signal and transform it into charges, to influence the output from optical ports).
      In the tutorials of scripted elements (https://support.lumerical.com/hc/en-us/articles/360036620253-Scripted-Element-Element-Library) the example scripts contain only output commands such as:
      setsparameter("port 2", "port 1", "coefficients", trans, frequency );
      But it is not possible to load it as a variable. There are ways to access to the ports' signal indirectly from the general script, but I would prefer to use it directly, if it is possible.

      Thank you again for the previous answer,
      Best regards.
    • GWANG
      Ansys Employee
      Hi Badrul
      Sorry for the late reply on this. In that case you would need to set the Scripted Element in time domain. Here are some examples of doing it at the end of this page: https://support.lumerical.com/hc/en-us/articles/360036620253-Scripted-Element-Element-Library
Viewing 3 reply threads
  • The topic ‘Importing data from files into scripted element [Interconnect]’ is closed to new replies.