QubitHamiltonian#
- class QubitHamiltonian(frequency, drives=None)[source]#
Bases:
HamiltonianHamiltonian of a single qubit, -frequency / 2 * pauli_z + drive.
The implementation uses the quantum information convention of having \(|0\rangle\) = [1 0]^T as ground state and \(|1\rangle\) = [0 1]^T as excited state, compatible with the projection of a higher-dimensional system. Hence, the Hamiltonian should be taken with a minus sign.
Methods
__init__(frequency[, drives])Return the dimension of the Hilbert space of the system.
get_drive_gradients(times)Return the gradients of all drives.
get_drive_matrix(times)Return the sum of all drives in matrix form.
Return the combined list of parameters from all drives.
get_gradient(times)Calculate the gradient of the Hamiltonian at different times.
Get parameters of the model.
get_value(times)Calculate the Hamiltonian at different times.
get_value_and_gradient(times)Calculate the value and the gradient of the object.
set_all_optimizable_parameters(all_params)Set all optimizable parameters in the optimization.
set_optimizable_parameters(params)Set which parameters associated with the object shall be considered during optimization.
Attributes
Get the optimizable parameters.
Get the name of the parameter.
Get the optimizable parameters.
Return the sigma minus operator.
Return the sigma plus operator.
Return the Pauli X operator.
Return the Pauli Y operator.
Return the Pauli Z operator.
drives- property all_optimizable_parameters: list[Quantity]#
Get the optimizable parameters.
- Returns:
The list of all the optimizable parameters considered in the optimization.
- dimension()[source]#
Return the dimension of the Hilbert space of the system.
- Returns:
Hilbert space dimension.
- Return type:
- get_drive_gradients(times)[source]#
Return the gradients of all drives.
This function can be used by Hamiltonian implementations for including the drive gradients.
- Parameters:
times (Array) – Array of time samples.
- Returns:
The gradients of all drives.
- Return type:
Array
- get_drive_matrix(times)[source]#
Return the sum of all drives in matrix form.
This function can be used by Hamiltonian implementations for including the drive.
- Parameters:
times (Array) – Array of times.
- Returns:
The sum of all drives in matrix form.
- Return type:
Array
- get_gradient(times)[source]#
Calculate the gradient of the Hamiltonian at different times.
- Parameters:
times (Array) – Array of times.
- Returns:
The gradient of the Hamiltonian. The dimension should be (n_times, n_params, dimension, dimension).
- Return type:
Array
- get_value(times)[source]#
Calculate the Hamiltonian at different times.
- Parameters:
times (Array) – Array of times.
- Returns:
The value of the Hamiltonian matrix at different times. The dimension should be (n_times, dimension, dimension).
- Return type:
Array
- get_value_and_gradient(times)[source]#
Calculate the value and the gradient of the object.
Note
The default implementation here gathers the value and the gradient separately. For cases where the value can be obtained during the gradient calculation, this method is overwritten for efficiency.
- Returns:
The value and the gradient of the object.
- Return type:
tuple[Array | Float, Array]
- property optimizable_parameters: list[Quantity]#
Get the optimizable parameters.
- Returns:
The list of optimizable parameters associated with the object.
- set_all_optimizable_parameters(all_params)[source]#
Set all optimizable parameters in the optimization.
- set_optimizable_parameters(params)[source]#
Set which parameters associated with the object shall be considered during optimization.
All quantities that are not in the response of get_parameters will be filtered out. This function is called by the optimizer before gradient based optimization to tell the layers which gradients to compute.
- property sigma_minus: Array#
Return the sigma minus operator.
- property sigma_plus: Array#
Return the sigma plus operator.
- property sigma_x: Array#
Return the Pauli X operator.
- property sigma_y: Array#
Return the Pauli Y operator.
- property sigma_z: Array#
Return the Pauli Z operator.