HilbertSpace#
- class scqubits.core.hilbert_space.HilbertSpace(subsystem_list, interaction_list=None, ignore_low_overlap=False)[source]#
Class holding information about the full Hilbert space, usually composed of multiple subsys_list. The class provides methods to turn subsystem operators into operators acting on the full Hilbert space, and establishes the interface to qutip. Returned operators are of the qutip.Qobj type. The class also provides methods for obtaining eigenvalues, absorption and emission spectra as a function of an external parameter.
- Parameters
subsystem_list (
List[Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]]) – List of all quantum systems comprising the composite Hilbert spaceinteraction_list (
Optional[List[Union[InteractionTerm,InteractionTermStr]]]) – (optional) typically, interaction terms are added one by one by means of the add_interaction method. Alternatively, a list of interaction term objects can be supplied here upon initialization of a HilbertSpace instance.
- Return type
Methods
HilbertSpace.__init__(subsystem_list[, ...])HilbertSpace.add_interaction([...])Specify the interaction between subsystems making up the HilbertSpace instance.
HilbertSpace.all_params_fixed(param_indices)Checks whether the indices provided fix all the parameters.
HilbertSpace.annihilate(subsystem)Annihilation operator a for subsystem
HilbertSpace.bare_eigenstates(subsys[, ...])Return ndarray of bare eigenstates for given subsystems and parameter index.
HilbertSpace.bare_eigenvals(subsys[, ...])Return NamedSlotsNdarray of bare eigenenergies for given subsystem, usually to be used with preslicing.
HilbertSpace.bare_hamiltonian([bare_esys])- type bare_esys
Optional[Dict[int,ndarray]]
HilbertSpace.bare_index(dressed_index[, ...])For given dressed index, look up the corresponding bare index.
HilbertSpace.bare_productstate(bare_index)Return the bare product state specified by bare_index.
HilbertSpace.broadcast(event, **kwargs)Request a broadcast from CENTRAL_DISPATCH reporting event.
HilbertSpace.create()- rtype
HilbertSpace
HilbertSpace.create_from_file(filename)Read initdata and spectral data from file, and use those to create a new SpectrumData object.
HilbertSpace.deserialize(io_data)Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
HilbertSpace.diag_hamiltonian(subsystem[, evals])Returns a qutip.Qobj which has the eigenenergies of the object subsystem on the diagonal.
HilbertSpace.diag_operator(diag_elements, ...)For given diagonal elements of a diagonal operator in subsystem, return the Qobj operator for the full Hilbert space (perform wrapping in identities for other subsys_list).
HilbertSpace.dressed_index(bare_labels[, ...])For given bare product state return the corresponding dressed-state index.
HilbertSpace.eigensys([evals_count, bare_esys])Calculates eigenvalues and eigenvectors of the full Hamiltonian using qutip.Qob.eigenstates().
HilbertSpace.eigenvals([evals_count, bare_esys])Calculates eigenvalues of the full Hamiltonian using qutip.Qob.eigenenergies().
HilbertSpace.energy_by_bare_index(bare_tuple)Look up dressed energy most closely corresponding to the given bare-state labels
HilbertSpace.energy_by_dressed_index(...[, ...])Look up the dressed eigenenergy belonging to the given dressed index, usually to be used with pre-slicing
HilbertSpace.filewrite(filename)Convenience method bound to the class.
For each parameter value of the parameter sweep, generate the map between bare states and dressed states.
Returns dict appropriate for creating/initializing a new HilbertSpace object.
Return eigenvalues (and optionally eigenstates) of the full Hamiltonian as a function of a parameter.
HilbertSpace.get_subsys_index(subsys)Return the index of the given subsystem in the HilbertSpace.
HilbertSpace.hamiltonian([bare_esys])- type bare_esys
Optional[Dict[int,ndarray]]
HilbertSpace.hubbard_operator(j, k, subsystem)Hubbard operator \(|j\rangle\langle k|\) for system subsystem
HilbertSpace.interaction_hamiltonian([bare_esys])Returns the interaction Hamiltonian, based on the interaction terms specified for the current HilbertSpace object
HilbertSpace.receive(event, sender, **kwargs)Receive a message from CENTRAL_DISPATCH and initiate action on it.
Convert the content of the current class instance into IOData format.
HilbertSpace.set_npindextuple([param_indices])- rtype
Tuple[Union[int,slice,Tuple[int],List[int]],...]
HilbertSpace.subsys_by_id_str(id_str)- rtype
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]
Attributes
Returns total dimension of joint Hilbert space
[Legacy] Auxiliary reference to self for compatibility with SpectrumLookupMixin class.
interaction_listDescriptor class for properties that are to be monitored for changes.
[Legacy] supporting old lookup interface.
osc_subsys_listDescriptor for read-only properties (stored in xxx._name)
qbt_subsys_listDescriptor for read-only properties (stored in xxx._name)
subsys_listReturns number of subsys_list composing the joint Hilbert space
Returns list of the Hilbert space dimensions of each subsystem
subsystem_list- add_interaction(check_validity=True, id_str=None, **kwargs)[source]#
Specify the interaction between subsystems making up the HilbertSpace instance. add_interaction(…) offers three different interfaces: :rtype:
NoneSimple interface for operator products
String-based interface for more general interaction operator expressions
General Qobj interface
- Simple interface for operator products
Specify ndarray, csc_matrix, or dia_matrix (subsystem operator in subsystem-internal basis) along with the corresponding subsystem
signature:
.add_interaction(g=<float>, op1=(<ndarray>, <QuantumSystem>), op2=(<csc_matrix>, <QuantumSystem>), …, add_hc=<bool>)Alternatively, specify subsystem operators via callable methods.
signature:
.add_interaction(g=<float>, op1=<Callable>, op2=<Callable>, …, add_hc=<bool>)
- String-based interface for more general interaction operator expressions
Specify a Python expression that generates the desired operator. The expression enables convenience use of basic qutip operations:
.add_interaction(expr=<str>, op1=(<str>, <ndarray>, <subsys>), op2=(<str>, <Callable>), …)
- General Qobj operator
Specify a fully identity-wrapped qutip.Qobj operator. Signature:
.add_interaction(qobj=<Qobj>)
- id_str:
optional string by which this instance can be referred to in HilbertSpace and ParameterSweep. If not provided, an id is auto-generated.
- Parameters
id_str (Optional[str]) –
- Return type
None
- all_params_fixed(param_indices)#
Checks whether the indices provided fix all the parameters.
- Parameters
param_indices (
Union[slice,tuple]) – Tuple or slice fixing all or a subset of the parameters.- Return type
bool- Returns
True if all parameters are being fixed by param_indices.
- annihilate(subsystem)[source]#
Annihilation operator a for subsystem
- Parameters
subsystem (
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) – specifies subsystem in which annihilation operator acts- Return type
Qobj
- bare_eigenstates(subsys, param_indices=None)#
Return ndarray of bare eigenstates for given subsystems and parameter index. Eigenstates are expressed in the basis internal to the subsystems. Usually to be with pre-slicing.
- Return type
- Parameters
subsys (Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) –
param_indices (Optional[Tuple[int, ...]]) –
- bare_eigenvals(subsys, param_indices=None)#
Return NamedSlotsNdarray of bare eigenenergies for given subsystem, usually to be used with preslicing.
- Parameters
subsys (
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) – Hilbert space subsystem for which bare eigendata is to be looked upparam_indices (
Optional[Tuple[int,...]]) – position indices of parameter values in question
- Return type
- Returns
bare eigenenergies for the specified subsystem and the external parameter fixed to the value indicated by its index
- bare_hamiltonian(bare_esys=None)[source]#
- Parameters
bare_esys (
Optional[Dict[int,ndarray]]) – optionally, the bare eigensystems for each subsystem can be provided to speed up computation; these are provided in dict form via <subsys>: esys- Return type
Qobj- Returns
composite Hamiltonian composed of bare Hamiltonians of subsys_list independent of the external parameter
- bare_index(dressed_index, param_indices=None)#
For given dressed index, look up the corresponding bare index.
- Return type
Optional[Tuple[int,...]]- Returns
Bare state specification in tuple form. Example: (1,0,3) means subsystem 1 is in bare state 1, subsystem 2 in bare state 0, and subsystem 3 in bare state 3.
- Parameters
dressed_index (int) –
param_indices (Optional[Tuple[int, ...]]) –
- bare_productstate(bare_index)#
Return the bare product state specified by bare_index. Note: no parameter dependence here, since the Hamiltonian is always represented in the bare product eigenbasis.
- Parameters
bare_index (
Tuple[int,...]) –- Return type
Qobj- Returns
ket in full Hilbert space
- broadcast(event, **kwargs)#
Request a broadcast from CENTRAL_DISPATCH reporting event.
- Parameters
event (
str) – event name from EVENTS**kwargs –
- Return type
None
- 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) –
- classmethod deserialize(io_data)[source]#
Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
- Return type
- Parameters
io_data (IOData) –
- diag_hamiltonian(subsystem, evals=None)[source]#
Returns a qutip.Qobj which has the eigenenergies of the object subsystem on the diagonal.
- Parameters
subsystem (
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) – Subsystem for which the Hamiltonian is to be provided.evals (
Optional[ndarray]) – Eigenenergies can be provided as evals; otherwise, they are calculated.
- Return type
Qobj
- diag_operator(diag_elements, subsystem)[source]#
For given diagonal elements of a diagonal operator in subsystem, return the Qobj operator for the full Hilbert space (perform wrapping in identities for other subsys_list).
- Parameters
diag_elements (
ndarray) – diagonal elements of subsystem diagonal operatorsubsystem (
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) – subsystem where diagonal operator is defined
- Return type
Qobj
- property dimension: int#
Returns total dimension of joint Hilbert space
- dressed_index(bare_labels, param_indices=None)#
For given bare product state return the corresponding dressed-state index.
- Parameters
bare_labels (
Tuple[int,...]) – bare_labels = (index, index2, …)param_indices (
Union[int,slice,Tuple[int],List[int],Tuple[Union[int,slice,Tuple[int],List[int]],...],None]) – indices of parameter values of interest
- Return type
Union[ndarray,int,None]- Returns
dressed state index closest to the specified bare state
- eigensys(evals_count=6, bare_esys=None)[source]#
Calculates eigenvalues and eigenvectors of the full Hamiltonian using qutip.Qob.eigenstates().
- Parameters
evals_count (
int) – number of desired eigenvalues/eigenstatesbare_esys (
Optional[Dict[int,Union[ndarray,List[ndarray]]]]) – optionally, the bare eigensystems for each subsystem can be provided to speed up computation; these are provided in dict form via <subsys>: esys
- Return type
Tuple[ndarray,QutipEigenstates]- Returns
eigenvalues and eigenvectors
- eigenvals(evals_count=6, bare_esys=None)[source]#
Calculates eigenvalues of the full Hamiltonian using qutip.Qob.eigenenergies().
- Parameters
evals_count (
int) – number of desired eigenvalues/eigenstatesbare_esys (
Optional[Dict[int,Union[ndarray,List[ndarray]]]]) – optionally, the bare eigensystems for each subsystem can be provided to speed up computation; these are provided in dict form via <subsys>: esys
- Return type
ndarray
- energy_by_bare_index(bare_tuple, subtract_ground=False, param_indices=None)#
Look up dressed energy most closely corresponding to the given bare-state labels
- Parameters
bare_tuple (
Tuple[int,...]) – bare state indicessubtract_ground (
bool) – whether to subtract the ground state energyparam_indices (
Union[int,slice,Tuple[int],List[int],Tuple[Union[int,slice,Tuple[int],List[int]],...],None]) – indices specifying the set of parameters
- Return type
- Returns
dressed energies, if lookup successful, otherwise nan;
- energy_by_dressed_index(dressed_index, subtract_ground=False, param_indices=None)#
Look up the dressed eigenenergy belonging to the given dressed index, usually to be used with pre-slicing
- Parameters
dressed_index (
int) – index of dressed state of interestsubtract_ground (
bool) – whether to subtract the ground state energyparam_indices (
Optional[Tuple[int,...]]) – specifies the desired choice of parameter values
- Return type
float- Returns
dressed energy
- filewrite(filename)#
Convenience method bound to the class. Simply accesses the write function.
- Return type
None- Parameters
filename (str) –
- generate_lookup()[source]#
For each parameter value of the parameter sweep, generate the map between bare states and dressed states.
- Return type
None- Returns
each list item is a list of dressed indices whose order corresponds to the ordering of bare indices (as stored in .canonical_bare_labels, thus establishing the mapping)
- get_initdata()[source]#
Returns dict appropriate for creating/initializing a new HilbertSpace object.
- Return type
Dict[str,Any]
- get_spectrum_vs_paramvals(param_vals, update_hilbertspace, evals_count=10, get_eigenstates=False, param_name='external_parameter', num_cpus=None)[source]#
Return eigenvalues (and optionally eigenstates) of the full Hamiltonian as a function of a parameter. Parameter values are specified as a list or array in param_vals. The Hamiltonian hamiltonian_func must be a function of that particular parameter, and is expected to internally set subsystem parameters. If a filename string is provided, then eigenvalue data is written to that file.
- Parameters
param_vals (
ndarray) – array of parameter valuesupdate_hilbertspace (
Callable) – update_hilbertspace(param_val) specifies how a change in the external parameter affects the Hilbert space componentsevals_count (
int) – number of desired energy levels (default value = 10)get_eigenstates (
bool) – set to true if eigenstates should be returned as well (default value = False)param_name (
str) – name for the parameter that is varied in param_vals (default value = “external_parameter”)num_cpus (
Optional[int]) – number of cores to be used for computation (default value: settings.NUM_CPUS)
- Return type
- get_subsys_index(subsys)[source]#
Return the index of the given subsystem in the HilbertSpace.
- Return type
int- Parameters
subsys (Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) –
- hamiltonian(bare_esys=None)[source]#
- Parameters
bare_esys (
Optional[Dict[int,ndarray]]) – optionally, the bare eigensystems for each subsystem can be provided to speed up computation; these are provided in dict form via <subsys>: esys- Return type
Qobj- Returns
Hamiltonian of the composite system, including the interaction between components
- property hilbertspace: HilbertSpace#
[Legacy] Auxiliary reference to self for compatibility with SpectrumLookupMixin class.
- hubbard_operator(j, k, subsystem)[source]#
Hubbard operator \(|j\rangle\langle k|\) for system subsystem
- Parameters
j (
int) – eigenstate indices for Hubbard operatork (
int) – eigenstate indices for Hubbard operatorsubsystem (
Union[QubitBaseClass, Oscillator, KerrOscillator, GenericQubit]) – subsystem in which Hubbard operator acts
- Return type
Qobj
- interaction_hamiltonian(bare_esys=None)[source]#
Returns the interaction Hamiltonian, based on the interaction terms specified for the current HilbertSpace object
- Parameters
bare_esys (
Optional[Dict[int,ndarray]]) – optionally, the bare eigensystems for each subsystem can be provided to speed up computation; these are provided in dict form via <subsys>: esys- Return type
Qobj- Returns
interaction Hamiltonian
- property lookup#
[Legacy] supporting old lookup interface.
- receive(event, sender, **kwargs)[source]#
Receive a message from CENTRAL_DISPATCH and initiate action on it.
- Parameters
event (
str) – event name from EVENTSsender (
Any) – original sender reporting the event**kwargs –
- Return type
None
- serialize()[source]#
Convert the content of the current class instance into IOData format.
- Return type
- property subsystem_count: int#
Returns number of subsys_list composing the joint Hilbert space
- property subsystem_dims: List[int]#
Returns list of the Hilbert space dimensions of each subsystem