Circuit#

class scqubits.core.circuit.Circuit(input_string, from_file=True, basis_completion='heuristic', ext_basis='discretized', initiate_sym_calc=True, truncated_dim=None, evals_method=None, evals_method_options=None, esys_method=None, esys_method_options=None)[source]#

Class for analysis of custom superconducting circuits.

Parameters:
  • input_string (str) – String describing the number of nodes and branches connecting then along with their parameters

  • from_file (bool) – Set to True by default, when a file name should be provided to input_string, else the circuit graph description in YAML should be provided as a string.

  • basis_completion (str) – either “heuristic” or “canonical”, defines the matrix used for completing the transformation matrix. Sometimes used to change the variable transformation to result in a simpler symbolic Hamiltonian, by default “heuristic”

  • ext_basis (str) – can be “discretized” or “harmonic” which chooses whether to use discretized phi or harmonic oscillator basis for extended variables, by default “discretized”

  • initiate_sym_calc (bool) – attribute to initiate Circuit instance, by default True

  • truncated_dim (Optional[int]) – truncated dimension if the user wants to use this circuit instance in HilbertSpace, by default None

Return type:

QuantumSystemType

Methods

Circuit.E01()

Returns the qubit's fundamental energy splitting, E_1 - E_0.

Circuit.__init__(input_string[, from_file, ...])

Circuit.anharmonicity()

Returns the qubit's anharmonicity, (E_2 - E_1) - (E_1 - E_0).

Circuit.broadcast(event, **kwargs)

Request a broadcast from CENTRAL_DISPATCH reporting event.

Circuit.build_hilbertspace([...])

Builds the HilbertSpace object for the Circuit instance if hierarchical_diagonalization is set to true.

Circuit.circuit_operator_functions()

Returns the set of operator functions to be turned into methods of the Circuit class.

Circuit.clear_unnecessary_attribs()

Clear all the attributes which are not part of the circuit description

Circuit.configure([transformation_matrix, ...])

Method which re-initializes a circuit instance to update, hierarchical diagonalization parameters or closure branches or the variable transformation used to describe the circuit.

Circuit.create()

Use ipywidgets to create a new class instance

Circuit.create_from_file(filename)

Read initdata and spectral data from file, and use those to create a new SpectrumData object.

Circuit.cutoffs_dict()

Returns a dictionary, where each variable is associated with its respective cutoff.

Circuit.default_params()

Return dictionary with default parameter values for initialization of class instance

Circuit.deserialize(iodata)

Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.

Circuit.dict_for_serialization()

Circuit.eigensys([evals_count, filename, ...])

Calculates eigenvalues and corresponding eigenvectors using scipy.linalg.eigh.

Circuit.eigenvals([evals_count, filename, ...])

Calculates eigenvalues using scipy.linalg.eigh, returns numpy array of eigenvalues.

Circuit.exp_i_pos_operator(var_sym, prefactor)

Returns the bare operator exp(i* heta*prefactor), without the kron product.

Circuit.external_flux_values()

Returns all the time independent external flux set using the circuit attributes for each of the closure branches.

Circuit.filewrite(filename)

Convenience method bound to the class.

Circuit.from_yaml(input_string[, from_file, ...])

Wrapper to Circuit __init__ to create a class instance.

Circuit.generate_hamiltonian_sym_for_numerics()

Generates a symbolic expression which is ready for numerical evaluation starting from the expression stored in the attribute hamiltonian_symbolic.

Circuit.generate_subsystems()

Generates the subsystems (child instances of Circuit) depending on the attribute self.system_hierarchy

Circuit.generate_wf_plot_data([which, ...])

Returns the plot of the probability density of the wave function in the requested variables for the current Circuit instance.

Circuit.get_cutoffs()

Method to get the cutoffs for each of the circuit's degree of freedom.

Circuit.get_dispersion_vs_paramvals(...[, ...])

Calculates eigenvalues/eigenstates for a varying system parameter, given an array of parameter values.

Circuit.get_eigenstates()

Returns the eigenstates for the SubSystem instance

Circuit.get_initdata()

Returns dict appropriate for creating/initializing a new Serializable object.

Circuit.get_matelements_vs_paramvals(...[, ...])

Calculates matrix elements for a varying system parameter, given an array of parameter values.

