Inverse design package with Lumapi and LumOpt

    • Wenyi Zhang
      Hi all,
      Our research group wants to use the inverse design function of Lumerical and we started with the example - 2D Ysplitter problem in the Lumerical example gallery. We are referring to this tutorial:  the
      We keep encountering issues when running the file. Here is what I did to install LumOpt and run the file.
      I typed all of these commands in a VSCode terminal on a windows10 desktop and I am using python3 and the latest version of Lumerical.
      1. First, I entered the directory where lumapi locates with the command:
      cd "C:\Program Files\Lumerical|v222\api\python"
      2. then I cloned the github repo mentioned in the tutorial by:
      After this operation, I could see I have LumOpt under "C:\Program Files\Lumerical|v222\api\python"
      3.Then I enter the LumOpt folder with:
      cd "C:\Program Files\Lumerical\v222\api\python\LumOpt"
      and run the setup file with:
      python develop --install-dir 'C:\Program Files\Lumerical\v222\api\python\LumOpt'
      From the output information, I can see all of the package requirements are satisfied.
      4.To make sure the can import the packages from lumopt successfully, I add two lines in the, which are:
      sys.path.append("C:\\Program Files\\Lumerical\\v222\\api\\python\\")
      sys.path.append("C:\\Program Files\\Lumerical\\v222\\api\\python\\LumOpt\\")
      and I tried to run with the command:
      python 'C:\Program Files\Lumerical\v222\api\python\LumOpt\examples\Ysplitter\'
      5. I can see the Lumerical window opens but after some quick initialization, an error was reported:
      AttributeError: 'SnapShots' object has no attribute '_tmpdir'
      and the Lumerical window quited quickly.
      Any help will be highly appreciated!
    • Taylor Robertson
      Ansys Employee


      Hello Wenyi,

      This sounds to me like it may be an issue with your Python environment. It should be easy to check using the python version we ship with. Simply run the splitter python code from the script editor in Lumerical.

      This is a more upt to date example, I would suggest you use. Just open the python file and click run.


      Also ther is no need to clone that git library you mentioned, we ship a version of lumapi, lumopt and python. This directory in windows should have a newer slightly different version of LumOpt then that found on Git. That version is witten for 3.6 I believe, but Lumerical version 2022 has updated to 3.9. You may need to reinstall Lumerical to return to the version of lumopt that we ship with, as doubt these variations will work together.


      Let us know how it works out and if you have any further issues.

    • Wenyi Zhang

      Hi Taylor,

      Thank you so much for the info and what you said is really the key. After I deleted all the files I cloned from the github and reinstalled Lumerical, I can run the python code in Lumerical without any problems. Results look good for me! :)

      Thanks again!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.