LayerModel¶
- class LayerModel(L, H2, H1=None, cyclic=False, keep_only_odd=None)[source]¶
Bases:
LocalHam1D
A model for representing a layer of time-evolution interactions.
Essentially, this class is a simple wrapper of
quimb.tensor.LocalHam1D
. Its main purpose is to provide a simple interface for constructing a Quimb-compatible Hamiltonian from Qiskit objects.Initialize a
LayerModel
instance.Most of the arguments below are simply forwarded to
quimb.tensor.LocalHam1D
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
.
Attributes
- keep_only_odd¶
Whether to keep only interactions on bonds with odd indices.
Methods
- classmethod from_quantum_circuit(circuit, *, scaling_factor=1.0, keep_only_odd=None, **kwargs)[source]¶
Construct a
LayerModel
from aQuantumCircuit
.You can see an example of this function in action in the docs of
quimb_layers
.- Parameters:
circuit (QuantumCircuit) – the quantum circuit to parse.
scaling_factor (float) – 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 | None) – the value to use for
keep_only_odd
.kwargs – any additional keyword arguments to pass to the
LayerModel
constructor.
- Returns:
A new LayerModel instance.
- Raises:
NotImplementedError – if an unsupported quantum gate is encountered.
- Return type:
- get_gate_expm(where, x)[source]¶
Get the local term at the sites
where
, matrix exponentiated byx
.If
where
applies to an even bond index andkeep_only_odd
isTrue
, this method will returnNone
.- Parameters:
- Returns:
The interaction in terms of an array or
None
depending onkeep_only_odd
(see above).- Return type:
ndarray | None