Circuit.get_operator_by_name(operator_name)

Returns the operator for the given operator symbol which has the same dimension as the hilbertdim of the instance from which the operator is requested.

Circuit.get_operator_names()

Returns a list of all operator names for the quantum system.

Circuit.get_osc_param(var_index[, which_param])

Returns the oscillator parameters based on the oscillator used to diagonalize the Hamiltonian in the harmonic oscillator basis.

Circuit.get_params()

Method to get the circuit parameters set for all the branches.

Circuit.get_spectrum_vs_paramvals(...[, ...])

Calculates eigenvalues/eigenstates for a varying system parameter, given an array of parameter values.

Circuit.get_subsystem_index(var_index)

Returns the subsystem index for the subsystem to which the given var_index belongs.

Circuit.grids_dict_for_discretized_extended_vars()

Circuit.hamiltonian()

Returns the Hamiltonian of the Circuit.

Circuit.hilbertdim()

Returns the Hilbert dimension of the Circuit instance

Circuit.identity_wrap_for_hd(operator, var_index)

Returns an identity wrapped operator whose size is equal to the self.hilbertdim().

Circuit.matrixelement_table(operator[, ...])

Returns table of matrix elements for operator with respect to the eigenstates of the qubit.

Circuit.offset_charge_transformation()

Prints the variable transformation between offset charges of periodic variables and the offset node charges

Circuit.offset_charge_values()

Returns all the offset charges set using the circuit attributes for each of the periodic degree of freedom.

Circuit.operator_names_in_hamiltonian_symbolic()

Returns a list of the names (strings) of all operators occurring in the symbolic Hamiltonian.

Circuit.plot_dispersion_vs_paramvals(...[, ...])

Generates a simple plot of a set of curves representing the charge or flux dispersion of transition energies.

Circuit.plot_evals_vs_paramvals(param_name, ...)

Generates a simple plot of a set of eigenvalues as a function of one parameter.

Circuit.plot_matelem_vs_paramvals(operator, ...)

Generates a simple plot of a set of eigenvalues as a function of one parameter.

Circuit.plot_matrixelements(operator[, ...])

Plots matrix elements for operator, given as a string referring to a class method that returns an operator matrix.

Circuit.plot_potential(**kwargs)

Returns the plot of the potential for the circuit instance.

Circuit.plot_wavefunction([which, ...])

Returns the plot of the probability density of the wave function in the requested variables for the current Circuit instance.

Circuit.potential_energy(**kwargs)

Returns the full potential of the circuit evaluated in a grid of points as chosen by the user or using default variable ranges.

Circuit.print_expr_in_latex(expr)

Print a sympy expression or a list of equalities in LaTeX

Circuit.process_hamiltonian(native_hamiltonian)

Return qubit Hamiltonian in chosen basis: either return unchanged (i.e., in native basis) or transform into eigenenergy basis

Circuit.process_op(native_op[, energy_esys])

Processes the operator native_op: either hand back native_op unchanged, or transform it into the energy eigenbasis.

Circuit.receive(event, sender, **kwargs)

Receive a message from CENTRAL_DISPATCH and initiate action on it.

Circuit.serialize()

Convert the content of the current class instance into IOData format.

Circuit.set_and_return(attr_name, value)

Allows to set an attribute after which self is returned. This is useful for doing something like example::.

Circuit.set_discretized_phi_range(...)

Sets the flux range for discretized phi basis when ext_basis is set to 'discretized'.

Circuit.set_operators()

Creates the operator methods <name>_operator for the circuit.

Circuit.set_params(**kwargs)

Set new parameters through the provided dictionary.

Circuit.set_params_from_gui(change)

Set new parameters through the provided dictionary.

Circuit.supported_noise_channels()

Returns a list of noise channels this QuantumSystem supports.

Circuit.sym_external_fluxes()

Method returns a dictionary of Human readable external fluxes with associated branches and loops (represented as lists of branches) for the current instance

Circuit.sym_hamiltonian([subsystem_index, ...])

Prints a user readable symbolic Hamiltonian for the current instance

Circuit.sym_interaction(subsystem_indices[, ...])

Print the interaction between any set of subsystems for the current instance.

Circuit.sym_lagrangian([vars_type, ...])

