squadds.simulations package#

Submodules#

squadds.simulations.ansys_simulator module#

class squadds.simulations.ansys_simulator.AnsysSimulator(analyzer, design_options, **kwargs)[source]#

Bases: object

AnsysSimulator class for simulating devices using Ansys.

analyzer#

The analyzer object.

design_options#

The design options.

lom_analysis_obj#

The LOM analysis object.

epr_analysis_obj#

The EPR analysis object.

design#

The design planar object.

gui#

The MetalGUI object.

Initialize the AnsysSimulator object.

Parameters:
  • analyzer – The analyzer object.

  • design_options – The design options.

Optional arguments:

open_gui (bool): If True, a MetalGUI instance is created and assigned to self.gui. Default is False.

get_design_screenshot()[source]#

Saves a screenshot of the design.

Returns:

None

get_renderer_screenshot()[source]#

Saves a screenshot of the renderer.

If the EPR analysis object is not None, it saves a screenshot of the EPR analysis simulation. If the LOM analysis object is not None, it saves a screenshot of the LOM analysis simulation.

get_xmon_info(xmon_dict)[source]#

Retrieves information about the Xmon qubit from the given xmon_dict.

Parameters:

xmon_dict (dict) – A dictionary containing simulation results and design options.

Returns:

A dictionary containing the qubit frequency in GHz and the anharmonicity in MHz.

Return type:

dict

plot_device(device_dict)[source]#

Plot the device based on the given device dictionary.

Parameters: - device_dict (dict): A dictionary containing the device information.

Returns: None

simulate(device_dict)[source]#

Simulates the device based on the provided device dictionary.

Parameters:

device_dict (dict) – A dictionary containing the device design options and setup.

Returns:

The simulation results.

Return type:

pandas.DataFrame

Raises:

None

sweep(sweep_dict, emode_setup=None, lom_setup=None)[source]#

Sweeps the device based on the provided sweep dictionary.

Parameters:

sweep_dict (dict) – A dictionary containing the sweep options.

Returns:

The sweep results.

Return type:

pandas.DataFrame

Raises:

None

sweep_qubit_cavity(device_dict, emode_setup=None, lom_setup=None)[source]#

Sweeps a single geometric parameter of the qubit and cavity system based on the provided sweep dictionary.

Parameters:
  • device_dict (dict) – A dictionary containing the device design options and setup.

  • emode_setup (dict) – A dictionary containing the eigenmode setup options.

  • lom_setup (dict) – A dictionary containing the LOM setup options.

Returns:

The sweep results.

Return type:

results

squadds.simulations.objects module#

SimulationConfig#

class squadds.simulations.objects.SimulationConfig(design_name='CavitySweep', renderer_type='hfss', sim_type='eigenmode', setup_name='Setup', max_passes=49, max_delta_f=0.05, min_converged_passes=2, Lj=0, Cj=0)[source]#

Bases: object

Represents the configuration for a simulation.

Parameters:
  • design_name (str) – The name of the design.

  • renderer_type (str) – The type of renderer.

  • sim_type (str) – The type of simulation.

  • setup_name (str) – The name of the setup.

  • max_passes (int) – The maximum number of passes.

  • max_delta_f (float) – The maximum delta frequency.

  • min_converged_passes (int) – The minimum number of converged passes.

  • Lj (float) – The value of Lj.

  • Cj (float) – The value of Cj.

Initialize the Simulation object.

Parameters:
  • design_name (str) – The name of the design.

  • renderer_type (str) – The type of renderer to be used.

  • sim_type (str) – The type of simulation.

  • setup_name (str) – The name of the setup.

  • max_passes (int) – The maximum number of passes.

  • max_delta_f (float) – The maximum change in frequency.

  • min_converged_passes (int) – The minimum number of converged passes.

  • Lj (float) – The value of inductance.

  • Cj (float) – The value of capacitance.

squadds.simulations.objects.get_sim_results(emode_df={}, lom_df={}, ncap_lom_df={})[source]#

Retrieves simulation results from the provided dataframes and calculates additional parameters.

Parameters:
  • emode_df (dict) – Dataframe containing eigenmode simulation results.

  • lom_df (dict) – Dataframe containing lumped element model simulation results.

  • ncap_lom_df (dict) – Dataframe containing lumped element model simulation results for NCap coupler.

Returns:

A dictionary containing the calculated simulation results.

Return type:

dict

squadds.simulations.objects.render_simulation_no_ports(epra, components, open_pins, ansys_design_name, setup_vars)[source]#

Renders the simulation into HFSS.

