Skip to content

Commit

Permalink
improve mmis for rib waveguides
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Mar 4, 2024
1 parent 4c2e9fc commit dfa7872
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 20 deletions.
31 changes: 20 additions & 11 deletions gdsfactory/components/mmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.straight import straight as straight_function
from gdsfactory.components.taper import taper as taper_function
from gdsfactory.typings import Callable, ComponentFactory, CrossSectionSpec

Expand All @@ -19,7 +18,6 @@ def mmi(
gap_input_tapers: float = 0.25,
gap_output_tapers: float = 0.25,
taper: ComponentFactory = taper_function,
straight: ComponentFactory = straight_function,
cross_section: CrossSectionSpec = "xs_sc",
input_positions: list[float] | None = None,
output_positions: list[float] | None = None,
Expand All @@ -38,7 +36,6 @@ def mmi(
gap_input_tapers: gap between input tapers from edge to edge.
gap_output_tapers: gap between output tapers from edge to edge.
taper: taper function.
straight: straight function.
cross_section: specification (CrossSection, string or dict).
input_positions: optional positions of the inputs.
output_positions: optional positions of the outputs.
Expand All @@ -65,11 +62,10 @@ def mmi(
c = Component()
gap_input_tapers = gf.snap.snap_to_grid(gap_input_tapers, grid_factor=2)
gap_output_tapers = gf.snap.snap_to_grid(gap_output_tapers, grid_factor=2)
w_mmi = width_mmi
w_taper = width_taper
x = gf.get_cross_section(cross_section)
xs_mmi = gf.get_cross_section(cross_section, width=w_mmi)
width = width or x.width
delta_width = width_mmi - width

_taper = taper(
length=length_taper,
Expand All @@ -79,7 +75,20 @@ def mmi(
add_pins=False,
)

mmi = c << straight(length=length_mmi, cross_section=xs_mmi, add_pins=False)
y = width_mmi / 2
c.add_polygon([(0, -y), (length_mmi, -y), (length_mmi, y), (0, y)], layer=x.layer)
for section in x.sections[1:]:
layer = section.layer
y = section.width / 2 + delta_width / 2
c.add_polygon(
[
(-delta_width, -y),
(length_mmi + delta_width, -y),
(length_mmi + delta_width, y),
(-delta_width, y),
],
layer=layer,
)

wg_spacing_input = gap_input_tapers + width_taper
wg_spacing_output = gap_output_tapers + width_taper
Expand Down Expand Up @@ -124,11 +133,10 @@ def mmi(
c.add_port(name=port.name, port=taper_ref.ports["o1"])
c.absorb(taper_ref)

c.absorb(mmi)
if x.add_bbox:
c = x.add_bbox(c)
x.add_bbox(c)
if x.add_pins:
c = x.add_pins(c)
x.add_pins(c)
c.auto_rename_ports()
if post_process:
post_process(c)
Expand All @@ -138,6 +146,7 @@ def mmi(
if __name__ == "__main__":
# import gdsfactory as gf
# c = gf.components.mmi1x2(cross_section="xs_rc")
c = mmi(inputs=2, outputs=4, gap_input_tapers=0.5, input_positions=[-1, 1])
print(len(c.ports))
# c = mmi(inputs=2, outputs=4, gap_input_tapers=0.5, input_positions=[-1, 1])
c = mmi(cross_section="xs_rc")
# print(len(c.ports))
c.show(show_ports=True)
20 changes: 16 additions & 4 deletions gdsfactory/components/mmi1x2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def mmi1x2(
c = Component()
gap_mmi = gf.snap.snap_to_grid(gap_mmi, grid_factor=2)
x = gf.get_cross_section(cross_section, **kwargs)
xs_mmi = gf.get_cross_section(cross_section, width=width_mmi)
width = width or x.width

_taper = taper(
Expand All @@ -73,9 +72,23 @@ def mmi1x2(
add_pins=False,
)

a = gap_mmi / 2 + width_taper / 2
mmi = c << straight(length=length_mmi, cross_section=xs_mmi, add_pins=False)
delta_width = width_mmi - width
y = width_mmi / 2
c.add_polygon([(0, -y), (length_mmi, -y), (length_mmi, y), (0, y)], layer=x.layer)
for section in x.sections[1:]:
layer = section.layer
y = section.width / 2 + delta_width / 2
c.add_polygon(
[
(-delta_width, -y),
(length_mmi + delta_width, -y),
(length_mmi + delta_width, y),
(-delta_width, y),
],
layer=layer,
)

a = gap_mmi / 2 + width_taper / 2
ports = [
gf.Port(
"o1",
Expand Down Expand Up @@ -109,7 +122,6 @@ def mmi1x2(
c.add_port(name=port.name, port=taper_ref.ports["o1"])
c.absorb(taper_ref)

c.absorb(mmi)
if with_bbox:
x.add_bbox(c)
if x.add_pins:
Expand Down
22 changes: 17 additions & 5 deletions gdsfactory/components/mmi2x2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def mmi2x2(
gap_mmi = gf.snap.snap_to_grid(gap_mmi, grid_factor=2)
w_taper = width_taper
x = gf.get_cross_section(cross_section, **kwargs)
xs_mmi = gf.get_cross_section(cross_section, width=width_mmi)
width = width or x.width

_taper = taper(
Expand All @@ -74,9 +73,23 @@ def mmi2x2(
add_pins=False,
)

a = gap_mmi / 2 + width_taper / 2
mmi = c << straight(length=length_mmi, cross_section=xs_mmi, add_pins=False)
delta_width = width_mmi - width
y = width_mmi / 2
c.add_polygon([(0, -y), (length_mmi, -y), (length_mmi, y), (0, y)], layer=x.layer)
for section in x.sections[1:]:
layer = section.layer
y = section.width / 2 + delta_width / 2
c.add_polygon(
[
(-delta_width, -y),
(length_mmi + delta_width, -y),
(length_mmi + delta_width, y),
(-delta_width, y),
],
layer=layer,
)

a = gap_mmi / 2 + width_taper / 2
ports = [
gf.Port("o1", orientation=180, center=(0, -a), width=w_taper, cross_section=x),
gf.Port("o2", orientation=180, center=(0, +a), width=w_taper, cross_section=x),
Expand All @@ -102,7 +115,6 @@ def mmi2x2(
c.add_port(name=port.name, port=taper_ref.ports["o1"])
c.absorb(taper_ref)

c.absorb(mmi)
if with_bbox:
x.add_bbox(c)
if x.add_pins:
Expand All @@ -114,6 +126,6 @@ def mmi2x2(

if __name__ == "__main__":
# c = mmi2x2(gap_mmi=0.252, cross_section="xs_m1")
c = mmi2x2(gap_mmi=0.252)
c = mmi2x2(gap_mmi=0.252, cross_section="xs_rc")
c.show(show_ports=True)
c.pprint()

0 comments on commit dfa7872

Please sign in to comment.