From 97e8020bd6c30eaf3c902aa572d84bae9e274171 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Sat, 9 Mar 2024 22:59:11 -0800 Subject: [PATCH 1/4] add models --- gplugins/klayout/drc/samples/drc_errors.py | 7 ++- gplugins/sax/models.py | 53 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/gplugins/klayout/drc/samples/drc_errors.py b/gplugins/klayout/drc/samples/drc_errors.py index f2d3d335..559dac08 100644 --- a/gplugins/klayout/drc/samples/drc_errors.py +++ b/gplugins/klayout/drc/samples/drc_errors.py @@ -46,8 +46,13 @@ 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 + + Args: + enclosing: value to enclose layer1 by layer2. + layer1: layer to enclose. + layer2: layer to enclose by. + """ w1 = 1 w2 = w1 + enclosing diff --git a/gplugins/sax/models.py b/gplugins/sax/models.py index 98fafd50..bd4d8957 100644 --- a/gplugins/sax/models.py +++ b/gplugins/sax/models.py @@ -1,11 +1,64 @@ from __future__ import annotations +from functools import cache + +import jax import jax.numpy as jnp +import sax from sax import SDict from sax.utils import reciprocal nm = 1e-3 +################ +# PassThrus +################ + + +@cache +def _2port(p1, p2): + @jax.jit + def _2port(wl=1.5): + wl = jnp.asarray(wl) + return sax.reciprocal({(p1, p2): jnp.ones_like(wl)}) + + return _2port + + +@cache +def _3port(p1, p2, p3): + @jax.jit + def _3port(wl=1.5): + wl = jnp.asarray(wl) + thru = jnp.ones_like(wl) / jnp.sqrt(2) + return sax.reciprocal( + { + (p1, p2): thru, + (p1, p3): thru, + } + ) + + return _3port + + +@cache +def _4port(p1, p2, p3, p4): + @jax.jit + def _4port(wl=1.5): + wl = jnp.asarray(wl) + thru = jnp.ones_like(wl) / jnp.sqrt(2) + cross = 1j * thru + return sax.reciprocal( + { + (p1, p4): thru, + (p2, p3): thru, + (p1, p3): cross, + (p2, p4): cross, + } + ) + + return _4port + def straight( *, From c75057fe48725dfe32aeb885215a0e2a8eec88f9 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Sat, 9 Mar 2024 23:05:41 -0800 Subject: [PATCH 2/4] increase number of errors --- gplugins/klayout/drc/samples/drc_errors.py | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/gplugins/klayout/drc/samples/drc_errors.py b/gplugins/klayout/drc/samples/drc_errors.py index 559dac08..624b3cca 100644 --- a/gplugins/klayout/drc/samples/drc_errors.py +++ b/gplugins/klayout/drc/samples/drc_errors.py @@ -2,21 +2,21 @@ from __future__ import annotations import gdsfactory as gf +import numpy as np from gdsfactory.component import Component -from gdsfactory.typings import Float2, Layer +from gdsfactory.typings import Layer layer = (1, 0) @gf.cell -def width_min(size: Float2 = (0.1, 0.1)) -> Component: - return gf.components.rectangle(size=size, layer=layer) +def width_min(width: float = 0.1) -> Component: + return gf.components.rectangle(size=(width, width), layer=layer) @gf.cell -def area_min() -> Component: - size = (0.2, 0.2) - return gf.components.rectangle(size=size, layer=layer) +def area_min(width: float = 0.2) -> Component: + return gf.components.rectangle(size=(width, width), layer=layer) @gf.cell @@ -74,18 +74,17 @@ def snapping_error(gap: float = 1e-3) -> Component: @gf.cell -def errors() -> Component: +def errors(n: int = 20) -> 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) + wmin = 0.1 + # components = [width_min(), gap_min(), separation(), enclosing()] + cs = [] + cs += [width_min(wmin * np.random.rand()) for _ in range(n)] + cs += [gap_min(gap=0.1 * np.random.rand()) for _ in range(n)] + cs += [separation(gap=0.1 * np.random.rand()) for _ in range(n)] + cs += [enclosing(enclosing=0.1 * np.random.rand()) for _ in range(n)] + + c = gf.pack(cs, spacing=1.5) return gf.add_padding_container(c[0], layers=((64, 0),), default=5) @@ -97,6 +96,6 @@ def errors2() -> Component: # c = snapping_error() # c.write_gds("snap.gds") - c = errors2() + c = errors() c.write_gds("errors.gds") c.show(show_ports=True) From bb322ff7d07e87406d7f7a339bd8dfba81981b49 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Sun, 10 Mar 2024 08:15:03 -0700 Subject: [PATCH 3/4] remove post_process --- notebooks/sdl_demo.pic.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/sdl_demo.pic.yml b/notebooks/sdl_demo.pic.yml index e55cd8de..8cb51609 100644 --- a/notebooks/sdl_demo.pic.yml +++ b/notebooks/sdl_demo.pic.yml @@ -9,10 +9,10 @@ instances: settings: {gap_mmi: 0.7} s1: component: straight - settings: {length: 20, npoints: 2, cross_section: xs_sc, post_process: null, info: null} + settings: {length: 20, npoints: 2, cross_section: xs_sc} s2: component: straight - settings: {length: 40, npoints: 2, cross_section: xs_sc, post_process: null, info: null} + settings: {length: 40, npoints: 2, cross_section: xs_sc} placements: mmi1: {x: null, y: null, port: null, rotation: 0.0, dx: -22.832156230736544, dy: -0.9358105716724547, mirror: null} From de0494c49bd9242c9a742bf7d7eec94657164628 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Sun, 10 Mar 2024 08:33:25 -0700 Subject: [PATCH 4/4] fix sdl --- notebooks/test.schem.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/test.schem.yml b/notebooks/test.schem.yml index 0122d3b0..a8c5e56c 100644 --- a/notebooks/test.schem.yml +++ b/notebooks/test.schem.yml @@ -8,10 +8,10 @@ instances: settings: {gap_mmi: 0.7} s1: component: straight - settings: {length: 20, npoints: 2, cross_section: xs_sc, post_process: null, info: null} + settings: {length: 20, npoints: 2, cross_section: xs_sc} s2: component: straight - settings: {length: 40, npoints: 2, cross_section: xs_sc, post_process: null, info: null} + settings: {length: 40, npoints: 2, cross_section: xs_sc} schematic_placements: mmi1: {x: null, y: null, port: null, rotation: 0.0, dx: -22.832156230736544, dy: -0.9358105716724547, mirror: null}