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.

device_dict#

The device dictionary containing design and setup 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 (dict) – The device dictionary (renamed to device_dict internally).

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_simulation_setup(target='all')[source]#

Displays the current simulation setup parameters.

Parameters:

target (str) – Which setup to display. Options: “all”, “qubit”, “cavity”, “coupler”, “generic”.

Returns:

Dictionary containing the requested setup(s).

Return type:

dict

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=None, run_async=False)[source]#

Simulates the device based on the provided device dictionary.

Parameters:
  • device_dict (dict, optional) – A dictionary containing the device design options and setup. If None, uses the internally stored device_dict.

  • run_async (bool) – If True, runs the simulation asynchronously.

Returns:

The simulation results or a Future object.

Return type:

pandas.DataFrame or concurrent.futures.Future

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

Sweeps the device based on the provided sweep dictionary.

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

update_design_parameters(**kwargs)[source]#

Updates the geometry design parameters in the stored device dictionary. Smartly searches for the keys in ‘design_options’, ‘design_options_qubit’, etc.

Parameters:

**kwargs – Key-value pairs of design parameters to update (e.g., cross_length=”300um”).

update_simulation_setup(target='all', **kwargs)[source]#

Updates the simulation setup parameters in the stored device dictionary. Intelligently maps targets to setup keys based on system type.

Parameters:
  • target (str) – Which setup to update. Options: “all”, “qubit”, “cavity”, “coupler”, “generic”.

  • **kwargs – Key-value pairs of parameters to update (e.g., max_passes=10).

wait_for_all()[source]#

