OpSum
Description
ITensors.Ops.OpSum
— TypeAn OpSum
represents a sum of operator terms.
Often it is used to create matrix product operator (MPO
) approximation of the sum of the terms in the OpSum
oject. Each term is a product of local operators specified by names such as "Sz"
or "N"
, times an optional coefficient which can be real or complex.
Which local operator names are available is determined by the function op
associated with the TagType
defined by special Index tags, such as "S=1/2"
, "S=1"
, "Fermion"
, and "Electron"
.
Methods
ITensorMPS.add!
— Functionadd!(opsum::OpSum,
op1::String, i1::Int)
add!(opsum::OpSum,
coef::Number,
op1::String, i1::Int)
add!(opsum::OpSum,
op1::String, i1::Int,
op2::String, i2::Int,
ops...)
add!(opsum::OpSum,
coef::Number,
op1::String, i1::Int,
op2::String, i2::Int,
ops...)
+(opsum:OpSum, term::Tuple)
Add a single- or multi-site operator term to the OpSum opsum
. Each operator is specified by a name (String) and a site number (Int). The second version accepts a real or complex coefficient.
The +
operator version of this function accepts a tuple with entries either (String,Int,String,Int,...) or (Number,String,Int,String,Int,...) where these tuple values are the same as valid inputs to the add!
function. For inputting a very large number of terms (tuples) to an OpSum, consider using the broadcasted operator .+=
which avoids reallocating the OpSum after each addition.
Examples
opsum = OpSum()
add!(opsum,"Sz",2,"Sz",3)
opsum += ("Sz",3,"Sz",4)
opsum += (0.5,"S+",4,"S-",5)
opsum .+= (0.5,"S+",5,"S-",6)
ITensorMPS.MPO
— MethodMPO(os::OpSum, sites::Vector{<:Index}; splitblocks=true, kwargs...)
MPO(eltype::Type{<:Number}, os::OpSum, sites::Vector{<:Index}; splitblocks=true, kwargs...)
Convert an OpSum object os
to an MPO, with indices given by sites
. The resulting MPO will have the indices sites[1], sites[1]', sites[2], sites[2]'
etc. The conversion is done by an algorithm that compresses the MPO resulting from adding the OpSum terms together, often achieving the minimum possible bond dimension.
Optionally specify the desired element type of the output MPO by passing the type as the first argument.
The keyword argument splitblocks
controls the sparsity of the resulting MPO. With the default splitblocks=true
, the link indices of the MPO are split into blocks of dimension 1, potentially making the MPO more sparse.
With the splitblocks=false
, the blocks of the link dimensions are packed as much as possible according to common quantum numbers, making larger blocks. Before ITensors 0.3.19, this was the default output, but we have found that in general MPOs output with splitblocks=true
lead to better performance in algorithms like DMRG.
Examples
os = OpSum()
os += "Sz",1,"Sz",2
os += "Sz",2,"Sz",3
os += "Sz",3,"Sz",4
sites = siteinds("S=1/2",4)
H = MPO(os,sites)
H = MPO(Float32,os,sites)
H = MPO(os,sites; splitblocks=false)