TermList
full name: tenpy.networks.terms.TermList
parent module:
tenpy.networks.terms
type: class
Inheritance Diagram
Methods
|
|
|
Load instance from a HDF5 file. |
|
Initialize from a list of terms given in lattice indices instead of MPS indices. |
Return the left-most site and right-most site any operator acts on. |
|
|
|
|
Order and combine operators in each term. |
|
Export self into a HDF5 file. |
|
Return a copy where i0 is added to all indices i in |
Convert to |
- 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
andMultiCouplingTerms
.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
orMultiCouplingTerms
toTermList
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.
- 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 aTriangularLattice
:>>> 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 aModel
.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:
- to_OnsiteTerms_CouplingTerms(sites)[source]
Convert to
OnsiteTerms
andCouplingTerms
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:
onsite_terms (
OnsiteTerms
) – Onsite terms.coupling_terms (
CouplingTerms
|MultiCouplingTerms
) – Coupling terms. If self contains terms involving more than two operators, aMultiCouplingTerms
instance, otherwise justCouplingTerms
.
- 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.
- 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__
withsave_dict_content()
, storing the format under the attribute'format'
.