QubitHamiltonian#

class QubitHamiltonian(frequency, drives=None)[source]#

Bases: Hamiltonian

Hamiltonian 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.

__init__(frequency, drives=None)[source]#
Parameters:
  • frequency (Quantity) – Frequency of the qubit.

  • drives (list[Drive] | None) – List of time-dependent drives.

Methods

__init__(frequency[, drives])

dimension()

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.

get_drive_parameters()

Return the combined list of parameters from all drives.

get_gradient(times)

Calculate the gradient of the Hamiltonian at different times.

get_parameters()

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

all_optimizable_parameters

Get the optimizable parameters.

name

Get the name of the parameter.

optimizable_parameters

Get the optimizable parameters.

sigma_minus

Return the sigma minus operator.

sigma_plus

Return the sigma plus operator.

sigma_x

Return the Pauli X operator.

sigma_y

Return the Pauli Y operator.

sigma_z

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:

int

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_drive_parameters()[source]#

Return the combined list of parameters from all drives.

Returns:

The combined list of parameters from all drives.

Return type:

list[Quantity]

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_parameters()[source]#

Get parameters of the model.

Returns:

The list of parameters of the system.

Return type:

list[Quantity]

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 name: str | None#

Get the name of the parameter.

Returns:

Name of the parameter.

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.

Parameters:

all_params (list[Quantity]) – List of optimizable parameters to be set.

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.

Parameters:

params (list[Quantity]) – List of optimizable parameters to be set.

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.