Skip to content

Commit

Permalink
wrong netlisting
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed May 20, 2024
1 parent ea89381 commit 6a634e4
Show file tree
Hide file tree
Showing 2 changed files with 496 additions and 123 deletions.
84 changes: 39 additions & 45 deletions piel/models/physical/photonic/mzi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def mzi(
straight_y: ComponentSpec | None = None,
straight_x_top: ComponentSpec | None = None,
straight_x_bot: ComponentSpec | None = None,
extend_ports_straight_x: float | None = None,
splitter: ComponentSpec = "mmi1x2",
combiner: ComponentSpec | None = None,
with_splitter: bool = True,
Expand All @@ -33,11 +34,13 @@ def mzi(
port_e1_combiner: str = "o2",
port_e0_combiner: str = "o3",
nbends: int = 2,
cross_section: CrossSectionSpec = "strip",
cross_section: CrossSectionSpec = "xs_sc",
cross_section_x_top: CrossSectionSpec | None = None,
cross_section_x_bot: CrossSectionSpec | None = None,
mirror_bot: bool = False,
add_optical_ports_arms: bool = False,
add_electrical_ports_bot: bool = True,
min_length: float = 0.01,
) -> Component:
"""Mzi.
Expand All @@ -50,6 +53,7 @@ def mzi(
straight_y: straight for length_y and delta_length.
straight_x_top: top straight for length_x.
straight_x_bot: bottom straight for length_x.
extend_ports_straight_x: optional extend ports for straight_x_bot/top.
splitter: splitter function.
combiner: combiner function.
with_splitter: if False removes splitter.
Expand All @@ -64,6 +68,8 @@ def mzi(
mirror_bot: if true, mirrors the bottom arm.
add_optical_ports_arms: add all other optical ports in the arms
with top_ and bot_ prefix.
add_electrical_ports_bot: add electrical ports to the bottom arm.
min_length: minimum length for the straight_x_bot/top.
.. code::
Expand Down Expand Up @@ -106,6 +112,21 @@ def mzi(
b5.mirror()
b5.connect("o1", cp1.ports[port_e0_splitter])

straight_x_top = (
gf.get_component(
straight_x_top, length=length_x, cross_section=cross_section_x_top
)
if length_x
else gf.get_component(straight_x_top)
)

if extend_ports_straight_x:
straight_x_top = gf.c.extend_ports(
straight_x_top, length=extend_ports_straight_x
)

length_x = length_x or straight_x_top.get_ports_xsize()

syl = c << gf.get_component(
straight_y, length=delta_length / 2 + length_y, cross_section=cross_section
)
Expand All @@ -120,6 +141,10 @@ def mzi(
if length_x
else gf.get_component(straight_x_bot)
)
if extend_ports_straight_x:
straight_x_bot = gf.c.extend_ports(
straight_x_bot, length=extend_ports_straight_x
)
sxb = c << straight_x_bot
if mirror_bot:
sxb.mirror()
Expand All @@ -135,19 +160,11 @@ def mzi(

b2 = c << bend
b2.connect("o2", sytl.ports["o2"])
straight_x_top = (
gf.get_component(
straight_x_top, length=length_x, cross_section=cross_section_x_top
)
if length_x
else gf.get_component(straight_x_top)
)
sxt = c << straight_x_top
sxt.connect("o1", b2.ports["o1"])

cp2.mirror()
xs = gf.get_cross_section(cross_section)
cp2.xmin = sxt.ports["o2"].x + bend.info["radius"] * nbends + 2 * xs.min_length
cp2.xmin = sxt.ports["o2"].x + bend.info["radius"] * nbends + 2 * min_length

route = get_route(
sxt.ports["o2"],
Expand Down Expand Up @@ -183,9 +200,11 @@ def mzi(
c.add_ports(cp2.get_ports_list(orientation=0), prefix="ou_")

c.add_ports(sxt.get_ports_list(port_type="electrical"), prefix="top_")
c.add_ports(sxb.get_ports_list(port_type="electrical"), prefix="bot_")
c.add_ports(sxt.get_ports_list(port_type="placement"), prefix="top_")
c.add_ports(sxb.get_ports_list(port_type="placement"), prefix="bot_")

if add_electrical_ports_bot:
c.add_ports(sxb.get_ports_list(port_type="electrical"), prefix="bot_")
c.add_ports(sxb.get_ports_list(port_type="placement"), prefix="bot_")

c.auto_rename_ports(port_type="optical", prefix="o")

Expand Down Expand Up @@ -225,54 +244,29 @@ def mzi(
)

mzi2x2_2x2_phase_shifter = partial(
mzi2x2_2x2, straight_x_top=straight_heater_metal_simple, length_x=200
)

mzi_phase_shifter_top_heater_metal = partial(
mzi_phase_shifter, straight_x_top=straight_heater_metal_simple
mzi2x2_2x2,
straight_x_top=straight_heater_metal_simple,
length_x=200,
)

if __name__ == "__main__":
# c = mzi_phase_shifter(splitter="mmi2x2")
# c = mzi_phase_shifter_top_heater_metal(splitter="mmi2x2")
# c = mzi_phase_shifter(splitter='mmi2x2')
# c = mzi_phase_shifter(
# straight_x_top=gf.components.straight_pin, straight_x_bot=gf.components.straight_pin
# )
# c = mzi_phase_shifter(
# # straight_x_top=gf.components.straight_heater_doped_rib,
# straight_x_bot=gf.components.straight_heater_doped_rib,
# delta_length=20,
# length_x=600,
# )
# c = mzi_phase_shifter()

# c = mzi_phase_shifter()
c = mzi_phase_shifter()
c.show(show_ports=True)
print(c.name)

c1 = mzi2x2_2x2_phase_shifter()
c1.show(show_ports=True)
print(c1.name)

if __name__ == "__main__":
c = mzi()
print(sorted([i.name for i in c.get_dependencies()]))
# print(sorted([i.name for i in c.get_dependencies()]))
# from gdsfactory import get_generic_pdk

# pdk = get_generic_pdk()
# pdk.activate()

# c = mzi(cross_section="strip")
# c = mzi(cross_section="xs_sc")
# c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
# c.show(show_ports=True)

# c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
c = gf.routing.add_fiber_array(c)
# gdspath = c.write_gds(flatten_invalid_refs=True)
# c = gf.routing.add_fiber_array(c)
# gdspath = c.write_gds(flatten_offgrid_references=True)
# gf.show(gdspath)
c.show()
c.show(show_ports=True)

# c1.write_gds("a.gds")

Expand Down
Loading

0 comments on commit 6a634e4

Please sign in to comment.