CouplingTerms¶
full name: tenpy.networks.terms.CouplingTerms
parent module:
tenpy.networks.terms
type: class
Inheritance Diagram
Methods

Initialize self. 

Add a twosite coupling term on given MPS sites. 

Add terms from 
Helping function to call before 


Load instance from a HDF5 file. 
Determine the maximal range in 


“Plot coupling terms into a given lattice. 

Remove entries close to 0 from 

Export self into a HDF5 file. 
Convert 

Convert the 

class
tenpy.networks.terms.
CouplingTerms
(L)[source]¶ Bases:
tenpy.tools.hdf5_io.Hdf5Exportable
Operator names, site indices and strengths representing twosite coupling terms.
 Parameters
L (int) – Number of sites.

coupling_terms
¶ Filled by
add_coupling_term()
. Nested dictionaries of the form{i: {('opname_i', 'opname_string'): {j: {'opname_j': strength}}}}
. Note that alwaysi < j
, but entries withj >= L
are allowed forbc_MPS == 'infinite'
, in which case they indicate couplings between different iMPS unit cells. Type
dict of dict

max_range
()[source]¶ Determine the maximal range in
coupling_terms
. Returns
max_range – The maximum of
j  i
for the i, j occuring in a term ofcoupling_terms
. Return type

add_coupling_term
(strength, i, j, op_i, op_j, op_string='Id')[source]¶ Add a twosite coupling term on given MPS sites.
 Parameters
strength (float) – The strength of the coupling term.
j (i,) – The MPS indices of the two sites on which the operator acts. We require
0 <= i < N_sites
andi < j
, i.e., op_i acts “left” of op_j. If j >= N_sites, it indicates couplings between unit cells of an infinite MPS.op2 (op1,) – Names of the involved operators.
op_string (str) – The operator to be inserted between i and j.

coupling_term_handle_JW
(strength, term, sites, op_string=None)[source]¶ Helping function to call before
add_multi_coupling_term()
. Parameters
strength (float) – The strength of the coupling term.
term ([(str, int), (str, int)]) – List of two tuples
(op, i)
where i is the MPS index of the site the operator named op acts on.sites (list of
Site
) – Defines the local Hilbert space for each site. Used to check whether the operators need JordanWigner strings.op_string (None  str) –
Operator name to be used as operator string between the operators, or
None
if the Jordan Wigner string should be figured out.
 Returns
Arguments for
MultiCouplingTerms.add_multi_coupling_term()
such that the added term corresponds to the parameters of this function. Return type
strength, i, j, op_i, op_j, op_string

plot_coupling_terms
(ax, lat, style_map='default', common_style={'linestyle': ''}, text=None, text_pos=0.4)[source]¶ “Plot coupling terms into a given lattice.
This function plots the
coupling_terms
 Parameters
ax (
matplotlib.axes.Axes
) – The axes on which we should plot.lat (
Lattice
) – The lattice for plotting the couplings, most probably theM.lat
of the corresponding modelM
, seelat
.style_map (function  None) – Function which get’s called with arguments
i, j, op_i, op_string, op_j, strength
for each twosite coupling and should return a keyworddictionary with the desired plotstyle for this coupling. By default (None
), the linewidth is given by the absolute value of strength, and the linecolor depends on the phase of strength (using the hsv colormap).common_style (dict) – Common style, which overwrites values of the dictionary returned by style_map. A
'label'
is only used for the first plotted line.text (format_string  None) – If not
None
, we add text labeling the couplings in the plot. Available keywords arei, j, op_i, op_string, op_j, strength
as well asstrength_abs, strength_angle, strength_real
.text_pos (float) – Specify where to put the text on the line between i (0.0) and j (1.0), e.g. 0.5 is exactly in the middle between i and j.
See also
tenpy.models.lattice.Lattice.plot_sites()
plot the sites of the lattice.

add_to_graph
(graph)[source]¶ Add terms from
coupling_terms
to an MPOGraph. Parameters
graph (
MPOGraph
) – The graph into which the terms fromcoupling_terms
should be added.

to_nn_bond_Arrays
(sites)[source]¶ Convert the
coupling_terms
into Arrays on nearest neighbor bonds. Parameters
sites (list of
Site
) – Defines the local Hilbert space for each site. Used to translate the operator names intoArray
. Returns
H_bond – The
coupling_terms
rewritten assum_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*']
. Return type
list of {
Array
 None}

remove_zeros
(tol_zero=1e15)[source]¶ Remove entries close to 0 from
coupling_terms
. Parameters
tol_zero (float) – Entries in
coupling_terms
with strength < tol_zero are considered to be zero and removed.

to_TermList
()[source]¶ Convert
onsite_terms
into aTermList
. Returns
term_list – Representation of the terms as a list of terms.
 Return type

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.