Repository navigation
SNEG 2.2.0
SNEG 2.2.0: changes since SNEG 2.1.
SNEG is a Wolfram Language package for symbolic calculations with noncommuting second-quantization operators. This release adds support for momentum space, periodic lattices, and finite periodic clusters, extends the spin algebra with spin sizes, representations, exact diagonalization of spin clusters, Stevens operators, and Hubbard X-operators, adds Bogoliubov transformations and mean-field theory for quadratic Hamiltonians, derives effective Hamiltonians by the Schrieffer-Wolff transformation, and computes Green's functions from closed equations of motion.
New functionality
Momentum space and lattices
See README_momentum.md for worked examples.
sneglatticeindexes[{R, ...}, Ns]andsnegmomentumindexes[{k, ...}, Ns]declare real summation indexes that label the unit cells and the crystal momenta of a periodic lattice withNscells.sneglatticevectors[a1, ...]declares lattice vectors used as displacements, e.g.c[R + a1].sumSimplifyKDeliminates Kronecker deltas of linear combinations of declared lattice or momentum indexes, e.g.Sum_k delta(p, k + q) f(k) = f(p - q), and reducesdelta(k, k + q)todelta(q, 0). Only coefficients of +-1 are solved; mixed lattice-momentum deltas and generic indexes keep the previous behavior.- Sums over declared indexes that do not appear in the summand evaluate to
Ns. blochphase[k, R]representsexp(i k.R).sumSimplifyKDperforms the lattice sumsSum_R exp(i K.R) = Ns delta(K, 0)andSum_k exp(i k.X) = Ns delta(X, 0).blochphaseexpconverts the phases to exponentials for explicit vectors.fourier[expr, c -> ck, R -> k]transforms fermionic and bosonic site operators to momentum operators with the conventionc_R = Ns^(-1/2) Sum_k exp(i k.R) c_k, and back with"Inverse" -> True. Momentum conservation is applied automatically.sumShiftshifts summation variables, andsumMomentumCanonicalcanonicalizes momentum labels and dummy-index names so that equivalent sums can be collected.sumFullSimplifyuses this canonicalization. Sums containingSEA-ordered operators are never shifted, because for linearized bands the shift is not a symmetry of the Fermi sea.blochhamiltonian[H, {ck[a], ...}, k]returns the Bloch Hamiltonian matrixh(k)of a bilinear fermionic or bosonic Hamiltonian, checks translation invariance and hermiticity, and supports the orbital-position convention through"OrbitalPositions".
Finite periodic clusters
fourierrules[c -> ck, {L1, ...}]gives the explicit Fourier transformation on a finite cluster, with optional twisted boundary conditions ("Twist").clusterhop[T, c[a], d[b], delta, {L1, ...}]constructs scalar or spin-matrix hopping on periodic or twisted clusters.sumCluster[expr, {L1, ...}, rules]specializes symbolic lattice and momentum sums to an explicit periodic cluster, folding site and momentum labels and evaluating Kronecker deltas modulo the cluster size.momentumbasis[bz, {L1, ...}]splits basis subspaces according to the total crystal momentum, which is appended to the quantum numbers.
Spin algebras and Hubbard X-operators
See README_spin.md for conventions and worked examples.
snegspinoperators[{S, s}]declares the spin sizes(a half-integer or a symbol). Products of operators on the same site are reduced automatically to the unique normal formSum p(S^z) (S^+-)^a, using the Casimir operator and, for numeric sizes, the finite dimension of the representation. Spin-1/2 products of Cartesian components follow the Pauli rule and stay Cartesian. Spins without a declared size keep the size-independent su(2) algebra.spincomponentsrewrites spin operators in terms ofS^z, S^+-(default) orS^x, S^y, S^z.snegspincomponentindexesandlevicivitasupport symbolic Cartesian components.spinclustermatricesbuilds sparse matrices of spin Hamiltonians in the subspaces of totalS^z.spinketbrarulesmaps spin operators to the bra-ket representation, andQSZaddspinketaccepts several spins, so that spins coupled to fermions can be diagonalized with the existing basis functions.jordanwigner,holsteinprimakoff(exact normal-ordered expansion truncated by the number of boson operators, symbolic spin size allowed),schwingerbosons, andabrikosovmap spin operators to fermions and bosons. Together withfourier,blochhamiltonian,bdghamiltonian, andbogoliubovthis gives linear spin-wave theory, also for antiferromagnets.spintensor(spherical tensor operators),stevens(Stevens operatorsO_k^q), androtatespin(site-dependent rotations of spin vectors).snegxoperatorsdeclares Hubbard X-operatorsX^ab = |a><b|for local states with fermion parities, with the graded algebra;xoperatorandxtofermionsgive the X-operators of the Hubbard atom in terms of fermions.
Quadratic forms, Bogoliubov transformations, and mean-field theory
See README_quadratic.md for conventions and worked examples.
quadraticform[H, modes]returns the BdG matrixMand constantE0of a quadratic Hamiltonian,H = 1/2 Psi^dagger M Psi + E0withPsi = (a, a^dagger), including anomalous and (for bosons, with"Linear" -> True) linear terms;"BdG" -> Falsereturns the hopping matrix of number-conserving Hamiltonians.quadraticoperatoris the inverse.bdghamiltonian[H, {ck[a], ...}, k]returns the Bloch BdG matrixH(k)forPsi_k = (c_k, c_-k^dagger)and the constantE0.bogoliubovdiagonalizes fermionic (unitary) and bosonic (paraunitary, Colpa's method) BdG matrices, numerically or symbolically for blocks of at most two modes, and returns the quasiparticle energies, the transformation, and the ground-state energy. Fermionic zero modes are handled."Momentum" -> Truetreats Bloch BdG matrices, whose particle-hole symmetry relateskand-k.bogoliubovrulesrewrites expressions in quasiparticle operators.gaussianaveragecomputes thermal and ground-state averages of arbitrary products of mode operators in the Gaussian state of a quadratic Hamiltonian with Wick's theorem, in real space and in momentum space.meanfielddecouples products of four or more operators in the Hartree, Fock, and pairing channels (or with a user-defined selection) into mean-field Hamiltonians with the averagesavg[...];meanfieldsolvesolves the mean-field equations self-consistently on finite sets of modes, at finite temperature and at fixed particle number.
Schrieffer-Wolff transformation
See README_schriefferwolff.md for conventions and worked examples.
schriefferwolff[H0, V, P, n]returns the contributions of order 0, ..., n to the effective HamiltonianP e^S H e^-S Pof the canonical Schrieffer-Wolff transformation (anti-Hermitian, block-off-diagonal generator), to arbitrary order for finite sets of modes. H0 must be diagonal in the occupation numbers of the local modes; band energies, linear bosons, Zeeman terms, and atomic Hamiltonians in X-operators are allowed for the other operators, and momentum sums are supported. For lattice sums, the projector can be given as a local rule (up to second order). Examples: Anderson to Kondo model, Hubbard to Heisenberg and t-J models, fourth-order exchange.eigenoperators[O, H0]splits an operator into eigenoperators of H0.schriefferwolffmatrixperforms the canonical transformation for matrices.fermionstox(inverse ofxtofermions) andxtospinconvert projected results to X-operators and spin operators.
Equations of motion, Green's functions, and sum rules
See README_greens.md for conventions and worked examples.
liouvillian[A, H, n]returns the iterated commutators[...[A, H], ..., H], also with symbolic sums.spectralmoments[A, B, H, n]returns the moments (sum rules) of the spectral function of the retarded Green's function<<A; B>>, with the anticommutator for fermion-oddAand the commutator otherwise.eomclosure[A, H]generates the closed set of operators of the equations of motion and the matrix of[O_i, H];greensfunction[A, B, H, z]solves the closed equations with symbolic averagesavg[...]or a given averaging function.thermalaverageandlehmanngive exact thermal averages and the Lehmann representation of finite fermion systems.
Documentation
- Help pages integrated in the Wolfram Documentation Center (Mathematica 14 or newer): reference pages with details, caveats, developer notes, and evaluated examples, and the guide page
paclet:SNEG/guide/SNEG. In notebooks, the startup message links to the guide page when the help pages are installed. - The help pages are generated from Markdown sources in
doc/src(doc/build-docs.wl); the example outputs are cached indoc/cacheand verified bydoc/test-docs.m. Seedoc/README.md. - The stand-alone LaTeX manual combines a tutorial, worked solid-state models, an illustrated Hubbard-dimer calculation, a grouped function reference, exercises and solutions. Build it with
wolframscript -file doc/manual/build-manual.wl. The downloadable chapter notebooks indoc/notebooksuse the same evaluated examples as the manual. The documentation and teaching material are licensed under CC BY 4.0. - Usage messages no longer contain the "More..." buttons of the former help browser.
LaTeX output
snegtex[expr]returns a LaTeX string in physics notation, e.g.c^\dagger_{1\uparrow} c_{2\uparrow},S^+_1,\sum_k ..., for expressions with fermion, boson, spin, Majorana, and X-operators.
Matrix-valued hopping (released in 2.1.1)
matrixhop[T, a[i], b[j]]constructs the spin-dependent hoppinga^dagger T b + h.c.for a dense or sparse 2 by 2 matrixT, with Pauli decomposition of symbolic matrices (includingMatrixExpresults). SeeREADME_matrixhop.md.
Behavior changes
- Internal helper functions and the names of local and pattern variables moved from
Sneg`toSneg`Private`. Names such ass,u,k,states, orenergyin user code therefore no longer trigger shadowing warnings or attach definitions to package symbols. All documented functions, the developer interface (ordering,cmt,acmt,isnumericQ,operatorQ, operator lists, constants such asEMPTY,SEA,NONE,BASIS), and the undocumented functions used in existing notebooks and in NRG Ljubljana (e.g.qbasis,genhop,hopphi,bcs,der,projectorE,transformtoLRvc,quickDBL) remain public. Code that called other internal helpers must use the qualified name, e.g.Sneg`Private`snegswdummies. - Summation indexes created by automatic renaming (for example
k1when two sums overkare multiplied) now inherit the realness (Conjugate[k] = k) and the lattice or momentum declaration of the original index. - Spin operators commute with all other operators and are now moved to the left of bosons, Majorana and Dirac fermions in products; operators of different spin symbols are sorted. Mixed expressions are therefore printed in a different order, and identities such as the conservation laws of the Kondo model with an abstract impurity spin now reduce to zero.
conjis defined for spin operators ((S^+)^dagger = S^-).blochhamiltonianreturns$Failedwith a message for Hamiltonians with anomalous or linear terms, which were previously dropped silently fromh(k).
Fixes
- Contractions check the ordering convention of both operators.
- Contractions between independent operator families with
NONEordering vanish, respecting a custom fermionic anticommutator. - Fixed iterator capture in
sumAbstractIndex,sumNameIndex, andsnegold2newrules. vevwick2handles single operators.- Matrix blocks that vanish only in floating-point arithmetic are filtered out in
makeallmatricesbzopandmakeallmatricesbzvc. SU2combineapplies the spin-projection selection rule, avoiding messages for nonphysical Clebsch-Gordan arguments.- Coefficients built from declared real or complex functions, e.g.
1 + ε[k]or-ε[k]aftersnegrealfunctions[ε], are now recognized as numbers byisnumericQ, so thatncfactors them out of operator products.
Testing
- The regression scripts return a nonzero exit status on failure. Missing expected values, evaluation messages, aborts, and timeouts count as failures.
- Expanded regression coverage with independent finite-space checks of bases, matrices, symmetry transformations, and Wick contractions.
- New regression groups for momentum-space deltas and lattice sums, Fourier transformations and Bloch Hamiltonians (chain, SSH, graphene, Rashba chain, bosons), momentum shifts, and finite clusters. The finite-cluster tests compare real-space and momentum-space spectra of the four-site Hubbard ring.
- New regression groups for spin algebras: normal forms checked against spin matrices for s = 1/2 to 5/2, Kondo conservation laws, Heisenberg ring, bra-ket and direct matrices, Jordan-Wigner XXZ spectra, magnon dispersions, Stevens-operator tables, rotations, and the X-operator algebra against its fermion representation (t-J dimer).
- New regression groups for quadratic forms: many-body spectra and thermal and ground-state averages of random BdG Hamiltonians compared with exact diagonalization, bosonic averages compared with truncated Fock spaces, Kitaev-chain zero modes and Bloch spectra, BCS coherence factors, antiferromagnetic magnons, the Wick consistency of mean-field Hamiltonians, the Hartree-Fock solutions of the Hubbard dimer, and the BCS gap equation on a ring.
- New regression groups for the Schrieffer-Wolff transformation: exchange of the Hubbard dimer to fourth order against the exact solution, operator against matrix transformations, the fifth-order remainder of the block-off-diagonal part, the Kondo coupling of the Anderson model with momentum sums against a discrete bath, the Heisenberg and t-J models on a lattice against explicit clusters, and the convergence of three-site t-J spectra.
examples/schriefferwolff-plaquette.mchecks the fourth-order plaquette against exact diagonalization. - Tests of the public and private contexts, and of
snegtex. doc/test-docs.mre-evaluates examples for the help pages and LaTeX chapters and compares them with the cached outputs.- New regression group for equations of motion: the Hubbard atom, the resonant level, spins and bosons, and the closed equations of the interacting Hubbard dimer against the Lehmann representation and its moments at zero and finite temperature.
Distribution
The release contains versioned SNEG-2.2.0.paclet and stable SNEG.paclet assets.
PacletInstall[
"https://github.com/rokzitko/sneg/releases/latest/download/SNEG.paclet"
]