Method that gives a user readable symbolic Lagrangian for the current instance

Circuit.sym_potential([float_round, ...])

Method prints a user readable symbolic potential for the current instance

Circuit.variable_transformation()

Prints the variable transformation used in this circuit

Circuit.widget([params])

Use ipywidgets to modify parameters of class instance

Attributes

id_str

truncated_dim

Descriptor class for properties that are to be monitored for changes.

E01()#

Returns the qubit’s fundamental energy splitting, E_1 - E_0.

Return type:

float

anharmonicity()#

Returns the qubit’s anharmonicity, (E_2 - E_1) - (E_1 - E_0).

Return type:

float

broadcast(event, **kwargs)#

Request a broadcast from CENTRAL_DISPATCH reporting event.

Parameters:
  • event (str) – event name from EVENTS

  • **kwargs

Return type:

None

build_hilbertspace(update_subsystem_indices=None)#

Builds the HilbertSpace object for the Circuit instance if hierarchical_diagonalization is set to true.

Parameters:

update_subsystem_indices (Optional[List[int]]) – List of subsystem indices which need to be updated. If set to None, all the are updated.

Return type:

None

circuit_operator_functions()#

Returns the set of operator functions to be turned into methods of the Circuit class.

Return type:

Dict[str, Callable]

clear_unnecessary_attribs()[source]#

Clear all the attributes which are not part of the circuit description

configure(transformation_matrix=None, system_hierarchy=None, subsystem_trunc_dims=None, closure_branches=None)[source]#

Method which re-initializes a circuit instance to update, hierarchical diagonalization parameters or closure branches or the variable transformation used to describe the circuit.

Parameters:
  • transformation_matrix (Optional[ndarray]) – A user defined variable transformation which has the dimensions of the number nodes (not counting the ground node), by default None

  • system_hierarchy (Optional[list]) – A list of lists which is provided by the user to define subsystems, by default None

  • subsystem_trunc_dims (Optional[list]) – dict object which can be generated for a specific system_hierarchy using the method truncation_template, by default None

  • closure_branches (Optional[List[Branch]]) – List of branches where external flux variables will be specified, by default None which then chooses closure branches by an internally generated spanning tree.

Raises:

Exception – when system_hierarchy is set and subsystem_trunc_dims is not set.

classmethod create()#

Use ipywidgets to create a new class instance

Return type:

QuantumSystem

classmethod create_from_file(filename)#

Read initdata and spectral data from file, and use those to create a new SpectrumData object.

Returns:

new SpectrumData object, initialized with data read from file

Return type:

SpectrumData

Parameters:

filename (str) –

cutoffs_dict()#

Returns a dictionary, where each variable is associated with its respective cutoff.

Return type:

Dict[int, int]

Returns:

Cutoffs dictionary; {var_index: cutoff}

static default_params()[source]#

Return dictionary with default parameter values for initialization of class instance

Return type:

Dict[str, Any]

classmethod deserialize(iodata)[source]#

Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.

Parameters:

iodata (IOData) –

Return type:

Circuit

Returns:

Circuit instance

eigensys(evals_count=6, filename=None, return_spectrumdata=False)#

Calculates eigenvalues and corresponding eigenvectors using scipy.linalg.eigh. Returns two numpy arrays containing the eigenvalues and eigenvectors, respectively.

Parameters:
  • evals_count (int) – number of desired eigenvalues/eigenstates (default value = 6)

  • filename (Optional[str]) – path and filename without suffix, if file output desired (default value = None)

  • return_spectrumdata (if set to true, the returned data is provided as a SpectrumData object) – (default value = False)

Return type:

Union[Tuple[ndarray, ndarray], SpectrumData]

Returns:

eigenvalues, eigenvectors as numpy arrays or in form of a SpectrumData object

eigenvals(evals_count=6, filename=None, return_spectrumdata=False)#

Calculates eigenvalues using scipy.linalg.eigh, returns numpy array of eigenvalues.

Parameters:
  • evals_count (int) – number of desired eigenvalues/eigenstates (default value = 6)

  • filename (Optional[str]) – path and filename without suffix, if file output desired (default value = None)

  • return_spectrumdata (bool) – if set to true, the returned data is provided as a SpectrumData object (default value = False)

