TAGGED: inverse-design
-
-
May 13, 2023 at 5:14 am
Coulson Jiang
SubscriberI'm trying to inversely design a structure of waveguide by using lumopt, and i follow the example of Y splitter to determine the base structure.Then i modified the python code for topology optimization, but i receive the following error, which i cannot deal with. Can you give me some useful advice? Thanks so much.
File "C:\Program Files\Lumerical\v202\api\python\lumopt\optimization.py", line 469, in run
self.initialize(working_dir)
File "C:\Program Files\Lumerical\v202\api\python\lumopt\optimization.py", line 543, in initialize
self.base_script(self.sim.fdtd)
File "C:\Program Files\Lumerical\v202\api\python\lumopt\utilities\base_script.py", line 42, in __call__
return self.eval(cad_handle)
File "C:\Program Files\Lumerical\v202\api\python\lumopt\utilities\base_script.py", line 52, in eval
return cad_handle.eval(self.script_str)
File "C:\Program Files\Lumerical\v202\api\python\lumapi.py", line 1184, in eval
evalScript(self.handle, code)
File "C:\Program Files\Lumerical\v202\api\python\lumapi.py", line 248, in evalScript
raise LumApiError("Failed to evaluate code")
lumapi.LumApiError: 'Failed to evaluate code' -
May 14, 2023 at 11:29 am
Coulson Jiang
SubscriberI found that the problem lies in the lumerical script I wrote, mainly because I called 'addimportedsource' command and wrote Ex and other source parameters by myself. The code is as follows, I wanna ask how to modify this to make the python file run? What's more, is a topology optimization must has a initial guess?
addimportedsource;
set('name','source');
M=readdata("beam.txt");
# define position vectors
w0 = 0.5e-6;
x = linspace(-3*w0,3*w0,200);
y = linspace(-3*w0,3*w0,200);
z = 0;
X = meshgridx(x,y);
Y = meshgridy(x,y);
lambda0 = 0.632e-6;
f = c/lambda0;
w = 2*pi*f;
k = 2*pi/lambda0;
Ex = sin(pi)*M;
Ey = cos(pi)*M;
Ez = 0*M;
EM = rectilineardataset("EM fields",x,y,z);
EM.addparameter("lambda",c/f,"f",f);
EM.addattribute("E",Ex,Ey,Ez);
select("source");
set('direction','Backward');
set('injection axis','z-axis');
set('x',0);
set('x span',3e-6);
set('y',0);
set('y span',3e-6);
set('z',0.11e-6);
importdataset(EM);
set("center wavelength",lambda0);
set("wavelength span",0);
importdataset(EM);
set("center wavelength",lambda0);
set("wavelength span",0);
matlabsave("EM.mat",EM);
-
May 29, 2023 at 9:49 pm
Taylor Robertson
Ansys EmployeeHello,
Your script is written in LSF, I would try and debug this in Lumerical before trying to call the script from python. Pay attention to the fsp file that this will run in, because many of these commands refer to objects in the fsp tree. If you are using lumopt it will likely start with a blank file, which is why this is called the set-up script. One thing I notice is that it is importing files which may be in a different directory then where python is running.
To use initial conditions in toplogy optimization I would direct you to the initialization section of this article.
https://optics.ansys.com/hc/en-us/articles/360052044913-Optimizable-Geometry-Python-API
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Why am I getting “process exited without calling finalize”, and how do I fix it?
- “Import optical generation” or “delta generation rate”?
- Error: addfdtd is not a valid function or a variable name
- Error on Lumerical device
- Using a license file on a new license server
- Ansys Insight: Transmission results greater than one
- Ansys Insight: Diverging Simulations
- Finding your Ansys (or Lumerical) account number
- Is there a Lumerical script command to output the Simulation and Memory requirements?
- Ansys Insight: Why my simulation result is different from published paper or experiment?
-
5204
-
3281
-
2459
-
1308
-
970
© 2023 Copyright ANSYS, Inc. All rights reserved.