## Learn to Use ITensor

main / classes / spinhalf C++v3 | C++v2

# SpinHalf and SpinHalfSite

The SpinHalf class is a specialization of SiteSet which initializes its sites to be of type SpinHalfSite, representing a S=1/2 spin.

The SpinHalfSite class can also be used to create custom SiteSets which mix SpinHalfSites with other types of sites.

SpinHalf and SpinHalfSite are defined in the file "itensor/mps/sites/spinhalf.h"

## Synopsis

//Make a spinhalf site with no QNs
auto s = SpinHalfSite({"ConserveQNs=",false});

//Make an Sz operator
auto Sz = op(s,"Sz");

//Get the Index of the site
auto i = index(s);

Print(hasInds(Sz,{i,prime(i)}));

//Make a set of SpinHalfSites
auto sites = SpinHalf(100);

auto Sz3 = op(sites,"Sz",3);

auto Sp4 = op(sites,"S+",4);

//Use IndexVals to get the +,+ element of the Sz operator
auto Szpp = elt(Sz3,sites(3,"Up"),prime(sites(3,"Up")));


## Args of a SpinHalfSite

• "ConserveQNs" — sets if the site has QN information or not. Defaults to true.

• "ConserveSz" — sets if the site has QN information or not. Defaults to true.

• "SiteNumber" — integer n. If specified, add a tag "n="+str(n) to the Index of the SpinHalfSite.

## States of a SpinHalfSite

• "Up" — the $m_z=+1/2$ spin state

• "Dn" — the $m_z=-1/2$ spin state

## Operators Provided by SpinHalfSite

• "Sz" — the $S^z = \frac{1}{2}\sigma^z$ spin operator

• "S+" — the $S^+ = \sigma^+$ operator (alternate name is "Sp")

• "S-" — the $S^- = \sigma^-$ operator (alternate name is "Sm")

• "Sx" — the $S^x = \frac{1}{2}\sigma^x$ operator (must be converted to an ITensor prior to usage)

• "Sy" — the $S^y = \frac{1}{2}\sigma^y$ operator (must be converted to an ITensor prior to usage)

• "ISy" — defined as $i\,S^y = \frac{i}{2}\sigma^y$ (must be converted to an ITensor prior to usage)

Back to Classes
Back to Main