<jupyter_start><jupyter_text>Sweeps - Eigenmode matrix  PrerequisiteYou need to have a working local installation of Ansys  1. Perform the necessary imports and create a QDesign in Metal first.<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
from qiskit_metal.analyses.quantization import EPRanalysis
# Create the design in Metal
# Create a design by specifying the chip size and open Metal GUI.

design = designs.DesignPlanar({}, True)
design.chips.main.size['size_x'] = '2mm'
design.chips.main.size['size_y'] = '2mm'

gui = MetalGUI(design)

from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
from qiskit_metal.qlibrary.terminations.open_to_ground import OpenToGround
from qiskit_metal.qlibrary.tlines.meandered import RouteMeander<jupyter_output><empty_output><jupyter_text>In this example, the design consists of 1 qubit and 1 CPW connected to OpenToGround.<jupyter_code># Allow running the same cell here multiple times to overwrite changes
design.overwrite_enabled = True

# Remove all qcomponents from GUI.
design.delete_all_components()

# So as to demonstrate the quality factor outputs easily, the
#subtrate material type is being changed to FR4_epoxy from the
#default of silicon
design.chips.main.material = 'FR4_epoxy'

q1 = TransmonPocket(
    design,
    'Q1',
    options=dict(pad_width='425 um',
                 pocket_height='650um', 
                 hfss_inductance = '17nH',
                 connection_pads=dict(
                     readout=dict(loc_W=+1, loc_H=+1, pad_width='200um'))))
otg = OpenToGround(design,
                   'open_to_ground',
                   options=dict(pos_x='1.75mm', pos_y='0um', orientation='0'))
readout = RouteMeander(
    design, 'readout',
    Dict(
        total_length='6 mm',
        hfss_wire_bonds = True,
        fillet='90 um',
        lead=dict(start_straight='100um'),
        pin_inputs=Dict(start_pin=Dict(component='Q1', pin='readout'),
                        end_pin=Dict(component='open_to_ground', pin='open')),
    ))

gui.rebuild()
gui.autoscale()<jupyter_output><empty_output><jupyter_text>2 Metal passes information to 'hfss' simulator, and gets a solution matrix.<jupyter_code># Create a separate analysis object for the combined qbit+readout.
eig_qres = EPRanalysis(design, "hfss")<jupyter_output><empty_output><jupyter_text>Prepare data to pass as arguments for method run_sweep().  Method run_sweep() will open the simulation software if software is not open already.<jupyter_code>### for render_design()
# Render every QComponent in QDesign.
render_qcomps = []

# Identify which kind of pins in Ansys. 
# Follow details from renderer in
# QHFSSRenderer.render_design.
# No pins are open, so don't need to utilize render_endcaps.
open_terminations = []

#List of tuples of jj's that shouldn't be rendered.  
#Follow details from renderer in QHFSSRenderer.render_design.
render_ignored_jjs = []

# Either calculate a bounding box based on the location of 
# rendered geometries or use chip size from design class.
box_plus_buffer = True
# For simulator hfss, the setup options are :
# min_freq_ghz, n_modes, max_delta_f, max_passes, min_passes, min_converged=None,
# pct_refinement, basis_order

# If you don't pass all the arguments, the default is determined by 
# QHFSSRenderer's default_options.

# If a setup named "sweeper_em_setup" exists in the project, it will be deleted, 
# and a new setup will be added.

eig_qres.sim.setup.name="sweeper_em_setup"
eig_qres.sim.setup.min_freq_ghz=4
eig_qres.sim.setup.n_modes=2
eig_qres.sim.setup.max_passes=15
eig_qres.sim.setup.min_converged = 2
eig_qres.sim.setup.max_delta_f = 0.2

eig_qres.setup.junctions.jj.rect = 'JJ_rect_Lj_Q1_rect_jj'
eig_qres.setup.junctions.jj.line = 'JJ_Lj_Q1_rect_jj_'<jupyter_output><empty_output><jupyter_text>- Connect to Ansys HFSS, eigenmode solution. - Rebuild QComponents in Metal. - Render QComponents within HFSS and setup. - Delete/Clear the HFSS between each calculation of solution matrix. - Calculate solution matrix for each value in option_sweep. Return a dict and return code.  If the return code is zero, there were no errors detected.   The dict has:  key = each value used to sweep, value = data from simulators This could take minutes based size of design.<jupyter_code>#Note: The method will connect to Ansys, activate_eigenmode_design(), add_eigenmode_setup().

all_sweeps, return_code = eig_qres.run_sweep(readout.name,
                                        'total_length', 
                                        ['10mm', '11mm', '12mm'],
                                        render_qcomps,
                                        open_terminations,
                                         ignored_jjs=render_ignored_jjs,
                                        design_name="GetEigenModeSolution", 
                                       box_plus_buffer=box_plus_buffer
                                      )

all_sweeps.keys()
# For example, just one group of solution data.
all_sweeps['10mm'].keys()

all_sweeps['10mm']

all_sweeps['10mm']['variables']
all_sweeps['10mm']['sim_variables']['convergence_t']
all_sweeps['10mm']['sim_variables']['convergence_f']
# Uncomment the next close simulation software. 
#eig_qres.sim.close()
# Uncomment next line if you would like to close the gui
#gui.main_window.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08657534246575342, 'fraction_numerical': 0.011141552511415525, 'mean_word_length': 3.628909551986475, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '41422', 'license': 'Apache-2.0', 'n_tokens_mistral': 1783, 'n_tokens_neox': 1687, 'n_words': 478, 'path': 'tutorials/4 Analysis/C. Parametric sweeps/4.22 Eigenmode matrix.ipynb', 'repo_name': 'camponogaraviera/qiskit-metal', 'size': '5475'}