Return type:

Union[SpectrumData, ndarray]

Returns:

eigenvalues as ndarray or in form of a SpectrumData object

exp_i_pos_operator(var_sym, prefactor)#

Returns the bare operator exp(i* heta*prefactor), without the kron product. Needs the oscillator lengths to be set in the attribute, osc_lengths, when ext_basis is set to “harmonic”.

Return type:

Union[csc_matrix, ndarray]

Parameters:
  • var_sym (Symbol) –

  • prefactor (float) –

external_flux_values()#

Returns all the time independent external flux set using the circuit attributes for each of the closure branches.

Return type:

List[float]

filewrite(filename)#

Convenience method bound to the class. Simply accesses the write function.

Return type:

None

Parameters:

filename (str) –

classmethod from_yaml(input_string, from_file=True, basis_completion='heuristic', ext_basis='discretized', initiate_sym_calc=True, truncated_dim=None, evals_method=None, evals_method_options=None, esys_method=None, esys_method_options=None)[source]#

Wrapper to Circuit __init__ to create a class instance. This is deprecated and will not be supported in future releases.

Parameters:
  • input_string (str) – String describing the number of nodes and branches connecting then along with their parameters

  • from_file (bool) – Set to True by default, when a file name should be provided to input_string, else the circuit graph description in YAML should be provided as a string.

  • basis_completion – either “heuristic” or “canonical”, defines the matrix used for completing the transformation matrix. Sometimes used to change the variable transformation to result in a simpler symbolic Hamiltonian, by default “heuristic”

  • ext_basis (str) – can be “discretized” or “harmonic” which chooses whether to use discretized phi or harmonic oscillator basis for extended variables, by default “discretized”

  • initiate_sym_calc (bool) – attribute to initiate Circuit instance, by default True

  • truncated_dim (Optional[int]) – truncated dimension if the user wants to use this circuit instance in HilbertSpace, by default None

  • evals_method (Callable | str | None) –

  • evals_method_options (dict | None) –

  • esys_method (Callable | str | None) –

  • esys_method_options (dict | None) –

generate_hamiltonian_sym_for_numerics()#

Generates a symbolic expression which is ready for numerical evaluation starting from the expression stored in the attribute hamiltonian_symbolic. Stores the result in the attribute _hamiltonian_sym_for_numerics.

generate_subsystems()#

Generates the subsystems (child instances of Circuit) depending on the attribute self.system_hierarchy

generate_wf_plot_data(which=0, var_indices=(1,), eigensys=None, change_discrete_charge_to_phi=True, grids_dict=None)#

Returns the plot of the probability density of the wave function in the requested variables for the current Circuit instance.

Parameters:
  • which (int) – integer to choose which wave function to plot

  • var_indices (Tuple[int]) – A tuple containing the indices of the variables chosen to plot the wave function in. Should not have more than 2 entries.

  • eigensys (Optional[ndarray]) – The object returned by the method instance. eigensys is used to avoid the re-evaluation of the eigensystems if already evaluated.

  • change_discrete_charge_to_phi (bool) – boolean to choose if the discrete charge basis for the periodic variable needs to be changed to phi basis.

  • grids_dict (Optional[Dict[int, Grid1d]]) – A dictionary which pairs var indices with the requested grids used to create the plot.

get_cutoffs()#

Method to get the cutoffs for each of the circuit’s degree of freedom.

Return type:

Dict[str, list]

get_dispersion_vs_paramvals(dispersion_name, param_name, param_vals, ref_param=None, transitions=(0, 1), levels=None, point_count=50, num_cpus=None)#

Calculates eigenvalues/eigenstates for a varying system parameter, given an array of parameter values. Returns a SpectrumData object with energy_data[n] containing eigenvalues calculated for parameter value param_vals[n].

Parameters:
  • dispersion_name (str) – parameter inducing the dispersion, typically ‘ng’ or ‘flux’ (will be scanned over range from 0 to 1)

  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • ref_param (Optional[str]) – optional, name of parameter to use as reference for the parameter value; e.g., to compute charge dispersion vs. EJ/EC, use EJ as param_name and EC as ref_param

  • transitions (Union[Tuple[int, int], Tuple[Tuple[int, int], ...]]) – integer tuple or tuples specifying for which transitions dispersion is to be calculated (default: = (0,1))

  • levels (Union[int, Tuple[int, ...], None]) – tuple specifying levels (rather than transitions) for which dispersion should be plotted; overrides transitions parameter when given

  • point_count (int) – number of points scanned for the dispersion parameter for determining min and max values of transition energies (default: 50)

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

