About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
LayerModel
class LayerModel(L, H2, H1=None, cyclic=False, keep_only_odd=None)
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
from_quantum_circuit
classmethod from_quantum_circuit(circuit, *, scaling_factor=1.0, keep_only_odd=None, **kwargs)
Construct a LayerModel
from a QuantumCircuit
.
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
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
is True
, this method will return None
.
Parameters
- where (tuple[int, int]) – the pair of site indices of the local term to get. This identifies the bond index.
- x (float) – 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
(see above).
Return type
ndarray | None
Was this page helpful?
Report a bug or request content on GitHub.