<jupyter_start><jupyter_text>Driven Modal Simulation and S-Parameters  PrerequisiteYou must have a working local installation of Ansys.<jupyter_code>%load_ext autoreload
%autoreload 2

import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict, Headings
import pyEPR as epr<jupyter_output><empty_output><jupyter_text>Create the design in MetalSet up a design of a given dimension. Dimensions will be respected in the design rendering.Note the chip design is centered at origin (0,0).<jupyter_code>design = designs.DesignPlanar({}, True)
design.chips.main.size['size_x'] = '2mm'
design.chips.main.size['size_y'] = '2mm'

#Reference to Ansys hfss QRenderer
hfss = design.renderers.hfss

gui = MetalGUI(design)<jupyter_output><empty_output><jupyter_text>Perform the necessary imports.<jupyter_code>from qiskit_metal.qlibrary.couplers.coupled_line_tee import CoupledLineTee
from qiskit_metal.qlibrary.tlines.meandered import RouteMeander
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
from qiskit_metal.qlibrary.tlines.straight_path import RouteStraight
from qiskit_metal.qlibrary.terminations.open_to_ground import OpenToGround<jupyter_output><empty_output><jupyter_text>Add 2 transmons to the design.<jupyter_code>options = dict(
    # Some options we want to modify from the deafults
    # (see below for defaults)
    pad_width = '425 um', 
    pocket_height = '650um',
    # Adding 4 connectors (see below for defaults)
    connection_pads=dict( 
        a = dict(loc_W=+1,loc_H=+1), 
        b = dict(loc_W=-1,loc_H=+1, pad_height='30um'),
        c = dict(loc_W=+1,loc_H=-1, pad_width='200um'),
        d = dict(loc_W=-1,loc_H=-1, pad_height='50um')
    )
)

## Create 2 transmons

q1 = TransmonPocket(design, 'Q1', options = dict(
    pos_x='+1.4mm', pos_y='0mm', orientation = '90', **options))
q2 = TransmonPocket(design, 'Q2', options = dict(
    pos_x='-0.6mm', pos_y='0mm', orientation = '90', **options))

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>Add 2 hangers consisting of capacitively coupled transmission lines.<jupyter_code>TQ1 = CoupledLineTee(design, 'TQ1', options=dict(pos_x='1mm',
                                             pos_y='3mm',
                                             coupling_length='200um'))
TQ2 = CoupledLineTee(design, 'TQ2', options=dict(pos_x='-1mm',
                                             pos_y='3mm',
                                             coupling_length='200um'))

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>Add 2 meandered CPWs connecting the transmons to the hangers.<jupyter_code>ops=dict(fillet='90um')
design.overwrite_enabled = True

options1 = Dict(
    total_length='8mm',
    hfss_wire_bonds = True,
    pin_inputs=Dict(
        start_pin=Dict(
            component='TQ1',
            pin='second_end'),
        end_pin=Dict(
            component='Q1',
            pin='a')),
    lead=Dict(
        start_straight='0.1mm'),
    **ops
)

options2 = Dict(
    total_length='9mm',
    hfss_wire_bonds = True,
    pin_inputs=Dict(
        start_pin=Dict(
            component='TQ2',
            pin='second_end'),
        end_pin=Dict(
            component='Q2',
            pin='a')),
    lead=Dict(
        start_straight='0.1mm'),
    **ops
)

meanderQ1 = RouteMeander(design, 'meanderQ1', options=options1)
meanderQ2 = RouteMeander(design, 'meanderQ2', options=options2)

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>Add 2 open to grounds at the ends of the horizontal CPW.<jupyter_code>otg1 = OpenToGround(design, 'otg1', options = dict(pos_x='3mm', 
                                                   pos_y='3mm'))
otg2 = OpenToGround(design, 'otg2', options = dict(pos_x = '-3mm', 
                                                   pos_y='3mm', 
                                                   orientation='180'))

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>Add 3 straight CPWs that comprise the long horizontal CPW.<jupyter_code>ops_oR = Dict(hfss_wire_bonds = True,
              pin_inputs=Dict(
                 start_pin=Dict(
                     component='TQ1',
                     pin='prime_end'),
                 end_pin=Dict(
                     component='otg1',
                     pin='open')))
