Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/siepic/opics

Photonic circuit simulator
https://github.com/siepic/opics

circuit circuit-solver photonics python python-package siepic siepic-photonics silicon silicon-photonics simulator solver ubc-photonics-group

Last synced: 2 months ago
JSON representation

Photonic circuit simulator

Lists

README

        

|build_badge| |license| |pypi|
==============================================

|opics_logo|

Open Photonic Integrated Circuit Simulator (OPICS)
==================================================

**OPICS** is an S-parameter based photonic integrated circuit simulator. For more information, refer to OPICS `Documentation `__

OPICS Quickstart
================

Installing OPICS
----------------

Installing from pypi
~~~~~~~~~~~~~~~~~~~~

The easiest way to install OPICS is using pip pypi:

.. code:: console

pip install opics

Installing from source
~~~~~~~~~~~~~~~~~~~~~~

Download the OPICS source code.

.. code:: console

git clone https://github.com/jaspreetj/opics

Install the OPICS package using ``pip``.

.. code:: console

pip install -e ./opics

and upgrade using

.. code:: console

pip install opics --upgrade

Once the package is installed, it can be imported using:

.. code:: ipython3

import opics

.. parsed-literal::

____ ____ _______________
/ __ \/ __ \/ _/ ____/ ___/
/ / / / /_/ // // / \__ \
/ /_/ / ____// // /___ ___/ /
\____/_/ /___/\____//____/

OPICS version 0.3.1

OPICS Libraries
---------------

Listing available libraries
~~~~~~~~~~~~~~~~~~~~~~~~~~~

The package does not come with any component libraries pre-installed.
You can select and download available libraries from the library
catalogue.

.. code:: ipython3

library_catalogue = opics.libraries.library_catalogue

print(f"Available Libraries: {[_ for _ in library_catalogue.keys()]} ")

.. parsed-literal::

Available Libraries: ['ebeam', 'shuksan']

Downloading libraries
~~~~~~~~~~~~~~~~~~~~~

The OPICS libraries are downloaded by passing in ``library_name``,
``library_url``, and ``library_path`` to the
``libraries.download_library`` module. The module returns ``True`` if
the library is downloaded successfully.

.. code:: ipython3

library = library_catalogue["ebeam"]

import os
installation_path = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop\\delete')

opics.libraries.download_library(
library_name=library["name"],
library_url=library["dl_link"],
library_path=installation_path,
)

# reload libraries
import importlib
importlib.reload(opics.libraries)

.. parsed-literal::

List installed libraries
~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython3

opics.libraries.installed_libraries

.. parsed-literal::

['ebeam']

List library components
~~~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython3

opics.libraries.ebeam.components_list

.. parsed-literal::

['BDC',
'DC_halfring',
'GC',
'Switch',
'TunableWG',
'Waveguide',
'Y',
'ebeam_y_1550',
'ebeam_gc_te1550',
'ebeam_wg_integral_1550']

Remove libraries
~~~~~~~~~~~~~~~~

Any of the installed libraries can be removed using the
``libraries.remove_library`` module.

.. code:: ipython3

opics.libraries.remove_library("ebeam")

importlib.reload(opics.libraries)

print(opics.libraries.installed_libraries)

.. parsed-literal::

[]

.. code:: ipython3

#reinstall ebeam library
opics.libraries.download_library(
library_name=library["name"],
library_url=library["dl_link"],
library_path=installation_path,
)

importlib.reload(opics.libraries)

print(opics.libraries.installed_libraries)

.. parsed-literal::

Download start
Download finished.
['ebeam']

Library components
~~~~~~~~~~~~~~~~~~

Let’s take a look at the library components.

.. code:: ipython3

ebeam_lib = opics.libraries.ebeam

Listing library components

.. code:: ipython3

ebeam_lib.components_list

.. parsed-literal::

['BDC',
'DC_halfring',
'GC',
'Switch',
'TunableWG',
'Waveguide',
'Y',
'ebeam_y_1550',
'ebeam_gc_te1550',
'ebeam_wg_integral_1550']

Let’s take a look inside a component for more information on its
parameters and layout, such as port locations.

.. code:: ipython3

ebeam_lib.Y?

Setting up a simulation
-----------------------

The network module is used to define a circuit, add and connect
components. The network module takes ``network_id`` and ``f`` as inputs.
If no ``f`` or frequency data points specified, the network module uses
the default value specified in ``opics.globals.F``.

.. code:: ipython3

from opics import Network
from opics.globals import C
import numpy as np

freq = np.linspace(C * 1e6 / 1.5, C * 1e6 / 1.6, 2000)
circuit = Network(network_id="circuit_name", f=freq)

Once an empty network is defined. We can start by adding components.

.. code:: ipython3

input_gc = circuit.add_component(ebeam_lib.GC)
y = circuit.add_component(ebeam_lib.Y)
wg2 = circuit.add_component(ebeam_lib.Waveguide, params=dict(length=0e-6))
wg1 = circuit.add_component(ebeam_lib.Waveguide, params={"length":15e-6})
y2 = circuit.add_component(ebeam_lib.Y)
output_gc = circuit.add_component(ebeam_lib.GC)

We can also define custom port names for components for easy reference.

.. code:: ipython3

input_gc.set_port_reference(0, "input_port")
output_gc.set_port_reference(0, "output_port")

Connect components using the ``Network.connect`` module.

.. code:: ipython3

circuit.connect(input_gc, 1, y, 0)
circuit.connect(y, 1, wg1, 0)
circuit.connect(y, 2, wg2, 0)
circuit.connect(y2, 0, output_gc, 1)
circuit.connect(wg1, 1, y2, 1)
circuit.connect(wg2, 1, y2, 2)

Simulate the network/circuit

.. code:: ipython3

circuit.simulate_network()

.. parsed-literal::

Plot the simulated response

.. code:: ipython3

circuit.sim_result.plot_sparameters(show_freq=False)

.. image:: /notebooks/_static/00-Quickstart_files/00-Quickstart_30_0.png

An interactive plot can be spawned by enabling the interactive option.

.. code:: ipython3

circuit.sim_result.plot_sparameters(show_freq=False, interactive=True)

.. raw:: html


.. raw:: html



Citing
~~~~~~

``OPICS`` is written by Jaspreet Jhoja. You can cite the package as

::

@misc{jhoja-2020-opics,
author = {Jaspreet Jhoja},
title = {OPICS: An Open Photonic Integrated Circuit Solver},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/SiEPIC-Kits/OPICS}}
}

License
~~~~~~~

Copyright © 2022, Jaspreet Jhoja, `MIT License `__

.. |opics_logo| image:: /docs/source/_static/_images/opics_logo.png

.. |pypi| image:: https://img.shields.io/pypi/v/opics?color=blue
:target: https://pypi.python.org/pypi/opics
.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://github.com/jaspreetj/opics/blob/master/LICENSE
.. |build_badge| image:: https://github.com/jaspreetj/opics/actions/workflows/CI.yml/badge.svg?branch=master
:target: https://github.com/jaspreetj/opics/actions/workflows/CI.yml