Parameters:
  • epra – The EPR analysis object.

  • ansys_design_name – The name of the Ansys design.

  • setup_vars – The setup variables for the rendering.

  • components – List of QComponent object.

squadds.simulations.objects.render_simulation_with_ports(epra, ansys_design_name, setup_vars, coupler)[source]#

Renders the simulation into HFSS.

Parameters:
  • epra – The EPR analysis object.

  • ansys_design_name – The name of the Ansys design.

  • setup_vars – The setup variables for the rendering.

  • coupler – The coupler object.

squadds.simulations.objects.run_capn_LOM(design, param, sim_options)[source]#

Run capacitance analysis using Qiskit Metal and Ansys HFSS.

Parameters:
  • design (metal.designs.design_planar.DesignPlanar) – The design object.

  • param (dict) – Design options for the coupler.

  • sim_options (dict) – Simulation options.

Returns:

A tuple containing the following:
  • data_df (dict): Dictionary containing design, simulation options, simulation results, and miscellaneous data.

  • loma (LOManalysis): The LOManalysis object.

Return type:

tuple

squadds.simulations.objects.run_eigenmode(design, geometry_dict, sim_options, **kwargs)[source]#

Runs the eigenmode simulation for a given design using Ansys HFSS.

Parameters:
  • design (str) – The name of the design.

  • geometry_dict (dict) – A dictionary containing the geometry options for the simulation.

  • sim_options (dict) – A dictionary containing the simulation options.

Returns:

A tuple containing the simulation results and the EPRAnalysis object.

The simulation results are stored in a dictionary with the following structure: {

”design”: {

“coupler_type”: “CLT”, “design_options”: geometry_dict, “design_tool”: “Qiskit Metal”

}, “sim_options”: {

”sim_type”: “epr”, “setup”: setup, “simulator”: “Ansys HFSS”

}, “sim_results”: {

”cavity_frequency”: f_rough, “Q”: Q, “kappa”: kappa

}, “misc”: data

} The EPRAnalysis object is returned for further analysis or post-processing.

Return type:

tuple

squadds.simulations.objects.run_qubit_cavity_sweep(design, device_options, emode_setup=None, lom_setup=None, filename='default_sweep')[source]#

Runs a parameter sweep for the specified design.

Parameters:
  • design (Design) – The design object.

  • sweep_opts (dict) – The sweep options.

  • device_dict (dict) – The device dictionary containing the design options and setup.

  • emode_setup (dict) – The eigenmode setup options.

  • lom_setup (dict) – The LOM setup options.

  • filename (str) – The filename for the simulation results.

  • Returns

squadds.simulations.objects.run_sweep(design, sweep_opts, emode_options, lom_options, filename='default_sweep')[source]#

Runs a parameter sweep for the specified design.

Parameters:
  • design (Design) – The design object.

  • sweep_opts (dict) – The sweep options.

  • emode_options (dict) – The eigenmode setup options.

  • lom_options (dict) – The LOM setup options.

  • filename (str) – The filename for the simulation results.

Returns:

None Saves each sweep iteration to a JSON file with the specified filename.

squadds.simulations.objects.run_xmon_LOM(design, cross_dict, sim_options)[source]#

Runs the XMON LOM simulation.

Parameters:
  • design (metal.designs.design_planar.DesignPlanar) – The design object.

  • cross_dict (dict) – The dictionary containing cross connection information.

  • sim_options (dict) – The simulation options.

Returns:

A tuple containing the simulation data and the LOManalysis object.

Return type:

tuple

squadds.simulations.objects.set_simulation_hyperparameters(epra, config)[source]#

Sets the simulation hyperparameters based on the provided configuration.

Parameters:
  • epra – The EPR analysis object.

  • config – The configuration settings for the simulation.

Returns:

The setup object with the updated settings.

squadds.simulations.objects.simulate_single_design(design, device_dict, emode_options={}, lom_options={}, coupler_type='CLT')[source]#

Simulates a single design using the provided parameters.

Parameters:
  • design (Design) – The design object representing the design.

  • device_dict (dict) – A dictionary containing device options.

  • emode_options (dict) – A dictionary containing the eigenmode simulation options.

  • lom_options (dict) – A dictionary containing the LOM simulation options.

  • coupler_type (str) – The type of coupler to be used.

  • sim_options (dict) – A dictionary containing simulation options.

Returns:

The simulation results. If eigenmode simulation is performed, returns a dictionary containing the eigenmode results. If LOM simulation is performed, returns a tuple containing the LOM dataframe and LOM object.

Return type:

dict or tuple