ops_mid = Dict(hfss_wire_bonds = True,
               pin_inputs=Dict(
                 start_pin=Dict(
                     component='TQ1',
                     pin='prime_start'),
                 end_pin=Dict(
                     component='TQ2',
                     pin='prime_end')))
ops_oL = Dict(hfss_wire_bonds = True,
              pin_inputs=Dict(
                 start_pin=Dict(
                     component='TQ2',
                     pin='prime_start'),
                 end_pin=Dict(
                     component='otg2',
                     pin='open')))

cpw_openRight = RouteStraight(design, 'cpw_openRight', options=ops_oR)
cpw_middle = RouteStraight(design, 'cpw_middle', options=ops_mid)
cpw_openLeft = RouteStraight(design, 'cpw_openLeft', options=ops_oL)

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>Render the qubit from Metal into the HangingResonators design in Ansys.  Open a new Ansys window, connect to it, and add a driven modal design called HangingResonators to the currently active project.If Ansys is already open, you can skip `hfss.open_ansys()`. **Wait for Ansys to fully open before proceeding.** If necessary, also close any Ansys popup windows.<jupyter_code>hfss.open_ansys()
hfss.connect_ansys()
hfss.activate_drivenmodal_design("HangingResonators")<jupyter_output>11:32AM 25s WARNING [activate_drivenmodal_design]: The name=HangingResonators was not in active project.  A new design will be inserted to the project.  Names in active project are: 
[].  
INFO 11:32AM [connect_design]: 	Opened active design
	Design:    HangingResonators [Solution type: DrivenModal]
WARNING 11:32AM [connect_setup]: 	No design setup detected.
WARNING 11:32AM [connect_setup]: 	Creating drivenmodal default setup.
INFO 11:32AM [get_setup]: 	Opened setup `Setup`  (<class 'pyEPR.ansys.HfssDMSetup'>)<jupyter_text>Set the buffer width at the edge of the design to be 0.5 mm in both directions.<jupyter_code>hfss.options['x_buffer_width_mm'] = 0.5
hfss.options['y_buffer_width_mm'] = 0.5<jupyter_output><empty_output><jupyter_text>Here, pin cpw_openRight_end and cpw_openLeft_end are converted into lumped ports, each with an impedance of 50 Ohms. Neither of the junctions in Q1 or Q2 are rendered. As a reminder, arguments are given as First parameter: List of components to render (empty list if rendering whole Metal design) Second parameter: List of pins (qcomp, pin) with open endcaps Third parameter: List of pins (qcomp, pin, impedance) to render as lumped ports Fourth parameter: List of junctions (qcomp, qgeometry_name, impedance, draw_ind) to render as lumped ports or as lumped port in parallel with a sheet inductance Fifth parameter: List of junctions (qcomp, qgeometry_name) to omit altogether during renderingSixth parameter: Whether to render chip via box plus buffer or fixed chip size<jupyter_code>hfss.render_design([], 
                   [], 
                   [('cpw_openRight', 'end', 50), ('cpw_openLeft', 'end', 50)], 
                   [], 
                   [('Q1', 'rect_jj'), ('Q2', 'rect_jj')],
                   True)
hfss.save_screenshot()
hfss.add_sweep(setup_name="Setup", 
               name="Sweep", 
               start_ghz=4.0,
               stop_ghz=8.0,
               count=2001,
               type="Interpolating")
hfss.analyze_sweep('Sweep', 'Setup')<jupyter_output>INFO 11:33AM [get_setup]: 	Opened setup `Setup`  (<class 'pyEPR.ansys.HfssDMSetup'>)
INFO 11:33AM [analyze]: Analyzing setup Setup : Sweep<jupyter_text>Plot S, Y, and Z parameters as a function of frequency. The left and right plots display the magnitude and phase, respectively.<jupyter_code>hfss.plot_params(['S11', 'S21'])
hfss.plot_params(['Y11', 'Y21'])
hfss.plot_params(['Z11', 'Z21'])
hfss.disconnect_ansys()
gui.main_window.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1068173532628509, 'fraction_numerical': 0.019929517559849314, 'mean_word_length': 3.1565656565656566, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '11057', 'license': 'Apache-2.0', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2610, 'n_words': 632, 'path': 'docs/tut/analysis/07 S Param Simulation.ipynb', 'repo_name': 'bicycle315/Qiskit-Metal', 'size': '8229'}