Learn to Use ITensor

main / classes / siteset


Class for specifying the local Hilbert space of each site of a lattice by storing the associated site index. A SiteSet does not store any information about the topology of the lattice, just the number of sites and information about each site.

ITensor comes with specialized subclasses of SiteSet, such as the SpinHalf and SpinOne classes, which provide facilities to create sites of a certain type (S=1/2 or S=1 spins, for example). However, these classes differ from SiteSet mainly in their constructors and read/write methods; after creating a specialized SiteSet type (such as SpinHalf) it can be safely converted to the base SiteSet type (for example, in the following code: SiteSet sites = SpinHalf(N);) without losing information about the underlying site type.


auto sites = SpinHalf(100);

Print(length(sites)); //prints: length(sites) = 100

auto s3 = sites(3); //retrieve the Index defining site number 3

auto s3up = sites(3,"Up"); //obtain the IndexVal defining the "Up" state at site number 3

auto sz3 = op(sites,"Sz",3); //obtain the "Sz" operator at site number 3

General SiteSet Interface

This part of the interface is common to all site set objects.

Operators Defined Automatically for all site types

Regardless of the specialized operators defined by each custom site type (such as the SpinHalfSite site type), the SiteSet class automatically provides the following operators which can be retrived as described from the .op method.

Generic SiteSet class

You can also use the SiteSet class itself as a generic collection of site indices which defines only the minimal set of operators discussed above above (for example "Id" and "Proj"). A generic SiteSet can still be very useful for keeping track of Hilbert spaces not necessarily equipped with specific local site operators.

Back to Classes
Back to Main