Skip to content

Commit

Permalink
Merge pull request #5 from gdsfactory/add_models
Browse files Browse the repository at this point in the history
add models
  • Loading branch information
joamatab authored Mar 7, 2024
2 parents ea06fed + db93c7d commit 0148320
Show file tree
Hide file tree
Showing 60 changed files with 1,651 additions and 128 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build docs
name: build docs

on:
pull_request:
push:
branches:
- main
Expand All @@ -16,7 +17,7 @@ jobs:
- name: Installing the library
shell: bash -l {0}
run: |
make dev
make install
- name: make docs
run: |
make docs
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
install:
pip install -e .[dev]
pre-commit install

dev:
pip install -e .[dev,docs]

test:
Expand Down
64 changes: 56 additions & 8 deletions cspdk/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
################
# Waveguides
################

straight_sc = partial(gf.c.straight, cross_section=xs_sc)
straight_so = partial(gf.c.straight, cross_section=xs_so)
straight_rc = partial(gf.c.straight, cross_section=xs_rc)
straight_ro = partial(gf.c.straight, cross_section=xs_ro)
straight_nc = partial(gf.c.straight, cross_section=xs_nc)
straight_no = partial(gf.c.straight, cross_section=xs_no)
straight_sc = partial(gf.c.straight, cross_section=xs_sc, info={"model": "straight_sc"})
straight_so = partial(gf.c.straight, cross_section=xs_so, info={"model": "straight_so"})
straight_rc = partial(gf.c.straight, cross_section=xs_rc, info={"model": "straight_rc"})
straight_ro = partial(gf.c.straight, cross_section=xs_ro, info={"model": "straight_ro"})
straight_nc = partial(gf.c.straight, cross_section=xs_nc, info={"model": "straight_nc"})
straight_no = partial(gf.c.straight, cross_section=xs_no, info={"model": "straight_no"})
straight = straight_sc


bend_sc = partial(gf.c.bend_euler, cross_section=xs_sc)
Expand Down Expand Up @@ -228,6 +228,54 @@
layer_slab=LAYER.NITRIDE,
slab_offset=0,
)
################
# MZI
################

mzi_sc = partial(
gf.c.mzi,
straight=straight_sc,
cross_section=xs_sc,
combiner=mmi1x2_sc,
splitter=mmi1x2_sc,
)
mzi_so = partial(
gf.c.mzi,
straight=straight_so,
cross_section=xs_so,
combiner=mmi1x2_sc,
splitter=mmi1x2_sc,
)
mzi_rc = partial(
gf.c.mzi,
straight=straight_rc,
cross_section=xs_rc,
combiner=mmi1x2_rc,
splitter=mmi1x2_rc,
)
mzi_ro = partial(
gf.c.mzi,
straight=straight_ro,
cross_section=xs_ro,
combiner=mmi1x2_ro,
splitter=mmi1x2_ro,
)

mzi_nc = partial(
gf.c.mzi,
straight=straight_nc,
cross_section=xs_nc,
combiner=mmi1x2_nc,
splitter=mmi1x2_nc,
)
mzi_no = partial(
gf.c.mzi,
straight=straight_no,
cross_section=xs_no,
combiner=mmi1x2_no,
splitter=mmi1x2_no,
)


################
# Packaging
Expand Down Expand Up @@ -354,7 +402,7 @@ def crossing_sc() -> gf.Component:


if __name__ == "__main__":
c = mmi1x2_rc()
c = straight_sc()
# c = gf.Component()
# w = c << straight_rc()
# t = c << trans_sc_rc10()
Expand Down
6 changes: 3 additions & 3 deletions cspdk/klayout/d25/Cornerstone.lyd25
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ core = input(3, 0)
nitride = input(203, 0)
nitride_etch = input(204, 0)
heater = input(39, 0)
metal2 = input(41, 0)
metal = input(41, 0)



