# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Star shaped qubit
#
# We'll be creating a 2D design and adding a star shaped qubit QComponent.
#
#
# There's a central star shaped component. This component is essentially a circle with trpezoids subtracted from it. A T-junction qubit is attached to this central shape. Then there are four coupling resonators and one readout resonator present in the default setting. The shape of the central component and the number coupling resonators are customizable. Let's try out a few diferent ways to create and render this component.

# So, let us dive right in. For convenience, let's begin by enabling
# automatic reloading of modules when they change.
# %load_ext autoreload
# %autoreload 2

# Next, we import the relevant modules. You can add new modules as and when needed. 

import qiskit_metal as metal
import numpy as np
from math import *
from qiskit_metal import designs, draw, Dict
from qiskit_metal.qlibrary.core import BaseQubit, QComponent

# Next we import the GUI

from qiskit_metal import MetalGUI

# A QDesign class must be instantiated each time a new quantum circuit design is created. The design class `DesignPlanar` is best for 2D circuit designs.

design = designs.DesignPlanar()
gui = MetalGUI(design)
gui.rebuild() 

# # A Star Qubit
#
# You can create a ready-made star qubit from the QComponent Library, qiskit_metal.qlibrary.qubits. star_qubit.py is the file containing our qubit so StarQubit is the module we import. 
#

from qiskit_metal.qlibrary.qubits.star_qubit import StarQubit

# The following default_options can be overridden by user.
StarQubit.get_template_options(design)

# To force overwrite a QComponent with an existing name.  
# This is useful when re-running cells in a notebook. 
design.overwrite_enabled = True

# Let us place the qubit at (x,y) =(5,5), and change the default rotation values. As this design is meant to have up to 5 contacts including one readout and up to 4 coupling resonators, these angles should be 72 degrees apart. However, the number of connectors may be changed to any value between 0 and 4.

# +
qubit_options = dict(
    pos_x = '7um',
    pos_y = '7um',  
    number_of_connectors = 4 # Change the number of connectors
)

# Create a new Concentric Transmon object with name 'Q1' 
q1 = StarQubit(design, 'Star', options=qubit_options)

gui.rebuild()  # rebuild the design and plot 
gui.autoscale() #resize GUI to see QComponent
gui.zoom_on_components(['Star']) #Can also gui.zoom_on_components([q1.name])

# +
#Let's see what the Q1 object looks like

q1 #print Q1 information
# -

#Save screenshot as a .png formatted file.
gui.screenshot()

# +
# Screenshot the canvas only as a .png formatted file.
gui.figure.savefig('shot.png')

from IPython.display import Image, display
_disp_ops = dict(width=500)
display(Image('shot.png', **_disp_ops))
# -

# # Closing the Qiskit Metal GUI

# +
# gui.main_window.close()
# -



StarcoderdataJupyterScriptsDedupFiltered