-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from twpalab/base_cpw
Add basic components and library structure
- Loading branch information
Showing
11 changed files
with
275 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
"""qutegds module.""" | ||
|
||
import importlib.metadata as im | ||
import sys | ||
|
||
__version__ = im.version(__package__) | ||
|
||
import gdsfactory as gf | ||
from gdsfactory.generic_tech import get_generic_pdk | ||
from gdsfactory.get_factories import get_cells | ||
|
||
from qutegds.components import * | ||
|
||
generic_pdk = get_generic_pdk() | ||
cells = get_cells(sys.modules[__name__]) | ||
qute_pdk = gf.Pdk( | ||
name="qute", | ||
cells=cells, | ||
base_pdk=generic_pdk, | ||
layers=generic_pdk.layers, | ||
layer_views=generic_pdk.layer_views, | ||
cross_sections=generic_pdk.cross_sections, | ||
) | ||
qute_pdk.activate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
"""List of coplanar waveguide elements.""" | ||
from functools import partial | ||
|
||
import gdsfactory as gf | ||
from gdsfactory import Component | ||
from gdsfactory.typings import ComponentFactory, ComponentSpec | ||
|
||
from qutegds.geometry import subtract | ||
|
||
WIDTH = 6 | ||
GAP = 3 | ||
WIDTH_PAD = 350 | ||
GAP_PAD = 70 | ||
SPACE_PAD = 10 | ||
|
||
|
||
@gf.cell() | ||
def cpw( | ||
component_name: str = "straight", gap: float = GAP, width: float = WIDTH, **kwargs | ||
) -> Component: | ||
""" | ||
Return simple coplanar waveguide from single component. | ||
By default, returns negative mask of the CPW trace. | ||
Args: | ||
component_name (str): name of the component to be used | ||
width (float): width of the central CPW trace | ||
gap (float): space in um between the CPW trace and ground | ||
""" | ||
cpw = gf.Component() | ||
outer = gf.get_component(component_name, width=width + 2 * gap, **kwargs) | ||
inner = gf.get_component(component_name, width=width, **kwargs) | ||
_ = cpw << subtract(outer, inner) | ||
cpw.add_ports(outer.ports) | ||
return cpw | ||
|
||
|
||
snake = partial(cpw, component_name="delay_snake") | ||
|
||
|
||
@gf.cell() | ||
def straight_taper( | ||
straight: ComponentSpec = gf.components.straight, | ||
taper: ComponentFactory = gf.components.taper, | ||
) -> Component: | ||
"""Return straight section connected with taper.""" | ||
st = gf.get_component(straight) | ||
return gf.add_tapers( | ||
st, | ||
taper=taper, | ||
ports=[st["o1"]], | ||
) | ||
|
||
|
||
@gf.cell() | ||
def rf_port( | ||
width1: float = WIDTH, | ||
width2: float = WIDTH_PAD, | ||
gap1: float = GAP, | ||
gap2: float = GAP_PAD, | ||
len_taper: float = 200, | ||
len_rect: float = 100, | ||
space_pad=SPACE_PAD, | ||
**kwargs, | ||
) -> Component: | ||
"""Return rf port.""" | ||
cpw = gf.Component() | ||
straight = partial(gf.components.straight, **kwargs) | ||
taper = partial(gf.components.taper, length=len_taper, **kwargs) | ||
|
||
outer = straight_taper( | ||
straight=partial( | ||
straight, length=len_rect + space_pad, width=width2 + 2 * gap2 | ||
), | ||
taper=partial(taper, width1=width1 + 2 * gap1, width2=width2 + 2 * gap2), | ||
) | ||
inner = straight_taper( | ||
straight=partial(straight, length=len_rect, width=width2), | ||
taper=partial(taper, width1=width1, width2=width2), | ||
) | ||
_ = cpw << subtract(outer, inner) | ||
cpw.add_ports(outer.ports) | ||
return cpw | ||
|
||
|
||
@gf.cell() | ||
def cpw_with_ports( | ||
gap=GAP, width=WIDTH, length=1000, straight=cpw, launcher=rf_port | ||
) -> Component: | ||
"""CPW with ports at extremities.""" | ||
launch = launcher(gap1=gap, width1=width) | ||
c = gf.Component() | ||
lref = c << launch | ||
lref2 = c << launch | ||
stref = c << straight(gap=gap, width=width, length=length) | ||
|
||
lref.connect("o1", stref.ports["o2"]) | ||
lref2.connect("o1", stref.ports["o1"]) | ||
return c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""Geometry related functions.""" | ||
from functools import partial | ||
|
||
import gdsfactory as gf | ||
|
||
subtract = partial(gf.geometry.boolean, operation="not") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
This code tests all your cells in the PDK. | ||
it will test 3 things: | ||
1. difftest: will test the GDS geometry of a new GDS compared to a reference. Thanks to Klayout fast booleans.add() | ||
2. settings test: will compare the settings in YAML with a reference YAML file.add() | ||
3. ensure ports are on grid, to avoid port snapping errors that can create 1nm gaps later on when you build circuits. | ||
""" | ||
import pathlib | ||
|
||
import pytest | ||
from gdsfactory.component import Component | ||
from pytest_regressions.data_regression import DataRegressionFixture | ||
|
||
from qutegds import cells | ||
|
||
skip_test = {"subtract"} | ||
cell_names = set(cells.keys()) - set(skip_test) | ||
dirpath = pathlib.Path(__file__).absolute().parent / "gds_ref" | ||
|
||
|
||
@pytest.fixture(params=cell_names, scope="function") | ||
def component(request) -> Component: | ||
"""Return requested component.""" | ||
return cells[request.param]() | ||
|
||
|
||
# def test_pdk_gds(component: Component) -> None: | ||
# """Avoid regressions in GDS geometry shapes and layers.""" | ||
# 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_assert_ports_on_grid(component: Component): | ||
"""Check if ports are aligned to grid.""" | ||
component.assert_ports_on_grid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function: cpw | ||
info: {} | ||
module: qutegds.components | ||
name: cpw | ||
settings: | ||
component_name: straight | ||
gap: 3 | ||
width: 6 |
12 changes: 12 additions & 0 deletions
12
tests/test_components/test_pdk_settings_cpw_with_ports_.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function: cpw_with_ports | ||
info: {} | ||
module: qutegds.components | ||
name: cpw_with_ports | ||
settings: | ||
gap: 3 | ||
launcher: | ||
function: rf_port | ||
length: 1000 | ||
straight: | ||
function: cpw | ||
width: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function: rf_port | ||
info: {} | ||
module: qutegds.components | ||
name: rf_port | ||
settings: | ||
gap1: 3 | ||
gap2: 70 | ||
len_rect: 100 | ||
len_taper: 200 | ||
space_pad: 10 | ||
width1: 6 | ||
width2: 350 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function: cpw | ||
info: {} | ||
module: qutegds.components | ||
name: cpw_component_namedelay_snake | ||
settings: | ||
component_name: delay_snake | ||
gap: 3 | ||
width: 6 |
15 changes: 15 additions & 0 deletions
15
tests/test_components/test_pdk_settings_straight_taper_.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function: straight_taper | ||
info: | ||
length: 10.0 | ||
route_info_length: 10.0 | ||
route_info_type: xs_sc | ||
route_info_weight: 10.0 | ||
route_info_xs_sc_length: 10.0 | ||
width: 0.5 | ||
module: qutegds.components | ||
name: straight_taper | ||
settings: | ||
straight: | ||
function: straight | ||
taper: | ||
function: taper |