Return type:

SpectrumData

get_eigenstates()#

Returns the eigenstates for the SubSystem instance

Return type:

ndarray

get_initdata()#

Returns dict appropriate for creating/initializing a new Serializable object.

Return type:

Dict[str, Any]

get_matelements_vs_paramvals(operator, param_name, param_vals, evals_count=6, num_cpus=None)#

Calculates matrix elements for a varying system parameter, given an array of parameter values. Returns a SpectrumData object containing matrix element data, eigenvalue data, and eigenstate data..

Parameters:
  • operator (str) – name of class method in string form, returning operator matrix

  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • evals_count (int) – number of desired eigenvalues (sorted from smallest to largest) (default value = 6)

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

Return type:

SpectrumData

get_operator_by_name(operator_name)#

Returns the operator for the given operator symbol which has the same dimension as the hilbertdim of the instance from which the operator is requested.

Parameters:

operator_name (str) – Name of a sympy Symbol object which should be one among the symbols in the attribute vars

Return type:

Qobj

Returns:

operator identified by operator_name

classmethod get_operator_names()#

Returns a list of all operator names for the quantum system. Note that this list omits any operators that start with “_”.

Parameters:

subsys – Class instance of quantum system

Return type:

List[str]

Returns:

list of operator names

get_osc_param(var_index, which_param='length')#

Returns the oscillator parameters based on the oscillator used to diagonalize the Hamiltonian in the harmonic oscillator basis.

Parameters:
  • var_index (int) – var index whose oscillator parameter needs to be fetched

  • which_param (str) – “length” or “freq” - decides which parameter is returned, by default “length”

Return type:

float

Returns:

returns the float value which is the oscillator length or the frequency of the oscillator corresponding to var_index depending on the string which_param.

get_params()#

Method to get the circuit parameters set for all the branches.

Return type:

List[float]

get_spectrum_vs_paramvals(param_name, param_vals, evals_count=6, subtract_ground=False, get_eigenstates=False, filename=None, num_cpus=None)#

Calculates eigenvalues/eigenstates for a varying system parameter, given an array of parameter values. Returns a SpectrumData object with energy_data[n] containing eigenvalues calculated for parameter value param_vals[n].

Parameters:
  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • evals_count (int) – number of desired eigenvalues (sorted from smallest to largest) (default value = 6)

  • subtract_ground (bool) – if True, eigenvalues are returned relative to the ground state eigenvalue (default value = False)

  • get_eigenstates (bool) – return eigenstates along with eigenvalues (default value = False)

  • filename (Optional[str]) – file name if direct output to disk is wanted

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

Return type:

SpectrumData

get_subsystem_index(var_index)#

Returns the subsystem index for the subsystem to which the given var_index belongs.

Parameters:

var_index (int) – variable index in integer starting from 1.

Return type:

int

Returns:

subsystem index which can be used to identify the subsystem index in the list self.subsystems.

hamiltonian()#

Returns the Hamiltonian of the Circuit.

Return type:

Union[csc_matrix, ndarray]

hilbertdim()#

Returns the Hilbert dimension of the Circuit instance

identity_wrap_for_hd(operator, var_index)#

Returns an identity wrapped operator whose size is equal to the self.hilbertdim(). Only converts operator which belongs to a specific variable index. For example, operator Q_1 or cos( heta_1). But not, Q1*Q2.

Parameters:
  • operator (Union[csc_matrix, ndarray, None]) – operator in the form of csc_matrix, ndarray

  • var_index (int) – integer which represents which variable index the given operator belongs to

Return type:

Qobj

Returns:

identity wrapped operator.

matrixelement_table(operator, evecs=None, evals_count=6, filename=None, return_datastore=False)#

Returns table of matrix elements for operator with respect to the eigenstates of the qubit. The operator is given as a string matching a class method returning an operator matrix. E.g., for an instance trm of Transmon, the matrix element table for the charge operator is given by trm.op_matrixelement_table(‘n_operator’). When esys is set to None, the eigensystem is calculated on-the-fly.

