Skip to content

Commit

Permalink
Merge pull request #2579 from gdsfactory/fix_transition_port
Browse files Browse the repository at this point in the history
Fix transition port size and MMIs with slab
  • Loading branch information
joamatab committed Mar 4, 2024
2 parents f9aea08 + 8cec57d commit 664b714
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 32 deletions.
4 changes: 2 additions & 2 deletions gdsfactory/components/grating_coupler_rectangular.py
Expand Up @@ -109,7 +109,7 @@ def grating_coupler_rectangular(

for section in xs.sections[1:]:
slab_xsize = cgrating.xmax + section.width / 2
slab_ysize = cgrating.ysize + section.width
slab_ysize = width_grating + section.width
yslab = slab_ysize / 2
c.add_polygon(
[
Expand All @@ -123,7 +123,7 @@ def grating_coupler_rectangular(

if layer_slab:
slab_xsize = cgrating.xmax + slab_offset
slab_ysize = c.ysize + 2 * slab_offset
slab_ysize = width_grating + 2 * slab_offset
yslab = slab_ysize / 2
c.add_polygon(
[
Expand Down
31 changes: 20 additions & 11 deletions gdsfactory/components/mmi.py
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
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
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()
5 changes: 2 additions & 3 deletions gdsfactory/components/taper.py
Expand Up @@ -202,8 +202,8 @@ def taper_strip_to_ridge(

c.info["length"] = float(length)
c.add_port(name="o1", port=taper_wg.ports["o1"])
c.add_port(name="o2", port=taper_slab.ports["o2"])
# Add pins instead only on the final component
c.add_port(name="o2", port=taper_wg.ports["o2"])

if xs.add_pins:
xs.add_pins(c)

Expand All @@ -212,7 +212,6 @@ def taper_strip_to_ridge(

if post_process:
post_process(c)

return c


Expand Down
3 changes: 2 additions & 1 deletion gdsfactory/components/taper_cross_section.py
Expand Up @@ -112,6 +112,7 @@ def taper_cross_section(
# cross_section1 = gf.cross_section.rib_heater_doped(width=2)
# cross_section2 = gf.cross_section.strip_rib_tip
# c = taper_cross_section(cross_section1, cross_section2)
c = taper_sc_nc_sine(length=10)
# c = taper_sc_nc_sine(length=10)
c = taper_cross_section_linear(length=10)
c.show(show_ports=True)
print(c.get_polygon_enclosure())
11 changes: 7 additions & 4 deletions gdsfactory/path.py
Expand Up @@ -1043,6 +1043,9 @@ def extrude_transition(
width1 = section1.width
width2 = section2.width

section1_layer = get_layer(section1.layer)
section2_layer = get_layer(section2.layer)

if callable(offset1):
offset1 = offset1(1)
if callable(offset2):
Expand Down Expand Up @@ -1071,14 +1074,14 @@ def width_func(t):
f"width_type={width_type!r} must be {'sine','linear','parabolic'}, or a Callable w(t, width1, width2) returning the transition profile as a function of path position t."
)

if section1.layer != section2.layer:
if section1_layer != section2_layer:
hidden = True
layer1 = get_layer(section1.layer)
layer2 = get_layer(section2.layer)
layer1 = get_layer(section1_layer)
layer2 = get_layer(section2_layer)
layer = (layer1, layer2)
else:
hidden = False
layer = get_layer(section1.layer)
layer = get_layer(section1_layer)

p_sec.offset(offset)
offset = 0
Expand Down
2 changes: 0 additions & 2 deletions test-data-regression/test_settings_mmi_.yml
Expand Up @@ -13,8 +13,6 @@ settings:
output_positions: null
outputs: 4
post_process: null
straight:
function: straight
taper:
function: taper
width: null
Expand Down

0 comments on commit 664b714

Please sign in to comment.