Circuit¶
- class scqubits.core.circuit.Circuit(input_string=None, from_file=True, basis_completion='heuristic', ext_basis='discretized', use_dynamic_flux_grouping=False, generate_noise_methods=False, initiate_sym_calc=True, truncated_dim=10, symbolic_param_dict={}, symbolic_hamiltonian=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 (
Optional
[str
]) – String describing the number of nodes and branches connecting then along with their parametersfrom_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”use_dynamic_flux_grouping (
bool
) – set to False by default. Indicates if the flux allocation is done by assuming that flux is time dependent. When set to True, it disables the option to change the closure branches.initiate_sym_calc (
bool
) – parameter to initiate Circuit instance, by default Truetruncated_dim (
int
) – truncated dimension if the user wants to use this circuit instance in HilbertSpace, by default Nonegenerate_noise_methods (bool)
symbolic_param_dict (Dict[str, float])
symbolic_hamiltonian (Expr | None)
evals_method (Callable | str | None)
evals_method_options (dict | None)
esys_method (Callable | str | None)
esys_method_options (dict | None)
- hierarchical_diagonalization¶
set to True when the circuit is defined hierarchically, by default False
- Type:
bool
- hamiltonian_symbolic¶
the symbolic Hamiltonian for the circuit
- Type:
sm.Expr
- external_fluxes¶
list of external flux variables
- Type:
List[sm.Symbol]
- offset_charges¶
list of offset charge variables
- Type:
List[sm.Symbol]
- free_charges¶
list of free charge variables
- Type:
List[sm.Symbol]
- var_categories¶
dictionary with keys “periodic”, “extended”, “free”, “frozen” and values as the indices of the respective variable types
- Type:
Dict[str, List[int]]
- cutoff_names¶
list of cutoff names for the variables
- Type:
List[str]
- discretized_phi_range¶
dictionary with keys as the indices of the extended variables and values as the range of discretized phi variables
- Type:
Dict[int, Tuple[float, float]]
- type_of_matrices¶
type of matrices used to construct the operators “dense” or “sparse”, by default “sparse”
- Type:
str
- truncated_dim¶
truncated dimension for the current instance
- Type:
int
- is_purely_harmonic¶
internally set to True when the instance is purely harmonic
- Type:
bool
- dynamic_var_indices¶
list of dynamic variable indices, showing the degrees of freedom of the circuit.
- Type:
List[int]
- hilbert_space¶
HilbertSpace instance for the instance, when hierarchical diagonalization is used
- Type:
- system_hierarchy¶
list of lists containing variable indices which is provided by the user to define subsystems
- Type:
list
- subsystem_trunc_dims¶
list of truncated dimensions for the subsystems inside the current subsystem
- Type:
list
Methods
Returns the qubit's fundamental energy splitting, E_1 - E_0.
Circuit.Q_from_branch
(branch)Extracts the Quality Factor 'Q' from a Given Branch.
Circuit.__init__
([input_string, from_file, ...])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.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.
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.
Returns a dictionary, where each variable is associated with its respective cutoff.
Return dictionary with default parameter values for initialization of class instance.
Circuit.deserialize
(io_data)Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
Circuit.discretized_grids_dict_for_vars
()Return a list of noise channels that are used when calculating the effective noise (i.e. via t1_effective and t2_effective.
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_operator
(var_sym, prefactor)Returns the bare operator exp(i* heta*prefactor), without the kron product.
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.
Returns the eigensystem of the Circuit, and all the subsystems involved in the bare basis.
This function is responsible for dynamically generating all the methods that calculate the different types of noise in the quantum circuit.
Circuit.generate_wf_plot_data
([which, mode, ...])Returns treated wave function of the current Circuit instance for the specified variables.
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.
Get the ext_basis object for the Circuit instance, according to the setting in self.hierarchical_diagonalization.
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.
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_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.
Returns the Hamiltonian of the Circuit.
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::.
Returns the Hilbert dimension of the Circuit instance.
Circuit.identity_wrap_for_hd
(operator, ...)Returns an identity wrapped operator whose size is equal to the self.hilbertdim().
Circuit.is_subsystem
(instance)Returns true if the instance is a subsystem of self (regardless of the hierarchy)
Circuit.matrixelement_table
(operator[, ...])Returns table of matrix elements for operator with respect to the eigenstates of the qubit.
Prints the variable transformation between offset charges of transformed variables and the node charges.
Returns all the offset charges set using the circuit attributes for each of the periodic degree of freedom.
Returns a list of the names (strings) of all operators occurring in the symbolic Hamiltonian.
Circuit.oscillator_list
(osc_index_list)If hierarchical diagonalization is used, specify subsystems that corresponds to single-mode oscillators, if there is any.
Circuit.plot_coherence_vs_paramvals
(...[, ...])Show plots of coherence for various channels supported by the qubit as they vary as a function of a changing parameter.
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.
Plot effective \(T_1\) coherence time (rate) as a function of changing parameter.
Plot effective \(T_2\) coherence time (rate) as a function of changing parameter.
Circuit.plot_wavefunction
([which, mode, ...])Returns the plot of the wavefunction in the requested variables.
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.
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.qubit_list
(qbt_index_list)If hierarchical diagonalization is used, specify subsystems that corresponds to single-mode oscillators, if there is any.
Circuit.receive
(event, sender, **kwargs)Method to help the CentralDispatch keep track of the sync status in Circuit and SubSystem modules.
Returns the parent Circuit instance.
Circuit.return_root_child
(var_index)Returns the root child of the subsystem instance with var_index in its dynamic_var_indices.
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_bare_eigensys
(eigensys)Sets the bare eigensystem of the Circuit in the lookup table of
hilbert_space
attribute, if hierarchical diagonalization is used.Sets the flux range for discretized phi basis or for plotting.
Circuit.set_params
(**kwargs)Set new parameters through the provided dictionary.
Circuit.set_params_from_gui
(change)Set new parameters through the provided dictionary.
Return a list of supported noise channels.
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.t1
(i, j, noise_op, spectral_density)Calculate the transition time (or rate) using Fermi's Golden Rule due to a noise channel with a spectral density spectral_density and system noise operator noise_op.
Circuit.t1_capacitive
([i, j, Q_cap, T, ...])\(T_1\) due to dielectric dissipation in the Josephson junction capacitances.
Circuit.t1_charge_impedance
([i, j, Z, T, ...])Noise due to charge coupling to an impedance (such as a transmission line).
Circuit.t1_effective
([noise_channels, ...])Calculate the effective \(T_1\) time (or rate).
Circuit.t1_flux_bias_line
([i, j, M, Z, T, ...])Noise due to a bias flux line.
Circuit.t1_inductive
([i, j, Q_ind, T, ...])\(T_1\) due to inductive dissipation in a superinductor.
Circuit.t1_quasiparticle_tunneling
([i, j, ...])Noise due to quasiparticle tunneling across a Josephson junction.
Circuit.t2_effective
([noise_channels, ...])Calculate the effective \(T_2\) time (or rate).
Circuit.tphi_1_over_f
(A_noise, i, j, noise_op)Calculate the 1/f dephasing time (or rate) due to arbitrary noise source.
Circuit.tphi_1_over_f_cc
([A_noise, i, j, ...])Calculate the 1/f dephasing time (or rate) due to critical current noise.
Circuit.tphi_1_over_f_flux
([A_noise, i, j, ...])Calculate the 1/f dephasing time (or rate) due to flux noise.
Circuit.tphi_1_over_f_ng
([A_noise, i, j, ...])Calculate the 1/f dephasing time (or rate) due to charge noise.
Circuit.transition_energy_derivative
(ni, nf, ...)Returns the first order and second order derivative of the nth eigenenergy.
Circuit.update
([calculate_bare_esys])Syncs all the parameters of the subsystems with the current instance.
Prints the variable transformation used in this circuit.
Circuit.widget
([params])Use ipywidgets to modify parameters of class instance.
Attributes
id_str
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
- static Q_from_branch(branch)¶
Extracts the Quality Factor ‘Q’ from a Given Branch.
This method performs the following steps:
Determines the type of the branch (‘L’ for inductor or ‘C’ for capacitor) and constructs a key for the quality factor (‘Q_ind’ for inductor or ‘Q_cap’ for capacitor).
Checks if the key is in the auxiliary parameters of the branch. If not, the method returns None.
If the key is in the auxiliary parameters, it retrieves the value of the quality factor, which is a string.
Checks if the string can be evaluated as a float using the ‘is_string_float’ helper function. If it can, it converts the string to a float and returns it.
If the string cannot be evaluated as a float, it assumes that the string represents a function of frequency ‘omega’ and temperature ‘T’. It defines a new function ‘Q_func’ that takes ‘omega’ and ‘T’ as parameters and evaluates the string using Python’s ‘eval’ function. It returns ‘Q_func’.
- Parameters:
branch (The branch from which to extract the quality factor. The branch should be an instance of the 'Branch' class. It should have a 'type' attribute that is either 'L' or 'C', and an 'aux_params' dictionary that contains a key 'Q_ind' or 'Q_cap' with the quality factor as the value.)
- Returns:
float or function: The quality factor as a float, or a function that calculates the quality factor given frequency and temperature. If the branch does not have a quality factor, None is returned.
- Raises:
AttributeError – If the branch does not have a ‘type’ attribute or an ‘aux_params’ dictionary.:
ValueError – If the branch’s type is not ‘L’ or ‘C’, or if the quality factor string cannot be evaluated as a float or a function of ‘omega’ and ‘T’.:
- 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
- configure(transformation_matrix=None, system_hierarchy=None, subsystem_trunc_dims=None, closure_branches=None, ext_basis=None, use_dynamic_flux_grouping=None, generate_noise_methods=False, subsys_dict=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 Nonesystem_hierarchy (
Optional
[list
]) – A list of lists which is provided by the user to define subsystems, by default Nonesubsystem_trunc_dims (
Optional
[list
]) – dict object which can be generated for a specific system_hierarchy using the method truncation_template, by default Noneclosure_branches (
Optional
[List
[Union
[Branch
,Dict
[Branch
,float
]]]]) – Each element of the list corresponds to one external flux variable. If the element is a branch the external flux will be associated with that branch. If the element is a dictionary, the external flux variable will be distributed across the branches according to the dictionary with the factor given as a key value.ext_basis (
Union
[str
,List
[str
],None
]) – can be “discretized” or “harmonic” which chooses whether to use discretized phi or harmonic oscillator basis for extended variables, by default Noneuse_dynamic_flux_grouping (
Optional
[bool
]) – set to False by default. Indicates if the flux allocation is done by assuming that flux is time dependent. When set to True, it disables the option to change the closure branches.generate_noise_methods (
bool
) – set to False by default. Indicates if the noise methods should be generated for the circuit instance.subsys_dict (
Optional
[Dict
[str
,Any
]]) – User provided dictionary with two keys “systems_sym” and “interaction_sym” defining the symbolic Hamiltonians and interactions for the subsystems. By default set to None, and is internally generated.
- Raises:
Exception – When system_hierarchy is set and subsystem_trunc_dims is not set.
Exception – When closure_branches is set and the Circuit instance is initialized with the setting use_dynamic_flux_grouping=True.
- classmethod create()¶
Use ipywidgets to create a new class instance.
- Return type:
- 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:
- 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(io_data)¶
Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
- Parameters:
io_data (IOData)
- effective_noise_channels()[source]¶
Return a list of noise channels that are used when calculating the effective noise (i.e. via t1_effective and t2_effective.
- 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_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)
- filewrite(filename)¶
Convenience method bound to the class.
Simply accesses the write function.
- Return type:
None
- Parameters:
filename (str)
- from_yaml(input_string, from_file=True, basis_completion='heuristic', ext_basis='discretized', use_dynamic_flux_grouping=False, generate_noise_methods=False, initiate_sym_calc=True, truncated_dim=10)[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 parametersfrom_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 Truetruncated_dim (
int
) – truncated dimension if the user wants to use this circuit instance in HilbertSpace, by default Noneuse_dynamic_flux_grouping (bool) – set to False by default. Indicates if the flux allocation is done by assuming that flux is time dependent. When set to True, it disables the option to change the closure branches.
generate_noise_methods (bool)
- generate_bare_eigensys()¶
Returns the eigensystem of the Circuit, and all the subsystems involved in the bare basis.
- generate_noise_methods()¶
This function is responsible for dynamically generating all the methods that calculate the different types of noise in the quantum circuit.
- Parameters:
self (object) – The instance of the class where this method is being added.
- Returns:
None
Notes
This function performs the following steps:
Unfreezes the circuit to allow changes.
Generates methods for calculating the derivatives of the Hamiltonian with respect to the different circuit parameters.
Generates methods for calculating the Tphi times due to 1/f noise for each branch in the circuit.
Generates methods for calculating the T1 times due to flux bias line noise for each branch in the circuit.
Generates methods for calculating the T1 times due to various noise sources for each branch in the circuit.
Generates methods for calculating the overall Tphi times due to charge coupling, flux, and ng noise for the entire circuit.
Generates methods for calculating the overall T1 times due to capacitive, charge impedance, inductive, flux bias line, and quasiparticle tunneling noise for the entire circuit.
Sets the _noise_methods_generated attribute to True.
Freezes the circuit again to prevent further changes.
The methods generated by this function are:
generate_methods_d_hamiltonian_d
generate_tphi_1_over_f_methods
generate_t1_flux_bias_line_methods
generate_t1_methods
generate_overall_tphi_cc
generate_overall_tphi_flux
generate_overall_tphi_ng
generate_overall_t1_capacitive
generate_overall_t1_charge_impedance
generate_overall_t1_inductive
generate_overall_t1_flux_bias_line
generate_overall_t1_quasiparticle_tunneling
This function does not return anything; it modifies the current instance by adding the noise calculation methods as attributes.
- 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 plotmode (
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_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_table[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 variedparam_vals (
ndarray
) – parameter values to be plugged inref_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_paramtransitions (
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 givenpoint_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:
- 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_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 (
Union
[str
,ndarray
,Qobj
,spmatrix
]) – name of class method in string form, returning operator matrixparam_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged inevals_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:
- 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 attributevars
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
- 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 fetchedwhich_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_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_table[n] containing eigenvalues calculated for parameter value param_vals[n].- Parameters:
param_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged inevals_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 (
str
) – file name if direct output to disk is wantednum_cpus (
Optional
[int
]) – number of cores to be used for computation (default value: settings.NUM_CPUS)
- Return type:
- 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 aboveprefactor (
float
) – prefactor with which the Hamiltonian and corresponding operators are multiplied, useful to set it to 2*np.pi for some qutip simulationsextra_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, ndarrayinstance – 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)
- 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 (
Union
[str
,ndarray
,Qobj
,spmatrix
]) – 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 flyevals_count (
int
) – number of desired matrix elements, starting with ground state (default value = 6)filename (
Optional
[str
]) – output file namereturn_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()¶
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
]
- oscillator_list(osc_index_list)[source]¶
If hierarchical diagonalization is used, specify subsystems that corresponds to single-mode oscillators, if there is any. The attributes _osc_subsys_list and osc_subsys_list of the
hilbert_space
attribute of the Circuit instance will be assigned accordingly, enabling the correct identification of harmonic modes for the dispersive regime analysis in ParameterSweep.- Parameters:
osc_index_list (
List
[int
]) – a list of indices of subsystems that are single-mode harmonic oscillators
- plot_coherence_vs_paramvals(param_name, param_vals, noise_channels=None, common_noise_options=None, spectrum_data=None, scale=1, num_cpus=None, **kwargs)¶
Show plots of coherence for various channels supported by the qubit as they vary as a function of a changing parameter.
For example, assuming qubit is a qubit object with
flux
being one of its parameters, one can see how coherence due to various noise channels vary as theflux
changes:qubit.plot_coherence_vs_paramvals(param_name='flux', param_vals=np.linspace(-0.5, 0.5, 100), scale=1e-3, ylabel=r"$\mu s$");
- Parameters:
param_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged innoise_channels (
Union
[str
,List
[str
],List
[Tuple
[str
,Dict
]],None
]) – channels to be plotted, if None then noise channels given by supported_noise_channels are usedcommon_noise_options (
Optional
[Dict
]) – common options used when calculating coherence timesspectrum_data (
Optional
[SpectrumData
]) – spectral data used during noise calculationsscale (float) – a number that all data is multiplied by before being plotted
num_cpus (
Optional
[int
]) – number of cores to be used for computation
- Return type:
Figure, Axes
- 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 variedparam_vals (
ndarray
) – parameter values to be plugged inref_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_paramtransitions (
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 givenpoint_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 variedparam_vals (
ndarray
) – parameter values to be plugged inevals_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 (
Union
[str
,ndarray
,Qobj
,spmatrix
]) – name of class method in string form, returning operator matrixparam_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged inselect_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 (
Union
[str
,ndarray
,Qobj
,spmatrix
]) – name of class method in string form, returning operator matrixevecs (
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_t1_effective_vs_paramvals(param_name, param_vals, noise_channels=None, common_noise_options=None, spectrum_data=None, get_rate=False, scale=1, num_cpus=None, **kwargs)¶
Plot effective \(T_1\) coherence time (rate) as a function of changing parameter.
The effective \(T_1\) is calculated by considering a variety of depolarizing noise channels, according to the formula:
\[\frac{1}{T_{1}^{\rm eff}} = \frac{1}{2} \sum_k \frac{1}{T_{1}^{k}}\]where \(k\) runs over the channels that can contribute to the effective noise. By default all the depolarizing noise channels given by the method effective_noise_channels are included.
For example, assuming qubit is a qubit object with
flux
being one of its parameters, one can see how the effective \(T_1\) varies as theflux
changes:qubit.plot_t1_effective_vs_paramvals(param_name='flux', param_vals=np.linspace(-0.5, 0.5, 100), );
- Parameters:
param_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged innoise_channels (
Union
[str
,List
[str
],List
[Tuple
[str
,Dict
]]]) – channels to be plotted, if None then noise channels given by supported_noise_channels are usedcommon_noise_options (
Dict
) – common options used when calculating coherence timesspectrum_data (
SpectrumData
) – spectral data used during noise calculationsget_rate (
bool
) – determines if rate or time should be plottedscale (
float
) – a number that all data is multiplied by before being plottednum_cpus (
Optional
[int
]) – number of cores to be used for computation
- Return type:
Figure, Axes
- plot_t2_effective_vs_paramvals(param_name, param_vals, noise_channels=None, common_noise_options=None, spectrum_data=None, get_rate=False, scale=1, num_cpus=None, **kwargs)¶
Plot effective \(T_2\) coherence time (rate) as a function of changing parameter.
The effective \(T_2\) is calculated from both pure dephasing channels, as well as depolarization channels, according to the formula:
\[\frac{1}{T_{2}^{\rm eff}} = \sum_k \frac{1}{T_{\phi}^{k}} + \frac{1}{2} \sum_j \frac{1}{T_{1}^{j}}\]where \(k\) (\(j\)) run over the relevant pure dephasing ( depolarization) channels that can contribute to the effective noise. By default all noise channels given by the method effective_noise_channels are included.
For example, assuming qubit is a qubit object with
flux
being one of its parameters, one can see how the effective \(T_2\) varies as theflux
changes:qubit.plot_t2_effective_vs_paramvals(param_name='flux', param_vals=np.linspace(-0.5, 0.5, 100), );
- Parameters:
param_name (
str
) – name of parameter to be variedparam_vals (
ndarray
) – parameter values to be plugged innoise_channels (
Union
[str
,List
[str
],List
[Tuple
[str
,Dict
]]]) – channels to be plotted, if None then noise channels given by supported_noise_channels are usedcommon_noise_options (
Dict
) – common options used when calculating coherence timesspectrum_data (
SpectrumData
) – spectral data used during noise calculationsget_rate (
bool
) – determines if rate or time should be plottedscale (
float
) – a number that all data is multiplied by before being plottednum_cpus (
Optional
[int
]) – number of cores to be used for computation
- Return type:
Figure, Axes
- 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
- 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 basisenergy_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 basisenergy_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
- qubit_list(qbt_index_list)[source]¶
If hierarchical diagonalization is used, specify subsystems that corresponds to single-mode oscillators, if there is any. The attributes _osc_subsys_list and osc_subsys_list of the hilbert_space attribute of the Circuit instance will be assigned accordingly, enabling the correct identification of harmonic modes for the dispersive regime analysis in ParameterSweep.
- Parameters:
qbt_index_list (
List
[int
]) – a list of indices of subsystems that are single-mode harmonic oscillators
- 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 (fromdynamic_var_indices
)- Returns:
Subsystem instance with var_index in its dynamic_var_indices.
- serialize()¶
Convert the content of the current class instance into IOData format.
- Return type:
- 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 formvalue (
Any
) – value that the attribute is to be set to
- Return type:
- 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 changedphi_range (
Tuple
[float
]) – The desired range for each of the discretized phi variables
- Return type:
None
- 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()[source]¶
Return a list of supported noise channels.
- Return type:
List
[str
]
- 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.
- 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 roundedprint_latex (
bool
) – if set to True, the expression is additionally printed as LaTeX codereturn_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 indicesfloat_round (
int
) – Number of digits after the decimal to which floats are roundedprint_latex (
bool
) – if set to True, the expression is additionally printed as LaTeX codereturn_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 codereturn_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 roundedprint_latex (
bool
) – if set to True, the expression is additionally printed as LaTeX codereturn_expr (
bool
) – if set to True, all printing is suppressed and the function will silently return the sympy expression
- Return type:
Optional
[Expr
]
- t1(i, j, noise_op, spectral_density, T=0.015, total=True, esys=None, get_rate=False)¶
Calculate the transition time (or rate) using Fermi’s Golden Rule due to a noise channel with a spectral density spectral_density and system noise operator noise_op. Mathematically, it reads:
\[\frac{1}{T_1} = \frac{1}{\hbar^2} |\langle i| A_{\rm noise} | j \rangle|^2 S(\omega)\]We assume that the qubit energies (or the passed in eigenspectrum) has units of frequency (and not angular frequency).
The spectral_density argument should be a callable object (typically a function) of one argument, which is assumed to be an angular frequency (in the units currently set as system units.
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
noise_op (
Union
[ndarray
,csc_matrix
]) – noise operatorT (
float
) – Temperature defined in Kelvinspectral_density (
Callable
) – defines a spectral density, must take two arguments: omega and T (assumed to be in units of 2 pi * <system units>)total (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- t1_capacitive(i=1, j=0, Q_cap=None, T=0.015, total=True, esys=None, get_rate=False, noise_op=None, branch_params=None)¶
\(T_1\) due to dielectric dissipation in the Josephson junction capacitances.
References: Smith et al (2020), see also Nguyen et al (2019).
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
Q_cap (
Union
[float
,Callable
,None
]) – capacitive quality factor; a fixed value or function of omegaT (
float
) – temperature in Kelvintotal (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or timenoise_op (ndarray | csc_matrix | Qobj | None)
branch_params (dict | None)
- Returns:
time or rate –
- decoherence time in units of \(2\pi\) (system units), or rate
in inverse units.
- Return type:
float
- t1_charge_impedance(i=1, j=0, Z=50, T=0.015, total=True, esys=None, get_rate=False, noise_op=None)¶
Noise due to charge coupling to an impedance (such as a transmission line).
References: Schoelkopf et al (2003), Ithier et al (2005)
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
Z (
Union
[float
,Callable
]) – impedance; a fixed value or function of omegaT (
float
) – temperature in Kelvintotal (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or timenoise_op (ndarray | csc_matrix | Qobj | None)
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- t1_effective(noise_channels=None, common_noise_options=None, esys=None, get_rate=False, **kwargs)¶
Calculate the effective \(T_1\) time (or rate).
The effective \(T_1\) is calculated by considering a variety of depolarizing noise channels, according to the formula:
\[\frac{1}{T_{1}^{\rm eff}} = \frac{1}{2} \sum_k \frac{1}{T_{1}^{k}}\]where \(k\) runs over the channels that can contribute to the effective noise. By default all the depolarizing noise channels given by the method effective_noise_channels are included. Users can also provide specific noise channels, with selected options, to be included in the effective \(T_1\) calculation. For example, assuming qubit is a qubit object, can can execute:
tune_tmon.t1_effective(noise_channels=['t1_charge_impedance', 't1_flux_bias_line'], common_noise_options=dict(T=0.050))
- Parameters:
noise_channels (
Union
[str
,List
[str
],List
[Tuple
[str
,Dict
]],None
]) – channels to be plotted, if None then noise channels given by supported_noise_channels are usedcommon_noise_options (
Optional
[Dict
]) – common options used when calculating coherence timesesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – spectral data used during noise calculationsget_rate (
bool
) – get rate or time
- Return type:
float
- Returns:
- decoherence time in units of \(2\pi\) (system units), or rate
in inverse units.
- t1_flux_bias_line(i=1, j=0, M=400, Z=50, T=0.015, total=True, esys=None, get_rate=False, noise_op_method=None)¶
Noise due to a bias flux line.
References: Koch et al (2007), Groszkowski et al (2018)
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
M (
float
) – Inductance in units of Phi_0 / AmpereZ (
Union
[complex
,float
,Callable
]) – A complex impedance; a fixed value or function of omegaT (
float
) – temperature in Kelvintotal (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or timenoise_op_method (Callable | None)
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- t1_inductive(i=1, j=0, Q_ind=None, T=0.015, total=True, esys=None, get_rate=False, noise_op=None, branch_params=None)¶
\(T_1\) due to inductive dissipation in a superinductor.
References: Smith et al (2020), see also Nguyen et al (2019).
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
Q_ind (
Union
[float
,Callable
]) – inductive quality factor; a fixed value or function of omegaT (
float
) – temperature in Kelvintotal (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or timenoise_op (ndarray | csc_matrix | Qobj | None)
branch_params (dict | None)
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- t1_quasiparticle_tunneling(i=1, j=0, Y_qp=None, x_qp=3e-06, T=0.015, Delta=0.00034, total=True, esys=None, get_rate=False, noise_op=None)¶
Noise due to quasiparticle tunneling across a Josephson junction.
References: Smith et al (2020), Catelani et al (2011), Pop et al (2014).
- Parameters:
i (int >=0) – state index that along with j defines a transition (i->j)
j (int >=0) – state index that along with i defines a transition (i->j)
Y_qp (
Union
[float
,Callable
,None
]) – complex admittance; a fixed value or function of omegax_qp (
float
) – quasiparticle density (in units of eV)T (
float
) – temperature in KelvinDelta (
float
) – superconducting gap (in units of eV)total (
bool
) – if False return a time/rate associated with a transition from state i to state j. if True return a time/rate associated with both i to j and j to i transitionsesys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or timenoise_op (ndarray | csc_matrix | Qobj | None)
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- t2_effective(noise_channels=None, common_noise_options=None, esys=None, get_rate=False)¶
Calculate the effective \(T_2\) time (or rate).
The effective \(T_2\) is calculated by considering a variety of pure dephasing and depolarizing noise channels, according to the formula:
\[\frac{1}{T_{2}^{\rm eff}} = \sum_k \frac{1}{T_{\phi}^{k}} + \frac{1}{2} \sum_j \frac{1}{T_{1}^{j}},\]where \(k\) (\(j\)) run over the relevant pure dephasing ( depolarization) channels that can contribute to the effective noise. By default all the noise channels given by the method effective_noise_channels are included. Users can also provide specific noise channels, with selected options, to be included in the effective \(T_2\) calculation. For example, assuming qubit is a qubit object, can can execute:
qubit.t2_effective(noise_channels=['t1_flux_bias_line', 't1_capacitive', ('tphi_1_over_f_flux', dict(A_noise=3e-6))], common_noise_options=dict(T=0.050))
- Parameters:
noise_channels (None or str or list(str) or list(tuple(str, dict))) – channels to be plotted, if None then noise channels given by supported_noise_channels are used
common_noise_options (dict) – common options used when calculating coherence times
esys (tuple(evals, evecs)) – spectral data used during noise calculations
get_rate (bool) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- tphi_1_over_f(A_noise, i, j, noise_op, esys=None, get_rate=False, **kwargs)¶
Calculate the 1/f dephasing time (or rate) due to arbitrary noise source.
We assume that the qubit energies (or the passed in eigenspectrum) has units of frequency (and not angular frequency).
- Parameters:
A_noise (
float
) – noise strengthi (int >=0) – state index that along with j defines a qubit
j (int >=0) – state index that along with i defines a qubit
noise_op (
Union
[ndarray
,csc_matrix
]) – noise operator, typically Hamiltonian derivative w.r.t. noisy parameteresys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- tphi_1_over_f_cc(A_noise=1e-07, i=0, j=1, esys=None, get_rate=False, **kwargs)¶
Calculate the 1/f dephasing time (or rate) due to critical current noise.
- Parameters:
A_noise (
float
) – noise strengthi (int >=0) – state index that along with j defines a qubit
j (int >=0) – state index that along with i defines a qubit
esys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- tphi_1_over_f_flux(A_noise=1e-06, i=0, j=1, esys=None, get_rate=False, **kwargs)¶
Calculate the 1/f dephasing time (or rate) due to flux noise.
- Parameters:
A_noise (
float
) – noise strengthi (int >=0) – state index that along with j defines a qubit
j (int >=0) – state index that along with i defines a qubit
esys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- tphi_1_over_f_ng(A_noise=0.0001, i=0, j=1, esys=None, get_rate=False, **kwargs)¶
Calculate the 1/f dephasing time (or rate) due to charge noise.
- Parameters:
A_noise (
float
) – noise strengthi (int >=0) – state index that along with j defines a qubit
j (int >=0) – state index that along with i defines a qubit
esys (
Optional
[Tuple
[ndarray
,ndarray
]]) – evals, evecs tupleget_rate (
bool
) – get rate or time
- Returns:
time or rate – decoherence time in units of \(2\pi\) (system units), or rate in inverse units.
- Return type:
float
- transition_energy_derivative(ni, nf, esys, hamiltonian_derivative)¶
Returns the first order and second order derivative of the nth eigenenergy.
- update(calculate_bare_esys=True)¶
Syncs all the parameters of the subsystems with the current instance.
- Parameters:
calculate_bare_esys (bool)
- variable_transformation(new_vars_to_node_vars=True)[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)