Parameters:
  • operator (str) – name of class method in string form, returning operator matrix in qubit-internal basis.

  • evecs (Optional[ndarray]) – if not provided, then the necessary eigenstates are calculated on the fly

  • evals_count (int) – number of desired matrix elements, starting with ground state (default value = 6)

  • filename (Optional[str]) – output file name

  • return_datastore (bool) – if set to true, the returned data is provided as a DataStore object (default value = False)

Return type:

Union[DataStore, ndarray]

offset_charge_transformation()[source]#

Prints the variable transformation between offset charges of periodic variables and the offset node charges

Return type:

None

offset_charge_values()#

Returns all the offset charges set using the circuit attributes for each of the periodic degree of freedom.

Return type:

List[float]

operator_names_in_hamiltonian_symbolic()#

Returns a list of the names (strings) of all operators occurring in the symbolic Hamiltonian.

Return type:

List[str]

plot_dispersion_vs_paramvals(dispersion_name, param_name, param_vals, ref_param=None, transitions=(0, 1), levels=None, point_count=50, num_cpus=None, **kwargs)#

Generates a simple plot of a set of curves representing the charge or flux dispersion of transition energies.

Parameters:
  • dispersion_name (str) – parameter inducing the dispersion, typically ‘ng’ or ‘flux’ (will be scanned over range from 0 to 1)

  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • ref_param (Optional[str]) – optional, name of parameter to use as reference for the parameter value; e.g., to compute charge dispersion vs. EJ/EC, use EJ as param_name and EC as ref_param

  • transitions (Union[Tuple[int, int], Tuple[Tuple[int, int], ...]]) – integer tuple or tuples specifying for which transitions dispersion is to be calculated (default: = (0,1))

  • levels (Union[int, Tuple[int, ...], None]) – int or tuple specifying level(s) (rather than transitions) for which dispersion should be plotted; overrides transitions parameter when given

  • point_count (int) – number of points scanned for the dispersion parameter for determining min and max values of transition energies (default: 50)

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

  • **kwargs – standard plotting option (see separate documentation)

Return type:

Tuple[Figure, Axes]

plot_evals_vs_paramvals(param_name, param_vals, evals_count=6, subtract_ground=False, num_cpus=None, **kwargs)#

Generates a simple plot of a set of eigenvalues as a function of one parameter. The individual points correspond to the a provided array of parameter values.

Parameters:
  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • evals_count (int) – number of desired eigenvalues (sorted from smallest to largest) (default value = 6)

  • subtract_ground (bool) – whether to subtract ground state energy from all eigenvalues (default value = False)

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

  • **kwargs – standard plotting option (see separate documentation)

Return type:

Tuple[Figure, Axes]

plot_matelem_vs_paramvals(operator, param_name, param_vals, select_elems=4, mode='abs', num_cpus=None, **kwargs)#

Generates a simple plot of a set of eigenvalues as a function of one parameter. The individual points correspond to the a provided array of parameter values.

Parameters:
  • operator (str) – name of class method in string form, returning operator matrix

  • param_name (str) – name of parameter to be varied

  • param_vals (ndarray) – parameter values to be plugged in

  • select_elems (Union[int, List[Tuple[int, int]]]) – either maximum index of desired matrix elements, or list [(i1, i2), (i3, i4), …] of index tuples for specific desired matrix elements (default value = 4)

  • mode (str) – idx_entry from MODE_FUNC_DICTIONARY, e.g., ‘abs’ for absolute value (default value = ‘abs’)

  • num_cpus (Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)

  • **kwargs – standard plotting option (see separate documentation)

Return type:

Tuple[Figure, Axes]

plot_matrixelements(operator, evecs=None, evals_count=6, mode='abs', show_numbers=False, show3d=True, **kwargs)#

Plots matrix elements for operator, given as a string referring to a class method that returns an operator matrix. E.g., for instance trm of Transmon, the matrix element plot for the charge operator n is obtained by trm.plot_matrixelements(‘n’). When esys is set to None, the eigensystem with which eigenvectors is calculated.