Waits for all submitted async simulations to complete.

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=None, lom_df=None, ncap_lom_df=None)[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, generate_plots=False, **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.

  • generate_plots (bool) – If True, generate convergence and field plots. Default is False.

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=None, lom_options=None, coupler_type='CLT', generate_plots=False)[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.

  • generate_plots (bool) – If True, generate convergence and field plots. Default is False.

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, generate_plots=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.

  • generate_plots (bool, optional) – If True, generate convergence and field plots. 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.result_normalization module#

Pure helpers for shaping simulation outputs into SQuADDS records.

squadds.simulations.result_normalization.build_eigenmode_payload(coupler_type, geometry_dict, setup, renderer_options, f_rough, Q, kappa, data)[source]#

Build the legacy eigenmode result payload.

squadds.simulations.result_normalization.build_ncap_lom_payload(param, setup, cap_df, data, coupler_name)[source]#

Build the legacy NCap lumped-element payload.

squadds.simulations.result_normalization.build_xmon_lom_payload(design_options, setup, renderer_options, cap_df, qname, cname)[source]#

Build the legacy Xmon lumped-element payload.

squadds.simulations.result_normalization.normalize_simulation_results(emode_df=None, lom_df=None, ncap_lom_df=None, *, find_g_a_fq_fn, find_kappa_fn)[source]#

Normalize raw eigenmode/LOM results into the legacy combined Hamiltonian payload.

squadds.simulations.simulator module#

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

Bases: ABC

abstractmethod get_design_screenshot()[source]#

squadds.simulations.sweeper_helperfunctions module#

Helpers for expanding nested sweep dictionaries into concrete combinations.

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

Rebuild nested dictionaries for every key/value combination.

Return type:

list[dict[str, Any]]

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

Return every concrete parameter combination from a nested sweep dictionary.

The public API is intentionally unchanged. Nested dictionaries are flattened into dotted paths, leaf values are converted into lists when needed, and the cartesian product of all leaf lists is reconstructed back into nested dictionaries.

Return type:

list[dict[str, Any]]

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

Flatten nested keys into dotted paths in traversal order.

Return type:

list[str]

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

Collect nested leaf values in traversal order, coercing scalars to lists.

Return type:

list[list[Any]]

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

Return the cartesian product for a list of leaf-value lists.

Return type:

list[tuple[Any, …]]

squadds.simulations.utils module#

squadds.simulations.utils.add_ground_strip_and_mesh(modeler, coupler, mesh_lengths)[source]#
squadds.simulations.utils.calculate_center_and_dimensions(bbox)[source]#
squadds.simulations.utils.chunk_sweep_options(sweep_opts, N)[source]#
squadds.simulations.utils.convert_str_to_float(value)[source]#
squadds.simulations.utils.create_claw(opts, cpw_length, design)[source]#
squadds.simulations.utils.create_clt_coupler(opts, design)[source]#
squadds.simulations.utils.create_cpw(opts, cplr, design)[source]#
squadds.simulations.utils.create_ncap_coupler(opts, design)[source]#
squadds.simulations.utils.create_qubitcavity(opts, design)[source]#
squadds.simulations.utils.delete_old_setups(aedt)[source]#
squadds.simulations.utils.extract_number(string)[source]#
squadds.simulations.utils.extract_value(dictionary, key)[source]#
squadds.simulations.utils.find_a_fq(C_g, C_B, Lj)[source]#
squadds.simulations.utils.find_chi(alpha, f_q, g, f_r)[source]#
squadds.simulations.utils.find_g_a_fq(C_g, C_B, f_r, Lj, N)[source]#
squadds.simulations.utils.find_kappa(f_rough, C_tg, C_tb)[source]#
squadds.simulations.utils.flatten_dict(dictionary_, delimiter=',')[source]#
squadds.simulations.utils.generate_bbox(component)[source]#
Return type:

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

squadds.simulations.utils.getMeshScreenshot(projectname, designname, solutiontype='Eigenmode')[source]#
squadds.simulations.utils.get_cavity_claw_options_keys(cavity_dict)[source]#
squadds.simulations.utils.get_freq(epra, test_hfss, generate_plots=False)[source]#
squadds.simulations.utils.get_freq_Q_kappa(epra, test_hfss, generate_plots=False)[source]#
squadds.simulations.utils.make_table(title, data)[source]#
squadds.simulations.utils.mesh_objects(modeler, mesh_lengths)[source]#
squadds.simulations.utils.read_json_files(directory)[source]#
squadds.simulations.utils.save_simulation_data_to_json(data, filename)[source]#
squadds.simulations.utils.setMaterialProperties(projectname, designname, solutiontype='Eigenmode')[source]#
squadds.simulations.utils.string_to_float(string)[source]#
squadds.simulations.utils.ultra_cold_silicon(aedt)[source]#
squadds.simulations.utils.unpack(parent_key, parent_value, delimiter=',')[source]#

squadds.simulations.utils_ansys module#

squadds.simulations.utils_ansys.add_ground_strip_and_mesh(modeler, coupler, mesh_lengths)[source]#
squadds.simulations.utils_ansys.delete_old_setups(aedt)[source]#
squadds.simulations.utils_ansys.getMeshScreenshot(projectname, designname, solutiontype='Eigenmode')[source]#
squadds.simulations.utils_ansys.get_freq(epra, test_hfss, generate_plots=False)[source]#
squadds.simulations.utils_ansys.get_freq_Q_kappa(epra, test_hfss, generate_plots=False)[source]#
squadds.simulations.utils_ansys.mesh_objects(modeler, mesh_lengths)[source]#
squadds.simulations.utils_ansys.setMaterialProperties(projectname, designname, solutiontype='Eigenmode')[source]#
squadds.simulations.utils_ansys.ultra_cold_silicon(aedt)[source]#

squadds.simulations.utils_component_factory module#

squadds.simulations.utils_component_factory.create_claw(opts, cpw_length, design)[source]#
squadds.simulations.utils_component_factory.create_clt_coupler(opts, design)[source]#
squadds.simulations.utils_component_factory.create_cpw(opts, cplr, design)[source]#
squadds.simulations.utils_component_factory.create_ncap_coupler(opts, design)[source]#
squadds.simulations.utils_component_factory.create_qubitcavity(opts, design)[source]#

squadds.simulations.utils_display module#

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

squadds.simulations.utils_geometry module#

squadds.simulations.utils_geometry.calculate_center_and_dimensions(bbox)[source]#
squadds.simulations.utils_geometry.generate_bbox(component)[source]#
Return type:

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

squadds.simulations.utils_geometry.get_cavity_claw_options_keys(cavity_dict)[source]#

squadds.simulations.utils_io module#

squadds.simulations.utils_io.read_json_files(directory)[source]#
squadds.simulations.utils_io.save_simulation_data_to_json(data, filename)[source]#

squadds.simulations.utils_parsing module#

squadds.simulations.utils_parsing.convert_str_to_float(value)[source]#
squadds.simulations.utils_parsing.extract_number(string)[source]#
squadds.simulations.utils_parsing.extract_value(dictionary, key)[source]#
squadds.simulations.utils_parsing.flatten_dict(dictionary_, delimiter=',')[source]#
squadds.simulations.utils_parsing.string_to_float(string)[source]#
squadds.simulations.utils_parsing.unpack(parent_key, parent_value, delimiter=',')[source]#

squadds.simulations.utils_physics module#

squadds.simulations.utils_physics.find_a_fq(C_g, C_B, Lj)[source]#
squadds.simulations.utils_physics.find_chi(alpha, f_q, g, f_r)[source]#
squadds.simulations.utils_physics.find_g_a_fq(C_g, C_B, f_r, Lj, N)[source]#
squadds.simulations.utils_physics.find_kappa(f_rough, C_tg, C_tb)[source]#

squadds.simulations.utils_sweep module#

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

Module contents#