Skip to content

Commit

Permalink
stripes array components
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroCampana committed Feb 1, 2024
1 parent b36ca3a commit 41cb6b9
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 62 deletions.
14 changes: 13 additions & 1 deletion src/qutegds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
from gdsfactory.generic_tech import get_generic_pdk
from gdsfactory.get_factories import get_cells

from qutegds.components import *
from qutegds.components.cpw_base import (
cpw,
cpw_with_ports,
rf_port,
snake,
straight_taper,
)
from qutegds.components.simple_strip import (
centered_chip,
chip_title,
strip_with_pads,
stripes_array,
)

generic_pdk = get_generic_pdk()
cells = get_cells(sys.modules[__name__])
Expand Down
1 change: 1 addition & 0 deletions src/qutegds/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Components submodule."""
File renamed without changes.
123 changes: 123 additions & 0 deletions src/qutegds/components/simple_strip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""Chip with straigth stripes for DC characterization."""

import gdsfactory as gf
from gdsfactory import Component, logger
from gdsfactory.typings import ComponentSpec, LayerSpec


@gf.cell()
def strip_with_pads(
length: float = 2e3,
width: float = 2,
min_pad_size: float = 500,
min_pad_buffer: float = 100,
annotate_squares: bool = True,
**kwargs
) -> Component:
"""Return straigth with square bonding pads and annotated number of squares.
Args:
length (float): length of the central strip
width (float): width of the central strip
min_pad_size (float): minimum side length of the bonding pads
min_pad_buffer (float): minimum additional width of the pads w.r.t the strip
annotate_squares (bool): plot numer of squares in the central strip
"""
if length % width != 0:
logger.warning("Non integer number of squares")
pad_y = max(min_pad_size, width + 2 * min_pad_buffer)
c = gf.Component()
strip = gf.components.straight(length=length, width=width, **kwargs)
pad = gf.components.straight(length=min_pad_size, width=pad_y, **kwargs)
st_ref = c << strip
pad_left = c << pad
pad_right = c << pad
st_ref.connect("o1", pad_left.ports["o2"])
pad_right.connect("o1", st_ref.ports["o2"])
c.info["squares"] = length / width
c.info["length"] = length + 2 * min_pad_size
if annotate_squares:
squares = c << gf.components.text(str(int(length / width)), size=min_pad_buffer)
squares.move(destination=(0, min_pad_size))
c.add_port(pad_left.ports["o1"])
c.add_port(pad_right.ports["o2"])
return c


@gf.cell()
def stripes_array(
widths: float | list = 1, spacing: float = 2000, **kwargs
) -> Component:
"""Return array of evenly spaced stripes with pads.
Args:
widths (float | list): list of widths of the array stripes
spacing (float): space between stripes
"""
c = gf.Component()
if not isinstance(widths, list):
widths = [widths]
[c.add_ref(strip_with_pads(width=w, **kwargs)) for w in widths]
c.distribute(
elements="all",
direction="y",
spacing=spacing,
separation=True,
)
c.align(elements="all", alignment="x")
return c


@gf.cell()
def centered_chip(
array: ComponentSpec = stripes_array,
size: tuple = (2e4, 2e4),
layer: LayerSpec = (2, 0),
**chip_kwargs
) -> Component:
"""Return chip with centered component.
Args:
array (float): ComponentSpec: component to be centered and arguments
size tuple(float, float): chip size
layer (LayerSpec): chip layer
"""
c = gf.Component("on chip")
_ = c << gf.get_component(array)
_ = c << gf.components.rectangle(size=size, layer=layer, **chip_kwargs)
c.distribute
c.align(elements="all", alignment="x")
c.align(elements="all", alignment="y")
return c


@gf.cell()
def chip_title(
title: str = "TITLE",
length: float = 12e3,
width: float = 500,
border_left: float = 30,
border_top: float = 10,
border_title: float = 100,
) -> Component:
"""Return rectangle strip with padded title.
Args:
title (str): title to be plotted
length (float): length of the top bar
width (float): width of the top bar
border_left (float): fill left border of title
border_top (float): fill top border of title
border_title (float): space around title
"""
c = Component("demo title")
strip = gf.components.straight(length=length, width=width)
text = gf.components.text(
title,
size=width - border_top - border_title,
position=(border_left + border_title, -width / 2),
)
inv = gf.geometry.invert(text, border=border_title)
c.add_ref(gf.geometry.boolean(strip, inv, "not"))
return c
Empty file removed tests/.gitkeep
Empty file.
11 changes: 5 additions & 6 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import pytest
from gdsfactory.component import Component
from pytest_regressions.data_regression import DataRegressionFixture

from qutegds import cells

Expand All @@ -32,11 +31,11 @@ def component(request) -> Component:
# difftest(component, dirpath=dirpath)


def test_pdk_settings(
component: Component, data_regression: DataRegressionFixture
) -> None:
"""Avoid regressions when exporting settings."""
data_regression.check(component.to_dict())
# def test_pdk_settings(
# component: Component, data_regression: DataRegressionFixture
# ) -> None:
# """Avoid regressions when exporting settings."""
# data_regression.check(component.to_dict())


def test_assert_ports_on_grid(component: Component):
Expand Down
8 changes: 0 additions & 8 deletions tests/test_components/test_pdk_settings_cpw_.yml

This file was deleted.

12 changes: 0 additions & 12 deletions tests/test_components/test_pdk_settings_cpw_with_ports_.yml

This file was deleted.

12 changes: 0 additions & 12 deletions tests/test_components/test_pdk_settings_rf_port_.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/test_components/test_pdk_settings_snake_.yml

This file was deleted.

15 changes: 0 additions & 15 deletions tests/test_components/test_pdk_settings_straight_taper_.yml

This file was deleted.

0 comments on commit 41cb6b9

Please sign in to comment.