NearestNeighborModel¶
full name: tenpy.models.model.NearestNeighborModel
parent module:
tenpy.models.model
type: class
Inheritance Diagram
Methods

Initialize self. 
Calculate bond energies <psiH_bondpsi>. 

Calculate the MPO Hamiltonian from the bond Hamiltonian. 


Initialize a NearestNeighborModel from a model class defining an MPO. 

Load instance from a HDF5 file. 

Modify self in place to group sites. 

Export self into a HDF5 file. 


Return a NearestNeighborModel with same lattice, but trivial (H=0) bonds. 

class
tenpy.models.model.
NearestNeighborModel
(lattice, H_bond)[source]¶ Bases:
tenpy.models.model.Model
Base class for a model of nearest neigbor interactions w.r.t. the MPS index.
In this class, the Hamiltonian \(H = \sum_{i} H_{i,i+1}\) is represented by “bond terms” \(H_{i,i+1}\) acting only on two neighboring sites i and i+1, where i is an integer. Instances of this class are suitable for
tebd
.Note that the “nearestneighbor” in the name referst to the MPS index, not the lattice. In short, this works only for 1dimensional (1D) nearestneighbor models: A 2D lattice is internally mapped to a 1D MPS “snake”, and even a nearestneighbor coupling in 2D becomes longrange in the MPS chain.
 Parameters
lattice (
tenpy.model.lattice.Lattice
) – The lattice defining the geometry and the local Hilbert space(s).H_bond (list of {
Array
 None}) – The Hamiltonian rewritten assum_i H_bond[i]
for MPS indicesi
.H_bond[i]
acts on sites(i1, i)
; we requirelen(H_bond) == lat.N_sites
. Legs of eachH_bond[i]
are['p0', 'p0*', 'p1', 'p1*']
.

H_bond
¶ The Hamiltonian rewritten as
sum_i H_bond[i]
for MPS indicesi
.H_bond[i]
acts on sites(i1, i)
,None
represents 0. Legs of eachH_bond[i]
are['p0', 'p0*', 'p1', 'p1*']
. Type
list of {
Array
 None}

classmethod
from_MPOModel
(mpo_model)[source]¶ Initialize a NearestNeighborModel from a model class defining an MPO.
This is especially usefull in combination with
MPOModel.group_sites()
. Parameters
mpo_model (
MPOModel
) – A model instance implementing the MPO. Does not need to be aNearestNeighborModel
, but should only have nearestneighbor couplings.
Examples
The SpinChainNNN2 has nextnearestneighbor couplings and thus only implements an MPO:
>>> from tenpy.models.spins_nnn import SpinChainNNN2 >>> nnn_chain = SpinChainNNN2({'L': 20}) parameter 'L'=20 for SpinChainNNN2 >>> print(isinstance(nnn_chain, NearestNeighborModel)) False >>> print("range before grouping:", nnn_chain.H_MPO.max_range) range before grouping: 2
By grouping each two neighboring sites, we can bring it down to nearest neighbors.
>>> nnn_chain.group_sites(2) >>> print("range after grouping:", nnn_chain.H_MPO.max_range) range after grouping: 1
Yet, TEBD will not yet work, as the model doesn’t define H_bond. However, we can initialize a NearestNeighborModel from the MPO:
>>> nnn_chain_for_tebd = NearestNeighborModel.from_MPOModel(nnn_chain)

trivial_like_NNModel
()[source]¶ Return a NearestNeighborModel with same lattice, but trivial (H=0) bonds.

bond_energies
(psi)[source]¶ Calculate bond energies <psiH_bondpsi>.
 Parameters
psi (
MPS
) – The MPS for which the bond energies should be calculated. Returns
E_bond – List of bond energies: for finite bc,
E_Bond[i]
is the energy of bondi, i+1
. (i.e. we omit bond 0 between sites L1 and 0); for infinite bcE_bond[i]
is the energy of bondi1, i
. Return type
1D ndarray

group_sites
(n=2, grouped_sites=None)[source]¶ Modify self in place to group sites.
Group each n sites together using the
GroupedSite
. This might allow to do TEBD with a Trotter decomposition, or help the convergence of DMRG (in case of too long range interactions).This has to be done after finishing initialization and can not be reverted.
 Parameters
n (int) – Number of sites to be grouped together.
grouped_sites (None  list of
GroupedSite
) – The sites grouped together.
 Returns
grouped_sites – The sites grouped together.
 Return type
list of
GroupedSite

calc_H_MPO_from_bond
(tol_zero=1e15)[source]¶ Calculate the MPO Hamiltonian from the bond Hamiltonian.

classmethod
from_hdf5
(hdf5_loader, h5gr, subpath)[source]¶ Load instance from a HDF5 file.
This method reconstructs a class instance from the data saved with
save_hdf5()
.

save_hdf5
(hdf5_saver, h5gr, subpath)[source]¶ Export self into a HDF5 file.
This method saves all the data it needs to reconstruct self with
from_hdf5()
.This implementation saves the content of
__dict__
withsave_dict_content()
, storing the format under the attribute'format'
. Parameters
hdf5_saver (
Hdf5Saver
) – Instance of the saving engine.h5gr (:class`Group`) – HDF5 group which is supposed to represent self.
subpath (str) – The name of h5gr with a
'/'
in the end.