z(core, zstart: 0.0, zstop: 0.2, name: 'core: si 3/0', )
z(nitride, zstart: 0.0, zstop: 0.3, name: 'nitride: sin 203/0', )
z(nitride_etch, zstart: 0.0, zstop: 0.3, name: 'nitride_etch: sin 204/0', )
z(heater, zstart: 1.1, zstop: 1.9, name: 'heater: TiN 39/0', )
z(metal2, zstart: 1.8, zstop: 2.5, name: 'metal2: Aluminum 41/0', )
z(heater, zstart: 1.1, zstop: 1.8, name: 'heater: TiN 39/0', )
z(metal, zstart: 1.8, zstop: 2.5, name: 'metal: Aluminum 41/0', )


</text>
Expand Down
34 changes: 34 additions & 0 deletions cspdk/klayout/layers.lyp
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,38 @@
<name>FLOORPLAN 99/0</name>
<source>99/0@1</source>
</properties>
<properties>
<frame-color>#00ffff</frame-color>
<fill-color>#00ffff</fill-color>
<frame-brightness>0</frame-brightness>
<fill-brightness>0</fill-brightness>
<dither-pattern>I1</dither-pattern>
<line-style/>
<valid>true</valid>
<visible>true</visible>
<transparent>false</transparent>
<width/>
<marked>false</marked>
<xfill>false</xfill>
<animation>0</animation>
<name>LABEL_SETTINGS 100/0</name>
<source>100/0@1</source>
</properties>
<properties>
<frame-color>#00ffff</frame-color>
<fill-color>#00ffff</fill-color>
<frame-brightness>0</frame-brightness>
<fill-brightness>0</fill-brightness>
<dither-pattern>I1</dither-pattern>
<line-style/>
<valid>true</valid>
<visible>true</visible>
<transparent>false</transparent>
<width/>
<marked>false</marked>
<xfill>false</xfill>
<animation>0</animation>
<name>LABEL_INSTANCE 101/0</name>
<source>101/0@1</source>
</properties>
</layer-properties>
34 changes: 34 additions & 0 deletions cspdk/klayout/tech/layers.lyp
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,38 @@
<name>FLOORPLAN 99/0</name>
<source>99/0@1</source>
</properties>
<properties>
<frame-color>#00ffff</frame-color>
<fill-color>#00ffff</fill-color>
<frame-brightness>0</frame-brightness>
<fill-brightness>0</fill-brightness>
<dither-pattern>I1</dither-pattern>
<line-style/>
<valid>true</valid>
<visible>true</visible>
<transparent>false</transparent>
<width/>
<marked>false</marked>
<xfill>false</xfill>
<animation>0</animation>
<name>LABEL_SETTINGS 100/0</name>
<source>100/0@1</source>
</properties>
<properties>
<frame-color>#00ffff</frame-color>
<fill-color>#00ffff</fill-color>
<frame-brightness>0</frame-brightness>
<fill-brightness>0</fill-brightness>
<dither-pattern>I1</dither-pattern>
<line-style/>
<valid>true</valid>
<visible>true</visible>
<transparent>false</transparent>
<width/>
<marked>false</marked>
<xfill>false</xfill>
<animation>0</animation>
<name>LABEL_INSTANCE 101/0</name>
<source>101/0@1</source>
</properties>
</layer-properties>
10 changes: 10 additions & 0 deletions cspdk/layers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ LayerViews:
layer_in_name: true
color: "black"
hatch_pattern: hollow
LABEL_SETTINGS:
layer: [100, 0]
layer_in_name: true
color: "cyan"
hatch_pattern: hollow
LABEL_INSTANCE:
layer: [101, 0]
layer_in_name: true
color: "cyan"
hatch_pattern: hollow
73 changes: 54 additions & 19 deletions cspdk/models.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,67 @@
from __future__ import annotations

from functools import partial

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

nm = 1e-3

straight_sc = partial(sm.straight, neff=2.34, ng=4.2, wl0=1.55)
straight_so = partial(sm.straight, neff=2.34, ng=4.2, wl0=1.31)

