qiskit-documentation/docs/api/qiskit-addon-mpf/0.2/backends-quimb-layers-layer...

89 lines
5.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: LayerModel (v0.2)
description: API reference for qiskit_addon_mpf.backends.quimb_layers.LayerModel in qiskit-addon-mpf v0.2
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit_addon_mpf.backends.quimb_layers.LayerModel
---
# LayerModel
<Class id="qiskit_addon_mpf.backends.quimb_layers.LayerModel" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.2/qiskit_addon_mpf/backends/quimb_layers/model.py#L25-L150" signature="LayerModel(L, H2, H1=None, cyclic=False, keep_only_odd=None)" modifiers="class">
Bases: [`LocalHam1D`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/tensor/tensor_1d_tebd/index.html#quimb.tensor.tensor_1d_tebd.LocalHam1D "(in quimb v1.10)")
A model for representing a layer of time-evolution interactions.
Essentially, this class is a simple wrapper of [`quimb.tensor.LocalHam1D`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/tensor/index.html#quimb.tensor.LocalHam1D "(in quimb v1.10)"). Its main purpose is to provide a simple interface for constructing a Quimb-compatible Hamiltonian from Qiskit objects.
Initialize a [`LayerModel`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel "qiskit_addon_mpf.backends.quimb_layers.LayerModel") instance.
Most of the arguments below are simply forwarded to [`quimb.tensor.LocalHam1D`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/tensor/index.html#quimb.tensor.LocalHam1D "(in quimb v1.10)") so check out its documentation for more details.
**Parameters**
* **L** the number of qubits.
* **H2** the two-site interactions.
* **H1** the optional on-site interactions.
* **cyclic** whether to apply periodic boundary conditions.
* **keep\_only\_odd** whether to keep only odd bond interactions. For more details see [`keep_only_odd`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd "qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd").
## Attributes
### keep\_only\_odd
<Attribute id="qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd">
Whether to keep only interactions on bonds with odd indices.
</Attribute>
## Methods
### from\_quantum\_circuit
<Function id="qiskit_addon_mpf.backends.quimb_layers.LayerModel.from_quantum_circuit" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.2/qiskit_addon_mpf/backends/quimb_layers/model.py#L73-L150" signature="from_quantum_circuit(circuit, *, scaling_factor=1.0, keep_only_odd=None, **kwargs)" modifiers="classmethod">
Construct a [`LayerModel`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel "qiskit_addon_mpf.backends.quimb_layers.LayerModel") from a [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit "(in Qiskit v1.3)").
You can see an example of this function in action in the docs of `quimb_layers`.
**Parameters**
* **circuit** ([*QuantumCircuit*](/api/qiskit/qiskit.circuit.QuantumCircuit "(in Qiskit v1.3)")) the quantum circuit to parse.
* **scaling\_factor** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")) a factor with which to scale the term strengths. This can be used to apply (for example) a time step scaling factor. It may also be used (e.g.) to split onsite terms into two layers (even and odd) with \$0.5\$ of the strength, each.
* **keep\_only\_odd** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)") *| None*) the value to use for [`keep_only_odd`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd "qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd").
* **kwargs** any additional keyword arguments to pass to the [`LayerModel`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel "qiskit_addon_mpf.backends.quimb_layers.LayerModel") constructor.
**Returns**
A new LayerModel instance.
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if an unsupported quantum gate is encountered.
**Return type**
[*LayerModel*](#qiskit_addon_mpf.backends.quimb_layers.LayerModel "qiskit_addon_mpf.backends.quimb_layers.model.LayerModel")
</Function>
### get\_gate\_expm
<Function id="qiskit_addon_mpf.backends.quimb_layers.LayerModel.get_gate_expm" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.2/qiskit_addon_mpf/backends/quimb_layers/model.py#L51-L71" signature="get_gate_expm(where, x)">
Get the local term at the sites `where`, matrix exponentiated by `x`.
If `where` applies to an even bond index and [`keep_only_odd`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd "qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd") is `True`, this method will return `None`.
**Parameters**
* **where** ([*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*,* [*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) the pair of site indices of the local term to get. This identifies the bond index.
* **x** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")) the value with which to matrix exponentiate the interaction term.
**Returns**
The interaction in terms of an array or `None` depending on [`keep_only_odd`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd "qiskit_addon_mpf.backends.quimb_layers.LayerModel.keep_only_odd") (see above).
**Return type**
[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.2)") | None
</Function>
</Class>