Git Product home page Git Product logo

opics's Introduction

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:

pip install opics

Installing from source

Download the OPICS source code.

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

Install the OPICS package using pip.

pip install -e ./opics

and upgrade using

pip install opics --upgrade

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

import opics

____ ____ _______________

/ __ / __ / _/ ____/ ___/

/ / / / /_/ // // / __

/ /_/ / ____// // /___ ___/ / ____/_/ /___/____//____/

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.

library_catalogue = opics.libraries.library_catalogue

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

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.

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)

<module 'opics.libraries' from 'c:\users\jeida\documents\github\dev-jaspreetj\opics\opics\libraries\__init__.py'>

List installed libraries

opics.libraries.installed_libraries

['ebeam']

List library components

opics.libraries.ebeam.components_list
['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.

opics.libraries.remove_library("ebeam")

importlib.reload(opics.libraries)

print(opics.libraries.installed_libraries)

[]

#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)

Download start Download finished. ['ebeam']

Library components

Let’s take a look at the library components.

ebeam_lib = opics.libraries.ebeam

Listing library components

ebeam_lib.components_list
['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.

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.

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.

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.

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

Connect components using the Network.connect module.

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

circuit.simulate_network()

<opics.components.componentModel at 0x2334a11daf0>

Plot the simulated response

circuit.sim_result.plot_sparameters(show_freq=False)

image

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

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

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's People

Contributors

jaspreetj avatar lukasc-ubc avatar mustafacc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opics's Issues

'TunableWG' object has no attribute 'componentParameters'

  • OPICS version: 0.3.3
  • Python version: 3.7
  • Operating System: WS11

I'm encountring an issue using TunableWG from the opics.libraries.ebeam

Here is how I'm using it >

wg2 = circuit.add_component(library.TunableWG, params={"length": 150e-6, "power": power_sweep})

And getting this error >

AttributeError: 'TunableWG' object has no attribute 'componentParameters'

Any suggestion for a solution?

Enhancement: Turn net into a class

  • OPICS version: 0.1.5
  • Python version: 3.7.7
  • Operating System: Win 64

Description

Currently nets are defined as a list. They should be turned into a class and allow for the following methods:

plot_net(self.net): plots the net s-parameters (as in probing the circuit at a specific net)
get_components(self.net) returns the components connected to the net

Can't change frequency list in Microring example

  • OPICS version: 0.3.3
  • Python version: Python 3.10.5
  • Operating System: Arch Linux

Description

I was trying to change the frequency range used in the microring example by changing the line in the Network initialization:

freq = np.linspace(C * 1e6 / 1.5, C * 1e6 / 1.6, 2000)

I changed "2000" to "20000" hoping to get 20000 points in the output plot instead of 2000 for more resolution.

When I did this I got an error:

daniel@acer-swift maybe_trash]$ python microring.py

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

OPICS version 0.3.3
20000
Traceback (most recent call last):
  File "/home/daniel/documents/school/masc/research/maybe_trash/microring.py", line 35, in <module>
    circuit.sim_result.plot_sparameters(
  File "/home/daniel/.local/lib/python3.10/site-packages/opics/components.py", line 262, in plot_sparameters
    plt.plot(x_data, np.square(np.abs(self.s[:, int(i), int(j)])))
  File "/usr/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2769, in plot
    return gca().plot(
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 1632, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 312, in __call__
    yield from self._plot_args(this, kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 498, in _plot_args
    raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (2000,) and (20000,)

What I Did

I was thinking this probably came from using the global frequency list instead of the supplied frequency list somewhere in the code. I traced my issue back in the Opics code to this line:

combination_f = F

This line seems to set the frequency list of the combined component to the global frequency list rather than using the frequency list of the supplied components. I believe this line should reuse the frequency list from the components that are being combined.

One quick fix for this is to change the line to:

combination_f = components[0].f

This fixes the problem for me. However, I'm not sure if this is an actual issue or if there's a proper way to do this I missed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.