gc_rectangular_sc = partial(sm.grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)
gc_rectangular_so = partial(sm.grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.31)
straight_sc = partial(straight, wl0=1.55, neff=2.4, ng=4.2)
straight_so = partial(straight, wl0=1.31, neff=2.4, ng=4.2)
straight_rc = partial(straight, wl0=1.55, neff=2.4, ng=4.2)
straight_ro = partial(straight, wl0=1.31, neff=2.4, ng=4.2)
straight_nc = partial(straight, wl0=1.55, neff=2.4, ng=4.2)
straight_no = partial(straight, wl0=1.31, neff=2.4, ng=4.2)

bend_sc = partial(bend, loss=0.03)
bend_so = partial(bend, loss=0.03)
bend_rc = partial(bend, loss=0.03)
bend_ro = partial(bend, loss=0.03)
bend_nc = partial(bend, loss=0.03)
bend_no = partial(bend, loss=0.03)

bend_sc = partial(sm.bend, loss=0.03)
bend_so = partial(sm.bend, loss=0.03)
bend_rc = partial(sm.bend, loss=0.03)
bend_ro = partial(sm.bend, loss=0.03)
bend_nc = partial(sm.bend, loss=0.03)
bend_no = partial(sm.bend, loss=0.03)
gc_rectangular_sc = partial(grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.55)
gc_rectangular_so = partial(grating_coupler, loss=6, bandwidth=35 * nm, wl0=1.31)


models = dict(
straight_sc=straight_sc,
straight_so=straight_so,
gc_rectangular_sc=gc_rectangular_sc,
gc_rectangular_so=gc_rectangular_so,
bend_sc=bend_sc,
bend_so=bend_so,
bend_rc=bend_rc,
bend_ro=bend_ro,
attenuator=attenuator,
bend_euler=bend,
bend_nc=bend_nc,
bend_no=bend_no,
bend_rc=bend_rc,
bend_ro=bend_ro,
bend_sc=bend_sc,
bend_so=bend_so,
coupler=coupler,
gc_rectangular_sc=gc_rectangular_sc,
gc_rectangular_so=gc_rectangular_so,
mmi1x2=mmi1x2,
mmi2x2=mmi2x2,
phase_shifter=phase_shifter,
straight=straight,
straight_sc=straight_sc,
straight_so=straight_so,
straight_rc=straight_rc,
straight_ro=straight_ro,
straight_nc=straight_nc,
straight_no=straight_no,
taper=straight,
)


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

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

import cspdk
from cspdk.models import models

if __name__ == "__main__":
c = cspdk.cells.mzi_nc(delta_length=20)
netlist = c.get_netlist()
circuit, _ = sax.circuit(netlist, models=models)
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)
plt.xlabel("λ [nm]")
plt.ylabel("T")
plt.grid(True)
plt.show()
54 changes: 54 additions & 0 deletions cspdk/samples/component_from_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
sample_pads = """
name: pads
pdk: cspdk
instances:
bl:
component: pad
tl:
component: pad
br:
component: pad
tr:
component: pad
placements:
tl:
x: -200
y: 500
br:
x: 400
y: 400
tr:
x: 400
y: 600
routes:
electrical:
settings:
cross_section: xs_metal_routing
separation: 20
width: 10
path_length_match_loops: 2
end_straight_length: 100
links:
tl,e3: tr,e1
bl,e3: br,e1
optical:
settings:
cross_section: xs_sc
radius: 100
links:
bl,e4: br,e3
"""


if __name__ == "__main__":
import gdsfactory as gf

c = gf.read.from_yaml(sample_pads)
c.show()
4 changes: 4 additions & 0 deletions cspdk/tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class LayerMapCornerstone(LayerMap):
NITRIDE: Layer = (203, 0)
NITRIDE_ETCH: Layer = (204, 0)

# labels for gdsfactory
LABEL_SETTINGS: Layer = (100, 0)
LABEL_INSTANCE: Layer = (101, 0)


LAYER = LayerMapCornerstone()

Expand Down
Loading

0 comments on commit 0148320

Please sign in to comment.