Skip to content

Commit

Permalink
865 gds handle multiplanar design with multiple chip names and layer. (
Browse files Browse the repository at this point in the history
…#869)

* Fix typos, add method for getting chip size to multi-planar

* Fix linting and typos

* Add logic to allow for junctions to be in multiple chips.  Thus, a file with junctions only needs to be imported the gdspy only once.
  • Loading branch information
priti-ashvin-shah-ibm authored Nov 9, 2022
1 parent a59271f commit c798b9d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 44 deletions.
2 changes: 1 addition & 1 deletion qiskit_metal/designs/design_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class QDesign():
"""
# pylint: disable=too-many-instance-attributes, too-many-public-methods

# Dummy private attribute used to check if an instanciated object is
# Dummy private attribute used to check if an instantiated object is
# indeed a QDesign class. The problem is that the `isinstance`
# built-in method fails when this module is reloaded.
# Used by `is_design` to check.
Expand Down
56 changes: 56 additions & 0 deletions qiskit_metal/designs/design_multiplanar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from qiskit_metal.designs.design_base import QDesign
from qiskit_metal.toolbox_metal.layer_stack_handler import LayerStackHandler
from addict import Dict
from typing import Tuple

__all__ = ['MultiPlanar']

Expand Down Expand Up @@ -92,3 +93,58 @@ def _add_chip_info(self):
size_x='9mm',
size_y='7mm',
)

def get_x_y_for_chip(self, chip_name: str) -> Tuple[tuple, int]:
"""If the chip_name is in self.chips, along with entry for size
information then return a tuple=(minx, miny, maxx, maxy). Used for
subtraction while exporting design.
Args:
chip_name (str): Name of chip that you want the size of.
Returns:
Tuple[tuple, int]:
tuple: The exact placement on rectangle coordinate (minx, miny, maxx, maxy).
int: 0=all is good
1=chip_name not in self._chips
2=size information missing or no good
"""
x_y_location = tuple()

if chip_name in self._chips:
if 'size' in self._chips[chip_name]:

size = self.parse_value(self.chips[chip_name]['size'])
if 'center_x' in size \
and 'center_y' in size \
and 'size_x' in size \
and 'size_y' in size:
if type(size.center_x) in [int, float] and \
type(size.center_y) in [int, float] and \
type(size.size_x) in [int, float] and \
type(size.size_y) in [int, float]:
x_y_location = (
size['center_x'] - (size['size_x'] / 2.0),
size['center_y'] - (size['size_y'] / 2.0),
size['center_x'] + (size['size_x'] / 2.0),
size['center_y'] + (size['size_y'] / 2.0))
return x_y_location, 0

self.logger.warning(
f'Size information within self.chips[{chip_name}]["size"]'
f' is NOT an int or float.')
return x_y_location, 2

self.logger.warning('center_x or center_y or size_x or size_y '
f' NOT in self._chips[{chip_name}]["size"]')
return x_y_location, 2

self.logger.warning(
f'Information for size in NOT in self._chips[{chip_name}]'
' dict. Return "None" in tuple.')
return x_y_location, 2

self.logger.warning(
f'Chip name "{chip_name}" is not in self._chips dict. Return "None" in tuple.'
)
return x_y_location, 1
Loading

0 comments on commit c798b9d

Please sign in to comment.