TAGGED: #automation#ACT
-
-
February 19, 2024 at 2:03 pmRaksha SinglaSubscriber
Hello,Â
I have recently started to work with Lumerical and have some technical questions about the automation of running simulations and analysis in FDTD. I am setting up simulations using the GUI of Lumerical and then creating *.fsp files from the optimization and sweep window to run them later using the terminal. I include some analysis objects in the simulation which from what I understand need to be run one by one for Lumerical to perform the calculations from the raw data.Â
I would like to automate this step using the python API package lumapi.
1. I can extract datasets from *.fsp files from Lumapi if I have previously "Run analysis" on the CAD.However, I would like this to be automated in my py script to "runanalysis" on each *fsp created in sweep and then extract and save data elsewhere. Could someone suggest ways for this?
I tried the following, this code loops over many filenames (all the *fsp files which have already run an FDTD sim)
with lumapi.FDTD(filename) as fdtd:
    data = method_to_get_data(fdtd)
method_to_get_data(fdtd):
     fdtd.runanalysis()but got the error:
raise LumApiError(message)
lumapi.LumApiError: 'in runanalysis: one or more analysis objects encountered errors'2. Do I need to "Run analysis" on each *fsp file of the sweep explicitly on the CAD?Â
3. I saw many different scripting examples but is there a way to extract the full *lsf file from a Lumerical project setup I created on the CAD - one that would have the setup, analysis objects, and sweep info in it. Sort of like export to *lsf?
Â
-
February 27, 2024 at 12:12 amTaylor RobertsonAnsys Employee
Hello Raksha,
- This is interesting it seems like ther is an error in one of the analysis groups in one of the files. It would be hard to say why without more information. Can you tell which file this was and then which analysis group? Does this cause python to stop running or it is just a warning? If so perhaps it would be worth while to wrap the runanalysis in a try...except{} which should allow the code to continue.
- Runanalysis is a post processing scripted step. The Analysis Groups - Simulation object have scripts associated with and can save .mat files of these results. You could adapt the scripts associated with analysis groups into a stand alone script that would have the same functionality. There is not a one click to solution unfortunately to do this, but I think should be straightforward. You can then use eval from python or adapt the script to python.
- When you run FDTD it cannot currently create standalone datasets usually. This is a feature we are exploring, but is not supported yet. Therefore you do need to open the file and run a script to get the resulst saved to another file like json, mat or h5.
I might also suggest leveraging the sweep utillity, this can be helpful because it will save the files and if you simply load from files it will open and runalysis automatically. If it is set up correctly it will create a dataset with the relevant results.
Â
I hope this helps let me know if it isn't clear.
-
March 4, 2024 at 9:07 amRaksha SinglaSubscriber
Thank you for your reply. I have been working with Q and lowQ analysis objects with a micropillar cavity design. Strangely, I do not get the error consistently, hence I am unable to inform you more.
My current workflow is
1. Setup structure and add analysis and param sweeps using the CAD.Â
2. Then using the option "save to files" from sweep in the CAD.
3. Running them (generated fsp files) sequentially through Command prompt on Windows
4. Using a python script to open a new FDTD object for each fsp file of the sweep -> runanalysis() on it and extract data to save elsewhere.
This seems to work well without raising errors. -
March 4, 2024 at 9:10 amRaksha SinglaSubscriber
I forgot to mention, i had lowQanalysis, Qanalysis, and mode_expansion monitors in place when the error message appeared.Â
The python code terminated due to the error (not a simple warning). The error message did not specify which of the analysis objects failed. -
March 6, 2024 at 9:42 pmTaylor RobertsonAnsys Employee
Hello Raksha,
Â
This sounds reasonable it is likely that there may have been issues (possibly extracting the data from Q analysis groups) that cause the code to fail. This can happen in sweeps from time to time and you will need to understand why the analysis is failing to understand how to fix it. For point 4 you could also do this using load from files it should perform the same functionality.
Â
Best Regards,
Â
-
March 13, 2024 at 3:37 pmRaksha SinglaSubscriber
Hello Taylor R.,
I investigated a bit more and now understand the reason for runanalysis failures with Lumapi. Perhaps, the API could be improved on error messages.
Here is the situation, If there are multiple analysis objects and if some are disabled or any of them fails to run properly -Â 1. partial execution occurs on CAD (clicking on run analysis button)
2. using the API and running from python fails and exits the code without giving much information on which object failed.Â
I am not sure if it is related to the order in which the analysis groups are added to the simulation or not.
-
- The topic ‘Automation with Lumapi and use of script commands’ is closed to new replies.
- Difference between answers in version 2024 and 2017 lumerical mode solution
- Errors Running Ring Modulator Example on Cluster
- INTERCONNECT – No results unless rerun simulation until it gives any
- Import material .txt file with script
- Trapezoidal ring
- Help for qINTERCONNECT
- Issues with getting result from interconnent analysis script
- Topology Optimization Error
- Edge Coupler EME Example Issue
- The two modes overlap the integral
-
1191
-
513
-
488
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.