Parameters:
  • operator (str) – name of class method in string form, returning operator matrix

  • evecs (Optional[ndarray]) – eigensystem data of evals, evecs; eigensystem will be calculated if set to None (default value = None)

  • evals_count (int) – number of desired matrix elements, starting with ground state (default value = 6)

  • mode (str) – idx_entry from MODE_FUNC_DICTIONARY, e.g., ‘abs’ for absolute value (default)

  • show_numbers (bool) – determines whether matrix element values are printed on top of the plot (default: False)

  • show3d (bool) – whether to show a 3d skyscraper plot of the matrix alongside the 2d plot (default: True)

  • **kwargs – standard plotting option (see separate documentation)

Return type:

Union[Tuple[Figure, Tuple[Axes, Axes]], Tuple[Figure, Axes]]

plot_potential(**kwargs)#

Returns the plot of the potential for the circuit instance. Make sure to not set more than two variables in the instance.potential to a Numpy array, as the the code cannot plot with more than 3 dimensions.

Parameters:

θ<index> – value(s) for the variable \(\theta_i\) occurring in the potential.

Return type:

Tuple[Figure, Axes]

Returns:

Returns a axes and figure for further editing.

plot_wavefunction(which=0, var_indices=(1,), esys=None, change_discrete_charge_to_phi=True, zero_calibrate=True, grids_dict={}, **kwargs)#

Returns the plot of the probability density of the wave function in the requested variables for the current Circuit instance.

Parameters:
  • which – integer to choose which wave function to plot

  • var_indices (Tuple[int]) – A tuple containing the indices of the variables chosen to plot the wave function in. Should not have more than 2 entries.

  • esys (Optional[Tuple[ndarray, ndarray]]) – The object returned by the method .eigensys, is used to avoid the re-evaluation of the eigen systems if already evaluated.

  • change_discrete_charge_to_phi (bool) – chooses if the discrete charge basis for the periodic variable needs to be changed to phi basis.

  • zero_calibrate (bool, optional) – if True, colors are adjusted to use zero wavefunction amplitude as the neutral color in the palette

  • grids_dict (Dict[int, Grid1d]) – A dictionary which pairs var indices with the requested grids used to create the plot.

  • **kwargs – plotting parameters

Return type:

Tuple[Figure, Axes]

Returns:

Returns a axes and figure for further editing.

potential_energy(**kwargs)#

Returns the full potential of the circuit evaluated in a grid of points as chosen by the user or using default variable ranges.

Parameters:

θ<index> – value(s) for variable :math:` heta_i` in the potential.

Return type:

ndarray

static print_expr_in_latex(expr)#

Print a sympy expression or a list of equalities in LaTeX

Parameters:

expr (Union[Expr, List[Equality]]) – a sympy expressions or a list of equalities

Return type:

None

process_hamiltonian(native_hamiltonian, energy_esys=False)#

Return qubit Hamiltonian in chosen basis: either return unchanged (i.e., in native basis) or transform into eigenenergy basis

Parameters:
  • native_hamiltonian (Union[ndarray, csc_matrix]) – Hamiltonian in native basis

  • energy_esys (Union[bool, Tuple[ndarray, ndarray]]) – If False (default), returns Hamiltonian in the native basis If True, the energy eigenspectrum is computed, returns Hamiltonian in the energy eigenbasis if energy_esys is the energy eigenspectrum, in the form of a tuple containing two ndarrays (eigenvalues and energy eigenvectors), returns Hamiltonian in the energy eigenbasis, and does not have to recalculate eigenspectrum.

Return type:

Union[ndarray, csc_matrix]

Returns:

Hamiltonian, either unchanged in native basis, or transformed into eigenenergy basis

process_op(native_op, energy_esys=False)#

