/lumopt

Python based continuous adjoint optimization wrapper for Lumerical

Primary LanguagePythonOtherNOASSERTION

Continuous adjoint optimization wrapper for Lumerical

Introduction

This is a continuous adjoint opimtization wrapper for Lumerical, using Python as the main user interface. It is released under an MIT license. It is still work in progress and any contribution will be very welcome! New features to come out soon, and make it even easier to use (hopefully)!

If you use this tool in any published work, please cite https://www.osapublishing.org/oe/abstract.cfm?uri=oe-21-18-21693 and give a link to this repo. Thanks!

Tutorials, Examples, and Documentation

It is all here: https://lumopt.readthedocs.io/en/latest/

Install

Make sure you have Python 3 and the latest version of Lumerical installed (it won't work correctly with older versions), and that lumapi (the python api) works.

cd your/install/folder/
git clone https://github.com/chriskeraly/LumOpt.git
python setup.py develop

I would strongly recommend using jupyter notebooks to run optimizations.

First optimization

If you are not using jupyter notebooks:

cd your/install/folder/examples/Ysplitter
python splitter_opt_2D.py

Otherwise copy your/install/folder/examples/Ysplitter/splitter_opt_2D.py into a notebook

安装说明

对于 Windows v202 版本: 0. 安装 Python 3 并将其加入系统路径,若无则还需安装 numpy 和 scipy 包。

  1. 将本仓库 clone 或下载并解压到本地。
  2. 在本地仓库路径下安装 lumopt 包:
python setup.py install

若提示信息中显示

Finished processing dependencies for LumOpt==0.0.1

则说明安装成功。 3. 打开 lumopt 包安装路径 python_path\Lib\site-packages\LumOpt-0.0.1-py3.7.egg\lumopt 下的 __init__.py 文件, 将其中的 Python api 路径设为所安装的 Lumerical 的 Python api 路径 (如 C:\Program Files\Lumerical\v202\api\python):

default_api_path = '/Program Files/Lumerical/v202/api/python'
  1. 打开所安装的 Lumerical 的 Python api 路径 (如 C:\Program Files\Lumerical\v202\api\python) 下的 lumopt 文件夹中的 __init__.py 文件,将其中的 Python api 路径设为所安装的 Lumerical 的 Python api 路径:
default_api_path = '/Program Files/Lumerical/v202/api/python'
  1. 将所安装的 Lumerical 的 Python api 路径 (如 C:\Program Files\Lumerical\v202\api\python) 下的 lumopt 文件夹中除 __init__.py 文件外的所有文件复制到 Python 的 lumopt 安装路径 (python_path\Lib\site-packages\LumOpt-0.0.1-py3.7.egg\lumopt) 下 (覆盖).
  2. 将所安装的 Lumerical 的 Python api 路径 (如 C:\Program Files\Lumerical\v202\api\python) 下的 lumapi.py 文件中的 interopapi.dll 替换成对应的完整路径名, 即把
INTEROPLIB = "interopapi.dll"

替换为

INTEROPLIB = INTEROPLIBDIR + "/interopapi.dll"
  1. Python 测试
import sys
sys.path.append("C:\\Program Files\\Lumerical\\v202\\api\\python\\") #Default windows lumapi path
import lumopt
import lumapi

若仅有提示信息而无报错, 则说明安装成功.