124 lines
7.9 KiB
Plaintext
124 lines
7.9 KiB
Plaintext
---
|
||
title: tenpy_tebd (latest version)
|
||
description: API reference for qiskit_addon_mpf.backends.tenpy_tebd in the latest version of qiskit-addon-mpf
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit_addon_mpf.backends.tenpy_tebd
|
||
---
|
||
|
||
<span id="module-qiskit_addon_mpf.backends.tenpy_tebd" />
|
||
|
||
<span id="tenpy-tebd-backend-qiskit-addon-mpf-backends-tenpy-tebd" />
|
||
|
||
# TeNPy TEBD backend
|
||
|
||
`qiskit_addon_mpf.backends.tenpy_tebd`
|
||
|
||
A [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")-based TEBD backend.
|
||
|
||
<Admonition title="Caution" type="note">
|
||
The optional dependency [TeNPy](https://github.com/tenpy/tenpy) was previously offered under a GPLv3 license. As of the release of [v1.0.4](https://github.com/tenpy/tenpy/releases/tag/v1.0.4) on October 2nd, 2024, it has been offered under the Apache v2 license. The license of this package is only compatible with Apache-licensed versions of TeNPy.
|
||
</Admonition>
|
||
|
||
<Admonition title="Warning" type="caution">
|
||
This backend is only available if the optional dependencies have been installed:
|
||
|
||
```python
|
||
pip install "qiskit-addon-mpf[tenpy]"
|
||
```
|
||
</Admonition>
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
|
||
| [`TEBDEvolver`](backends-tenpy-tebd-tebd-evolver "qiskit_addon_mpf.backends.tenpy_tebd.TEBDEvolver") | A TEBD algorithm for evolving an internal MPO. |
|
||
| [`MPOState`](backends-tenpy-tebd-mpo-state "qiskit_addon_mpf.backends.tenpy_tebd.MPOState") | A mediator class to make TeNPy's MPO match the [`State`](backends#state "qiskit_addon_mpf.backends.State") interface. |
|
||
| [`MPS_neel_state`](backends-tenpy-tebd-mps-neel-state "qiskit_addon_mpf.backends.tenpy_tebd.MPS_neel_state") | Constructs the Néel state as an MPS. |
|
||
|
||
## Underlying method
|
||
|
||
This module provides a time-evolution backend for computing dynamic MPF coefficients based on the time-evolving block decimation (TEBD) algorithm \[1] implemented in the [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)") tensor network library.
|
||
|
||
The classes provided by this module serve two purposes:
|
||
|
||
1. Connecting [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")’s implementation to the interface set out by [`qiskit_addon_mpf.backends`](backends#module-qiskit_addon_mpf.backends "qiskit_addon_mpf.backends").
|
||
2. Extending [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")’s TEBD implementation to handle an internal MPO (rather than MPS) state (see also [`State`](backends#state "qiskit_addon_mpf.backends.State") for more details).
|
||
|
||
In the simplest sense, this module provides a straight-forward extension of the TEBD algorithm to evolve an internal MPO state. As such, if you wish to use this backend for your dynamic MPF algorithm, you must encode the Hamiltonian that you wish to time-evolve, in a [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")-native form. To be more concrete, the [`TEBDEvolver`](backends-tenpy-tebd-tebd-evolver "qiskit_addon_mpf.backends.tenpy_tebd.TEBDEvolver") class (which is a subclass of [`tenpy.algorithms.tebd.TEBDEngine`](https://tenpy.readthedocs.io/en/latest/reference/tenpy.algorithms.tebd.TEBDEngine.html#tenpy.algorithms.tebd.TEBDEngine "(in TeNPy v1.0.5)")) works with a Hamiltonian in the form of a [`Model`](https://tenpy.readthedocs.io/en/latest/reference/tenpy.models.model.Model.html#tenpy.models.model.Model "(in TeNPy v1.0.5)"). TeNPy provides a number of convenience methods for constructing such Hamiltonians in its [`tenpy.models`](https://tenpy.readthedocs.io/en/latest/reference/tenpy.models.html#module-tenpy.models "(in TeNPy v1.0.5)") module. If none of those fulfill your needs, you can consider using the [`LayerModel`](backends-tenpy-layers-layer-model "qiskit_addon_mpf.backends.tenpy_layers.LayerModel") class which implements some conversion methods from Qiskit-native objects.
|
||
|
||
## Code example
|
||
|
||
This section shows a simple example to get you started with using this backend. The example shows how to create the three factory functions required for the [`setup_dynamic_lse()`](dynamic#setup_dynamic_lse "qiskit_addon_mpf.dynamic.setup_dynamic_lse").
|
||
|
||
First of all, we define the Hamiltonian which we would like to time-evolve. Here, we simply choose one of [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")’s convenience methods.
|
||
|
||
```python
|
||
>>> from tenpy.models import XXZChain2
|
||
>>> hamil = XXZChain2(
|
||
... {
|
||
... "L": 10,
|
||
... "Jz": 0.8,
|
||
... "Jxx": 0.7,
|
||
... "hz": 0.3,
|
||
... "bc_MPS": "finite",
|
||
... "sort_charge": False,
|
||
... }
|
||
... )
|
||
```
|
||
|
||
Next, we can create the `identity_factory` which has to match the [`IdentityStateFactory`](dynamic#identitystatefactory "qiskit_addon_mpf.dynamic.IdentityStateFactory") protocol. We do so by using the `initialize_from_lattice()` convenience method which takes the lattice underlying the Hamiltonian which we just defined as its only input.
|
||
|
||
```python
|
||
>>> from functools import partial
|
||
>>> from qiskit_addon_mpf.backends.tenpy_tebd import MPOState
|
||
>>> identity_factory = partial(MPOState.initialize_from_lattice, hamil.lat),
|
||
```
|
||
|
||
We can now construct the [`ExactEvolverFactory`](dynamic#exactevolverfactory "qiskit_addon_mpf.dynamic.ExactEvolverFactory") and [`ApproxEvolverFactory`](dynamic#approxevolverfactory "qiskit_addon_mpf.dynamic.ApproxEvolverFactory") time-evolution instance factories. To do so, we can simply bind the pre-defined values of the [`TEBDEvolver`](backends-tenpy-tebd-tebd-evolver "qiskit_addon_mpf.backends.tenpy_tebd.TEBDEvolver") initializer, reducing it to the correct interface as expected by the respective function protocols.
|
||
|
||
```python
|
||
>>> from qiskit_addon_mpf.backends.tenpy_tebd import TEBDEvolver
|
||
>>> exact_evolver_factory = partial(
|
||
... TEBDEvolver,
|
||
... model=hamil,
|
||
... dt=0.05,
|
||
... options={
|
||
... "order": 4,
|
||
... "preserve_norm": False,
|
||
... },
|
||
... )
|
||
```
|
||
|
||
Notice, how we have fixed the `dt` value to a small time step and have used a higher-order Suzuki-Trotter decomposition to mimic the exact time-evolution above.
|
||
|
||
Below, we do not fix the `dt` value and use only a second-order Suzuki-Trotter formula for the approximate time-evolution. Additionally, we also specify some truncation settings.
|
||
|
||
```python
|
||
>>> approx_evolver_factory = partial(
|
||
... TEBDEvolver,
|
||
... model=hamil,
|
||
... options={
|
||
... "order": 2,
|
||
... "preserve_norm": False,
|
||
... "trunc_params": {
|
||
... "chi_max": 10,
|
||
... "svd_min": 1e-5,
|
||
... "trunc_cut": None,
|
||
... },
|
||
... },
|
||
... )
|
||
```
|
||
|
||
Of course, you are not limited to the examples shown here, and we encourage you to play around with the other settings provided by TeNPy’s [`TEBDEngine`](https://tenpy.readthedocs.io/en/latest/reference/tenpy.algorithms.tebd.TEBDEngine.html#tenpy.algorithms.tebd.TEBDEngine "(in TeNPy v1.0.5)") implementation.
|
||
|
||
## Limitations
|
||
|
||
Finally, we point out a few known limitations on what kind of Hamiltonians can be treated by this backend:
|
||
|
||
* all interactions must be 1-dimensional
|
||
* the interactions must use finite boundary conditions
|
||
|
||
## Resources
|
||
|
||
\[1]: [https://en.wikipedia.org/wiki/Time-evolving\_block\_decimation](https://en.wikipedia.org/wiki/Time-evolving_block_decimation)
|
||
|