Skip to content

Commit

Permalink
load opics library, unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Jan 8, 2025
1 parent 4918bca commit d085fda
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
7 changes: 6 additions & 1 deletion klayout/EBeam/pymacros/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# $autorun

version = "0.4.30"
version = "0.4.31"

print('SiEPIC-EBeam-PDK Python module: pymacros, v%s' % version)

Expand All @@ -19,3 +19,8 @@
load_klayout_library(tech, 'EBeam-ANT', "v%s, ANT components" % version, 'gds/ANT','', verbose=verbose)


# Load OPICS simulation library
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import opics_ebeam

56 changes: 56 additions & 0 deletions klayout/EBeam/pymacros/tests/test_opics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@


# Unit test for simulation using OPICS


def test_opics():
import SiEPIC

# using https://github.com/siepic/opics
# in SiEPIC-Tools
import SiEPIC.opics as opics
from SiEPIC.opics.network import Network
from SiEPIC.opics.globals import C

import siepic_ebeam_pdk

import opics_ebeam
ebeam_lib = opics_ebeam

print(f"Components: {ebeam_lib.components_list}")

# Create a Mach-Zehnder circuit simulation
import numpy as np
freq = np.linspace(C * 1e6 / 1.45, C * 1e6 / 1.61, 5000)
circuit = Network(network_id="circuit_name", f=freq)

input_gc = circuit.add_component(ebeam_lib.GC)
y = circuit.add_component(ebeam_lib.Y)
wg2 = circuit.add_component(ebeam_lib.ebeam_wg_integral_1550, params=dict(wg_length=40e-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)

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

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)

circuit.simulate_network()

result = circuit.sim_result.get_data()
wavelengths = C/circuit.f
transmission = result['S_0_1']
reflection = result['S_0_0']

print(len(transmission))

assert len(transmission)==5000

if __name__ == "__main__":
test_opics()
4 changes: 2 additions & 2 deletions klayout/grain.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<salt-grain>
<name>siepic_ebeam_pdk</name>
<version>0.4.30</version>
<version>0.4.31</version>
<api-version>0.27</api-version>
<title>SiEPIC EBeam PDK</title>
<doc>A Process Design Kit for Silicon Photonics fabricated using Electron Beam Lithography, at Applied Nanotools (ANT)</doc>
Expand All @@ -14,7 +14,7 @@
<depends>
<name>siepic_tools</name>
<url/>
<version>0.5.16</version>
<version>0.5.19</version>
</depends>
<depends>
<name>xsection</name>
Expand Down
2 changes: 1 addition & 1 deletion klayout/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ packages = [

[project]
name = "siepic_ebeam_pdk"
version = "0.4.30"
version = "0.4.31"
authors = [
{ name="Lukas Chrostowski", email="[email protected]" },
]
Expand Down

0 comments on commit d085fda

Please sign in to comment.