# Error runing Topological optimization example

I am unable to reproduce the results from the example of Inverse design of a Y splitter using topology optimization

I am using Lumerical 2019b and I am getting an error :

CONFIGURATION FILE {‘root’: ‘C:\Program Files\Lumerical\2019b\api\python’, ‘lumapi’: ‘C:\Program Files\Lumerical\2019b\api\python’}
Wavelength range of source object will be superseded by the global settings.
Running forward solves
Traceback (most recent call last):
runSim(initial_cond, eps_min, eps_max, x_pos, y_pos, filter_R*1e-9)
opt.run()
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 145, in run
self.initialize()
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 216, in initialize
self.optimizer.initialize(start_params = start_params, callable_fom = callable_fom, callable_jac = callable_jac, bounds = bounds, plotting_function = plotting_function)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimizers\optimizer.py”, line 45, in initialize
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimizers\optimizer.py”, line 51, in reset_start_params
self.auto_detect_scaling(min_required_rel_change)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimizers\optimizer.py”, line 72, in auto_detect_scaling
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimizers\generic_optimizers.py”, line 57, in callable_jac_local
gradients= -callable_jac(params / self.scaling_factor) / self.scaling_factor
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 308, in callable_jac
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 268, in run_adjoint_solves
fom = self.run_forward_solves(params)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 230, in run_forward_solves
self.make_forward_sim(params)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\optimization.py”, line 221, in make_forward_sim
self.geometry.update_geometry(params, self.sim)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\geometries\topology.py”, line 111, in update_geometry
self.eps = self.get_eps_from_params(sim, params)
File “C:\Program Files\Lumerical\2019b\api\python\lumopt\geometries\topology.py”, line 101, in get_eps_from_params
‘eps_geo = topoparamstoindex(params,topo_rho);’).format(self.eps_min,self.eps_max,self.filter_R,self.beta,self.eta,self.dx,self.dy) )
File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 1198, in eval
evalScript(self.handle, code)
File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 259, in evalScript
raise LumApiError(“Failed to evaluate code”)
lumapi.LumApiError: ‘Failed to evaluate code’

Hey @bod442,

Just to double check you have 2019b R2.

Regards,

?version;
8.22.1998

Hey @bod442,

I’ve been able to replicate this error and t seems you have the correct version, but not the correct license. In the original post you linked to Jens states:

This is an updated license that our sales will gladly provide to our registered users at no additional cost. If you have not updated your license since this new feature was released, please contact.

sales@lumerical.com

You may have to ask you administrator if you do not have the necessary network privileges.

Regards,

Hi @trobertson , I am running into the same problem as @bod442 when i run the topology optimization python code. I have checked that my version is the 2019b R2 and with most updated license but I am still running into the same error. Please advice

Hello @vrrajago,

If you are receiving this error than you need to update your Automation API license. For topology optimization we had to make adjustments to the license upon release (July 2019). If you activated you license before that tiem then you will need to update it to run this feature.

Regards,

Hello,

When I run the file, following error is prompted. TypeError: __init__() got an unexpected keyword argument 'target_fom'. My licenses and Lumerical product are up to date as far as i know. Could you help me identify the problem?

Hello,

Regards,

When you delete target_fom, following error is prompted.

File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 1198, in eval
evalScript(self.handle, code)
File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 259, in evalScript
raise LumApiError(“Failed to evaluate code”)
lumapi.LumApiError: ‘Failed to evaluate code’

Regards

Hello @oyesilyu,

I was able to get it to run when I removed this flag. Could you provide more information on the stack trace. Is that the same line where you modified the script? This seems like it could be syntax error somewhere in your modification. Maybe you could share your modified files.

Thanks,

Of course, the file is attached. I have only deleted target_fom argument. Thanks for the quick help.splitter_opt_2D_TE_topology_target_fom.py (3.4 KB)

Hello @oyesilyu,

It runs on my machine. Are you running this from fsp an file? If you are running this from command line have you defined your path?

If the path is defined appropriately check with your computer administrator to verify that the Flexnet licenses located on “your license server”:8095 has the topology_toolbox license. This ships with the Automation API 2.0 license which was updated in July. If your license was activated before then it will likely have to be reissued.

Thanks,

Hello,

I am able to run the simulation. I had an license problem earlier. But as you mentioned, ‘‘target_fom’’ should be deleted.

Thanks for the help

1 Like

Hi,

I have the same error:
File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 1198, in eval
evalScript(self.handle, code)
File “C:\Program Files\Lumerical\2019b\api\python\lumapi.py”, line 259, in evalScript
raise LumApiError(“Failed to evaluate code”)
lumapi.LumApiError: ‘Failed to evaluate code’

I checked with the sales team that my license is up to date. It was renewed in August. I am running the Python script in Lumerical. I have not defined my path anywhere. I am not sure where I should be doing that.

Thank you,

I still have a problem with a topological example. I Have an updated license for the API and I have an updated version of Lumerical package

?version;
8.22.2088

I believe that as of September all new academic licenses issues come with the topology toolbox; however this was not always the case. If you do not have the license you will need to contact your license manager and get them to request a new license from sales@lumerical.com. Then they will deactivate the old and send a new activation code.