Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/Components/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,23 @@ end
maxbondsize(psi::MPS) = maximum(bondsizes(psi; sorted=false))

function Base.show(io::IO, psi::MPS)
print(io, "MPS (#tensors=$(ntensors(psi)), #inds=$(ninds(psi)) #maxbondsize=$(maxbondsize(psi)))")
print(io, "MPS (#tensors=$(ntensors(psi)), #inds=$(ninds(psi)), maxbondsize=$(maxbondsize(psi)))")
end

""" Expectation value for a one-site operator `op` on site `op_site` of mps `psi`, brings `psi` to canonical form. """
function expect_1site!(psi::MPS, op::AbstractArray, op_site::Int)
canonize!(psi, MixedCanonical(site"$(op_site)"))
plug_ind = ind_at(psi, plug"$(op_site)")
temp_ind = Index(:_temp_bra)
ev = binary_einsum(psi[op_site], Tensor(op, [temp_ind, plug_ind]))
ev = binary_einsum(ev, conj(replace(psi[op_site], plug_ind => temp_ind)))

return ev
end

""" Expectation value for a one-site operator `op` on site `op_site` of mps `psi`.
This makes a copy of the MPS """
function expect_1site(psi::MPS, op::AbstractArray, op_site::Int)
psi = copy(psi)
expect_1site!(psi, op, op_site)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind moving them to a Operations/expect.jl file please?

5 changes: 5 additions & 0 deletions src/Operations/evolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ struct ZipUpAlgorithm <: EvolveAlgorithm end

function evolve! end

function evolve(tn, op; kwargs...)
tn = copy(tn)
evolve!(tn, op; kwargs...)
end

evolve!(tn, op; kwargs...) = evolve!(tn, op, DelegatorTrait(Evolvable(), tn); kwargs...)
evolve!(tn, op, ::DelegateToField; kwargs...) = evolve!(delegator(Evolvable(), tn), op; kwargs...)
evolve!(tn, op, ::DontDelegate; algorithm=UnknownAlgorithm(), kwargs...) = evolve!(algorithm, tn, op; kwargs...)
Expand Down
Loading