Package: opics
Installing OPICSInstalling from pypiThe easiest way to install OPICS is using pip pypi:pip install opicsInstalling from sourceDownload the OPICS source code.git clone https://github.com/jaspreetj/opicsInstall the OPICS package usingpip.pip install -e ./opicsOnce the package is installed, it can be imported using:import opics as opOPICS LibrariesListing available librariesThe package does not come with any component libraries pre-installed.
You can select and download available libraries from the library
catalogue.library_catalogue = op.libraries.library_catalogue

print(f"Available Libraries: {[_ for _ in library_catalogue.keys()]} ")Downloading librariesThe OPICS libraries are downloaded by passing inlibrary_name,library_url, andlibrary_pathto thelibraries.download_librarymodule. The module returnsTrueif
the library is downloaded successfully.import os
installation_path = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop\\delete')

op.libraries.download_library("ebeam",  installation_path)

# reload libraries
import importlib
importlib.reload(op.libraries)List installed librariesop.libraries.installed_librariesList library componentsop.libraries.ebeam.components_listRemove librariesAny of the installed libraries can be removed using thelibraries.remove_librarymodule.op.libraries.remove_library("ebeam")

importlib.reload(op.libraries)

print(op.libraries.installed_libraries)#reinstall ebeam library
op.libraries.download_library(
    library_name="ebeam",
    library_path=installation_path,
)

importlib.reload(op.libraries)

print(op.libraries.installed_libraries)Library componentsLetâ€™s take a look at the library components.ebeam_lib = op.libraries.ebeamListing library componentsebeam_lib.components_listLetâ€™s take a look inside a component for more information on its
parameters and layout, such as port locations.ebeam_lib.BDC?Setting up a simulationThe network module is used to define a circuit, add and connect
components. The network module takesnetwork_idandfas inputs.
If nofor frequency data points specified, the network module uses
the default value specified inopics.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 theNetwork.connectmodule.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/circuitcircuit.simulate_network()Plot the simulated responsecircuit.sim_result.plot_sparameters(show_freq=False)An interactive plot can be spawned by enabling the interactive option.circuit.sim_result.plot_sparameters(show_freq=False, interactive=True)