CircuitABC

class scqubits.core.circuit.CircuitABC[source]

Methods

CircuitABC.__init__()

CircuitABC.create()

CircuitABC.cutoffs_dict()

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

CircuitABC.default_params()

CircuitABC.deserialize(io_data)

CircuitABC.discretized_grids_dict_for_vars()

CircuitABC.exp_i_operator(var_sym, prefactor)

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

CircuitABC.generate_bare_eigensys()

Returns the eigensystem of the Circuit, and all the subsystems involved in the bare basis.

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

Returns treated wave function of the current Circuit instance for the specified variables.

CircuitABC.get_cutoffs()

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

CircuitABC.get_ext_basis()

Get the ext_basis object for the Circuit instance, according to the setting in self.hierarchical_diagonalization.

CircuitABC.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.

CircuitABC.get_osc_param(var_index[, ...])

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

CircuitABC.get_subsystem_index(var_index)

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

CircuitABC.hamiltonian()

Returns the Hamiltonian of the Circuit.

CircuitABC.hamiltonian_for_qutip_dynamics(...)

Returns the Hamiltonian in a format amenable to be forwarded to mesolve in Qutip. Also returns the symbolic expressions of time independent and time dependent terms of the Hamiltonian, which can be used for reference. free_var_func_dict is a dictionary with key-value pair {"var": f}, where f is a function returning the value of the variable var at time t. If one has extra terms to be added to the Hamiltonian (for instance, charge driving a fluxonium where there is no offset charge) they can be passed as a string in extra_terms. For example, to get the Hamiltonian for a circuit where Φ1 is the time varying parameter, this method can be called in the following way::.

CircuitABC.hilbertdim()

Returns the Hilbert dimension of the Circuit instance.

CircuitABC.identity_wrap_for_hd(operator, ...)

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

CircuitABC.is_subsystem(instance)

Returns true if the instance is a subsystem of self (regardless of the hierarchy)

CircuitABC.offset_charge_transformation()

Prints the variable transformation between offset charges of transformed variables and the node charges.

CircuitABC.offset_free_charge_values()

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

CircuitABC.operator_names_in_hamiltonian_symbolic()

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

CircuitABC.plot_potential(**kwargs)

Returns the plot of the potential for the circuit instance.

CircuitABC.plot_wavefunction([which, mode, ...])

Returns the plot of the wavefunction in the requested variables.

CircuitABC.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.

CircuitABC.print_expr_in_latex(expr)

Print a sympy expression or a list of equalities in LaTeX.

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

Method to help the CentralDispatch keep track of the sync status in Circuit and SubSystem modules.

CircuitABC.return_parent_circuit()

Returns the parent Circuit instance.

CircuitABC.return_root_child(var_index)

Returns the root child of the subsystem instance with var_index in its dynamic_var_indices.

CircuitABC.serialize()

CircuitABC.set_and_return(attr_name, value)

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

CircuitABC.set_bare_eigensys(eigensys)

Sets the bare eigensystem of the Circuit in the lookup table of hilbert_space attribute, if hierarchical diagonalization is used.

CircuitABC.set_discretized_phi_range(...)

Sets the flux range for discretized phi basis or for plotting.

CircuitABC.sym_hamiltonian([...])

Prints a user readable symbolic Hamiltonian for the current instance.

CircuitABC.sym_interaction(subsystem_indices)

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

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

Method prints a user readable symbolic potential for the current instance.

CircuitABC.update([calculate_bare_esys])

Syncs all the parameters of the subsystems with the current instance.

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}

exp_i_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)

generate_bare_eigensys()

Returns the eigensystem of the Circuit, and all the subsystems involved in the bare basis.

generate_wf_plot_data(which=0, mode='abs-sqr', var_indices=(1,), eigensys=None, change_discrete_charge_to_phi=True, grids_dict=None)

Returns treated wave function of the current Circuit instance for the specified variables.

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

  • mode (str) – “abs”, “real”, “imag”, “abs-sqr” - decides which part of the wave function is plotted.

  • 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 (ndarray) – eigenvalues and eigenstates of the Circuit instance; if not provided, calling this method will perform a diagonalization to obtain these.

  • extended_variable_basis (str) – The basis in which the extended variables are plotted. Can be either “phi” or “charge”.

  • periodic_variable_basis (str) – The basis in which the periodic variables are plotted. Can be either “phi” or “charge”.

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

  • change_discrete_charge_to_phi (bool)

get_cutoffs()

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

Return type:

Dict[str, list]

get_ext_basis()

Get the ext_basis object for the Circuit instance, according to the setting in self.hierarchical_diagonalization.

Return type:

Union[str, List[str]]

get_operator_by_name(operator_name, power=None, bare_esys=None)

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

  • power (Optional[int]) – If asking for an operator raised to a certain power. Which wen set to None defaults to 1

Return type:

Qobj

Returns:

