OpSum
Description
ITensors.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
ITensors.add!
— Functionadd!(ampo::OpSum,
op1::String, i1::Int)
add!(ampo::OpSum,
coef::Number,
op1::String, i1::Int)
add!(ampo::OpSum,
op1::String, i1::Int,
op2::String, i2::Int,
ops...)
add!(ampo::OpSum,
coef::Number,
op1::String, i1::Int,
op2::String, i2::Int,
ops...)
+(ampo:OpSum, term::Tuple)
Add a single- or multi-site operator term to the OpSum ampo
. 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
ampo = OpSum()
add!(ampo,"Sz",2,"Sz",3)
ampo += ("Sz",3,"Sz",4)
ampo += (0.5,"S+",4,"S-",5)
ampo .+= (0.5,"S+",5,"S-",6)
ITensors.MPO
— MethodMPO(ampo::OpSum,sites::Vector{<:Index};kwargs...)
Convert an OpSum object ampo
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.
Examples
ampo = OpSum()
ampo += ("Sz",1,"Sz",2)
ampo += ("Sz",2,"Sz",3)
ampo += ("Sz",3,"Sz",4)
sites = siteinds("S=1/2",4)
H = MPO(ampo,sites)