HilbertSpace Class

HilbertSpace

class scqubits.HilbertSpace(subsystem_list, interaction_list=None)[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.

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:

  • Simple interface for operator products

  • String-based interface for more general interaction operator expressions

  • General Qobj interface

  1. 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>)
    
  2. 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>),
                     …)
    
  3. 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.

Return type

None

annihilate(subsystem)[source]

Annihilation operator a for subsystem

Parameters

subsystem (Union[QubitBaseClass, Oscillator]) – specifies subsystem in which annihilation operator acts

Return type

Qobj

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

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

SpectrumData

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

HilbertSpace

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]) – 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 operator

  • subsystem (Union[QubitBaseClass, Oscillator]) – subsystem where diagonal operator is defined

Return type

Qobj

property dimension: int

Returns total dimension of joint Hilbert space

Return type

int

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/eigenstates

  • 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

Returns

Return type

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/eigenstates

  • 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

ndarray

filewrite(filename)

Convenience method bound to the class. Simply accesses the write function.

Return type

None

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 values

  • update_hilbertspace (Callable) – update_hilbertspace(param_val) specifies how a change in the external parameter affects the Hilbert space components

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

SpectrumData

get_subsys_index(subsys)[source]

Return the index of the given subsystem in the HilbertSpace.

Return type

int

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

hubbard_operator(j, k, subsystem)[source]

Hubbard operator \(|j\rangle\langle k|\) for system subsystem

Parameters
  • j (int) – eigenstate indices for Hubbard operator

  • k (int) – eigenstate indices for Hubbard operator

  • subsystem (Union[QubitBaseClass, Oscillator]) – 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

Returns

Return type

interaction Hamiltonian

interactionterm_hamiltonian(interactionterm, evecs1=None, evecs2=None)[source]

Deprecated, will not work in future versions.

Return type

Qobj

receive(event, sender, **kwargs)[source]

Receive a message from CENTRAL_DISPATCH and initiate action on it.

Parameters
  • event (str) – event name from EVENTS

  • sender (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

IOData

property subsystem_count: int

Returns number of subsys_list composing the joint Hilbert space

Return type

int

property subsystem_dims: List[int]

Returns list of the Hilbert space dimensions of each subsystem

Return type

List[int]