Skip to content

Commit

Permalink
fix simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Mar 24, 2024
1 parent 3a09249 commit 5af193f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
]
dependencies = [
"gdsfactory==7.22.2",
"gplugins[tidy3d,sax,schematic]>=0.10.2,<0.11"
"gplugins[tidy3d,sax,schematic]>=0.11,<0.12"
]
description = "ubcpdk pdk"
keywords = ["python"]
Expand Down
10 changes: 6 additions & 4 deletions ubcpdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from gdsfactory.config import PATH as GPATH
from gdsfactory.get_factories import get_cells
from gdsfactory.pdk import Pdk
from gplugins.sax.models import get_models

from ubcpdk import components, data, tech
from ubcpdk import components, data, models, tech
from ubcpdk.config import CONFIG, PATH
from ubcpdk.tech import LAYER, LAYER_STACK, LAYER_VIEWS, cross_sections

Expand All @@ -29,6 +30,7 @@
name="ubcpdk",
cells=cells,
cross_sections=cross_sections,
models=get_models(models),
layers=dict(LAYER),
layer_stack=LAYER_STACK,
layer_views=LAYER_VIEWS,
Expand All @@ -40,6 +42,6 @@


if __name__ == "__main__":
f = PDK.cells
for k, _v in f.items():
print(k)
m = get_models(models)
for model in m.keys():
print(model)
57 changes: 20 additions & 37 deletions ubcpdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,33 @@

from functools import partial

from gplugins.sax.models import (
attenuator,
bend,
coupler,
grating_coupler,
mmi1x2,
mmi2x2,
phase_shifter,
)
from gplugins.sax.models import straight as _straight
import gplugins.sax.models as sm

nm = 1e-3


straight = partial(_straight, wl0=1.55, neff=2.4, ng=4.2)
bend_euler = partial(bend, loss=0.03)
straight = partial(sm.straight, wl0=1.55, neff=2.4, ng=4.2)
bend_euler_sc = bend_euler = partial(sm.bend, loss=0.03)

gc_te1550 = partial(grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)
gc_te1550_broadband = partial(grating_coupler, loss=6, bandwidth=50 * nm, wl0=1.55)
gc_tm1550 = partial(grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)

gc_te1310_broadband = partial(grating_coupler, loss=6, bandwidth=50 * nm, wl0=1.31)
gc_te1310 = partial(grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.31)


models = dict(
attenuator=attenuator,
bend_euler=bend,
coupler=coupler,
mmi1x2=mmi1x2,
mmi2x2=mmi2x2,
phase_shifter=phase_shifter,
straight=straight,
taper=straight,
gc_te1550=gc_te1550,
gc_te1550_broadband=gc_te1550_broadband,
gc_tm1550=gc_tm1550,
gc_te1310_broadband=gc_te1310_broadband,
gc_te1310=gc_te1310,
)
################
# grating couplers
################
gc_te1550 = partial(sm.grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)
gc_te1550_broadband = partial(sm.grating_coupler, loss=6, bandwidth=50 * nm, wl0=1.55)
gc_tm1550 = partial(sm.grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)
gc_te1310_broadband = partial(sm.grating_coupler, loss=6, bandwidth=50 * nm, wl0=1.31)
gc_te1310 = partial(sm.grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.31)

################
# MMIs
################
mmi1x2 = partial(sm.mmi1x2, wl0=1.55, fwhm=0.2, loss_dB=0.3)
mmi2x2 = partial(sm.mmi2x2, wl0=1.55, fwhm=0.2, loss_dB=0.3)
ebeam_y_1550 = mmi1x2
coupler = sm.coupler

if __name__ == "__main__":
import gplugins.sax as gs

gs.plot_model(grating_coupler)
# gs.plot_model(coupler)
gs.plot_model(gc_te1550)
gs.plot_model(coupler)
34 changes: 34 additions & 0 deletions ubcpdk/samples/test_circuit_simulations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import jax.numpy as jnp
import matplotlib.pyplot as plt
import sax

import ubcpdk
from ubcpdk import PDK


def test_mzi():
c = ubcpdk.components.mzi(delta_length=20)
netlist = c.get_netlist()
models = PDK.models
circuit, _ = sax.circuit(netlist, models=models) # type: ignore
wl = jnp.linspace(1.5, 1.6)

S = circuit(wl=wl)
assert S


if __name__ == "__main__":
c = ubcpdk.components.mzi(delta_length=20)
netlist = c.get_netlist()
models = PDK.models
circuit, _ = sax.circuit(netlist, models=models) # type: ignore
wl = jnp.linspace(1.5, 1.6)

S = circuit(wl=wl)
plt.figure(figsize=(14, 4))
plt.title("MZI")
plt.plot(1e3 * wl, jnp.abs(S["o1", "o2"]) ** 2) # type: ignore
plt.xlabel("λ [nm]")
plt.ylabel("T")
plt.grid(True)
plt.show()

0 comments on commit 5af193f

Please sign in to comment.