operator identified by operator_name

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_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]

hamiltonian_for_qutip_dynamics(free_var_func_dict, prefactor=1.0, extra_terms=None)

Returns the Hamiltonian in a format amenable to be forwarded to mesolve in Qutip. Also returns the symbolic expressions of time independent and time dependent terms of the Hamiltonian, which can be used for reference. free_var_func_dict is a dictionary with key-value pair {“var”: f}, where f is a function returning the value of the variable var at time t. If one has extra terms to be added to the Hamiltonian (for instance, charge driving a fluxonium where there is no offset charge) they can be passed as a string in extra_terms. For example, to get the Hamiltonian for a circuit where Φ1 is the time varying parameter, this method can be called in the following way:

def flux_t(t, args):
    return 0.5 + 0.02*np.sin(t*2)
def ng_t(t, args):
    return 0.5 + 0.02*np.cos(t*2)
def EJ_t(t, args):
    return (1-np.exp(-t/1))*0.2
free_var_func_dict = {"Φ1": flux_t, "EJ": EJ_t, "ng": ng_t}

mesolve_input_H = self.hamiltonian_for_qutip_dynamics(free_var_func_dict, extra_terms="0.1*ng*Q1")
Parameters:
  • free_var_func_dict (Dict[str, Callable]) – Dict, as defined in the description above

  • prefactor (float) – prefactor with which the Hamiltonian and corresponding operators are multiplied, useful to set it to 2*np.pi for some qutip simulations

  • extra_terms (Optional[str]) – a string which will be converted into sympy expression, containing terms which are not present in the Circuit Hamiltonian. It is useful to define custom drive operators.

Return type:

Tuple[List[Union[Qobj, Tuple[Qobj, Callable]]], Expr, Dict[Qobj, Expr]]

hilbertdim()

Returns the Hilbert dimension of the Circuit instance.

identity_wrap_for_hd(operator, child_instance, bare_esys=None)

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

  • instance – The subsystem to which the operator belongs

  • bare_esys (Optional[Dict[int, Tuple]]) – Dict containing subsystem indices starting from 0, paired with the bare esys for each of the subsystem

Return type:

Qobj

Returns:

identity wrapped operator.

is_subsystem(instance)

Returns true if the instance is a subsystem of self (regardless of the hierarchy)

offset_charge_transformation()

Prints the variable transformation between offset charges of transformed variables and the node charges.

Return type:

None

offset_free_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_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, mode='abs-sqr', var_indices=(1,), esys=None, change_discrete_charge_to_phi=True, zero_calibrate=True, grids_dict={}, **kwargs)

Returns the plot of the wavefunction in the requested variables. At most 2 numbers of variables for wavefunction can be specified as plotting axis. If the number of plotting variables for wave function is smaller than the number of variables in the circuit, the marginal probability distribution of the state with respect to the specified variables is plotted. This means the norm square of the wave function is integrated over the rest of the variables and is then plotted.

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

  • mode (str) – “abs”, “real”, “imag”, “abs-sqr” - decides which part of the wave function is plotted, by default “abs-sqr”

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

  • esys (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) – If True, the wave function is plotted in the phi basis for the periodic variables. If False, the wave function is plotted in the charge basis for the periodic variables.

  • 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 grids used to create the plot. The way to specify the grids is as follows: 1. For extended variables, the grids should be of type discretization.Grid1d. 2. When the discretized phi basis is used for the extended variable, the grids used in the diagonalization is used to plot the wave function instead of the grids specified here. 3. For periodic variables, only if change_discrete_charge_to_phi is True, the grid specified here will used for plotting. The grid is specified as an integer which is the number of points in the grid. The grid has a minimum and maximum value of -pi and pi respectively. 4. If the grid is not specified for a variable that requires a grid for plotting (i.e. extended variable with harmonic oscillator basis, or periodic variable with change_discrete_charge_to_phi set to True), the default grid is used.

  • **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

receive(event, sender, **kwargs)

Method to help the CentralDispatch keep track of the sync status in Circuit and SubSystem modules.

Return type:

None

Parameters:
  • event (str)

  • sender (object)

return_parent_circuit()

Returns the parent Circuit instance.

return_root_child(var_index)

Returns the root child of the subsystem instance with var_index in its dynamic_var_indices.

Parameters:

var_index (int) – index of one of the dynamical degrees of freedom (from dynamic_var_indices)

Returns:

Subsystem instance with var_index in its dynamic_var_indices.

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_bare_eigensys(eigensys)

Sets the bare eigensystem of the Circuit in the lookup table of hilbert_space attribute, if hierarchical diagonalization is used.

set_discretized_phi_range(var_indices, phi_range)

Sets the flux range for discretized phi basis or for plotting.

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

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_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]

update(calculate_bare_esys=True)

Syncs all the parameters of the subsystems with the current instance.

Parameters:

calculate_bare_esys (bool)