Skip to content

Commit

Permalink
custom mmi
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed Mar 7, 2024
1 parent 79a09e9 commit 7efa69b
Showing 1 changed file with 54 additions and 18 deletions.
72 changes: 54 additions & 18 deletions cspdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import jax
import jax.numpy as jnp
import sax
from gplugins.sax.models import bend, coupler, grating_coupler, straight
from gplugins.sax.models import bend, grating_coupler, straight

from cspdk.tech import LAYER

Expand Down Expand Up @@ -106,7 +106,6 @@ def _check_cross_section(cross_section):
raise err


@partial(jax.jit, static_argnames=["cross_section"])
def _straight(
*,
wl: float = 1.55,
Expand Down Expand Up @@ -150,18 +149,59 @@ def _straight(
# MMIs
################

mmi1x2_rc = coupler
mmi2x2_rc = coupler
mmi1x2_sc = coupler
mmi2x2_sc = coupler
mmi1x2_ro = coupler
mmi2x2_ro = coupler
mmi1x2_so = coupler
mmi2x2_so = coupler
mmi1x2_no = coupler
mmi2x2_no = coupler
mmi1x2_nc = coupler
mmi2x2_nc = coupler

def _mmi_amp(wl=1.55, wl0=1.55, fwhm=0.2, loss_dB=0.3):
max_power = 10 ** (-abs(loss_dB) / 10)
print(max_power)
f = 1 / wl
f0 = 1 / wl0
f1 = 1 / (wl0 + fwhm / 2)
f2 = 1 / (wl0 - fwhm / 2)
_fwhm = f2 - f1

sigma = _fwhm / (2 * jnp.sqrt(2 * jnp.log(2)))
power = jnp.exp(-((f - f0) ** 2) / (2 * sigma**2))
power = max_power * power / power.max() / 2
amp = jnp.sqrt(power)
return amp


def mmi1x2(wl=1.55, wl0=1.55, fwhm=0.2, loss_dB=0.3):
thru = _mmi_amp(wl=wl, wl0=wl0, fwhm=fwhm, loss_dB=loss_dB)
return sax.reciprocal(
{
("o1", "o2"): thru,
("o1", "o3"): thru,
}
)


def mmi2x2(wl=1.55, wl0=1.55, fwhm=0.2, loss_dB=0.3, shift=0.005):
thru = _mmi_amp(wl=wl, wl0=wl0, fwhm=fwhm, loss_dB=loss_dB)
cross = 1j * _mmi_amp(wl=wl, wl0=wl0 + shift, fwhm=fwhm, loss_dB=loss_dB)
return sax.reciprocal(
{
("o1", "o3"): thru,
("o1", "o4"): cross,
("o2", "o3"): cross,
("o2", "o4"): thru,
}
)


mmi1x2_rc = mmi1x2
mmi1x2_sc = mmi1x2
mmi1x2_ro = mmi1x2
mmi1x2_so = mmi1x2
mmi1x2_no = mmi1x2
mmi1x2_nc = mmi1x2

mmi2x2_nc = mmi2x2
mmi2x2_no = mmi2x2
mmi2x2_so = mmi2x2
mmi2x2_ro = mmi2x2
mmi2x2_rc = mmi2x2
mmi2x2_sc = mmi2x2

##############################
# grating couplers Rectangular
Expand Down Expand Up @@ -248,7 +288,3 @@ def _crossing(wl=1.5):
pad=pad,
heater=heater,
)


if __name__ == "__main__":
print(coupler())

0 comments on commit 7efa69b

Please sign in to comment.