QubitBase
Abstract base class for all superconducting qubits. Provides shared methods for Hamiltonian diagonalization, parameter sweeps, matrix element computation, noise analysis, and wavefunction utilities.
All qubit types in HybridSuperQubits inherit from this class.
- class HybridSuperQubits.qubit_base.QubitBase(dimension)[source]
Bases:
ABC- Parameters:
dimension (int)
- abstractmethod n_operator()[source]
Returns the number operator for the qubit.
- Returns:
The number operator for the qubit.
- Return type:
ndarray
- displacement_operator()[source]
Returns the displacement operator.
- Returns:
The displacement operator.
- Return type:
np.ndarray
- abstractmethod hamiltonian()[source]
Returns the Hamiltonian for the qubit.
- Returns:
The Hamiltonian for the qubit.
- Return type:
ndarray
- eigensys(evals_count=None)[source]
Calculates eigenvalues and corresponding eigenvectors using scipy.linalg.eigh.
- Parameters:
evals_count (int, optional) – Number of desired eigenvalues/eigenstates (default is None, in which case all are calculated).
- Returns:
Eigenvalues and eigenvectors as numpy arrays.
- Return type:
Tuple[np.ndarray, np.ndarray]
- eigenvals(evals_count=None)[source]
Calculates eigenvalues using scipy.linalg.eigh.
- Parameters:
evals_count (int, optional) – Number of desired eigenvalues (default is None, in which case all are calculated).
- Returns:
Eigenvalues as a numpy array.
- Return type:
np.ndarray
- get_spectrum_vs_paramvals(param_name, param_vals, evals_count=None, subtract_ground=False, show_progress=True)[source]
Calculates the eigenenergies and eigenstates for a range of parameter values.
- Parameters:
param_name (str) – The name of the parameter to vary.
param_vals (List[float]) – The values of the parameter to vary.
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is None, in which case all are calculated).
subtract_ground (bool, optional) – Whether to subtract the ground state energy from the eigenenergies (default is False).
show_progress (bool)
- Returns:
The eigenenergies and eigenstates for the range of parameter values.
- Return type:
Tuple[np.ndarray, np.ndarray]
- matrixelement_table(operator, evecs=None, evals_count=None)[source]
Returns a table of matrix elements for a given operator with respect to the eigenstates.
- Parameters:
- Returns:
The table of matrix elements.
- Return type:
np.ndarray
- get_matelements_vs_paramvals(operators, param_name, param_vals, evals_count=None, show_progress=True)[source]
Calculates the matrix elements for a list of operators over a range of parameter values.
- Parameters:
operators (Union[str, List[str]]) – The name(s) of the operator(s).
param_name (str) – The name of the parameter to vary.
param_vals (np.ndarray) – The values of the parameter to vary.
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is None, in which case all are calculated).
show_progress (bool, optional) – Whether to display a progress bar during calculation (default is True).
- Returns:
The matrix elements for the operators over the range of parameter values.
- Return type:
- harm_osc_wavefunction(n, x, l_osc)[source]
Returns the value of the harmonic oscillator wave function.
The wave function is computed using the parabolic cylinder function Dν(z), which satisfies the Weber differential equation. This implementation is based on the connection between the wave function of the harmonic oscillator and the solutions to the Weber equation.
- Parameters:
- Returns:
Value of harmonic oscillator wave function.
- Return type:
Union[float, np.ndarray]
References
ParabolicCylinderD[ν, z]: https://reference.wolfram.com/language/ref/ParabolicCylinderD.html
The wave functions of the quantum harmonic oscillator are proportional
to the parabolic cylinder functions Dν(z).
- t1_capacitive(i=1, j=0, Q_cap=None, T=0.015, esys=None, matrix_elements=None, get_rate=False)[source]
- t1_inductive(i=1, j=0, Q_ind=None, T=0.015, esys=None, matrix_elements=None, get_rate=False)[source]
- t1_flux_bias_line(i=1, j=0, M=2500, Z=50, T=0.015, esys=None, matrix_elements=None, get_rate=False)[source]
- tphi_1_over_f(A_noise, noise_op, esys=None, get_rate=False, **kwargs)[source]
Calculates the 1/f dephasing time (or rate) due to an arbitrary noise source.
- Parameters:
A_noise (float) – Noise strength.
noise_op (Union[str, List[str]]) – Noise operator(s) to use.
esys (Tuple[np.ndarray, np.ndarray], optional) – Precomputed eigenvalues and eigenvectors (default is None).
get_rate (bool, optional) – Whether to return the rate instead of the Tphi time (default is False).
- Returns:
The 1/f dephasing time (or rate) due to an arbitrary noise source.
- Return type:
np.ndarray
- tphi_CQPS(fp=17000000000.0, z=0.05, esys=None, get_rate=False)[source]
Calculates the CQPS dephasing time (or rate).
- Parameters:
- Returns:
The CQPS dephasing time (or rate).
- Return type:
np.ndarray
- get_t1_vs_paramvals(noise_channels, param_name=None, param_vals=None, evals_count=None, spectrum_data=None, **kwargs)[source]
Calculates the T1 times for given noise channels over a range of parameter values.
- Parameters:
noise_channels (Union[str, List[str]]) – The noise channels to calculate (‘capacitive’, ‘inductive’, etc.).
param_name (str) – The name of the parameter to vary.
param_vals (np.ndarray) – The values of the parameter to vary.
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is None, in which case all are calculated).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
**kwargs – Additional arguments to pass to the T1 calculation method.
- Returns:
The T1 times for the specified noise channels over the range of parameter values.
- Return type:
- get_t1_capacitive_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, Q_cap=None, T=0.015, **kwargs)[source]
T1 times for capacitive noise over a parameter sweep.
- Parameters:
- Return type:
- get_t1_inductive_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, Q_ind=None, T=0.015, **kwargs)[source]
T1 times for inductive noise over a parameter sweep.
- Parameters:
- Return type:
- get_t1_charge_impedance_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, Z=50, T=0.015, **kwargs)[source]
T1 times for charge-impedance noise over a parameter sweep.
- Parameters:
- Return type:
- get_t1_flux_bias_line_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, M=2500, Z=50, T=0.015, **kwargs)[source]
T1 times for flux-bias-line noise over a parameter sweep.
- Parameters:
- Return type:
- get_t1_1_over_f_flux_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, A_noise=1e-06, **kwargs)[source]
T1 times for 1/f flux noise over a parameter sweep.
- Parameters:
param_name (str | None)
param_vals (ndarray | None)
evals_count (int | None)
spectrum_data (SpectrumData | None)
A_noise (float)
- Return type:
- get_t1_critical_current_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, A_noise=1e-07, N=100, **kwargs)[source]
T1 times for critical-current noise over a parameter sweep.
- Parameters:
- Return type:
- get_t1_er_vs_paramvals(param_name=None, param_vals=None, evals_count=None, spectrum_data=None, R=50, T=0.015, **kwargs)[source]
T1 times for Fermi-level (Andreev) noise over a parameter sweep.
- Parameters:
- Return type:
- get_tphi_flux_vs_paramvals(param_name=None, param_vals=None, A_noise=6.283185307179586e-06, evals_count=None, spectrum_data=None, **kwargs)[source]
Calculates the Tphi times for flux noise over a range of parameter values.
- Parameters:
param_name (str, optional) – The name of the parameter to vary. If not provided, extracted from spectrum_data.
param_vals (np.ndarray, optional) – The values of the parameter to vary. If not provided, extracted from spectrum_data.
A_noise (float) – The amplitude of the noise.
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is 6).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
**kwargs – Additional arguments to pass to the Tphi calculation method.
- Returns:
The Tphi times for flux noise over the range of parameter values.
- Return type:
- get_tphi_charge_vs_paramvals(param_name=None, param_vals=None, A_noise=3.8740458649318246e-18, evals_count=None, spectrum_data=None, **kwargs)[source]
Calculates the Tphi times for charge noise over a range of parameter values.
- Parameters:
param_name (str, optional) – The name of the parameter to vary.
param_vals (np.ndarray, optional) – The values of the parameter to vary.
A_noise (float, optional) – The amplitude of the noise (default is 1e-4).
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is 6).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
**kwargs – Additional arguments to pass to the Tphi calculation method.
- Returns:
The Tphi times for charge noise over the range of parameter values.
- Return type:
- get_tphi_CQPS_vs_paramvals(param_name=None, param_vals=None, fp=17000000000.0, z=0.05, evals_count=6, spectrum_data=None, **kwargs)[source]
Calculates the Tphi times for Coherence Quantum Phase Slip noise over a range of parameter values.
- Parameters:
param_name (str, optional) – The name of the parameter to vary.
param_vals (np.ndarray, optional) – The values of the parameter to vary.
fp (float, optional) – The plasma frequency of the junctions in the array (default is 17 GHz).
z (float, optional) – The adimensional impedance z = Z / R_Q (default is 0.05).
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is 6).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
**kwargs – Additional arguments to pass to the Tphi calculation method.
- Returns:
The Tphi times for Coherence Quantum Phase Slip noise over the range of parameter values.
- Return type:
- get_tphi_vs_paramvals(noise_channels, param_name=None, param_vals=None, evals_count=None, spectrum_data=None, **kwargs)[source]
- Parameters:
- Return type:
- get_d2E_d_param_vs_paramvals(operators, param_name=None, param_vals=None, evals_count=None, spectrum_data=None, show_progress=True, **kwargs)[source]
Calculates the second derivative of energy with respect to a parameter over a range of parameter values.
- Parameters:
operators (List[str]) – The operators used to calculate the derivatives. Must contain two elements: First element: first derivative operator (e.g., ‘d_hamiltonian_d_phase’) Second element: second derivative operator (e.g., ‘d2_hamiltonian_d_phase2’)
param_name (str, optional) – The name of the parameter to vary.
param_vals (np.ndarray, optional) – The values of the parameter to vary.
evals_count (int, optional) – The number of eigenvalues and eigenstates to calculate (default is None, which uses self.dimension).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
show_progress (bool, optional) – Whether to show a progress bar during the calculation (default is True).
- Returns:
The spectral data with added second derivatives.
- Return type:
- plot_evals_vs_paramvals(param_name=None, param_vals=None, evals_count=6, subtract_ground=False, spectrum_data=None, **kwargs)[source]
Plot eigenvalues as a function of a parameter.
- Parameters:
param_name (str) – Name of the parameter to vary.
param_vals (np.ndarray) – Values of the parameter to vary.
evals_count (int, optional) – Number of eigenvalues to calculate (default is 6).
subtract_ground (bool, optional) – Whether to subtract the ground state energy from all eigenvalues (default is False).
**kwargs –
Additional arguments for plotting. Can include: - fig_ax: Tuple[plt.Figure, plt.Axes], optional
Figure and axes to use for plotting. If not provided, a new figure and axes are created.
- color: str or list of str, optional
Color of the lines. Can be a single color or a list of colors.
- linestyle: str or list of str, optional
Linestyle of the lines. Can be a single linestyle or a list of linestyles.
spectrum_data (SpectrumData | None)
- Returns:
The figure and axes of the plot.
- Return type:
Tuple[plt.Figure, plt.Axes]
- plot_matelem_vs_paramvals(operator, param_name=None, param_vals=None, select_elems=None, mode='abs', spectrum_data=None, **kwargs)[source]
Plot matrix elements as a function of a parameter.
- Parameters:
operator (str) – Name of the operator.
param_name (str) – Name of the parameter to vary.
param_vals (np.ndarray) – Values of the parameter to vary.
select_elems (Union[int, List[Tuple[int, int]]], optional) – Number of elements to select or list of specific elements to plot (default is [(1, 0)]).
mode (Literal["abs", "real", "imag", "abs_squared"], optional) – Mode for plotting the matrix elements (‘abs’, ‘real’, ‘imag’, ‘abs_squared’) (default is ‘abs’).
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use (default is None).
**kwargs –
Additional arguments for plotting. Can include: - fig_ax: Tuple[plt.Figure, plt.Axes], optional
Figure and axes to use for plotting. If not provided, a new figure and axes are created.
- Returns:
The figure and axes of the plot.
- Return type:
Tuple[plt.Figure, plt.Axes]
- plot_t1_vs_paramvals(noise_channels, param_name=None, param_vals=None, select_elems=None, spectrum_data=None, **kwargs)[source]
Plot T1 times due to capacitive noise as a function of a parameter.
- Parameters:
noise_channels (List[str]) – List of noise channels to plot.
param_name (str, optional) – Name of the parameter to vary.
param_vals (np.ndarray, optional) – Values of the parameter to vary.
select_elems (Union[int, List[Tuple[int, int]]], optional) – Number of elements to select or list of specific elements to plot. Default is [(1, 0)].
spectrum_data (SpectrumData, optional) – Precomputed spectral data to use.
**kwargs – Additional arguments for plotting.
- Returns:
The figure and axes of the plot.
- Return type:
Tuple[plt.Figure, plt.Axes]
- plot_tphi_vs_paramvals(noise_channels, param_name=None, param_vals=None, select_elems=None, spectrum_data=None, **kwargs)[source]
Plot Tphi times due to specified noise channels as a function of a parameter.
- Parameters:
- Return type:
- set_param(param_name, val)[source]
Sets the value of a parameter if it exists.
- Parameters:
param_name (str) – The name of the parameter to set.
val (Any) – The value to set for the parameter.
- Raises:
AttributeError – If the parameter does not exist.
- Return type:
None