MultiCouplingTerms

  • full name: tenpy.networks.terms.MultiCouplingTerms

  • parent module: tenpy.networks.terms

  • type: class

Inheritance Diagram

Inheritance diagram of tenpy.networks.terms.MultiCouplingTerms

Methods

MultiCouplingTerms.__init__(L)

Initialize self.

MultiCouplingTerms.add_coupling_term(…[, …])

Add a two-site coupling term on given MPS sites.

MultiCouplingTerms.add_multi_coupling_term(…)

Add a multi-site coupling term.

MultiCouplingTerms.add_to_graph(graph[, _i, …])

Add terms from coupling_terms to an MPOGraph.

MultiCouplingTerms.coupling_term_handle_JW(…)

Helping function to call before add_multi_coupling_term().

MultiCouplingTerms.from_hdf5(hdf5_loader, …)

Load instance from a HDF5 file.

MultiCouplingTerms.max_range()

Determine the maximal range in coupling_terms.

MultiCouplingTerms.multi_coupling_term_handle_JW(…)

Helping function to call before add_multi_coupling_term().

MultiCouplingTerms.plot_coupling_terms(ax, lat)

“Plot coupling terms into a given lattice.

MultiCouplingTerms.remove_zeros([tol_zero, _d0])

Remove entries close to 0 from coupling_terms.

MultiCouplingTerms.save_hdf5(hdf5_saver, …)

Export self into a HDF5 file.

MultiCouplingTerms.to_TermList()

Convert onsite_terms into a TermList.

MultiCouplingTerms.to_nn_bond_Arrays(sites)

Convert the coupling_terms into Arrays on nearest neighbor bonds.

class tenpy.networks.terms.MultiCouplingTerms(L)[source]

Bases: tenpy.networks.terms.CouplingTerms

Operator names, site indices and strengths representing general M-site coupling terms.

Generalizes the coupling_terms of CouplingTerms to M-site couplings. The structure of the nested dictionary coupling_terms is similar, but we allow an arbitrary recursion depth of the dictionary.

Parameters

L (int) – Number of sites.

L

Number of sites.

Type

int

coupling_terms

Nested dictionaries of the following form:

{i: {('opname_i', 'opname_string_ij'):
        {j: {('opname_j', 'opname_string_jk'):
                {k: {('opname_k', 'opname_string_kl'):
                    ...
                        {l: {'opname_l':
                                strength
                        }   }
                    ...
                }   }
        }   }
}   }

For a M-site coupling, this involves a nesting depth of 2*M dictionaries. Note that always i < j < k < ... < l, but entries with j,k,l >= L are allowed for the case of bc_MPS == 'infinite', when they indicate couplings between different iMPS unit cells.

Type

dict of dict

add_multi_coupling_term(strength, ijkl, ops_ijkl, op_string='Id')[source]

Add a multi-site coupling term.

Parameters
  • strength (float) – The strength of the coupling term.

  • ijkl (list of int) – The MPS indices of the sites on which the operators acts. With i, j, k, … = ijkl, we require that they are ordered ascending, i < j < k < ... and that 0 <= i < N_sites. Inidces >= N_sites indicate couplings between different unit cells of an infinite MPS.

  • ops_ijkl (list of str) – Names of the involved operators on sites i, j, k, ….

  • op_string ((list of) str) – Names of the operator to be inserted between the operators, e.g., op_string[0] is inserted between i and j. A single name holds for all in-between segments.

multi_coupling_term_handle_JW(strength, term, sites, op_string=None)[source]

Helping function to call before add_multi_coupling_term().

Handle/figure out Jordan-Wigner strings if needed.

Parameters
  • strength (float) – The strength of the term.

  • term (list of (str, int)) – List of tuples (op_i, i) where i is the MPS index of the site the operator named op_i acts on. We require the operators to be sorted (strictly ascending) by sites. If necessary, call order_combine_term() beforehand.

  • sites (list of Site) – Defines the local Hilbert space for each site. Used to check whether the operators need Jordan-Wigner 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, ijkl, ops_ijkl, op_string

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 of coupling_terms.

Return type

int

add_to_graph(graph, _i=None, _d1=None, _label_left=None)[source]

Add terms from coupling_terms to an MPOGraph.

Parameters
  • graph (MPOGraph) – The graph into which the terms from coupling_terms should be added.

  • _d1, _label_left (_i,) – Should not be given; only needed for recursion.

remove_zeros(tol_zero=1e-15, _d0=None)[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.

  • _d0 (None) – Should not be given; only needed for recursion.

to_TermList()[source]

Convert onsite_terms into a TermList.

Returns

term_list – Representation of the terms as a list of terms.

Return type

TermList

add_coupling_term(strength, i, j, op_i, op_j, op_string='Id')[source]

Add a two-site 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 and i < 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 Jordan-Wigner 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

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().

Parameters
  • hdf5_loader (Hdf5Loader) – Instance of the loading engine.

  • h5gr (Group) – HDF5 group which is represent the object to be constructed.

  • subpath (str) – The name of h5gr with a '/' in the end.

Returns

obj – Newly generated class instance containing the required data.

Return type

cls

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 the M.lat of the corresponding model M, see lat.

  • style_map (function | None) – Function which get’s called with arguments i, j, op_i, op_string, op_j, strength for each two-site coupling and should return a keyword-dictionary with the desired plot-style 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 are i, j, op_i, op_string, op_j, strength as well as strength_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.

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__ with save_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.

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 into Array.

Returns

H_bond – The coupling_terms rewritten as sum_i H_bond[i] for MPS indices i. H_bond[i] acts on sites (i-1, i), None represents 0. Legs of each H_bond[i] are ['p0', 'p0*', 'p1', 'p1*'].

Return type

list of {Array | None}