diff --git a/gdsfactory/components/grating_coupler_rectangular.py b/gdsfactory/components/grating_coupler_rectangular.py index d085db455e..9430f85b9c 100644 --- a/gdsfactory/components/grating_coupler_rectangular.py +++ b/gdsfactory/components/grating_coupler_rectangular.py @@ -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( [ @@ -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( [ diff --git a/gdsfactory/components/mmi.py b/gdsfactory/components/mmi.py index a1c838ba9e..1228aa0705 100644 --- a/gdsfactory/components/mmi.py +++ b/gdsfactory/components/mmi.py @@ -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 @@ -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, @@ -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. @@ -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, @@ -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 @@ -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) @@ -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) diff --git a/gdsfactory/components/mmi1x2.py b/gdsfactory/components/mmi1x2.py index fa690cc55a..3421a89569 100644 --- a/gdsfactory/components/mmi1x2.py +++ b/gdsfactory/components/mmi1x2.py @@ -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( @@ -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", @@ -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: diff --git a/gdsfactory/components/mmi2x2.py b/gdsfactory/components/mmi2x2.py index b80c909403..53d5024753 100644 --- a/gdsfactory/components/mmi2x2.py +++ b/gdsfactory/components/mmi2x2.py @@ -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( @@ -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), @@ -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: @@ -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() diff --git a/gdsfactory/components/taper.py b/gdsfactory/components/taper.py index 9a6a502b62..1dc6f3ff50 100644 --- a/gdsfactory/components/taper.py +++ b/gdsfactory/components/taper.py @@ -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) @@ -212,7 +212,6 @@ def taper_strip_to_ridge( if post_process: post_process(c) - return c diff --git a/gdsfactory/components/taper_cross_section.py b/gdsfactory/components/taper_cross_section.py index 3c4889a465..dc23d86b1a 100644 --- a/gdsfactory/components/taper_cross_section.py +++ b/gdsfactory/components/taper_cross_section.py @@ -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()) diff --git a/gdsfactory/path.py b/gdsfactory/path.py index 336c5a5e17..63a950ee23 100644 --- a/gdsfactory/path.py +++ b/gdsfactory/path.py @@ -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): @@ -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 diff --git a/test-data-regression/test_settings_mmi_.yml b/test-data-regression/test_settings_mmi_.yml index a8e30ab7d9..1b15c64019 100644 --- a/test-data-regression/test_settings_mmi_.yml +++ b/test-data-regression/test_settings_mmi_.yml @@ -13,8 +13,6 @@ settings: output_positions: null outputs: 4 post_process: null - straight: - function: straight taper: function: taper width: null