---
title: LayerModel (latest version)
description: API reference for qiskit_addon_mpf.backends.quimb_layers.LayerModel in the latest version of qiskit-addon-mpf
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-addon-mpf/backends-quimb-layers-layer-model
---

# LayerModel

*class* `LayerModel(L, H2, H1=None, cyclic=False)`

[GitHub](https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/quimb_layers/model.py#L25-L135)

Bases: [`LocalHam1D`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/tensor/tensor_1d_tebd/index.html#quimb.tensor.tensor_1d_tebd.LocalHam1D)

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). Its main purpose is to provide a simple interface for constructing a Quimb-compatible Hamiltonian from Qiskit objects.

## Methods

### from\_quantum\_circuit

*classmethod* `from_quantum_circuit(circuit, *, keep_only_odd=None, **kwargs)`

[GitHub](https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/quimb_layers/model.py#L50-L135)

Construct a [`LayerModel`](#qiskit_addon_mpf.backends.quimb_layers.LayerModel "qiskit_addon_mpf.backends.quimb_layers.LayerModel") from a [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit).

You can see an example of this function in action in the docs of `quimb_layers`.

**Parameters**

- **circuit** ([*QuantumCircuit*](/docs/api/qiskit/qiskit.circuit.QuantumCircuit)) – the quantum circuit to parse.
- **keep\_only\_odd** ([*bool*](https://docs.python.org/3/library/functions.html#bool) *| None*) – whether to keep only interactions on bonds with odd indices.
- **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) – 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")

### get\_gate\_expm

`get_gate_expm(where, x)`

[GitHub](https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/quimb_layers/model.py#L33-L48)

Get the local term at the sites `where`, matrix exponentiated by `x`.

**Parameters**

- **where** ([*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*,* [*int*](https://docs.python.org/3/library/functions.html#int)*]*) – 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)) – the value with which to matrix exponentiate the interaction term.

**Returns**

The interaction in terms of an array or `None` if this layer has no interaction on this bond.

**Return type**

[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) | None
