Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix via stack port orientations #1844

Merged
merged 4 commits into from Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_toc.yml
Expand Up @@ -27,8 +27,8 @@ parts:
- file: notebooks/04_components_hierarchy
- file: notebooks/07_mask
- file: notebooks/04_routing
- file: notebooks/041_routing_electrical
- file: notebooks/042_non-manhattan-router
- file: notebooks/04_routing_electrical
- file: notebooks/04_routing_non_manhattan
- file: notebooks/rib_strip_autotransition
- file: notebooks/common_mistakes
- file: notebooks/dataprep
Expand Down
6 changes: 2 additions & 4 deletions gdsfactory/component.py
Expand Up @@ -2625,7 +2625,7 @@ def copy_reference(
)


def test_get_layers() -> Component:
def test_get_layers() -> None:
import gdsfactory as gf

c1 = gf.components.straight(
Expand All @@ -2643,7 +2643,6 @@ def test_get_layers() -> Component:
# return c1
c2 = c1.remove_layers([(111, 0)])
assert c2.get_layers() == {(2, 0)}, c2.get_layers()
return c2


def _filter_polys(polygons, layers_excl):
Expand Down Expand Up @@ -2830,7 +2829,7 @@ def test_netlist_complex() -> None:
assert len(netlist["instances"]) == 4, len(netlist["instances"])


def test_extract() -> Component:
def test_extract() -> None:
import gdsfactory as gf

c = gf.components.straight(
Expand All @@ -2848,7 +2847,6 @@ def test_extract() -> Component:
assert len(c.polygons) == 2, len(c.polygons)
assert len(c2.polygons) == 1, len(c2.polygons)
assert gf.LAYER.WGCLAD in c2.layers
return c2


def hash_file(filepath):
Expand Down
13 changes: 6 additions & 7 deletions gdsfactory/components/bend_port.py
Expand Up @@ -11,8 +11,8 @@
@gf.cell
def bend_port(
component: ComponentSpec = straight_heater_metal,
port_name: str = "e1",
port_name2: str = "e2",
port_name: str = "l_e1",
port_name2: str = "r_e1",
port_name1_bend: Optional[str] = None,
port_name2_bend: Optional[str] = None,
cross_section: CrossSectionSpec = "metal3_with_bend",
Expand All @@ -25,8 +25,8 @@ def bend_port(

Args:
component: to bend.
port_name: of the component.
port_name2: of the component, to extend to.
port_name: of the component port origin.
port_name2: of the component port destination.
port_name1_bend: for bend port.
port_name2_bend: for bend port.
cross_section: for the bend.
Expand Down Expand Up @@ -77,7 +77,6 @@ def bend_port(
# c = gf.components.straight_heater_metal()
# c = bend_port(component=c, port_name="e1")
# c = bend_port(component=gf.components.mzi_phase_shifter)

c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
c = bend_port(c)
# c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
c = bend_port()
c.show(show_ports=True)
2 changes: 1 addition & 1 deletion gdsfactory/components/compass.py
Expand Up @@ -12,7 +12,7 @@
def compass(
size=(4.0, 2.0),
layer: LayerSpec = "WG",
port_type: Optional[str] = "placement",
port_type: Optional[str] = "electrical",
port_inclusion: float = 0.0,
port_orientations: Optional[Ints] = (180, 90, 0, -90),
) -> Component:
Expand Down
3 changes: 1 addition & 2 deletions gdsfactory/components/delay_snake.py
Expand Up @@ -86,12 +86,11 @@ def delay_snake(
return c


def test_delay_snake_length():
def test_delay_snake_length() -> None:
length = 200.0
c = delay_snake(n=1, length=length, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
return c


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions gdsfactory/components/delay_snake2.py
Expand Up @@ -91,14 +91,13 @@ def delay_snake2(
)


def test_length_delay_snake2():
def test_length_delay_snake2() -> Component:
import numpy as np

length = 200.0
c = delay_snake2(length=length, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
return c


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions gdsfactory/components/delay_snake_sbend.py
Expand Up @@ -124,14 +124,13 @@ def delay_snake_sbend(
return c


def test_delay_snake_sbend_length():
def test_delay_snake_sbend_length() -> None:
import numpy as np

length = 200.0
c = delay_snake_sbend(length=length, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
return c


if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions gdsfactory/components/mzi_pads_center.py
Expand Up @@ -16,10 +16,10 @@ def mzi_pads_center(
pad: ComponentSpec = pad_small,
length_x: float = 500,
length_y: float = 40,
mzi_sig_top: str = "top_e2",
mzi_gnd_top: str = "top_e1",
mzi_sig_bot: str = "bot_e1",
mzi_gnd_bot: str = "bot_e2",
mzi_sig_top: str = "top_r_e2",
mzi_gnd_top: str = "top_l_e2",
mzi_sig_bot: str = "bot_l_e2",
mzi_gnd_bot: str = "bot_r_e2",
pad_sig_bot: str = "e1_1_1",
pad_sig_top: str = "e3_1_3",
pad_gnd_bot: str = "e4_1_2",
Expand Down
4 changes: 1 addition & 3 deletions gdsfactory/components/pad.py
Expand Up @@ -34,9 +34,7 @@ def pad(
layer = gf.get_layer(layer)
size = gf.get_constant(size)
rect = compass(
size=size,
layer=layer,
port_inclusion=port_inclusion, # port_type="electrical"
size=size, layer=layer, port_inclusion=port_inclusion, port_type="electrical"
)
c_ref = c.add_ref(rect)
c.add_ports(c_ref.ports)
Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/components/rectangle.py
Expand Up @@ -14,7 +14,7 @@ def rectangle(
size=(4.0, 2.0),
layer: LayerSpec = "WG",
centered: bool = False,
port_type: Optional[str] = "placement",
port_type: Optional[str] = "electrical",
port_orientations: Optional[Ints] = (180, 90, 0, -90),
) -> Component:
"""Returns a rectangle.
Expand Down
44 changes: 24 additions & 20 deletions gdsfactory/components/ring_double_heater.py
Expand Up @@ -5,10 +5,10 @@
import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.bend_euler import bend_euler
from gdsfactory.components.coupler_ring import coupler_ring, coupler_ring_point
from gdsfactory.components.coupler_ring import coupler_ring
from gdsfactory.components.straight import straight
from gdsfactory.components.via_stack import via_stack_heater_m3
from gdsfactory.typings import ComponentSpec, CrossSectionSpec, Float2
from gdsfactory.typings import ComponentSpec, CrossSectionSpec, Float2, Optional

via_stack_heater_m3_mini = partial(via_stack_heater_m3, size=(4, 4))

Expand All @@ -27,7 +27,7 @@ def ring_double_heater(
cross_section_waveguide_heater: CrossSectionSpec = "strip_heater_metal",
cross_section: CrossSectionSpec = "strip",
via_stack: gf.typings.ComponentSpec = via_stack_heater_m3_mini,
port_orientation: float = 90,
port_orientation: Optional[float] = None,
via_stack_offset: Float2 = (0, 0),
**kwargs,
) -> Component:
Expand Down Expand Up @@ -125,8 +125,8 @@ def ring_double_heater(
f"No ports found for port_orientation {port_orientation} in {valid_orientations}"
)

c.add_ports(p1, prefix="e1")
c.add_ports(p2, prefix="e2")
c.add_ports(p1, prefix="l_")
c.add_ports(p2, prefix="r_")

heater_top = c << gf.get_component(
straight,
Expand All @@ -135,24 +135,28 @@ def ring_double_heater(
)
heater_top.connect("e1", ct.ports["e1"])

c.auto_rename_ports()
return c


if __name__ == "__main__":
c1 = ring_double_heater(via_stack="via_stack")
c1.pprint_ports()

c2 = ring_double_heater(via_stack="via_stack_slot")
c2.pprint_ports()
# c = ring_double_heater(width=1, layer=(2, 0), length_y=3)
c = ring_double_heater(
length_x=0,
port_orientation=90,
bend=gf.components.bend_circular,
via_stack_offset=(2, 0),
coupler_ring_top=coupler_ring,
coupler_ring=gf.partial(
coupler_ring_point,
coupler_ring=coupler_ring,
open_layers=("HEATER",),
open_sizes=((5, 7),),
),
)
c.show(show_ports=True)
# c = ring_double_heater(
# length_x=0,
# port_orientation=90,
# bend=gf.components.bend_circular,
# via_stack_offset=(2, 0),
# coupler_ring_top=coupler_ring,
# coupler_ring=gf.partial(
# coupler_ring_point,
# coupler_ring=coupler_ring,
# open_layers=("HEATER",),
# open_sizes=((5, 7),),
# ),
# )
c2.show(show_ports=True)
# c.pprint()
8 changes: 3 additions & 5 deletions gdsfactory/components/ring_single_heater.py
Expand Up @@ -24,7 +24,7 @@ def ring_single_heater(
cross_section_waveguide_heater: CrossSectionSpec = "strip_heater_metal",
cross_section: CrossSectionSpec = "strip",
via_stack: ComponentSpec = via_stack_heater_mtop_mini,
port_orientation: Optional[float] = 90,
port_orientation: Optional[float] = None,
via_stack_offset: Float2 = (0, 0),
**kwargs,
) -> gf.Component:
Expand Down Expand Up @@ -122,10 +122,8 @@ def ring_single_heater(
f"No ports found for port_orientation {port_orientation} in {valid_orientations}"
)

c.add_ports(p1, prefix="e1")
c.add_ports(p2, prefix="e2")

c.auto_rename_ports()
c.add_ports(p1, prefix="l_")
c.add_ports(p2, prefix="r_")
return c


Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/components/straight_heater_doped_rib.py
Expand Up @@ -204,7 +204,7 @@ def test_straight_heater_doped_rib_ports() -> Component:


if __name__ == "__main__":
c = straight_heater_doped_rib(xoffset_tip1=10, via_stack=None)
c = straight_heater_doped_rib(xoffset_tip1=10)
# c = straight_heater_doped_rib(with_taper1=False)
# c = straight_heater_doped_rib(length=500)
c.show(show_ports=True)
14 changes: 7 additions & 7 deletions gdsfactory/components/straight_heater_meander.py
Expand Up @@ -17,8 +17,8 @@ def straight_heater_meander(
layer_heater: LayerSpec = "HEATER",
radius: float = 5.0,
via_stack: Optional[ComponentSpec] = "via_stack_heater_mtop",
port_orientation1: int = 180,
port_orientation2: int = 0,
port_orientation1: Optional[int] = None,
port_orientation2: Optional[int] = None,
heater_taper_length: Optional[float] = 10.0,
straight_widths: Floats = (0.8, 0.9, 0.8),
taper_length: float = 10,
Expand All @@ -39,8 +39,8 @@ def straight_heater_meander(
layer_heater: for top heater, if None, it does not add a heater.
radius: for the meander bends.
via_stack: for the heater to via_stack metal.
port_orientation1: in degrees.
port_orientation2: in degrees.
port_orientation1: in degrees. None adds all orientations.
port_orientation2: in degrees. None adds all orientations.
heater_taper_length: minimizes current concentrations from heater to via_stack.
straight_width: width of the straight section.
taper_length: from the cross_section.
Expand Down Expand Up @@ -179,8 +179,8 @@ def straight_heater_meander(
f"No ports for port_orientation2 {port_orientation2} in {valid_orientations}"
)

c.add_port("e1", port=p1[0])
c.add_port("e2", port=p2[0])
c.add_ports(p1, prefix="l_")
c.add_ports(p2, prefix="r_")

if heater_taper_length:
taper = gf.c.taper(
Expand Down Expand Up @@ -231,7 +231,7 @@ def straight_heater_meander(
taper_length=10,
# taper_length=10,
length=1000,
port_orientation1=0
# port_orientation1=0
# cross_section=partial(gf.cross_section.strip, width=0.8),
)
c.show(show_ports=True)
Expand Down
37 changes: 23 additions & 14 deletions gdsfactory/components/straight_heater_meander_doped.py
@@ -1,14 +1,13 @@
from __future__ import annotations

from functools import partial
from typing import List

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.via import via
from gdsfactory.components.via_stack import via_stack
from gdsfactory.cross_section import Section
from gdsfactory.typings import ComponentSpec, Floats, LayerSpec, Optional
from gdsfactory.typings import ComponentSpec, Floats, LayerSpecs, Optional

via_stack = partial(
via_stack,
Expand Down Expand Up @@ -40,11 +39,11 @@ def straight_heater_meander_doped(
cross_section: gf.typings.CrossSectionSpec = "strip",
heater_width: float = 1.5,
extension_length: float = 15.0,
layers_doping: List[LayerSpec] = ("P", "PP", "PPP"),
layers_doping: LayerSpecs = ("P", "PP", "PPP"),
radius: float = 5.0,
via_stack: Optional[ComponentSpec] = via_stack,
port_orientation1: int = 180,
port_orientation2: int = 0,
port_orientation1: Optional[int] = None,
port_orientation2: Optional[int] = None,
straight_widths: Floats = (0.8, 0.9, 0.8),
taper_length: float = 10,
) -> Component:
Expand All @@ -64,8 +63,8 @@ def straight_heater_meander_doped(
layers_doping: doping layers to be used for heater.
radius: for the meander bends.
via_stack: for the heater to via_stack metal.
port_orientation1: in degrees.
port_orientation2: in degrees.
port_orientation1: in degrees. None adds all orientations.
port_orientation2: in degrees. None adds all orientations.
straight_width: width of the straight section.
taper_length: from the cross_section.
"""
Expand Down Expand Up @@ -188,7 +187,7 @@ def straight_heater_meander_doped(
heater.movey(spacing * (rows // 2))

if layers_doping and via_stack:
via_stacke = via_stackw = gf.get_component(via_stack)
via = via_stacke = via_stackw = gf.get_component(via_stack)
dx = via_stackw.get_ports_xsize() / 2 or 0
via_stack_west_center = heater.size_info.cw + (dx, 0)
via_stack_east_center = heater.size_info.ce - (dx, 0)
Expand All @@ -200,12 +199,22 @@ def straight_heater_meander_doped(
via_stack_east = c << via_stacke
via_stack_west.move(via_stack_west_center)
via_stack_east.move(via_stack_east_center)
c.add_port(
"e1", port=via_stack_west.get_ports_list(orientation=port_orientation1)[0]
)
c.add_port(
"e2", port=via_stack_east.get_ports_list(orientation=port_orientation2)[0]
)

valid_orientations = {p.orientation for p in via.ports.values()}
p1 = via_stack_west.get_ports_list(orientation=port_orientation1)
p2 = via_stack_east.get_ports_list(orientation=port_orientation2)

if not p1:
raise ValueError(
f"No ports for port_orientation1 {port_orientation1} in {valid_orientations}"
)
if not p2:
raise ValueError(
f"No ports for port_orientation2 {port_orientation2} in {valid_orientations}"
)

c.add_ports(p1, prefix="l_")
c.add_ports(p2, prefix="r_")
return c


Expand Down