Ansys Learning Forum Forums Discuss Simulation Photonics Blocking calls with Lumerical’s python lumapi? Reply To: Blocking calls with Lumerical’s python lumapi?

Taylor Robertson
Ansys Employee
Thanks for the question. So from my understanding in 3. you are saving the index monitor results to a data set in the lumerical workspace. Are you doing this by evaluating a string argument as lsf code. For example.
fdtd.eval("A = getresult('index monitor','index');")
Python basically treats the Lumerical GUI environment as a client. Once it passes this code to be evaluated it will move on, since it is not expecting any results to be returned. Lumerical may still be evaluating the code when you are trying to get the results? Not entirely sure about the sequence of events here, but in this case it may be be better to return the results directly to Python using
A = fdtd.getresult('index monitor','index')
This will return a dictionary with the same structure as the lumerical dataset see - Passing Data - Python API
Also the index monitor returns a number of results; some of which are available in layout mode, but the more accurate datasets will require the simulation to be meshed. It may be that the index preview was generated before before updating the material and it failed to update the results when the material data was changed? If you wanted the most accurate results, that take into account the advanced meshing refinement options, I would suggest meshing the structure after updating the material properties. There is a hidden way of doing this without having to run the simulation.
fdtd.addjob("myFileName.fsp", "FDTD", "-mesh-only");
Then you can use assignment in python or get the variable from the script workspace if you like. One note the syntax you are using to pass variables to python is deprecated. I would suggest
A = fdtd.getv('index_matrix')
The simplest possible thing may to just build in a bit of a time buffer. To do this I use python time module.
import time
.
.
#Update material data
time.sleep(15) #wait for 15 seconds before moving on
.


I hope this helps.
Best Regards