In this article, we demonstrate the dynamic import of a KLayout Library cell into Lumerical to perform design sweeps and characterizations. The feature supports dynamic import into Lumerical FDTD, MODE, and all tools under the Finite Element IDE, including CHARGE, HEAT, FEEM, MQW, DGTD.
Note: Linux support has not been fully tested and supported. Please proceed with caution. |
In this example, the workflow imports KLayout library cell geometry and parameters into FDTD, MODE, and Finite Element IDE. The workflow only works for KLayout cells that are registered in a particular technology and library, and belong to a python API compatible KLayout PDK.
Required Setups
Installing KLayout Python API
This workflow requires the path to a Python executable with the PyPI KLayout Python API. You can find information about the Python API here. The required packages to be installed using pip are:
- klayout (version 0.29.0)
- json
- os
- sys
Installing PDK in KLayout
In the examples in this page we use EBeam PDK available here. Please follow instruction to install this PDK. After installation make sure to find the PDK in blow paths:
- On Windows: C:\Users\<USER NAME>\KLayout\salt
- On Linux: /home/<USER NAME>/.klayout/salt
SiEPIC python package is required to be installed to be able to use this PDK for this workflow. Please use below command to install this package to your python executable:
pip install SiEPIC
Steps to make any KLayout PDK compatible with KLayout Python API
The EBeam PDK used in the examples in this page is compatible with KLayout Python API. To make a regular KLayout PDK compatible with KLayout Python API package, we require the 3 files highlighted below.
Two __init__.py files need to be introduced inside Technology and pymacros folders. A python package is typically implemented as a directory containing an __init__.py file. When we import the package as shown in the next section, this __init__.py file is implicitly executed, and the objects it defines are bound to names in the package’s namespace.
PDK_name
├── Technology_name
├── __init__.py # init script which registers technology in KLayout Python API
├── pymacros
├── __init__.py # init script which registers Library in KLayout Python API
├── <name>_Library.py # python script which registers Library in KLayout Python API
├── <name>_Library.lym # script which registers Library in KLayout App
├── pcells # Library P-Cells
- Create a __init__.py file to register the technology.
- Create python file <name>_Library.py in /pymacros, which contains the script (which is identical to the script inside <name>_Library.lym file) required to register the library to technology, and to define the P-Cells for the library. Each library folder inside /pymacros should have its corresponding <name>_Library.py.
- Create a __init__.py file to register the library. <name>_Library.py files of each of the libraries in the technology should be imported inside this __init__.py file.
- Use the python environment to check if the PDK is properly installed by inserting the path to the salt folder through the sys package. i.e. - insert the path to ~KLayout\salt as a sys.path.
>>> import os
>>> import sys
>>> sys.path.insert(0,os.path.expanduser('~\\KLayout\salt\\'))
>>> import siepic_ebeam_pdk.EBeam
If you are using Linux, then change the path to salt folder as follows:
>>> sys.path.insert(0,os.path.expanduser('~/.klayout/salt/'))
>>> import siepic_ebeam_pdk.EBeam
Steps to Dynamically Import from EBeam PDK
Note: Safe mode (found at the bottom of the window) must be turned off. |
Step 1: Updating the config.json file
When you download and unzip the package attached to this artice, you will find a config.json file in the package. If the config.json file exists, the workflow will find the path to the config.json file in the project folder where the script is run. However, if the config.json file does not exist, then a GUI will pop up asking for all the setup parameter information which is explained further in Step 3.
- Open the config.json available inside the package.
- Follow the example below to ensure the format of the 8 parameters of the config.json file. An explanation of the config file parameters is given below.
-
device_to_import
- tech_name::lib_name::cell_name - This defines the cell that needs to be imported using the setup script
-
FDTD
- enable_fdtd_generation : flag that determines if FDTD solver and ports should be set up automatically. Set this flag to 1.0 to enable.
- light_injection_layer_source : the layer source number for the Si (silicon) in the process PDK. If the geometry has multiple waveguide layers (eg. rib waveguide) this parameter can include multiple layers separated by “,” (eg – “1:0,1:1”).
- port_layer_source : the layer source number for the device pins in the process PDK
-
device_to_import
- The process_file and python_exe paths should be correctly specified as shown in the example below.
- Skip Step 3 if using the config.json file and there are no errors in the format parameters.
Example of the config file format in Windows OS:
{
"FDTD" :
{
"auto_generate_FDTD_region_and_ports" : 1.0,
"light_injection_layer" : "1:0",
"port_layer" : "1:10"
},
"device_to_import" :
{
"cell_name" : "ebeam_taper_te1550",
"lib_name" : "EBeam",
"tech_name" : "EBeam"
},
"process_file" : "C:/Users/<USER NAME>/KLayout/salt/siepic_ebeam_pdk/EBeam/Silicon.lbr",
"python_exe" : "<PATH_TO>/.venv/Scripts/python.exe"
}
Step 2: Run the script
- Ensure that klayout_flow_driver.lsfx, and config.json are in the same project directory, while klayout_get_geometry.lsfx and klayout_automated_fdtd.lsfx are inside the /scripts folder within that same project directory.
- Open FDTD, MODE, or Finite Element IDE and run klayout_flow_driver.lsfx. Use the feval command in the script prompt.
> feval("../path/to/klayout_flow_driver.lsfx");
Step 3: Complete the wizard [if GUI workflow is used]
Note: The GUI workflow will be enabled if the config file is missing or if there was an error in the config file. Further as mentioned in Step 1, if you have the config file setup without errors, the GUI-based workflow will not be enabled. At the end of the GUI workflow, the config file will be automatically created (or overwritten). |
- Find and select the python executable.
- Find and select the process file.
- Select the library cell to import. The library cells are organized by <technology name>::<library name>::<cell name>.
Note: Ensure that the process file contains and defines layers found in the library cell's layout. - Set up cell params and simulation setup (if available). If the simulation setup section is available, ensure that the “Light injection layer” and “Port layer” are specified appropriately and verify the setup before running simulations.
-
- The FDTD simulation region is centered in the z-axis by the “Light injection layer”
- The ports are generated based on rectangular pins found on the “Port layer”
Step 4: Check the 3D device structure in Lumerical Multiphysics
After Step 2 (if the config file exists) or if continuing from Step 3 (using the GUI and then clicking “Next”), the workflow extracts cell geometry and params from PDK cells through the KLayout Python API, which may take a few seconds to complete. Then, the device geometry and simulation region are generated. Note that a command line window may pop up, please ignore this window.
- Import Geometry: In FDTD and MODE, once cell geometry is imported, an analysis group with a setup script is generated in the “Object Tree”. In Finite Element IDE, once cell geometry is imported, the "setup script" is contained in the "model" group in the "Object Tree".
FDTD
|
MODE |
Finite Element IDE |
The "analysis group" and "setup script" allow changes to the:
-
- Layer builder geometry
- background_x_margin : x margin added to the background of the layer group
- Background_y_margin : y margin added to the background of the layer group
- Simulation setup override flag
- simulation_setup_user_override : This setup flag allows changes to the simulation object properties after importing a cell. More information is provided below.
- Cell params that will reflect in its geometry (if the cell is a P-cell)
- Depends on the P-cell
-
FDTD only:
- simulation region
- fdtd_z_margin : span of the FDTD region in z-axis
- port geometry
- port_x_span_margin : span of all the ports in x-axis
- port_y_span_margin : span of all the ports in y-axis
- port_z_span_margin : span of all the ports in z-axis
- boundary and device geometry adjustments
- wg_extension_deltaL : The waveguide extension length that is added at the end of each device pin/port (default is 0.2 um)
- boundary_offset_ratio : The amount of distance the FDTD boundary is offset away from the ports, which is a percentage amount of the waveguide extension (default offset is 40%)
- bent_waveguide_parameter : This is the P-cell parameter name that specifies the value of the parameter which will be dynamically assigned to the bent waveguide bend radius.
- simulation region
- Layer builder geometry
- Important - Change the simulation_setup_user_override in analysis group user properties to 1.
- If the simulation_setup_user_override is set to 0; when the analysis group is edited, and the setup script is run (which means a new geometry is imported from KLayout Python API), all the objects created by the script in the object tree (layer model, FDTD and ports) will be deleted and recreated with default properties. Hence, if the user wants to import a new cell by changing tech_name::lib_name::cell_name, then the setup script will replace the existing model with the new model.
- If the simulation_setup_user_override is set to 1; when the analysis group is edited, the setup script will only make specified changes to the current objects and other settings of the objects in the object tree (such as mesh order, temp, monitor points etc.) will be untouched. The user will not be able to change the existing cell in the simulation when simulation_setup_user_override is set to 1.
Parameter Sweeps
Parameter sweeps can be set up to characterize the device.
-
Import the EBeam::EBeam::ebeam_taper_te1550 cell following the steps described above.
-
Change the simulation_setup_user_override to 1, in the analysis group settings.
- In the FDTD::ports object, change the source port from port 1 to port 2 and press OK. Since the simulation_setup_user_override is set to 1, it will only make this specified source port change to the ports object and the other settings of the objects in the object tree will be untouched. Further, adjust the wg_extension_deltaL parameter as required to fit the simulation needs.
- In the “Optimizations and Sweeps” tab, press “Create a New Parameter Sweep” or “Create a New Optimization” or “Create a New Monte Carlo Analysis”.
- Set the parameter to sweep. As shown below, the parameters defined in the analysis group will be available under its “Properties”:
- Run the sweep. Once finished, the results will be available for visualization. More information can be found about Lumerical Parameter Sweep Utility here and Optimization Utility here.
Dynamic Bent Waveguide based P-cell parameter sweep
If the simulation has bent waveguides, the following steps can be followed.
- Import a cell that has bent waveguides. In this example, we use EBeam::EBeam::ebeam_dc_halfring_straight.
- Change the simulation_setup_user_override to 1, in the analysis group settings. Further, set the bent_waveguide_parameter to the name of the p-cell parameter (i.e. -"radius").
- Choose the ports that are injected into bent waveguides (port 1 and port 2 in this example) and check the bent waveguide box under “Modal Properties” tab. Press OK.
- When you open the “Modal Properties” tab again, you will notice that the bend radius has been updated to the same value as the p-cell radius parameter automatically.
- Set up the FDTD simulation as shown below and use port 3 as the source port. Further, adjust the wg_extension_deltaL parameter as required (set to 1 um or 1e-6 in this example). (You will notice that the bent waveguide extensions have been converted to angled extensions).
- In the “Optimizations and Sweeps” tab, press “Create a New Parameter Sweep”.
- Set the parameter to sweep (radius (um) from 10 to 20 um, in this example) and the results to visualize (Transmission through port 2/4).
- Run the sweep. Once finished, the results will be available for visualization (Transmission through 4).