squadds.simulations.objects.simulate_whole_device(design, device_dict, eigenmode_options, LOM_options, open_gui=False)[source]#

Simulates the whole device by running eigenmode and LOM simulations.

Parameters:
  • design (metal.designs.design_planar.DesignPlanar) – The design object.

  • cross_dict (dict) – Dictionary containing qubit options.

  • cavity_dict (dict) – Dictionary containing cavity options.

  • LOM_options (dict) – Dictionary containing LOM setup options.

  • eigenmode_options (dict) – Dictionary containing eigenmode setup options.

  • open_gui (bool, optional) – If True, the Metal GUI is opened. Default is False.

Returns:

A tuple containing the simulation results, LOM analysis object, and eigenmode analysis object.

Return type:

tuple

squadds.simulations.objects.start_simulation(design, config)[source]#

Starts the simulation with the specified design and configuration.

Parameters:
  • design – The design to be simulated.

  • config – The configuration settings for the simulation.

Returns:

A tuple containing the EPR analysis object and the HFSS object.

squadds.simulations.simulator module#

class squadds.simulations.simulator.Simulator[source]#

Bases: ABC

abstract get_design_screenshot()[source]#

squadds.simulations.sweeper_helperfunctions module#

squadds.simulations.sweeper_helperfunctions.as_list(x)[source]#

Converts the input to a list if it is not already a list.

Parameters:

x – The input value.

Returns:

A list containing the input value if it is not already a list.

squadds.simulations.sweeper_helperfunctions.create_dict_list(keys, values)[source]#

‘ Takes in a list of strings (keys) and a list of values, and returns a list of nested dictionaries where . in the string references the level of nesting.

Input: * keys (list of strings) - A list of strings representing

the keys for the dictionaries.

  • values (list) - A list of values to be used as the

    values for the dictionaries

Output: * dict_list (list of nested dictionaries) - A list of

nested dictionaries where each dictionary has the keys as its keys and the values as its values.

squadds.simulations.sweeper_helperfunctions.extract_QSweep_parameters(parameters)[source]#

Input: * parameters (dict) - nested dictionary with a list

at the end of the nest

Output: * list_of_combos (list of dicts) - same nested structure

as your input. But you’ll have each combination.

Return type:

list[dict]

squadds.simulations.sweeper_helperfunctions.extract_parameters(dictionary, keys=None, prefix='')[source]#

Extract keys in nested dict, then separates these keys by a . For our purposes, gets the parameters of interest

Input: * dictionary (dict)

Output: * keys (list of string)

Example: my_dict = {‘transmon1’: {‘cross_width’: ‘30um’,

‘connection_pads’: {‘readout’: {‘pad_width’: ‘200um’}}}}

print(extract_keys(my_dict)) # prints: [‘transmon1.cross_width’, ‘transmon1.connection_pads.readout.pad_width’]

squadds.simulations.sweeper_helperfunctions.extract_values(dictionary, values=None)[source]#

Extract values in nested dict For our purposes, gets the initial guesses associated w/ self.parameters

Input: * dictionary (dict)

Output: * values (list of string)

Example: my_dict = {‘transmon1’: {‘cross_width’: ‘30um’,

‘connection_pads’: {‘readout’: {‘pad_width’: ‘200um’}}}}

print(extract_values(my_dict)) # prints: [‘30um’, ‘200um’]

squadds.simulations.sweeper_helperfunctions.generate_combinations(lists)[source]#

This function takes in a list of lists and returns a list of tuples that contain all possible combinations of the elements in the input lists.

Input: * lists (list) - A list of lists containing elements

that we want to generate combinations for.

Output: * combination (list of tuples) - A list of tuples

containing all possible combinations of the elements in the input lists.

squadds.simulations.utils module#

This file contains utility functions for the simulation.#

squadds.simulations.utils.add_ground_strip_and_mesh(modeler, coupler, mesh_lengths)[source]#

Draw the rectangle in the Ansys modeler, update the model, and set the mesh based on the input dictionary.

Parameters:
  • modeler – The modeler object.

  • center – The center coordinates tuple.

  • dimensions – The dimensions tuple.

  • coupler – The coupler object.

  • cpw – The cpw object.

  • claw – The claw object.

  • mesh_lengths – Dictionary containing mesh names, associated objects, and MaxLength values.

squadds.simulations.utils.calculate_center_and_dimensions(bbox)[source]#

Calculate the center and dimensions from the bounding box.

Parameters:

bbox – The bounding box dictionary with keys ‘min_x’, ‘max_x’, ‘min_y’, ‘max_y’.

Returns:

