TermList

Inheritance Diagram

Inheritance diagram of tenpy.networks.terms.TermList

Methods

TermList.__init__(terms[, strength])

TermList.from_hdf5(hdf5_loader, h5gr, subpath)

Load instance from a HDF5 file.

TermList.from_lattice_locations(lattice, terms)

Initialize from a list of terms given in lattice indices instead of MPS indices.

TermList.limits()

Return the left-most site and right-most site any operator acts on.

TermList.max_range()

TermList.order_combine(sites)

Order and combine operators in each term.

TermList.save_hdf5(hdf5_saver, h5gr, subpath)

Export self into a HDF5 file.

TermList.shift(i0)

Return a copy where i0 is added to all indices i in terms.

TermList.to_OnsiteTerms_CouplingTerms(sites)

Convert to OnsiteTerms and CouplingTerms

class tenpy.networks.terms.TermList(terms, strength=1.0)[source]

Bases: Hdf5Exportable

A list of terms (=operator names and sites they act on) and associated strengths.

A representation of terms, similar as OnsiteTerms, CouplingTerms and MultiCouplingTerms.

This class does not store operator strings between the sites. Jordan-Wigner strings of fermions are added during conversion to (Multi)CouplingTerms.

Warning

Since this class does not store the operator string between the sites, conversion from CouplingTerms or MultiCouplingTerms to TermList is lossy!

Parameters:
  • terms (list of list of (str, int)) – List of terms where each term is a list of tuples (opname, i) of an operator name and a site i it acts on. For Fermions, the order is the order in the mathematic sense, i.e., the right-most/last operator in the list acts last.

  • strength ((list of) float/complex) – For each term in terms an associated prefactor or strength. A single number holds for all terms equally.

terms

List of terms where each term is a tuple (opname, i) of an operator name and a site i it acts on.

Type:

list of list of (str, int)

strength

For each term in terms an associated prefactor or strength.

Type:

1D ndarray

Examples

For fermions, the term \(0.5(c^\dagger_0 c_2 + h.c.) + 1.3 * n_1\) can be represented by:

>>> t = TermList([[('Cd', 0), ('C', 2)], [('Cd', 2), ('C', 0)], [('N', 1)]],
...              [0.5,                   0.5,                   1.3])
>>> print(t)
0.50000 * Cd_0 C_2 +
0.50000 * Cd_2 C_0 +
1.30000 * N_1

If you have a Lattice, you might also want to specify the location of the operators by lattice indices instead of MPS indices. For example, you can obtain the nearest-neighbor density terms without double counting each pair) on a TriangularLattice:

>>> lat = tenpy.models.lattice.Triangular(6, 6, None, bc_MPS='infinite', bc='periodic')
>>> t2_terms = [[('N', [0, 0, u1]), ('N', [dx[0], dx[1], u2])]
...             for (u1, u2, dx) in lat.pairs['nearest_neighbors']]
>>> t2 = TermList.from_lattice_locations(lat, t2_terms)
>>> print(t2)
1.00000 * N_0 N_6 +
1.00000 * N_0 N_-5 +
1.00000 * N_0 N_5

The negative index -5 here indicates a tensor left of the current MPS unit cell.

classmethod from_lattice_locations(lattice, terms, strength=1.0, shift=None)[source]

Initialize from a list of terms given in lattice indices instead of MPS indices.

Parameters:
  • lattice (Lattice) – The underlying lattice to be used for conversion, e.g. M.lat from a Model.

  • terms (list of list of (str, tuple)) – List of terms, where each term is a tuple (opname, lat_idx) with lat_idx itself being a tuple (x, y, u) (for a 2D lattice) of the lattice coordinates.

  • strengths ((list of) float/complex) – For each term in terms an associated prefactor or strength. A single number holds for all terms equally.

  • shift (None | tuple of int) – Overall shift added to all lattice coordinates lat_idx in terms before conversion. None defaults to no shift.

Returns:

term_list – Representation of the terms.

Return type:

TermList

to_OnsiteTerms_CouplingTerms(sites)[source]

Convert to OnsiteTerms and CouplingTerms

Performs Jordan-Wigner transformation for fermionic operators.

Parameters:

sites (list of Site) – Defines the local Hilbert space for each site. Used to check whether the operators need Jordan-Wigner strings. The length is used as L for the onsite_terms and coupling_terms.

Returns:

order_combine(sites)[source]

Order and combine operators in each term.

Parameters:

sites (list of Site) – Defines the local Hilbert space for each site. Used to check whether the operators anticommute (= whether they need Jordan-Wigner strings) and for multiplication rules.

See also

order_and_combine_term

does it for a single term.

limits()[source]

Return the left-most site and right-most site any operator acts on.

shift(i0)[source]

Return a copy where i0 is added to all indices i in terms.

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

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.