QubitBaseClass1d#

class scqubits.core.qubit_base.QubitBaseClass1d(id_str, evals_method=None, evals_method_options=None, esys_method=None, esys_method_options=None)[source]#

Base class for superconducting qubit objects with one degree of freedom. Provide general mechanisms and routines for plotting spectra, matrix elements, and writing data to files.

Methods

QubitBaseClass1d.E01()

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

QubitBaseClass1d.__init__(id_str[, ...])

QubitBaseClass1d.anharmonicity()

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

QubitBaseClass1d.broadcast(event, **kwargs)

Request a broadcast from CENTRAL_DISPATCH reporting event.

QubitBaseClass1d.create()

Use ipywidgets to create a new class instance

QubitBaseClass1d.default_params()

Return dictionary with default parameter values for initialization of class instance

QubitBaseClass1d.eigensys([evals_count, ...])

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

QubitBaseClass1d.eigenvals([evals_count, ...])

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

QubitBaseClass1d.get_dispersion_vs_paramvals(...)

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

QubitBaseClass1d.get_initdata()

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

QubitBaseClass1d.get_matelements_vs_paramvals(...)

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

QubitBaseClass1d.get_operator_names()

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

QubitBaseClass1d.get_spectrum_vs_paramvals(...)

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

QubitBaseClass1d.hamiltonian()

Returns the Hamiltonian

QubitBaseClass1d.hilbertdim()

Returns dimension of Hilbert space

QubitBaseClass1d.matrixelement_table(operator)

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

QubitBaseClass1d.plot_dispersion_vs_paramvals(...)

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

QubitBaseClass1d.plot_evals_vs_paramvals(...)

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

QubitBaseClass1d.plot_matelem_vs_paramvals(...)

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

QubitBaseClass1d.plot_matrixelements(operator)

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

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

Plot 1d phase-basis wave function(s).

QubitBaseClass1d.potential(phi)

rtype:

Union[float, ndarray]

QubitBaseClass1d.process_hamiltonian(...[, ...])

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

QubitBaseClass1d.process_op(native_op[, ...])

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

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

Receive a message from CENTRAL_DISPATCH and initiate action on it.

QubitBaseClass1d.set_and_return(attr_name, value)

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

QubitBaseClass1d.set_params(**kwargs)

Set new parameters through the provided dictionary.

QubitBaseClass1d.set_params_from_gui(change)

Set new parameters through the provided dictionary.

QubitBaseClass1d.supported_noise_channels()

Returns a list of noise channels this QuantumSystem supports.

QubitBaseClass1d.wavefunction(esys[, which, ...])

rtype:

WaveFunction

QubitBaseClass1d.wavefunction1d_defaults(...)

Plot defaults for plotting.wavefunction1d.

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

Return type:

QuantumSystemType

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

classmethod create()#

Use ipywidgets to create a new class instance

Return type:

QuantumSystem

abstract static default_params()#

Return dictionary with default parameter values for initialization of class instance

Return type:

Dict[str, Any]

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

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

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

abstract hamiltonian()#

Returns the Hamiltonian

abstract hilbertdim()#

Returns dimension of Hilbert space

Return type:

int

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]

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_wavefunction(which=0, mode='real', esys=None, phi_grid=None, scaling=None, **kwargs)[source]#

Plot 1d phase-basis wave function(s). Must be overwritten by higher-dimensional qubits like FluxQubits and ZeroPi.

Parameters:
  • which (Union[int, Iterable[int]]) – single index or tuple/list of integers indexing the wave function(s) to be plotted. If which is -1, all wavefunctions up to the truncation limit are plotted.

  • mode (str) – choices as specified in constants.MODE_FUNC_DICT (default value = ‘abs_sqr’)

  • esys (Optional[Tuple[ndarray, ndarray]]) – eigenvalues, eigenvectors

  • phi_grid (Optional[Grid1d]) – used for setting a custom grid for phi; if None use self._default_grid

  • scaling (Optional[float]) – custom scaling of wave function amplitude/modulus

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

Return type:

Tuple[Figure, Axes]

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

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

wavefunction1d_defaults(mode, evals, wavefunc_count)[source]#

Plot defaults for plotting.wavefunction1d.

Parameters:
  • mode (str) – amplitude modifier, needed to give the correct default y label

  • evals (ndarray) – eigenvalues to include in plot

  • wavefunc_count (int) – number of wave functions to be plotted

Return type:

Dict[str, Any]

widget(params=None)#

Use ipywidgets to modify parameters of class instance

Parameters:

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