qiskit_metal.qlibrary.QNLMetal.bandage
Bandage.
`top`
`top_left` _________|________ `top_right`
| |
| |
| |
| |
`left` - | * | - `right`
| |
| |
| |
| |
| |
`bottom_left` ‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾‾‾ `bottom_right`
`bottom`
1# This code was written by Deval Deliwala. 2# 3# This code is to be used by QNL. 4# 5# Any modifications or derivative works of this code must retain this 6# notice, and modified files need to carry a notice indicating 7# that they have been altered from the originals. 8 9""" Bandage. 10 11.. code-block:: 12 13 `top` 14 `top_left` _________|________ `top_right` 15 | | 16 | | 17 | | 18 | | 19 `left` - | * | - `right` 20 | | 21 | | 22 | | 23 | | 24 | | 25 `bottom_left` ‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾‾‾ `bottom_right` 26 `bottom` 27 28 29""" 30 31import numpy as np 32from qiskit_metal import draw, Dict 33from qiskit_metal.qlibrary.core import QComponent 34from qiskit_metal.toolbox_python.utility_functions import rotate_point 35 36 37class Bandage(QComponent): 38 """ 39 Inherits `QComponent` class. 40 41 Description: 42 A rectangular bandage structure. 43 44 Options: 45 * width : width of the rectangle 46 * height : height of the rectangle 47 * pos_x/_y: position of the bandage on chip 48 * orientation : 0-> is parallel to x-axis, with orientation (in degrees) counterclockwise 49 * layer : the layer number for the bandage 50 51 """ 52 53 # Default drawing options 54 default_options = Dict( 55 width='100um', 56 height='200um', 57 pos_x='0um', 58 pos_y='0um', 59 orientation='0', 60 layer='1', 61 ) 62 63 # Component metadata 64 # Name prefix for component, if user doesn't provide name 65 component_metadata = Dict( 66 short_name='bandage', 67 _qgeometry_table_poly='True', 68 ) 69 70 def make(self): 71 """ Convert self.options into QGeometry. """ 72 p = self.parse_options() # string options -> numbers 73 74 bandage = draw.rectangle(p.width, p.height) 75 bandage = draw.rotate(bandage, p.orientation) 76 bandage = draw.translate(bandage, p.pos_x, p.pos_y) 77 78 # Converting drawing to qgeometry 79 self.add_qgeometry('poly', {'bandage': bandage}, layer=p.layer) 80 81 # Positioning nodes 82 nodes = Dict() 83 nodes.origin = np.zeros(2) 84 nodes.top = np.array((0, +p.height/2)) 85 nodes.bottom = np.array((0, -p.height/2)) 86 nodes.left = np.array((-p.width/2, 0)) 87 nodes.right = np.array((+p.width/2, 0)) 88 nodes.top_left = nodes.top + nodes.left 89 nodes.top_right = nodes.top + nodes.right 90 nodes.bottom_left = nodes.bottom + nodes.left 91 nodes.bottom_right = nodes.bottom + nodes.right 92 93 # Moving all nodes along with component 94 translation_vec = np.array((p.pos_x, p.pos_y)) 95 theta = np.deg2rad(p.orientation) 96 for key, point in nodes.items(): 97 rotated = rotate_point(point, theta) 98 nodes[key] = rotated + translation_vec 99 100 self.nodes = nodes 101 return 102 103 def node(self, key): 104 return self.nodes.get(key, None)
class
Bandage(qiskit_metal.qlibrary.core.base.QComponent):
38class Bandage(QComponent): 39 """ 40 Inherits `QComponent` class. 41 42 Description: 43 A rectangular bandage structure. 44 45 Options: 46 * width : width of the rectangle 47 * height : height of the rectangle 48 * pos_x/_y: position of the bandage on chip 49 * orientation : 0-> is parallel to x-axis, with orientation (in degrees) counterclockwise 50 * layer : the layer number for the bandage 51 52 """ 53 54 # Default drawing options 55 default_options = Dict( 56 width='100um', 57 height='200um', 58 pos_x='0um', 59 pos_y='0um', 60 orientation='0', 61 layer='1', 62 ) 63 64 # Component metadata 65 # Name prefix for component, if user doesn't provide name 66 component_metadata = Dict( 67 short_name='bandage', 68 _qgeometry_table_poly='True', 69 ) 70 71 def make(self): 72 """ Convert self.options into QGeometry. """ 73 p = self.parse_options() # string options -> numbers 74 75 bandage = draw.rectangle(p.width, p.height) 76 bandage = draw.rotate(bandage, p.orientation) 77 bandage = draw.translate(bandage, p.pos_x, p.pos_y) 78 79 # Converting drawing to qgeometry 80 self.add_qgeometry('poly', {'bandage': bandage}, layer=p.layer) 81 82 # Positioning nodes 83 nodes = Dict() 84 nodes.origin = np.zeros(2) 85 nodes.top = np.array((0, +p.height/2)) 86 nodes.bottom = np.array((0, -p.height/2)) 87 nodes.left = np.array((-p.width/2, 0)) 88 nodes.right = np.array((+p.width/2, 0)) 89 nodes.top_left = nodes.top + nodes.left 90 nodes.top_right = nodes.top + nodes.right 91 nodes.bottom_left = nodes.bottom + nodes.left 92 nodes.bottom_right = nodes.bottom + nodes.right 93 94 # Moving all nodes along with component 95 translation_vec = np.array((p.pos_x, p.pos_y)) 96 theta = np.deg2rad(p.orientation) 97 for key, point in nodes.items(): 98 rotated = rotate_point(point, theta) 99 nodes[key] = rotated + translation_vec 100 101 self.nodes = nodes 102 return 103 104 def node(self, key): 105 return self.nodes.get(key, None)
Inherits QComponent
class.
Description: A rectangular bandage structure.
Options: * width : width of the rectangle * height : height of the rectangle * pos_x/_y: position of the bandage on chip * orientation : 0-> is parallel to x-axis, with orientation (in degrees) counterclockwise * layer : the layer number for the bandage
default_options =
{'width': '100um', 'height': '200um', 'pos_x': '0um', 'pos_y': '0um', 'orientation': '0', 'layer': '1'}
Default drawing options
def
make(self):
71 def make(self): 72 """ Convert self.options into QGeometry. """ 73 p = self.parse_options() # string options -> numbers 74 75 bandage = draw.rectangle(p.width, p.height) 76 bandage = draw.rotate(bandage, p.orientation) 77 bandage = draw.translate(bandage, p.pos_x, p.pos_y) 78 79 # Converting drawing to qgeometry 80 self.add_qgeometry('poly', {'bandage': bandage}, layer=p.layer) 81 82 # Positioning nodes 83 nodes = Dict() 84 nodes.origin = np.zeros(2) 85 nodes.top = np.array((0, +p.height/2)) 86 nodes.bottom = np.array((0, -p.height/2)) 87 nodes.left = np.array((-p.width/2, 0)) 88 nodes.right = np.array((+p.width/2, 0)) 89 nodes.top_left = nodes.top + nodes.left 90 nodes.top_right = nodes.top + nodes.right 91 nodes.bottom_left = nodes.bottom + nodes.left 92 nodes.bottom_right = nodes.bottom + nodes.right 93 94 # Moving all nodes along with component 95 translation_vec = np.array((p.pos_x, p.pos_y)) 96 theta = np.deg2rad(p.orientation) 97 for key, point in nodes.items(): 98 rotated = rotate_point(point, theta) 99 nodes[key] = rotated + translation_vec 100 101 self.nodes = nodes 102 return
Convert self.options into QGeometry.