From d1a3b17861da3720f1ea130db10497caedb19d9f Mon Sep 17 00:00:00 2001 From: maxhant Date: Tue, 16 Jan 2024 17:23:34 +0100 Subject: [PATCH 1/3] failed to far --- .../qgeometries/qgeometries_handler.py | 6 +++- qiskit_metal/qlibrary/core/base.py | 8 ++++- .../renderers/renderer_gds/gds_renderer.py | 32 ++++++++++--------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/qiskit_metal/qgeometries/qgeometries_handler.py b/qiskit_metal/qgeometries/qgeometries_handler.py index 643e8290d..bc6cead1c 100644 --- a/qiskit_metal/qgeometries/qgeometries_handler.py +++ b/qiskit_metal/qgeometries/qgeometries_handler.py @@ -99,6 +99,7 @@ def is_qgeometry_table(obj): subtract=bool, # do we subtract from the ground place of the chip helper=bool, # helper or not chip=str, # chip name + sublayer=int, # gds type of sublayer # type=str, # metal, helper. poly=10 or path=11 __renderers__=dict( # ADD specific renderers here, all renderes must register here. @@ -445,6 +446,7 @@ def add_qgeometry( helper: bool = False, layer: Union[int, str] = 1, # chip will be here chip: str = 'main', + sublayer: Union[int, str] = 0, **other_options): """Main interface to add qgeometries. @@ -456,6 +458,7 @@ def add_qgeometry( helper (bool): Helper - passed through. Defaults to False. layer (Union[int, str]): Layer - passed through. Defaults to 1. chip (str): Chip name - passed through. Defaults to 'main'. + sublayer (Union[int, str]): Sublayer - passed through. Defaults to 0. **other_options (object): Other_options - passed through. """ # TODO: Add unit test @@ -472,7 +475,7 @@ def add_qgeometry( f'Kind must be in {self.get_element_types()}. This failed for component' f'name = `{component_name}`.\n' f' The call was with subtract={subtract} and helper={helper}' - f' and layer={layer}, and options={other_options}') + f' and layer={layer}, and sublayer={sublayer} and options={other_options}') #Checks if (any) of the geometry are MultiPolygons, and breaks them up into #individual polygons. Rounds the coordinate sequences of those values to avoid @@ -503,6 +506,7 @@ def add_qgeometry( helper=helper, layer=int(layer), chip=chip, + sublayer=int(sublayer), **other_options) #replaces line above to generate the options. diff --git a/qiskit_metal/qlibrary/core/base.py b/qiskit_metal/qlibrary/core/base.py index 336789362..9d6c44f83 100644 --- a/qiskit_metal/qlibrary/core/base.py +++ b/qiskit_metal/qlibrary/core/base.py @@ -78,6 +78,7 @@ class QComponent(): Expressed counter-clockwise orientation. * chip: 'main' -- Chip holding the QComponent. * layer: '1' -- Manufacturing layer used for the QComponent. + * sublayer: '0' -- Manufacturing sublayer used for the QComponent. Nested default options can be overwritten with the update function. The following code demonstrates how the update works. @@ -120,7 +121,8 @@ class QComponent(): pos_y='0.0um', orientation='0.0', chip='main', - layer='1') + layer='1', + sublayer='0',) """Default drawing options""" component_metadata = Dict() @@ -1078,6 +1080,7 @@ def add_qgeometry( helper: bool = False, layer: Union[int, str] = None, # chip will be here chip: str = None, + sublayer: Union[int, str] = None, **kwargs): r"""Add QGeometry. @@ -1108,6 +1111,8 @@ def add_qgeometry( if layer is None: layer = self.options.layer + if sublayer is None: + sublayer = self.options.sublayer if chip is None: chip = self.options.chip @@ -1137,6 +1142,7 @@ def add_qgeometry( helper=helper, layer=layer, chip=chip, + sublayer=sublayer, **renderer_and_options) def _get_specific_table_values_from_renderers(self, kind: str) -> Dict: diff --git a/qiskit_metal/renderers/renderer_gds/gds_renderer.py b/qiskit_metal/renderers/renderer_gds/gds_renderer.py index c6e2e7670..f1b05822f 100644 --- a/qiskit_metal/renderers/renderer_gds/gds_renderer.py +++ b/qiskit_metal/renderers/renderer_gds/gds_renderer.py @@ -1532,7 +1532,7 @@ def _populate_poly_path_for_export(self): for chip_layer in layers_in_chip: self._handle_photo_resist(lib, chip_only_top, chip_name, - chip_layer, rectangle_points, + chip_layer, sublayer, rectangle_points, precision, max_points) # If junction table, import the cell and cell to chip_only_top @@ -1549,7 +1549,7 @@ def _populate_poly_path_for_export(self): def _handle_photo_resist(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, chip_name: str, - chip_layer: int, rectangle_points: list, + chip_layer: int, sublayer: int, rectangle_points: list, precision: float, max_points: int): """Handle the positive vs negative mask. @@ -1565,19 +1565,19 @@ def _handle_photo_resist(self, lib: gdspy.GdsLibrary, """ self.chip_info[chip_name]['subtract_poly'] = gdspy.Polygon( - rectangle_points, chip_layer) + rectangle_points, chip_layer, datatype=sublayer) ground_cell_name = f'TOP_{chip_name}_{chip_layer}' ground_cell = lib.new_cell(ground_cell_name, overwrite_duplicate=True) if self._is_negative_mask(chip_name, chip_layer): self._negative_mask(lib, chip_only_top, ground_cell, chip_name, - chip_layer, precision, max_points) + chip_layer, sublayer, precision, max_points) else: self._positive_mask(lib, chip_only_top, ground_cell, chip_name, - chip_layer, precision, max_points) + chip_layer, sublayer, precision, max_points) - def _is_negative_mask(self, chip: str, layer: int) -> bool: + def _is_negative_mask(self, chip: str, layer: int, sublayer: int) -> bool: """Check options to see if negative mask is requested for the chip and layer. @@ -1598,7 +1598,7 @@ def _is_negative_mask(self, chip: str, layer: int) -> bool: def _negative_mask(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, ground_cell: gdspy.library.Cell, chip_name: str, - chip_layer: int, precision: float, max_points: int): + chip_layer: int, sublayer: int, precision: float, max_points: int): """Apply logic for negative_mask. Args: @@ -1632,7 +1632,8 @@ def _negative_mask(self, lib: gdspy.GdsLibrary, 'not', max_points=max_points, precision=precision, - layer=chip_layer) + layer=chip_layer, + datatype=sublayer) lib.remove(subtract_true_cell) lib.remove(subtract_false_cell) @@ -1649,7 +1650,7 @@ def _negative_mask(self, lib: gdspy.GdsLibrary, def _positive_mask(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, ground_cell: gdspy.library.Cell, chip_name: str, - chip_layer: int, precision: float, max_points: int): + chip_layer: int, sublayer: int, precision: float, max_points: int): """Apply logic for positive mask. Args: @@ -1680,7 +1681,8 @@ def _positive_mask(self, lib: gdspy.GdsLibrary, 'not', max_points=max_points, precision=precision, - layer=chip_layer) + layer=chip_layer, + datatype=sublayer) lib.remove(subtract_cell) @@ -2283,7 +2285,7 @@ class to a series of GDSII format on the input pd.Series. exterior_poly = gdspy.Polygon( list(geom.exterior.coords), layer=qgeometry_element.layer, - datatype=10, + datatype=qgeometry_element.sublayer, ) # If polygons have a holes, need to remove it for gdspy. @@ -2294,7 +2296,7 @@ class to a series of GDSII format on the input pd.Series. all_interiors.append(interior_coords) a_poly_set = gdspy.PolygonSet(all_interiors, layer=qgeometry_element.layer, - datatype=10) + datatype=qgeometry_element.sublayer) # Since there is max_points in boolean, don't need to do this twice. # a_poly_set = a_poly_set.fracture(max_points=max_points) # exterior_poly = exterior_poly.fracture(max_points=max_points) @@ -2304,7 +2306,7 @@ class to a series of GDSII format on the input pd.Series. max_points=max_points, precision=precision, layer=qgeometry_element.layer, - datatype=10) + datatype=qgeometry_element.sublayer) return a_poly exterior_poly = exterior_poly.fracture(max_points=max_points, @@ -2343,13 +2345,13 @@ class to a series of GDSII format on the input pd.Series. use_width, layer=qgeometry_element.layer, max_points=max_points, - datatype=11) + datatype=qgeometry_element.sublayer) else: to_return = gdspy.FlexPath( list(geom.coords), use_width, layer=qgeometry_element.layer, - datatype=11, + datatype=qgeometry_element.sublayer, max_points=max_points, corners=corners, bend_radius=qgeometry_element.fillet, From 127b8468bdfb0875d98638d8db4ea977a3d5f843 Mon Sep 17 00:00:00 2001 From: maxhant Date: Tue, 16 Jan 2024 18:12:35 +0100 Subject: [PATCH 2/3] removing sublayer as input in fucntions --- .../qgeometries/qgeometries_handler.py | 2 +- .../renderers/renderer_gds/gds_renderer.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/qiskit_metal/qgeometries/qgeometries_handler.py b/qiskit_metal/qgeometries/qgeometries_handler.py index bc6cead1c..c379e4828 100644 --- a/qiskit_metal/qgeometries/qgeometries_handler.py +++ b/qiskit_metal/qgeometries/qgeometries_handler.py @@ -446,7 +446,7 @@ def add_qgeometry( helper: bool = False, layer: Union[int, str] = 1, # chip will be here chip: str = 'main', - sublayer: Union[int, str] = 0, + sublayer: Union[int, str] = 10, **other_options): """Main interface to add qgeometries. diff --git a/qiskit_metal/renderers/renderer_gds/gds_renderer.py b/qiskit_metal/renderers/renderer_gds/gds_renderer.py index f1b05822f..77c45e132 100644 --- a/qiskit_metal/renderers/renderer_gds/gds_renderer.py +++ b/qiskit_metal/renderers/renderer_gds/gds_renderer.py @@ -1532,7 +1532,7 @@ def _populate_poly_path_for_export(self): for chip_layer in layers_in_chip: self._handle_photo_resist(lib, chip_only_top, chip_name, - chip_layer, sublayer, rectangle_points, + chip_layer, rectangle_points, precision, max_points) # If junction table, import the cell and cell to chip_only_top @@ -1549,7 +1549,7 @@ def _populate_poly_path_for_export(self): def _handle_photo_resist(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, chip_name: str, - chip_layer: int, sublayer: int, rectangle_points: list, + chip_layer: int, rectangle_points: list, precision: float, max_points: int): """Handle the positive vs negative mask. @@ -1565,19 +1565,19 @@ def _handle_photo_resist(self, lib: gdspy.GdsLibrary, """ self.chip_info[chip_name]['subtract_poly'] = gdspy.Polygon( - rectangle_points, chip_layer, datatype=sublayer) + rectangle_points, chip_layer) ground_cell_name = f'TOP_{chip_name}_{chip_layer}' ground_cell = lib.new_cell(ground_cell_name, overwrite_duplicate=True) if self._is_negative_mask(chip_name, chip_layer): self._negative_mask(lib, chip_only_top, ground_cell, chip_name, - chip_layer, sublayer, precision, max_points) + chip_layer, precision, max_points) else: self._positive_mask(lib, chip_only_top, ground_cell, chip_name, - chip_layer, sublayer, precision, max_points) + chip_layer, precision, max_points) - def _is_negative_mask(self, chip: str, layer: int, sublayer: int) -> bool: + def _is_negative_mask(self, chip: str, layer: int) -> bool: """Check options to see if negative mask is requested for the chip and layer. @@ -1598,7 +1598,7 @@ def _is_negative_mask(self, chip: str, layer: int, sublayer: int) -> bool: def _negative_mask(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, ground_cell: gdspy.library.Cell, chip_name: str, - chip_layer: int, sublayer: int, precision: float, max_points: int): + chip_layer: int, precision: float, max_points: int): """Apply logic for negative_mask. Args: @@ -1633,7 +1633,7 @@ def _negative_mask(self, lib: gdspy.GdsLibrary, max_points=max_points, precision=precision, layer=chip_layer, - datatype=sublayer) + ) lib.remove(subtract_true_cell) lib.remove(subtract_false_cell) @@ -1650,7 +1650,7 @@ def _negative_mask(self, lib: gdspy.GdsLibrary, def _positive_mask(self, lib: gdspy.GdsLibrary, chip_only_top: gdspy.library.Cell, ground_cell: gdspy.library.Cell, chip_name: str, - chip_layer: int, sublayer: int, precision: float, max_points: int): + chip_layer: int, precision: float, max_points: int): """Apply logic for positive mask. Args: @@ -1682,7 +1682,7 @@ def _positive_mask(self, lib: gdspy.GdsLibrary, max_points=max_points, precision=precision, layer=chip_layer, - datatype=sublayer) + ) lib.remove(subtract_cell) From 07fbf84550c3ca889db4fbe86e1dee4fb9d3c0be Mon Sep 17 00:00:00 2001 From: maxhant Date: Wed, 17 Jan 2024 09:48:21 +0100 Subject: [PATCH 3/3] keep compatibilty with default values --- qiskit_metal/qlibrary/core/base.py | 5 +++-- qiskit_metal/renderers/renderer_gds/gds_renderer.py | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/qiskit_metal/qlibrary/core/base.py b/qiskit_metal/qlibrary/core/base.py index 9d6c44f83..d484b9995 100644 --- a/qiskit_metal/qlibrary/core/base.py +++ b/qiskit_metal/qlibrary/core/base.py @@ -78,7 +78,7 @@ class QComponent(): Expressed counter-clockwise orientation. * chip: 'main' -- Chip holding the QComponent. * layer: '1' -- Manufacturing layer used for the QComponent. - * sublayer: '0' -- Manufacturing sublayer used for the QComponent. + * sublayer: '10' -- Manufacturing sublayer used for the QComponent. Nested default options can be overwritten with the update function. The following code demonstrates how the update works. @@ -122,7 +122,7 @@ class QComponent(): orientation='0.0', chip='main', layer='1', - sublayer='0',) + sublayer='10',) """Default drawing options""" component_metadata = Dict() @@ -1098,6 +1098,7 @@ def add_qgeometry( Defaults to False. layer (int, str): The layer to which the set of QGeometry will belong Defaults to None, which is converted to self.options.chip. + sublayer (int, str): The sublayer to which the set of QGeometry will belong chip (str): Chip name. Defaults to None, which is converted to self.options.chip. kwargs (dict): Parameters dictionary diff --git a/qiskit_metal/renderers/renderer_gds/gds_renderer.py b/qiskit_metal/renderers/renderer_gds/gds_renderer.py index 77c45e132..96f47381b 100644 --- a/qiskit_metal/renderers/renderer_gds/gds_renderer.py +++ b/qiskit_metal/renderers/renderer_gds/gds_renderer.py @@ -1632,8 +1632,7 @@ def _negative_mask(self, lib: gdspy.GdsLibrary, 'not', max_points=max_points, precision=precision, - layer=chip_layer, - ) + layer=chip_layer) lib.remove(subtract_true_cell) lib.remove(subtract_false_cell) @@ -1681,8 +1680,7 @@ def _positive_mask(self, lib: gdspy.GdsLibrary, 'not', max_points=max_points, precision=precision, - layer=chip_layer, - ) + layer=chip_layer) lib.remove(subtract_cell) @@ -2345,13 +2343,13 @@ class to a series of GDSII format on the input pd.Series. use_width, layer=qgeometry_element.layer, max_points=max_points, - datatype=qgeometry_element.sublayer) + datatype=qgeometry_element.sublayer+1) else: to_return = gdspy.FlexPath( list(geom.coords), use_width, layer=qgeometry_element.layer, - datatype=qgeometry_element.sublayer, + datatype=qgeometry_element.sublayer+1, max_points=max_points, corners=corners, bend_radius=qgeometry_element.fillet,