LayerModel
class LayerModel(model_params)
Bases: CouplingMPOModel
, NearestNeighborModel
A model for representing a layer of time-evolution interactions.
Essentially, this class is a simple wrapper of tenpy.models.model.CouplingMPOModel
and tenpy.models.model.NearestNeighborModel
. Its main purpose is to provide a simple interface for constructing a TeNPy-compatible Hamiltonian from Qiskit objects.
Methods
calc_H_bond
calc_H_bond(tol_zero=1e-15)
Calculate the interaction Hamiltonian based on the coupling and onsite terms.
Essentially, this class overwrites calc_H_bond()
and takes care of removing even or odd bond interaction Hamiltonians depending on the value of keep_only_odd
(see tenpy_layers
for more details).
Parameters
tol_zero (float) – the threshold for values considered to be zero.
Returns
The list of interaction Hamiltonians for all bonds.
Return type
from_quantum_circuit
classmethod from_quantum_circuit(circuit, *, scaling_factor=1.0, **kwargs)
Construct a LayerModel
from a QuantumCircuit
.
You can see an example of this function in action in the docs of tenpy_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.
- 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
init_sites
init_sites(model_params)
Initializes the sites of this Hamiltonian.
See init_sites()
for more details.
Currently, this enforces Sz
conservation on all sites.
Parameters
model_params (Config) – the model parameters.
Returns
The site to be used internally.
Return type
init_terms
init_terms(model_params)
Initializes the terms of this Hamiltonian.
See init_terms()
for more details.
Parameters
model_params (Config) – the model parameters.
Return type
None