78 lines
4.6 KiB
Plaintext
78 lines
4.6 KiB
Plaintext
---
|
||
title: excitation_preserving (latest version)
|
||
description: API reference for qiskit.circuit.library.excitation_preserving in the latest version of qiskit
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.circuit.library.excitation_preserving
|
||
---
|
||
|
||
<span id="excitation-preserving" />
|
||
|
||
# excitation\_preserving
|
||
|
||
<Class id="qiskit.circuit.library.excitation_preserving" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/circuit/library/n_local/excitation_preserving.py#L26-L140" signature="qiskit.circuit.library.excitation_preserving(num_qubits, mode='iswap', entanglement='full', reps=3, skip_unentangled_qubits=False, skip_final_rotation_layer=False, parameter_prefix='θ', insert_barriers=False, name='ExcitationPreserving')" modifiers="class">
|
||
Bases:
|
||
|
||
The heuristic excitation-preserving wave function ansatz.
|
||
|
||
The `excitation_preserving` circuit preserves the ratio of $|00\rangle$, $|01\rangle + |10\rangle$ and $|11\rangle$ states. To this end, this circuit uses two-qubit interactions of the form
|
||
|
||
$$
|
||
\newcommand{\rotationangle}{\theta/2}
|
||
|
||
\begin{pmatrix}
|
||
1 & 0 & 0 & 0 \\
|
||
0 & \cos\left(\rotationangle\right) & -i\sin\left(\rotationangle\right) & 0 \\
|
||
0 & -i\sin\left(\rotationangle\right) & \cos\left(\rotationangle\right) & 0 \\
|
||
0 & 0 & 0 & e^{-i\phi}
|
||
\end{pmatrix}
|
||
$$
|
||
|
||
for the mode `"fsim"` or with $e^{-i\phi} = 1$ for the mode `"iswap"`.
|
||
|
||
Note that other wave functions, such as UCC-ansatzes, are also excitation preserving. However these can become complex quickly, while this heuristically motivated circuit follows a simpler pattern.
|
||
|
||
This trial wave function consists of layers of $Z$ rotations with 2-qubit entanglements. The entangling is creating using $XX+YY$ rotations and optionally a controlled-phase gate for the mode `"fsim"`.
|
||
|
||
**Examples**
|
||
|
||
With linear entanglement, this circuit is given by:
|
||
|
||
```python
|
||
from qiskit.circuit.library import excitation_preserving
|
||
|
||
ansatz = excitation_preserving(3, reps=1, insert_barriers=True, entanglement="linear")
|
||
ansatz.draw("mpl")
|
||
```
|
||
|
||

|
||
|
||
The entanglement structure can be explicitly specified with the `entanglement` argument. The `"fsim"` mode includes an additional parameterized [`CPhaseGate`](qiskit.circuit.library.CPhaseGate "qiskit.circuit.library.CPhaseGate") in each block:
|
||
|
||
```python
|
||
ansatz = excitation_preserving(3, reps=1, mode="fsim", entanglement=[[0, 2]])
|
||
ansatz.draw("mpl")
|
||
```
|
||
|
||

|
||
|
||

|
||
|
||
**Parameters**
|
||
|
||
* **num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The number of qubits.
|
||
* **mode** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – Choose the entangler mode, can be “iswap” or “fsim”.
|
||
* **reps** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – Specifies how often the structure of a rotation layer followed by an entanglement layer is repeated.
|
||
* **entanglement** (*BlockEntanglement | Iterable\[BlockEntanglement] | Callable\[\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*], BlockEntanglement | Iterable\[BlockEntanglement]]*) – The indices specifying on which qubits the input blocks act. See `n_local()` for detailed information.
|
||
* **skip\_final\_rotation\_layer** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – Whether a final rotation layer is added to the circuit.
|
||
* **skip\_unentangled\_qubits** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – If `True`, the rotation gates act only on qubits that are entangled. If `False`, the rotation gates act on all qubits.
|
||
* **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The name of the free parameters.
|
||
* **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – If True, barriers are inserted in between each layer. If False, no barriers are inserted.
|
||
* **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The name of the circuit.
|
||
|
||
**Returns**
|
||
|
||
An excitation-preserving circuit.
|
||
</Class>
|
||
|