TAGGED: lumerical-script
-
-
January 21, 2022 at 6:59 pm
wcai05
SubscriberHi, I wonder what's the equivalent python command for the following lumerical script?
pole = [0,0; 1,9; 6,9.8; 10,10]*1e-6; set("poles",pole);Thank you
January 24, 2022 at 8:41 pmKyle
Ansys Employee
The Python equivalent of a Lumerical matrix is a NumPy array. There is more information on equivalent data types this page: Passing Data.
You can then use the set command as a Python method, as described on this page: Script Commands as Methods.
January 25, 2022 at 6:41 amJanuary 28, 2022 at 1:55 amKyle
Ansys Employee
That function should take a lumapi.MODE object as an argument and set up the simulation with the required objects, as described on this page: Getting Started with lumopt - Python API. This page has an example that uses this approach: https://support.lumerical.com/hc/en-us/articles/360042305274
Also, note that you are passing the function itself to the Optimization constructor, so you shouldn't be calling the function in line 108 in your second screenshot.
January 28, 2022 at 2:42 amFebruary 5, 2022 at 8:46 pmFebruary 7, 2022 at 8:54 pmKyle
Ansys EmployeeThe created source might be outside the simulation region. If you open the simulation created by the script, is there a plane wave source with the name "source" inside the simulation region?
February 7, 2022 at 10:23 pmFebruary 9, 2022 at 2:20 amKyle
Ansys Employee
As you can see in the Python files indicated in the traceback, this error occurs because the script command getnamednumber("source") returns a number less than 1. If you enter the command
?getnamednumber("source");
In the script prompt with this file, what value is returned? Are you sure that this is the base simulation script file being used when you run the optimization?
February 9, 2022 at 5:53 amFebruary 9, 2022 at 11:10 pmKyle
Ansys EmployeeThat's odd, I'm not sure what might be causing this issue. One thing you could tryinpassing the base simulation to the optimization with this predefined FSP file rather than defining the it with a Python method. The "Project Init" section of this page describes how to do this: https://support.lumerical.com/hc/en-us/articles/360050995394.
February 9, 2022 at 11:56 pmwcai05
Subscriber
The script will work if the base simulation was defined in FSP file. The reason why I'm trying to redo it in python is that the run time of the script is too long so I wish to push it on to a cluster. however, the formatting of the cluster only allows one file to run.
February 11, 2022 at 12:57 amKyle
Ansys Employee
If it works with the FSP file directly, there might be something wrong with the Python method used to set up the geometry. A lumapi.FDTD object, representing an FDTD simulation, is passed to the Python method. This is the simulation where the geometry and simulation objects need to be added. I would recommend double checking that you're adding simulation objects to this FDTD object, you might be creating a new FDTD simulation and adding the objects to that.
Viewing 12 reply threads- The topic ‘equivalent python command for matrix data type’ is closed to new replies.
Innovation SpaceTrending discussionsTop Contributors-
5834
-
1906
-
1420
-
1305
-
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.
-