A tuple containing the center coordinates and dimensions.

squadds.simulations.utils.chunk_sweep_options(sweep_opts, N)[source]#

Divide the sweep options into multiple chunks based on the number of computers.

Parameters:
  • sweep_opts (dict) – The sweep options dictionary.

  • N (int) – The number of computers to divide the sweep options into.

Returns:

A list of dictionaries, each containing a chunk of the sweep options.

Return type:

list

squadds.simulations.utils.convert_str_to_float(value)[source]#

COnvert value from str to float

Parameters:

value – The value to convert

Returns:

The value as a float

squadds.simulations.utils.create_claw(opts, cpw_length, design)[source]#

Create a TransmonClaw object with the given options, cpw_length, and design.

Parameters:
  • opts (dict) – A dictionary of options for the TransmonClaw object.

  • cpw_length (int) – The length of the cpw.

  • design (str) – The design name.

Returns:

The created TransmonClaw object.

Return type:

TransmonClaw

squadds.simulations.utils.create_clt_coupler(opts, design)[source]#

Create a CoupledLineTee coupler based on the given options and design.

Parameters:
  • opts (dict) – A dictionary containing the options for the coupler.

  • design – The design object.

Returns:

The created coupler object.

squadds.simulations.utils.create_cpw(opts, cplr, design)[source]#

Create a coplanar waveguide (CPW) based on the given options, coupler, and design.

Parameters:
  • opts (dict) – Options for creating the CPW.

  • cplr (Coupler) – Coupler object used for creating the CPW.

  • design (Design) – Design object used for creating the CPW.

Returns:

The created coplanar waveguide (CPW).

Return type:

RouteMeander

squadds.simulations.utils.create_ncap_coupler(opts, design)[source]#

Create a coupler based on the given options and design.

Parameters:
  • opts (dict) – A dictionary containing the options for the coupler.

  • design – The design object.

Returns:

The created coupler object.

squadds.simulations.utils.create_qubitcavity(opts, design)[source]#

Create a QubitCavity object.

Parameters:
  • opts (dict) – Options for the QubitCavity object.

  • design (str) – Design name.

Returns:

The created QubitCavity object.

Return type:

QubitCavity

squadds.simulations.utils.delete_old_setups(aedt)[source]#

Delete old setups

Parameters:

aedt (pyAEDT Desktop obj)

squadds.simulations.utils.extract_number(string)[source]#

Remove non-digit characters from a string, except for decimal.

Parameters:

string (str) – The input string.

Returns:

The string with non-digit characters removed, except for decimal.

Return type:

str

squadds.simulations.utils.extract_value(dictionary, key)[source]#

Extracts the value of a specified key from a given nested dictionary.

Parameters:
  • dictionary (dict) – The nested dictionary.

  • key (str) – The key to extract the value for.

Returns:

The value of the specified key, or None if the key is not found.

Return type:

Any

squadds.simulations.utils.find_a_fq(C_g, C_B, Lj)[source]#

Calculate the anharmonicity and frequency of a transmon qubit.

Parameters:
  • C_g (float) – Gate capacitance in Farads.

  • C_B (float) – Bias capacitance in Farads.

  • Lj (float) – Josephson inductance in Henries.

Returns:

A tuple containing the anharmonicity (a) in linear MHz and the frequency (f_q) in linear GHz.

Return type:

tuple

squadds.simulations.utils.find_chi(alpha, f_q, g, f_r)[source]#

Calculate the full cavity frequency shift between |0> and |1> states of a qubit using g, f_r, f_q, and alpha. It uses the result derived using 2nd-order pertubation theory (equation 9 in SquaDDs paper).

Parameters:
  • alpha (-) – Anharmonicity of the transmon qubit.

  • f_q (-) – Resonant frequency of the transmon qubit in linear units.

  • g (-) – The coupling strength between the qubit and the cavity.

  • f_r (-) – The resonant frequency of the cavity in linear units.

Returns:

The full dispersive shift of the cavity

Return type:

  • (float)

squadds.simulations.utils.find_g_a_fq(C_g, C_B, f_r, Lj, N)[source]#

Calculate the values of g, a, and f_q for a transmon qubit.

Parameters:
  • C_g (float) – Capacitance of the gate in Farads.

  • C_B (float) – Capacitance of the bias in Farads.

  • f_r (float) – Resonance frequency of the resonator in Hz.

  • Lj (float) – Josephson inductance in Henries.

  • N (int) – Number of photons in the resonator.

Returns:

A tuple containing the values of g, a, and f_q.
  • g (float): Coupling strength in MHz.

  • a (float): Anharmonicity in MHz.

  • f_q (float): Transition frequency in GHz.

