From db49e8bb82ad2ed8e6f68f3c4852e8ce641f0999 Mon Sep 17 00:00:00 2001 From: mustafacc Date: Wed, 6 Mar 2024 12:42:45 -0800 Subject: [PATCH] fix gdsfactory region loader --- gds_tidy3d/lyprocessor.py | 8 +++++++- gds_tidy3d/simprocessor.py | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gds_tidy3d/lyprocessor.py b/gds_tidy3d/lyprocessor.py index 5327f4b..b80caa7 100644 --- a/gds_tidy3d/lyprocessor.py +++ b/gds_tidy3d/lyprocessor.py @@ -9,7 +9,7 @@ import logging -def dilate(vertices, extension=1): +def dilate(vertices, extension=1.3): """grow or shrink a rectangle defined as [[x1,y1],[x2,y2]] Args: @@ -76,6 +76,12 @@ def load_region(layout, layer=[68, 0], z_center=0, z_span=5, extension=1.3): layout to extract the polygons from. layer : klayout.db (pya) layout.layer() type Layer to place detect the devrec object from. + z_center: float + Z-center of the layout. Defaults to 0 (microns). + z_span: float + Z-span of the layout. Defaults to 5 (microns). + extension: float + amount of extended region to retrieve beyond specified region. Returns ------- diff --git a/gds_tidy3d/simprocessor.py b/gds_tidy3d/simprocessor.py index 44b7aca..8035e2e 100644 --- a/gds_tidy3d/simprocessor.py +++ b/gds_tidy3d/simprocessor.py @@ -7,12 +7,13 @@ import tidy3d as td import numpy as np -from .core import structure, region, port, component +from .core import structure, region, port, component, Simulation from .lyprocessor import ( load_structure, load_region, load_ports, load_structure_from_bounds, + dilate, dilate_1d, ) @@ -309,7 +310,6 @@ def make_sim( Returns: simulation: Generated simulation instance. """ - from .core import Simulation import numpy as np import matplotlib.pyplot as plt @@ -519,7 +519,7 @@ def build_sim_from_tech(tech, layout, in_port=0, **kwargs): ) -def from_gdsfactory(c, tech, in_port=0, **kwargs): +def from_gdsfactory(c, tech: dict, in_port: int = 0, **kwargs): device_wg = [] ports = [] @@ -536,7 +536,7 @@ def from_gdsfactory(c, tech, in_port=0, **kwargs): z_base=tech["device"][idx]["z_base"], z_span=tech["device"][idx]["z_span"], material=get_material(tech["device"][idx]), - sidewall_angle=90, + sidewall_angle=tech["device"][idx]["sidewall_angle"], ) ) @@ -570,10 +570,10 @@ def min_dim(square): else: return "xy" - # expand the bbox region by 2 um (on each side) on the smallest dimension - bbox = dilate_1d(c.bbox.tolist(), extension=1, dim=min_dim(c.bbox.tolist())) - - bounds = region(vertices=bbox, z_center=z_center, z_span=z_span) + # expand the bbox region by 1.3 um (on each side) on the smallest dimension + bbox = dilate_1d(c.bbox.tolist(), extension=0, dim=min_dim(c.bbox.tolist())) + bbox_dilated = dilate(bbox) + bounds = region(vertices=bbox_dilated, z_center=z_center, z_span=z_span) # make the superstrate and substrate based on device bounds # this information isn't typically captured in a 2D layer stack