Skip to content

Commit

Permalink
Merge pull request #2524 from gdsfactory/add_post_process_to_more_pcells
Browse files Browse the repository at this point in the history
add post process to more pcells
  • Loading branch information
joamatab committed Feb 14, 2024
2 parents 539546d + 51a35fb commit e60feff
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 10 deletions.
6 changes: 5 additions & 1 deletion gdsfactory/components/coupler.py
Expand Up @@ -8,7 +8,7 @@
from gdsfactory.components.coupler_symmetric import (
coupler_symmetric as coupler_symmetric_function,
)
from gdsfactory.typings import ComponentFactory, CrossSectionSpec
from gdsfactory.typings import Callable, ComponentFactory, CrossSectionSpec


@gf.cell
Expand All @@ -20,6 +20,7 @@ def coupler(
dy: float = 4.0,
dx: float = 10.0,
cross_section: CrossSectionSpec = "xs_sc",
post_process: Callable | None = None,
) -> Component:
r"""Symmetric coupler.
Expand All @@ -31,6 +32,7 @@ def coupler(
dy: port to port vertical spacing in um.
dx: length of bend in x direction in um.
cross_section: spec (CrossSection, string or dict).
post_process: function to call after the component is created.
.. code::
Expand Down Expand Up @@ -78,6 +80,8 @@ def coupler(
x = gf.get_cross_section(cross_section)
x.add_bbox(c)
x.add_pins(c)
if post_process:
post_process(c)
return c


Expand Down
10 changes: 3 additions & 7 deletions gdsfactory/components/coupler_straight.py
Expand Up @@ -2,15 +2,15 @@

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.straight import straight
from gdsfactory.components.straight import straight as straight_function
from gdsfactory.cross_section import CrossSectionSpec


@gf.cell
def coupler_straight(
length: float = 10.0,
gap: float = 0.27,
straight: Component = straight,
straight: Component = straight_function,
cross_section: CrossSectionSpec = "xs_sc_no_pins",
**kwargs,
) -> Component:
Expand All @@ -31,12 +31,8 @@ def coupler_straight(
"""
component = Component()

x = gf.get_cross_section(cross_section, **kwargs)

straight_component = straight(
length=length,
cross_section=x,
add_pins=False,
length=length, cross_section=cross_section, add_pins=False, **kwargs
)

top = component << straight_component
Expand Down
6 changes: 5 additions & 1 deletion gdsfactory/components/resistance_sheet.py
Expand Up @@ -6,7 +6,7 @@
from gdsfactory.component import Component
from gdsfactory.components.compass import compass
from gdsfactory.components.via_stack import via_stack_slab_npp_m3
from gdsfactory.typings import ComponentSpec, Floats, LayerSpecs
from gdsfactory.typings import Callable, ComponentSpec, Floats, LayerSpecs

pad_via_stack_slab_npp = partial(via_stack_slab_npp_m3, size=(80, 80))

Expand All @@ -21,6 +21,7 @@ def resistance_sheet(
ohms_per_square: float | None = None,
port_orientation1: int = 180,
port_orientation2: int = 0,
post_process: Callable | None = None,
) -> Component:
"""Returns Sheet resistance.
Expand All @@ -35,6 +36,7 @@ def resistance_sheet(
ohms_per_square: optional sheet resistance to compute info.resistance.
port_orientation1: in degrees.
port_orientation2: in degrees.
post_process: function to post process the component.
"""
c = Component()

Expand Down Expand Up @@ -75,6 +77,8 @@ def resistance_sheet(
)
c.absorb(pad1)
c.absorb(pad2)
if post_process:
post_process(c)
return c


Expand Down
6 changes: 5 additions & 1 deletion gdsfactory/components/triangles.py
Expand Up @@ -4,7 +4,7 @@

from gdsfactory.cell import cell
from gdsfactory.component import Component
from gdsfactory.typings import LayerSpec, LayerSpecs
from gdsfactory.typings import Callable, LayerSpec, LayerSpecs


@cell
Expand All @@ -15,6 +15,7 @@ def triangle(
ybot: float = 0,
layer: LayerSpec = "WG",
layers: LayerSpecs | None = None,
post_process: Callable | None = None,
) -> Component:
r"""Return triangle.
Expand All @@ -25,6 +26,7 @@ def triangle(
ybot: bottom ysize.
layer: layer.
layers: optional list of layers to duplicate the geometry.
post_process: function to call after the component is created.
.. code::
Expand All @@ -44,6 +46,8 @@ def triangle(
layers = layers or [layer]
for layer in layers:
c.add_polygon(points, layer=layer)
if post_process:
post_process(c)
return c


Expand Down
5 changes: 5 additions & 0 deletions gdsfactory/components/via_stack.py
Expand Up @@ -11,6 +11,7 @@
from gdsfactory.components.via import via1, via2, viac
from gdsfactory.components.wire import wire_corner45
from gdsfactory.typings import (
Callable,
ComponentFactory,
ComponentSpec,
Float2,
Expand All @@ -30,6 +31,7 @@ def via_stack(
correct_size: bool = True,
slot_horizontal: bool = False,
slot_vertical: bool = False,
post_process: Callable | None = None,
) -> Component:
"""Rectangular via array stack.
Expand Down Expand Up @@ -154,6 +156,9 @@ def via_stack(
y0 = -b + ch + h / 2
ref.move((x0, y0))

if post_process:
post_process(c)

return c


Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_netlists_mzit_.yml
Expand Up @@ -264,6 +264,7 @@ instances:
dy: 2.0
gap: 0.3
length: 10.0
post_process: null
coupler_2:
component: coupler
info:
Expand All @@ -279,6 +280,7 @@ instances:
dy: 2.0
gap: 0.2
length: 5.0
post_process: null
straight_1:
component: straight
info:
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_coupler_.yml
Expand Up @@ -14,3 +14,4 @@ settings:
dy: 4.0
gap: 0.236
length: 20.0
post_process: null
1 change: 1 addition & 0 deletions test-data-regression/test_settings_resistance_sheet_.yml
Expand Up @@ -32,4 +32,5 @@ settings:
pad_pitch: 100.0
port_orientation1: 180
port_orientation2: 0
post_process: null
width: 10
1 change: 1 addition & 0 deletions test-data-regression/test_settings_triangle_.yml
Expand Up @@ -5,6 +5,7 @@ name: triangle
settings:
layer: WG
layers: null
post_process: null
x: 10
xtop: 0
y: 20
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_via_stack_.yml
Expand Up @@ -16,6 +16,7 @@ settings:
- M1
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -15,6 +15,7 @@ settings:
layers:
- HEATER
- M2
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -16,6 +16,7 @@ settings:
- HEATER
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -16,6 +16,7 @@ settings:
- HEATER
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_via_stack_slab_m3_.yml
Expand Up @@ -17,6 +17,7 @@ settings:
- M1
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down

0 comments on commit e60feff

Please sign in to comment.