OpStrings
TenNetLib.jl provides an alternative, called OpStrings
, to ITensors.jl's OpSum
to automatically construct Hamiltonains / operators. TenNetLib.jl's own CouplingModel
is built from OpStrings
and is not compatible with OpSum
.
OpString
OpStrings
is basically a vector of OpString
objects (notice the difference in 's' at the end)
TenNetLib.OpString
— Typestruct OpString{T <: Number}
coeff::T
ops::Vector{Pair{String, Int}}
end
Holds operator strings (operator names with corresponding positions) along with the coefficient.
coeff::T
: Coeffcient of the operator string.ops::Vector{Pair{String, Int}}
: String of operator names along with the positions.
TenNetLib.coefficient
— Methodfunction coefficient(opstr::OpString)
Returns the coefficient of the OpString
.
TenNetLib.operators
— Methodfunction operators(opstr::OpString)
Returns the operator string of the OpString
.
TenNetLib.minsite
— Methodfunction minsite(opstr::OpString)
Returns the lowest site position in the operator string of the OpString
.
TenNetLib.maxsite
— Methodfunction maxsite(opstr::OpString)
Returns the highest site position in the operator string of the OpString
.
TenNetLib.removeIds
— Methodfunction removeIds(opstr::OpString{T}) where {T <: Number}
Returns an OpString
with all "Id" operators removed from the original.
TenNetLib.bosonize
— Methodfunction bosonize(opstr::OpString{T1},
sites::Vector{Index{T2}}) where {T1 <: Number, T2}
Returns an OpString
after "bosonizing" the original with Jordan-Wigner strings as needed. See bosonize
.
OpStrings
TenNetLib.OpStrings
— Typeconst OpStrings{T} = Vector{OpString{T}}
Collection of OpString
s.
Syntax:
os = OpStrings()
os += 1, "Sx" => i, "Sx" => j, "Sx" => k, ....
os += "Sx" => i, "Sx" => j, "Sx" => k, ....
Example:
os = OpStrings()
for j=1:N-1
os += 1, "Sz" => j, "Sz" => j+1
os += 0.5, "S+" => j, "S-" => j+1
os += 0.5, "S-" => j, "S+" => j+1
end
TenNetLib.removeIdsZeros
— Methodfunction removeIdsZeros(os::OpStrings{T}) where {T <: Number}
Returns an OpStrings
with all "Id" operators removed from the original, as well as any OpString
term that has coeff
less than Float64_threshold()
.
TenNetLib.bosonize
— Methodfunction bosonize(os::OpStrings{T1}, sites::Vector{Index{T2}}) where {T1 <: Number, T2}
Returns an OpStrings
after "bosonizing" the original with Jordan-Wigner strings as needed. See bosonize
.
TenNetLib.mergeterms
— Methodfunction mergeterms(os::OpStrings{T}) where T <: Number
Returns an OpStrings
where OpString
elements with exactly same operator strings has been merged by adding the coefficients.
MPO
from OpStrings
ITensors.MPO
— Methodfunction ITensors.MPO(os::OpStrings{T1},
sites::Vector{Index{T2}};
maxdim::Int = typemax(Int),
mindim::Int = 1,
cutoff::Float64 = Float64_threashold(),
svd_alg::String = "divide_and_conquer",
chunksize::Int = 12) where {T1 <: Number, T2}
Creates MPO
from os::OpStrings
. The present version uses recursive SVDs to create the MPO. Very inefficient when number of Hamiltonian terms is large. Future updates will solve the problem.
Named arguments and their default values:
maxdim::Int = typemax(Int)
: Maximum MPO bond dimension after SVD truncation.mindim::Int = 1
: Minimum MPO bond dimension after SVD truncation.cutoff::Float64 = Float64_threshold()
: Cutoff for SVD truncation.svd_alg::String = "divide_and_conquer"
.chunksize::Int = 12
. Maximum size of the chunks on which recursive SVDs are performed.