Skip to content

Commit

Permalink
Merge pull request #350 from gdsfactory/add_drc_samples
Browse files Browse the repository at this point in the history
add drc samples
  • Loading branch information
joamatab committed Mar 5, 2024
2 parents 382a6b0 + 79867d3 commit 89345c1
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 18 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,24 @@ jobs:
pip install pre-commit
pre-commit run -a
test_code_pip:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
container: ghcr.io/gdsfactory/gdsfactory:main
strategy:
fail-fast: false
max-parallel: 12
matrix:
python-version: ['3.11']
os: [ubuntu-latest]
plugin: [femwell, gmsh, meow, sax, tidy3d, klayout, vlsir]

name: Test ${{ matrix.plugin }} on ${{ matrix.os }}
name: Test ${{ matrix.plugin }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ hashFiles('pyproject.toml') }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
make gmsh
pip install -e .[${{ matrix.plugin }},dev]
- name: Test with pytest
env:
Expand Down
97 changes: 97 additions & 0 deletions gplugins/klayout/drc/samples/drc_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""Write GDS with sample errors."""
from __future__ import annotations

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.typings import Float2, Layer

layer = (1, 0)


@gf.cell
def width_min(size: Float2 = (0.1, 0.1)) -> Component:
return gf.components.rectangle(size=size, layer=layer)


@gf.cell
def area_min() -> Component:
size = (0.2, 0.2)
return gf.components.rectangle(size=size, layer=layer)


@gf.cell
def gap_min(gap: float = 0.1) -> Component:
c = gf.Component()
r1 = c << gf.components.rectangle(size=(1, 1), layer=layer)
r2 = c << gf.components.rectangle(size=(1, 1), layer=layer)
r1.xmax = 0
r2.xmin = gap
return c


@gf.cell
def separation(
gap: float = 0.1, layer1: Layer = (47, 0), layer2: Layer = (41, 0)
) -> Component:
c = gf.Component()
r1 = c << gf.components.rectangle(size=(1, 1), layer=layer1)
r2 = c << gf.components.rectangle(size=(1, 1), layer=layer2)
r1.xmax = 0
r2.xmin = gap
return c


@gf.cell
def enclosing(
enclosing: float = 0.1, layer1: Layer = (40, 0), layer2: Layer = (41, 0)
) -> Component:
"""Layer1 must be enclosed by layer2 by value.
checks if layer1 encloses (is bigger than) layer2 by value
"""
w1 = 1
w2 = w1 + enclosing
c = gf.Component()
c << gf.components.rectangle(size=(w1, w1), layer=layer1, centered=True)
r2 = c << gf.components.rectangle(size=(w2, w2), layer=layer2, centered=True)
r2.movex(0.5)
return c


@gf.cell
def snapping_error(gap: float = 1e-3) -> Component:
c = gf.Component()
r1 = c << gf.components.rectangle(size=(1, 1), layer=layer)
r2 = c << gf.components.rectangle(size=(1, 1), layer=layer)
r1.xmax = 0
r2.xmin = gap
return c


@gf.cell
def errors() -> Component:
"""Write a GDS with sample errors."""
components = [width_min(), gap_min(), separation(), enclosing()]
c = gf.pack(components, spacing=1.5)
return gf.add_padding_container(c[0], layers=((64, 0),), default=5)


@gf.cell
def errors2() -> Component:
"""Write a GDS with sample errors."""
components = 2 * [width_min(), gap_min(), separation(), enclosing()]
c = gf.pack(components, spacing=1.5)
return gf.add_padding_container(c[0], layers=((64, 0),), default=5)


if __name__ == "__main__":
# c = width_min()
# c.write_gds("wmin.gds")
# c = gap_min()
# c.write_gds("gmin.gds")
# c = snapping_error()
# c.write_gds("snap.gds")

c = errors2()
c.write_gds("errors.gds")
c.show(show_ports=True)
16 changes: 8 additions & 8 deletions gplugins/klayout/drc/write_drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,14 @@ def write_drc_deck_macro(

rules = [
derived_layer_boolean("TRENCH", "SLAB90", "-", "WG"),
# check_width(layer="WG", value=0.2),
# check_space(layer="WG", value=0.2),
# check_separation(layer1="HEATER", layer2="M1", value=1.0),
# check_enclosing(layer1="VIAC", layer2="M1", value=0.2),
# check_area(layer="WG", min_area_um2=0.05),
# check_not_inside(layer="VIAC", not_inside="NPP"),
# new_layers(TRENCHES=(2, 33)),
# size(layer="WG", dbu=1000),
check_width(layer="WG", value=0.2),
check_space(layer="WG", value=0.2),
check_separation(layer1="HEATER", layer2="M1", value=1.0),
check_enclosing(layer1="VIAC", layer2="M1", value=0.2),
check_area(layer="WG", min_area_um2=0.05),
check_not_inside(layer="VIAC", not_inside="NPP"),
new_layers(TRENCHES=(2, 33)),
size(layer="WG", value=1000),
output_layer("TRENCH", (2, 33)),
]

Expand Down
2 changes: 1 addition & 1 deletion gplugins/tidy3d/write_sparameters_grating_coupler.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def write_sparameters_grating_coupler(
filepath: PathType | None = None,
overwrite: bool = False,
port_waveguide_name: str = "o1",
fiber_port_prefix: str = "opt",
fiber_port_prefix: str = "o2",
verbose: bool = False,
run: bool = True,
**kwargs,
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ gmsh = [
"shapely",
"meshwell>=1.0.7,<=1.1"
]
klayout = [
"klayout",
"pyvis<=0.3.1"
]
meow = [
"jax==0.4.23",
"jaxlib==0.4.23",
Expand Down

0 comments on commit 89345c1

Please sign in to comment.