From e35b22f26d29ccb41a753da32eb17964bf290345 Mon Sep 17 00:00:00 2001 From: Caspar Ockeloen-Korppi Date: Wed, 18 Oct 2023 05:55:55 +0000 Subject: [PATCH] generalize protect_opposite_face --- .../elements/airbridges/airbridge_multi_face.py | 2 +- .../python/kqcircuits/elements/element.py | 15 +++++++++++---- .../flip_chip_connector_rf.py | 2 +- .../elements/spiral_resonator_polygon.py | 4 ++-- .../kqcircuits/elements/waveguide_coplanar.py | 5 ++--- .../elements/waveguide_coplanar_curved.py | 5 ++--- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/klayout_package/python/kqcircuits/elements/airbridges/airbridge_multi_face.py b/klayout_package/python/kqcircuits/elements/airbridges/airbridge_multi_face.py index 5588da11e..79d2c56d5 100644 --- a/klayout_package/python/kqcircuits/elements/airbridges/airbridge_multi_face.py +++ b/klayout_package/python/kqcircuits/elements/airbridges/airbridge_multi_face.py @@ -50,7 +50,7 @@ def build(self): self.cell.shapes(self.get_layer("base_metal_addition", 1)).insert(shape) # Add ground grid avoidance to second face - self.add_protection(shape.enlarged(self.margin, self.margin), 1, 0) + self.add_protection(shape.enlarged(self.margin, self.margin), 1) # Flip-chip bump if self.include_bumps: diff --git a/klayout_package/python/kqcircuits/elements/element.py b/klayout_package/python/kqcircuits/elements/element.py index 563f71161..b9fdfafa7 100644 --- a/klayout_package/python/kqcircuits/elements/element.py +++ b/klayout_package/python/kqcircuits/elements/element.py @@ -114,6 +114,8 @@ class Element(pya.PCellDeclarationHelper): face_ids = Param(pdt.TypeList, "Chip face IDs list", ["1t1", "2b1", "1b1", "2t1"]) display_name = Param(pdt.TypeString, "Name displayed in GUI (empty for default)", "") protect_opposite_face = Param(pdt.TypeBoolean, "Add opposite face protection too", False) + opposing_face_id_groups = Param(pdt.TypeList, "Opposing face ID groups (list of lists)", [["1t1", "2b1"]], + hidden=True) def __init__(self): "" @@ -518,18 +520,23 @@ def raise_error_on_cell(self, error_msg, position=pya.DPoint()): self.insert_cell(error_text_cell, pya.DTrans(position - text_center)) raise ValueError(error_msg) - def add_protection(self, shape, face_id=0, opposite_face_id=1): + def add_protection(self, shape, face_id=0): """Add ground grid protection shape Args: shape: The shape (Region, DPolygon, etc.) to add to ground_grid_avoidance layer face_id: primary face index of ground_grid_avoidance layer, default=0 - opposite_face_id: opposite face index, will be used if protect_opposite_face is True, default=1 """ self.cell.shapes(self.get_layer("ground_grid_avoidance", face_id)).insert(shape) - if self.protect_opposite_face and len(self.face_ids) > opposite_face_id: - self.cell.shapes(self.get_layer("ground_grid_avoidance", opposite_face_id)).insert(shape) + if self.protect_opposite_face: + for group in self.opposing_face_id_groups: + if self.face_ids[face_id] in group: + for other_face_id in group: + if other_face_id != self.face_ids[face_id] and other_face_id in self.face_ids: + self.cell.shapes(self.get_layer("ground_grid_avoidance", + self.face_ids.index(other_face_id))).insert(shape) + break def sync_parameters(self, abc): """Syncronise the calling class' parameters with a JSON representation. diff --git a/klayout_package/python/kqcircuits/elements/flip_chip_connectors/flip_chip_connector_rf.py b/klayout_package/python/kqcircuits/elements/flip_chip_connectors/flip_chip_connector_rf.py index c62ba1a46..033065e25 100644 --- a/klayout_package/python/kqcircuits/elements/flip_chip_connectors/flip_chip_connector_rf.py +++ b/klayout_package/python/kqcircuits/elements/flip_chip_connectors/flip_chip_connector_rf.py @@ -102,7 +102,7 @@ def produce_shape(face, a, b, rotation, trace_rotation): dtrans = pya.DCplxTrans(1, rotation, False, 0, 0) itrans = dtrans.to_itrans(self.layout.dbu) self.cell.shapes(self.get_layer("base_metal_gap_wo_grid", face)).insert(region.transformed(itrans)) - self.add_protection(avoid_region.transformed(itrans), face, 0) + self.add_protection(avoid_region.transformed(itrans), face) self.add_port("{}_port".format(self.face_ids[face]), dtrans * pya.DPoint(-bumps_length/2, 0) + trace_dtrans * dtrans * pya.DVector(-w/2, 0), trace_dtrans * dtrans * pya.DVector(-1, 0), face) diff --git a/klayout_package/python/kqcircuits/elements/spiral_resonator_polygon.py b/klayout_package/python/kqcircuits/elements/spiral_resonator_polygon.py index 40f72f334..c1a445c3b 100644 --- a/klayout_package/python/kqcircuits/elements/spiral_resonator_polygon.py +++ b/klayout_package/python/kqcircuits/elements/spiral_resonator_polygon.py @@ -322,7 +322,7 @@ def _fix_waveguide_end(self, points, current_length): curve_trans = pya.DCplxTrans(1, degrees(alpha1) - v1.vprod_sign(v2)*90, v1.vprod_sign(v2) < 0, corner_pos) self.insert_cell(curve_cell, curve_trans) - WaveguideCoplanarCurved.produce_curve_termination(self, curve_alpha, self.term2, curve_trans, *fids) + WaveguideCoplanarCurved.produce_curve_termination(self, curve_alpha, self.term2, curve_trans, fids[0]) return True # set last point to correct position based on length @@ -398,7 +398,7 @@ def insert_wg_with_connector(segment, distance): else: self.insert_cell(WaveguideCoplanar, path=points[:segment + 1] + [b_pos], term2=0) if segment + 2 == len(points) and s_len - conn_len - distance < 1e-3: - WaveguideCoplanar.produce_end_termination(self, b_pos, t_pos, term2, face_index=1, opp_face_index=0) + WaveguideCoplanar.produce_end_termination(self, b_pos, t_pos, term2, face_index=1) else: self.insert_cell(WaveguideCoplanar, path=[t_pos] + points[segment + 1:], term1=0, term2=term2, face_ids=self.face_ids[1::-1]) diff --git a/klayout_package/python/kqcircuits/elements/waveguide_coplanar.py b/klayout_package/python/kqcircuits/elements/waveguide_coplanar.py index b576e16a4..030b0451d 100644 --- a/klayout_package/python/kqcircuits/elements/waveguide_coplanar.py +++ b/klayout_package/python/kqcircuits/elements/waveguide_coplanar.py @@ -160,7 +160,7 @@ def get_corner_data(point1, point2, point3, r): return v1, v2, alpha1, alpha2, corner_pos @staticmethod - def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_face_index=1): + def produce_end_termination(elem, point_1, point_2, term_len, face_index=0): """Produces termination for a waveguide. The termination consists of a rectangular polygon in the metal gap layer, and grid avoidance around it. @@ -173,7 +173,6 @@ def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_ point_2: DPoint after which termination is produced term_len (double): termination length, assumed positive face_index (int): face index of the face in elem where the termination is created - opp_face_index (int): face index of the opposite face """ a = elem.a b = elem.b @@ -192,7 +191,7 @@ def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_ term_len += elem.margin poly2 = pya.DPolygon([u*(a/2 + b + elem.margin), u*(a/2 + b + elem.margin) + v*term_len, u*(-a/2 - b - elem.margin) + v*term_len, u*(-a/2 - b - elem.margin)]) - elem.add_protection(poly2.transform(shift_start), face_index, opp_face_index) + elem.add_protection(poly2.transform(shift_start), face_index) @staticmethod def is_continuous(waveguide_cell, annotation_layer, tolerance): diff --git a/klayout_package/python/kqcircuits/elements/waveguide_coplanar_curved.py b/klayout_package/python/kqcircuits/elements/waveguide_coplanar_curved.py index bdcd3643d..d2c20e389 100644 --- a/klayout_package/python/kqcircuits/elements/waveguide_coplanar_curved.py +++ b/klayout_package/python/kqcircuits/elements/waveguide_coplanar_curved.py @@ -116,7 +116,7 @@ def create_curve_arcs(elem, angle): annotation @staticmethod - def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_face_index=1): + def produce_curve_termination(elem, angle, term_len, trans, face_index=0): """Produces termination for a curved waveguide. The termination consists of a rectangular polygon in the metal gap layer, and grid avoidance around it. @@ -128,7 +128,6 @@ def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_fa term_len (double): termination length, assumed positive trans (DTrans): transformation applied to the termination face_index (int): face index of the face in elem where the termination is created - opp_face_index (int): face index of the opposite face """ left_inner_arc, left_outer_arc, right_inner_arc, right_outer_arc, left_protection_arc, right_protection_arc,\ _ = WaveguideCoplanarCurved.create_curve_arcs(elem, angle) @@ -156,4 +155,4 @@ def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_fa right_protection_arc[0] + (term_len + elem.margin)*term_dir, right_protection_arc[0], ] - elem.add_protection(trans * pya.DPolygon(protection_pts), face_index, opp_face_index) + elem.add_protection(trans * pya.DPolygon(protection_pts), face_index)