uniqc.algorithmics.circuits.thermal_state module#

Thermal state preparation circuit.

uniqc.algorithmics.circuits.thermal_state.thermal_state_circuit(circuit, beta, qubits=None)[source]#

Prepare a thermal state via single-qubit rotations.

For the transverse-field-free Hamiltonian \(H = \sum_i Z_i\), the thermal (Gibbs) state at inverse temperature \(\beta\) factorises into a product of single-qubit states. Each qubit is prepared in

\[\sqrt{p_0}\,|0\rangle + \sqrt{p_1}\,|1\rangle\]

where

\[p_0 = \frac{e^{\beta}}{e^{\beta}+e^{-\beta}}, \qquad p_1 = 1 - p_0.\]

This is achieved by applying \(R_y(\theta)\) with \(\theta = 2\arccos(\sqrt{p_0})\) to every qubit independently.

This is a lightweight, circuit-only counterpart of state_preparation.thermal_state for the default Hamiltonian case.

Parameters:
  • circuit (Circuit) – Quantum circuit to operate on (mutated in-place).

  • beta (float) – Inverse temperature (\(\beta > 0\)). Larger values bias the state towards \(|0\rangle\).

  • qubits (List[int] | None) – Qubit indices to use. None means all qubits of circuit (list(range(circuit.qubit_num))).

Raises:

ValueErrorbeta is negative.

Return type:

None

Example

>>> from uniqc.circuit_builder import Circuit
>>> from uniqc.algorithmics.circuits import thermal_state_circuit
>>> c = Circuit(3)
>>> thermal_state_circuit(c, beta=1.0)