SNEG quick reference
SNEG is an open-source Mathematica package for second quantization and many-body calculations. This reference uses the GitHub release SNEG 2.2.1 and covers fermionic operator algebra, Wick’s theorem, Hubbard model exact diagonalization, and a retarded Green’s function.
Install and load SNEG
With Mathematica 12.1 or newer, install the version used here.
PacletInstall["https://github.com/rokzitko/sneg/releases/download/v2.2.1/SNEG.paclet"]
In a fresh kernel, evaluate the load and version check in successive cells.
Needs["sneg`"]
$SnegVersion
The version check returns "2.2.1". With Mathematica 14.0
or newer, open paclet:SNEG/guide/SNEG for the integrated
help. For source installation and older Mathematica versions, see the installation
guide.
Operator notation
- Declare an operator family with
snegfermionoperators[c]. For a spinful level,c[CR, i, UP]creates an up-spin electron at leveliandc[AN, i, DO]annihilates a down-spin electron.c[i]designates the level in constructors such asnumber[c[i]]. - Use
nc[a, b]for noncommutative multiplication, ordinary multiplication for scalar prefactors,pow[a, n]for operator powers, andconj[a]for the Hermitian adjoint.ncapplies the algebra and ordering rules for the declared operator families. - For fermions,
EMPTYis the default reference state.ordering[c] = SEAselects the Fermi sea.ordering[c] = NONEkeeps the input order of that family. See the ordering reference for the contraction and mixed-family rules.
Four worked recipes
Start each recipe with a fresh kernel and evaluate the load cell before the recipe. Each block includes the operator and parameter declarations it needs.
Fermionic anticommutators and normal ordering
snegfermionoperators[c];
car = Table[antikomutator[c[AN, s], c[CR, r]],
{s, {UP, DO}}, {r, {UP, DO}}];
normalOrderCheck = Expand[
nc[c[AN, UP], c[CR, UP]] + nc[c[CR, UP], c[AN, UP]]];
{car, normalOrderCheck}
The result is {{{1, 0}, {0, 1}}, 1}. The matrix encodes
the two spin components of the canonical anticommutator. The last entry
checks the sign and constant term in normal ordering. First
calculation with the Hubbard atom
Wick’s theorem for a filled Fermi sea
snegfermionoperators[c];
ordering[c] = SEA;
snegfreeindexes[k1, k2, k3, k4];
fourPoint = SimplifyKD[vevwick[nc[
c[CR, k1, UP], c[CR, k2, UP], c[AN, k3, UP], c[AN, k4, UP]]]];
{fourPoint /. {k1 -> -1, k2 -> -2, k3 -> -2, k4 -> -1},
fourPoint /. {k1 -> -1, k2 -> -2, k3 -> -1, k4 -> -2}}
The result is {1, -1}. The first assignment selects the
direct contraction and the second selects the exchange contraction for
two distinct occupied levels. The signed label immediately after
CR or AN is measured relative to the Fermi
level. Negative labels have occupation UnitStep[-k] = 1.
The step-function identities used by SimplifyKD assume
nonzero arguments. Wick
theorem example · SimplifyKD
reference
Exact diagonalization of the Hubbard dimer
snegfermionoperators[c];
sites = {c[1], c[2]};
h = -hop[c[1], c[2]] + 4 Total[hubbard[sites]];
sectors = qszbasisvc[sites, 1/2];
states = First[Cases[sectors, {{0, 0}, statesInSector_} :> statesInSector]];
m = matrixrepresentationvcsparse[h, states];
{Dimensions[m], Min[Eigenvalues[Normal[m]]]}
This uses hopping t = 1, on-site repulsion
U = 4, and the half-filled sector with
Q = N - 2 = 0 and Sz = 0. The matrix
dimensions are {4, 4} and its ground-state energy is
.
qszbasisvc sets BASIS, so construct the matrix
while the basis for these sites is active. Hubbard
dimer example · Occupation
basis reference
Retarded Green’s function of the Hubbard atom
snegfermionoperators[d];
snegrealconstants[eps, U];
h = eps number[d[]] + U hubbard[d[]];
g = greensfunction[d[AN, UP], d[CR, UP], h, z];
expected = (1 - w)/(z - eps) + w/(z - eps - U);
Together[(g /. avg[number[d[], DO]] -> w) - expected]
The result is 0. Here eps is the level
energy relative to the chemical potential, Im[z] > 0
selects the retarded function, and w is the mean down-spin
occupation. The poles at eps and eps + U have
weights 1 - w and w. The function takes both
operators explicitly and leaves state averages symbolic by default. Hubbard
atom example · Green’s
function reference
Choose a method
- Periodic lattices and band structure. Use
fourierandblochhamiltonianfor Bloch matrices, orclusterhopandmomentumbasisfor finite periodic clusters. Momentum-space guide · SSH chain - Quantum spin models. Use
snegspinoperatorsandspinclustermatricesfor spin Hamiltonians, orjordanwignerfor the fermionic representation. Spin guide · XXZ chain - Pairing and quadratic Hamiltonians. Use
bdghamiltonianandbogoliubovfor quadratic problems, ormeanfieldandmeanfieldsolvefor self-consistent decoupling. Quadratic Hamiltonians guide · Kitaev chain - Low-energy effective models. Use
schriefferwolffwith a specified low-energy projector and perturbative order. Schrieffer–Wolff guide · Anderson model example
See the worked examples and the SNEG manual for full calculations. Report documentation issues with the package version and a minimal Wolfram Language example. GitHub Issues
For published work, cite R. Žitko, Computer Physics Communications 182, 2259–2264 (2011). SNEG paper
SNEG documentation project · CC BY 4.0.