The @mpoham macro
When dealing with (quasi-) one-dimensional systems that are defined by a sum of local operators, a convenient representation exists in terms of a sparse matrix product operator with an upper diagonal structure (MPOHamiltonian). The generation of such an object starting from a sum of local operators is facilitated by the macro @mpoham, which provides several syntactic sugar features.
MPSKitModels.@mpoham — Macro
@mpoham(block)Specify a Matrix Product Operator that is represented by a sum of local operators.
This macro converts expressions of the form O{i...} to an operator acting on sites i... where O is an operator, and i can be an integer or a lattice point. The macro recognizes expressions of the following forms:
O{i...}to indicate local operatorsOacting on sitesi...-Inf:Inf,-∞:∞,-Inf:step:Inf,-∞:step:∞to indicate infinite chains.1:Lto indicate finite chains.∑to represent sums.
Examples
H_ising = @mpoham sum(σᶻᶻ{i, i+1} + h * σˣ{i} for i in -Inf:Inf)
H_heisenberg = @mpoham ∑(sigma_exchange(){i,j} for (i,j) in nearest_neighbours(-∞:∞))Internally, the macro generates operators that have some knowledge of the lattice structure, through the following structures:
MPSKitModels.LocalOperator — Type
struct LocalOperator{T,G}N-body operator acting on N sites, indexed through lattice points of type G. The operator is represented as a vector of MPOTens, instantiate_operatorors, each of which acts on a single site.
Fields
opp::Vector{T}:N-body operator represented by an MPO.inds::Vector{G}:Nsite indices.
MPSKitModels.SumOfLocalOperators — Type
SumOfLocalOperators{L<:LocalOperator}Lazy sum of local operators.