-
-
March 31, 2022 at 6:17 pm
andrew.perkins
SubscriberIs there a script command to get a list of the active materials in lumerical? IT seems there should be because the 'Check simulation and memory requirements' triggers warnings for the active materials, so this list must exist somewhere in Lumerical. I need a command script to access it.
I know the getmaterial command, but you need to know the names of the objects to do this.
I'm hoping to save myself the trouble of writing a function to traverse the objects tree to get the names of all objects, and then use 'haveproperty("material") to see if each object has a material. I'm afraid that is not so simple for a generic N-ary tree to do this.
Anybody else already solve this problem of getting a list of all active materials in a lumerical simulation? I want to plot each material in python plotly.
April 5, 2022 at 8:46 pmkghaffari
Ansys EmployeeHi Andy Thanks for your question. Are you referring to materials listed under ÔÇ£Current materialsÔÇØ:
Alternatively, you can use the GUI to find these materials through the database. To do this click on the delete icon on the top. This would place the materials that can not be deleted on the top (since they are in use):
Otherwise to do this through script, I think what you suggested using the getmaterial command would be the best workaround.
Hope this helps.
Best Khash
April 5, 2022 at 8:50 pmandrew.perkins
SubscriberHi Khash Yes, option 1 you show for materials listed under "current materials". I need a script command that will give me that list of materials names. IS that possible?
April 5, 2022 at 9:12 pmkghaffari
Ansys EmployeeHi Andy Unfortunately not, we don't have a dedicated command for this purpose. Please consider submitting a feature request for this on our ideas exchange platform.
Thank you
April 22, 2022 at 10:06 pmandrew.perkins
SubscriberHi Khash or Lumerical SUpport
I see a command now called 'runsystemcheck' which returns a struct with the active materials as fields. However I still can't get the individual material names because I can't access struct fields without knowing ahead of time what they are named. Is there a Lumerical Command to get the names of fields in a struct?
systemcheck = runsystemcheck;
materials_struct= systemcheck.Materials;
I can see the material names as fields in the struct object, but I can't actually get those material names individually like I would if these were a list or cell object with something like materials_struct[1].
How do I create a list with the fields of a struct group without knowing apriori what the field names are?
April 26, 2022 at 11:20 pmTaylor Robertson
Ansys EmployeeHey
Based on our discussion I think that you can use getfield to return the fields of the struct as a string. Then you can use some string slicing commands to create a cell of the available materials. Posting this for anyone who has a similar question.
A =runsystemcheck;
Mat =getfield(A.Materials);
Mat = splitstring(Mat, endl);
May 6, 2022 at 9:42 pmandrew.perkins
SubscriberI am still having an issue with getting proper material names. For some reason material names with spaces, parenthesis, and duplicate letters get changed.
For example, 'Cu (Copper) - Palik' becomes "Cu_Coper_Palik' when returned by the runsystemcheck command. What is going on here? I need the correct name in order to be plot it in a script.
May 10, 2022 at 11:46 pmkghaffari
Ansys EmployeeHi Andy Sorry I missed your posts. In the systemcheck materials struct, the name it self is stored. So you can access the exact name without the character change using a code like:
systemcheck = runsystemcheck;
materials = systemcheck.Materials;
Cu = materials.Cu_Coper_Palik;
Cu_name = Cu.Material_Name;
Does this work for you? This approach still relies on knowing what the stored material is when the "." operator is used (in line 3).
Best Khash
May 11, 2022 at 6:22 amandrew.perkins
SubscriberHi Khash It's a bit convoluted, but now that I see everything is built on struct data I can use nested getfield() functions and get the proper Material_Name without having to handle the incorrectly formatted Materials.
Combining trobert's code with yours, I can get the proper names of all active materials with the function I created below.
I have a working solution now, but I'm curious as to why system_check.Materials returns the material names with such odd formatting. I can understand removing special characters, but why are repeated characters removed? Oddities like this where Lumerical can't handle data type formatting properly forces me to the Python API, which I'm grateful for, but adds extra complexity.
Thanks for your help.
May 11, 2022 at 10:57 pmkghaffari
Ansys EmployeeHi Andy Thank you for sharing your script here, good to know you have managed to make this work. I am not sure about the material name formatting. Sorry for the inconvenience, please consider submitting a feature request for easier accessing to active material on ideas exchange platform.
All the best
Viewing 9 reply threads- The topic ‘Get list of active materials in script (Lumerical)’ is closed to new replies.
Innovation SpaceTrending discussionsTop Contributors-
5879
-
1906
-
1420
-
1306
-
1021
Top Rated Tags© 2026 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-
Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.