The S2 operator is defined as S2x+S2y+S2z or: S2=∑τ,σ34a†τ,σa†τ,σ+∑τ1,τ2∑σ1,σ2−σ1σ2a†τ1σ1a†τ2σ2a†τ1σ1a†τ2σ2−a†τ1↑a†τ2↓a†τ1↓a†τ2↑, with σ the spin index which either can be 1/2 for spin up (↑) or −1/2 for spin down (↓). The equivalent operator in Quanty is created by:
OppSsqr = NewOperator("Ssqr", NF, IndexUp, IndexDn)