Processes the operator native_op: either hand back native_op unchanged, or transform it into the energy eigenbasis. (Native basis refers to the basis used internally by each qubit, e.g., charge basis in the case of Transmon.

Parameters:
  • native_op (Union[ndarray, csc_matrix]) – operator in native basis

  • energy_esys (Union[bool, Tuple[ndarray, ndarray]]) – If False (default), returns operator in the native basis If True, the energy eigenspectrum is computed, returns operator in the energy eigenbasis if energy_esys is the energy eigenspectrum, in the form of a tuple containing two ndarrays (eigenvalues and energy eigenvectors), returns operator in the energy eigenbasis, and does not have to recalculate eigenspectrum.

Return type:

Union[ndarray, csc_matrix]

Returns:

native_op either unchanged or transformed into eigenenergy basis

receive(event, sender, **kwargs)#

Receive a message from CENTRAL_DISPATCH and initiate action on it.

Parameters:
  • event (str) – event name from EVENTS

  • sender (DispatchClient) – original sender reporting the event

  • **kwargs

Return type:

None

serialize()[source]#

Convert the content of the current class instance into IOData format.

set_and_return(attr_name, value)#

Allows to set an attribute after which self is returned. This is useful for doing something like example:

qubit.set_and_return('flux', 0.23).some_method()

instead of example:

qubit.flux=0.23
qubit.some_method()
Parameters:
  • attr_name (str) – name of class attribute in string form

  • value (Any) – value that the attribute is to be set to

Return type:

QubitBaseClass

Returns:

self

set_discretized_phi_range(var_indices, phi_range)[source]#

Sets the flux range for discretized phi basis when ext_basis is set to ‘discretized’.

Parameters:
  • var_indices (Tuple[int]) – list of var_indices whose range needs to be changed

  • phi_range (Tuple[float]) – The desired range for each of the discretized phi variables

Return type:

None

set_operators()#

Creates the operator methods <name>_operator for the circuit.

Return type:

Dict[str, Callable]

set_params(**kwargs)#

Set new parameters through the provided dictionary.

set_params_from_gui(change)#

Set new parameters through the provided dictionary.

supported_noise_channels()#

Returns a list of noise channels this QuantumSystem supports. If none, return an empty list.

Return type:

List

sym_external_fluxes()[source]#

Method returns a dictionary of Human readable external fluxes with associated branches and loops (represented as lists of branches) for the current instance

Return type:

Dict[Expr, Tuple[Branch, List[Branch]]]

Returns:

A dictionary of Human readable external fluxes with their associated branches and loops

sym_hamiltonian(subsystem_index=None, float_round=6, print_latex=False, return_expr=False)#

Prints a user readable symbolic Hamiltonian for the current instance

Parameters:
  • subsystem_index (Optional[int]) – when set to an index, the Hamiltonian for the corresponding subsystem is returned.

  • float_round (int) – Number of digits after the decimal to which floats are rounded

  • print_latex (bool) – if set to True, the expression is additionally printed as LaTeX code

  • return_expr (bool) – if set to True, all printing is suppressed and the function will silently return the sympy expression

Return type:

Optional[Expr]

sym_interaction(subsystem_indices, float_round=6, print_latex=False, return_expr=False)#

Print the interaction between any set of subsystems for the current instance. It would print the interaction terms having operators from all the subsystems mentioned in the tuple.

Parameters:
  • subsystem_indices (Tuple[int]) – Tuple of subsystem indices

  • float_round (int) – Number of digits after the decimal to which floats are rounded

  • print_latex (bool) – if set to True, the expression is additionally printed as LaTeX code

  • return_expr (bool) – if set to True, all printing is suppressed and the function will silently return the sympy expression

Return type:

Optional[Expr]

sym_lagrangian(vars_type='node', print_latex=False, return_expr=False)[source]#

Method that gives a user readable symbolic Lagrangian for the current instance

Parameters:
  • vars_type (str) – “node” or “new”, fixes the kind of lagrangian requested, by default “node”

  • print_latex (bool) – if set to True, the expression is additionally printed as LaTeX code

  • return_expr (bool) – if set to True, all printing is suppressed and the function will silently return the sympy expression

Return type:

Optional[Expr]

sym_potential(float_round=6, print_latex=False, return_expr=False)#

Method prints a user readable symbolic potential for the current instance

Parameters:
  • float_round (int) – Number of digits after the decimal to which floats are rounded

  • print_latex (bool) – if set to True, the expression is additionally printed as LaTeX code

  • return_expr (bool) – if set to True, all printing is suppressed and the function will silently return the sympy expression

Return type:

Optional[Expr]

variable_transformation()[source]#

Prints the variable transformation used in this circuit

Return type:

None

widget(params=None)#

Use ipywidgets to modify parameters of class instance

Parameters:

params (Dict[str, Any] | None) –