Setting up the editor environment (PyCharm)¶
If you haven’t installed PyCharm yet, please download a copy from https://www.jetbrains.com/pycharm/download/. The Community Edition is well suited for IPKISS use and is free of charge.
IPKISS comes with preconfigured PyCharm IDE settings. To use these settings, you need to start PyCharm through the Luceda Control Center.
The following settings are preconfigured:
- Default location of new projects (under
- Setting up of the Python interpreter. The name of the interpreter contains the IPKISS version that you’ll use (for example, ‘ipkiss 3.1.3, python 2.7.15’)
- The interpreter can be selected when starting a new design project
- The samples project is set up to open from the correct location, using the installed Python interpreter. To open the samples, just click the ‘Samples in PyCharm’ button.
Although we recommend to start PyCharm via the Luceda Control Center, PyCharm can be of course also be started in the classical way (from the start menu or desktop shortcut on Windows, or from the terminal on Linux). In this case, a bit more setup is needed to choose the proper Python executable, configure the samples project, etc.
Creating a PyCharm project¶
Like many IDE’s, PyCharm has a built-in project manager that we can use to structure our work into different projects. In order to create a new project, start PyCharm and select Create(note: if this is your first time running, you’ll see this window anyway):
Specify the project
C:\Users\username\luceda\projects\my_design_project. Note that the correct Python interpreter is already chosen (with IPKISS 3.1.3 preinstalled):
Then click. Once the project has been created, you can start creating python packages and modules.
Configuring Python interpreter after project creation¶
We have configured the Python interpreter when we created a project in the previous step. But if that’s not done for some reason (for example, in case you directly open a folder in PyCharm), we can also configure that from the project settings in PyCharm. In PyCharm menu bar, selectThen in the Settings dialog, select tab. Then, select the gear next to the interpreter list; and then click .
In Add Local Python Interpreter dialog, under Conda Environment section, select
You may enable Make available to all projects. Then click.
This is how you create a fresh new IPKISS design project in PyCharm. In the following, we provide a design project example, so you may have a first try from directly opening an IPKISS project and run a first IPKISS design.
Setting up an IPKISS design project¶
Before we do our first design, we need to set up the design project structure properly so the design project can be easier extended and maintained.
Typically, a photonics design consists of custom PCells, subcircuits, input-output cells, top-level circuits, and utility functions for automating parts of the design flow. All those files are organized in different Python files and are part of the IPKISS design project. A design project also typically links to a PDK (Process Design Kit) which contains the technology information and a series of predefined building blocks.
We strongly recommend structuring your files, and, if possible, use version control to manage and share your code in an efficient way.
To illustrate this, let’s take the example project that is bundled with the IPKISS installation. First, open this project in PyCharm by
<path_to_IPKISS_installation>\samples\demo\projects. After loading, you will see the following project structure in the PyCharm project navigator:
You may refer to Library Organization in the documentation to find out more explanations on the library structure and its content.
Let’s now add the PDK and a custom design library that we’d like to reference in our current design project. Go to
Now add an additional content root: add
<path_to_IPKISS_installation>\samples\demo\built_libraries\my_library to the project. Now your project looks like shown below. It contains the reference to the PDK demolib, a user-made library my_library, and a series of designs that create GDSII files:
Now, the project has all the packages needed (PDKs and other custom design floders).
If you have an IPKISS version of the PDK (e.g., IMEC, IME, IHP, IMECAS, Cornerstone, ASP, SiEPIC, LigenTec, Smartphotonics, Tyndall), you will use it as an imported module in your IPKISS design project in PyCharm. Similar to how we added demolib in the previous step, you can also add the PDKs mentioned above to your project.
In order to be able to use those packages in your IPKISS design, next, we will tell PyCharm to properly reference them.
Adding PDKs (or other modules) to your PYTHONPATH¶
Before we run a first sample design, we need to configure
PYTHONPATH (this is where Python searches for packages & modules).
In this sample project, we will add the demolib PDK and the custom design library my_library to
PYTHONPATH. This can be done by right-clicking on the folders in the project navigator, then select .
You may see the marked directory is highlighted in blue color now:
Now you can start designing. For example, you may test your settings by running a first IPKISS design:
After running, a 4-channel ring DEMUX will be visualized, and written to GDS.
Some useful PyCharm features¶
Below you find a short, incomplete list of a few useful features:
While typing, PyCharm will try to autocomplete your code. This happens automatically as you type your class, function or method. To invoke the auto-completion manually, press the Ctrl+Space key.
If PyCharm can deduce what you’re trying to type it will complete your code. If multiple choices are available, it will present those choices to you.
To efficiently jump to the definition of an object, just hover your cursor over the class, function or module to which you want to navigate and press Ctrl+[left-click]. PyCharm will then jump to the correct location. When you just press Ctrl, PyCharm will present a link if it knows where to jump to, and also the documentation of the class.
To place a breakpoint, left click next to the line number. Now a red dot appears. When you now debug your program (by Ctrl+[right-click] somewhere in your code window and selecting ‘Debug [filename]’), it will stop right before executing this dot:
If you are familiar with Wing IDE and want to set up IPKISS for Wing, you can follow the guide to set up Wing IDE.
Manually setting the project interpreter¶
If you are not starting PyCharm from the Luceda Control Center, you will want to manually set the project interpreter.
Continuing from the ‘Create Project’ menu, in the same dialog window, expand the Project Interpreter label and select. Then select .
You are prompted with Add Local Python Interpreter dialog. Under Conda Environment section, modify the Interpreter path to:
<path_to_IPKISS_installation>/python/envs/ipkiss3/python.exe. You may enable Make available to all projects. Then click .
- Introduction to Python
- Setting up the editor environment (PyCharm)
- Quickstart: First simple circuit design
- First simple layout
- Advanced layout: hierarchy and waveguides
- Implementing circuit models in IPKISS
- Advanced topics in circuit modeling