Getting Started
This page introduces the core EDKit workflow:
- define local terms,
- specify where they act,
- choose a basis,
- build an operator,
- apply it or convert it to an explicit matrix.
The Main Abstraction
The central user-facing object in EDKit is Operator.
An Operator stores a many-body operator as a sum of local terms on a chosen basis. That means you can describe your Hamiltonian once and then decide how you want to use it:
- apply it directly to a state vector,
- convert it to
Array(H)for dense exact diagonalization, - convert it to
sparse(H)for sparse workflows.
A First Example
Here is a compact open-chain XXZ Hamiltonian on L = 8 sites:
using EDKit, LinearAlgebra, SparseArrays
L = 8
Delta = 1.5
mats = [
fill(spin("XX"), L - 1);
fill(spin("YY"), L - 1);
fill(Delta * spin("ZZ"), L - 1);
]
inds = vcat(
[[i, i + 1] for i in 1:L-1],
[[i, i + 1] for i in 1:L-1],
[[i, i + 1] for i in 1:L-1],
)
H = operator(mats, inds, L)H is now an Operator acting on the full TensorBasis of a spin-1/2 chain.
Using The Operator
Apply it to a state:
psi = normalize(randn(ComplexF64, 2^L))
Hpsi = H * psiConvert it to explicit matrix representations:
Hdense = Array(H)
Hsparse = sparse(H)Diagonalize the dense version:
vals = eigvals(Hermitian(Hdense))Working In A Symmetry Sector
EDKit becomes especially useful when you do not want the full Hilbert space.
For example, the half-filling momentum-zero sector can be built with the high-level basis(...) helper:
using EDKit, LinearAlgebra
L = 12
B = basis(L = L, N = L ÷ 2, k = 0)
h2 = spin((1.0, "xx"), (1.0, "yy"), (1.0, "zz"))
H = trans_inv_operator(h2, 1:2, B)
vals, vecs = eigen(Hermitian(Array(H)))The construction logic is the same as before, but the basis is now symmetry reduced.
What To Read Next
- Bases and Sectors explains which basis to use.
- Operators explains
operator,trans_inv_operator, andspin. - Maps and Symmetrizers explains how to move between bases.