Return type:

tuple

squadds.simulations.utils.find_kappa(f_rough, C_tg, C_tb)[source]#

Calculate the cavity linewidth (kappa) using the rough frequency and capacitances.

Parameters:
  • f_rough (float) – The rough frequency of the cavity in GHz.

  • C_tg (float) – The total capacitance of the ground in Farads.

  • C_tb (float) – The total capacitance of the bias in Farads.

Returns:

The cavity linewidth (kappa) in kHz.

Return type:

float

squadds.simulations.utils.flatten_dict(dictionary_, delimiter=',')[source]#

A function to flatten a nested dictionary :param dictionary_: The dictionary to be flattened :return: dict

squadds.simulations.utils.generate_bbox(component)[source]#

Generates a bounding box dictionary from a given QComponent.

Parameters: component (QComponent): The component for which to generate a bounding box.

Returns: Dict[str, float]: A dictionary representing the bounding box with keys ‘min_x’, ‘max_x’, ‘min_y’, ‘max_y’.

Return type:

qiskit_metal.Dict.(<class ‘str’>, <class ‘float’>)

squadds.simulations.utils.getMeshScreenshot(projectname, designname, solutiontype='Eigenmode')[source]#

Get a screenshot of the mesh for a given project, design, and solution type.

Parameters:
  • projectname (str) – The name of the project.

  • designname (str) – The name of the design.

  • solutiontype (str, optional) – The type of solution. Defaults to “Eigenmode”.

Raises:

NotImplementedError – This function is not implemented yet.

squadds.simulations.utils.get_cavity_claw_options_keys(cavity_dict)[source]#
squadds.simulations.utils.get_freq(epra, test_hfss)[source]#

Analyze the simulation, plot the results, and report the frequencies, Q, and kappa.

Parameters:
  • epra – The EPR analysis object.

  • test_hfss – The HFSS object.

squadds.simulations.utils.get_freq_Q_kappa(epra, test_hfss)[source]#

Analyze the simulation, plot the results, and report the frequencies, Q, and kappa.

Parameters:
  • epra – The EPR analysis object.

  • test_hfss – The HFSS object.

squadds.simulations.utils.make_table(title, data)[source]#

Create a table from a dictionary with a specified title.

Parameters:
  • title (str) – The title of the table.

  • data (dict) – The dictionary containing the data for the table.

Returns:

The formatted table as a string.

Return type:

str

squadds.simulations.utils.mesh_objects(modeler, mesh_lengths)[source]#

Draw the rectangle in the Ansys modeler, update the model, and set the mesh based on the input dictionary.

Parameters:
  • modeler – The modeler object.

  • center – The center coordinates tuple.

  • dimensions – The dimensions tuple.

  • cpw – The cpw object.

  • claw – The claw object.

  • mesh_lengths – Dictionary containing mesh names, associated objects, and MaxLength values.

squadds.simulations.utils.read_json_files(directory)[source]#

Read all JSON files from a specified directory.

Parameters:

directory (str) – The directory path.

Returns:

A list of dictionaries, each containing the data from a JSON file.

Return type:

list

squadds.simulations.utils.save_simulation_data_to_json(data, filename)[source]#

Save simulation data to a JSON file.

Parameters:
  • data (dict) – The simulation data to be saved.

  • filename (str) – The name of the file to save the data to.

Returns:

None

squadds.simulations.utils.setMaterialProperties(projectname, designname, solutiontype='Eigenmode')[source]#

Interfaces with ANSYS via pyEPR for more custom automation. 1. Connects to ANSYS. 2. Changes Silicon permittivity to 11.45, representing ultra cold silicon. 3. Deletes any preexisting setups.

Parameters:
  • projectname (str) – The name of the project.

  • designname (str) – The name of the design.

  • solutiontype (str, optional) – The type of solution. Defaults to “Eigenmode”.

squadds.simulations.utils.string_to_float(string)[source]#

Converts a string representation of a number to a float.

Parameters:

string (str) – The string representation of the number.

Returns:

The converted float value.

Return type:

float

squadds.simulations.utils.ultra_cold_silicon(aedt)[source]#

Change silicon properties to ultra cold silicon

Parameters:

aedt (pyAEDT Desktop obj)

squadds.simulations.utils.unpack(parent_key, parent_value, delimiter=',')[source]#

A function to unpack one level of nesting in a python dictionary :param parent_key: The key in the parent dictionary being flattened :param parent_value: The value of the parent key, value pair :return: list(tuple(,))

Module contents#