quairkit.ansatz.trotter

class quairkit.ansatz.trotter.TrotterLayer(hamiltonian, qubits_idx, tau, num_steps, order, name)

Add time-evolving circuits to a user-specified circuit.

This circuit could approximate the time-evolving operator of a system given its Hamiltonian H, i.e., \(U_{\rm cir}~ e^{-iHt}\).

Parameters:
hamiltonian : Hamiltonian

Hamiltonian of the system whose time evolution is to be simulated.

qubits_idx : List[int]

Indices of the qubits on which the layer is applied.

tau : float

Evolution time of each trotter block.

num_steps : int

Number of trotter blocks that will be added in total, where num_steps * tau should be the total evolution time.

order : int

Order of the Trotter-Suzuki decomposition.

name : str

Name of the Hamiltonian. Defaults to ‘H’.

Raises:
  • ValueError – The order of the trotter-suzuki decomposition should be either 1, 2 or 2k (k an integer)

  • ValueError – The number of qubits_idx must be bigger than the number of qubits in the Hamiltonian

  • ValueError – Grouping method grouping is not supported, valid key words: ‘xyz’, ‘even_odd’

  • ValueError – The method method is not supported, valid method keywords: ‘suzuki’, ‘custom’

property fidelity : float

The fidelity of the Trotterization.

get_suzuki_p_values(k)

Calculate the parameter p(k) in the Suzuki recurrence relationship.

Parameters:
k : int

Order of the Suzuki decomposition.

Returns:

A list of length five of form [p, p, (1 - 4 * p), p, p].

Return type:

List

add_n_pauli_gate(theta, pauli_word, which_qubits)

Add a rotation gate for a tensor product of Pauli operators, for example \(e^{-\theta/2 * X \otimes I \otimes X \otimes Y}\).

Parameters:
theta : Tensor | float

Rotation angle.

pauli_word : str

Pauli operators in a string format, e.g., "XXZ".

which_qubits : Iterable

List of the index of the qubit that each Pauli operator in the pauli_word acts on.

Raises:

ValueError – The which_qubits should be either list, tuple, or np.ndarray.