Skip to content

Commit

Permalink
Renaming MPSMultiline and MPOMultiline to MultilineMPS and `Mul…
Browse files Browse the repository at this point in the history
…tilineMPO` (#210)

* find and replace `MPSMultiline` with `MultilineMPS`

* rename the rest of the `MPSMultiline` occurences

* find and replace `MPOMultiline` with `MultilineMPO`

* more finding and replacing `MPOMultiline` with `MultilineMPO`
  • Loading branch information
VictorVanthilt authored Dec 16, 2024
1 parent 283a62c commit a868108
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 160 deletions.
2 changes: 1 addition & 1 deletion docs/src/lib/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
FiniteMPS
InfiniteMPS
WindowMPS
MPSMultiline
MultilineMPS
```

## Operators
Expand Down
10 changes: 5 additions & 5 deletions docs/src/man/states.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ Such a set can be created by

```julia
data = fill(TensorMap(rand,ComplexF64,ℂ^10*^2,ℂ^10),2,2);
MPSMultiline(data);
MultilineMPS(data);
```
MPSMultiline is also used extensively in as of yet unreleased peps code.
MultilineMPS is also used extensively in as of yet unreleased peps code.

You can access properties by calling
```julia
Expand All @@ -153,7 +153,7 @@ struct Multiline{T}
end
```

MPSMultiline/MPOMultiline are then defined as
MultilineMPS/MultilineMPO are then defined as
```julia
const MPSMultiline = Multiline{<:InfiniteMPS}
const MPOMultiline = Multiline{<:DenseMPO}
const MultilineMPS = Multiline{<:InfiniteMPS}
const MultilineMPO = Multiline{<:DenseMPO}
8 changes: 4 additions & 4 deletions src/MPSKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using Base: @kwdef
using LoggingExtras

# bells and whistles for mpses
export InfiniteMPS, FiniteMPS, WindowMPS, MPSMultiline
export InfiniteMPS, FiniteMPS, WindowMPS, MultilineMPS
export PeriodicArray, PeriodicVector, PeriodicMatrix, WindowArray
export MPSTensor
export QP, LeftGaugedQP, RightGaugedQP
Expand All @@ -34,7 +34,7 @@ export braille
export AbstractMPO
export MPO, FiniteMPO, InfiniteMPO
export MPOHamiltonian, FiniteMPOHamiltonian, InfiniteMPOHamiltonian
export SparseMPO, DenseMPO, MPOMultiline
export SparseMPO, DenseMPO, MultilineMPO
export UntimedOperator, TimedOperator, MultipliedOperator, LazySum

export ∂C, ∂AC, ∂AC2, environments, expectation_value, effective_excitation_hamiltonian
Expand Down Expand Up @@ -83,7 +83,7 @@ include("utility/linearcombination.jl")
# maybe we should introduce an abstract state type
include("states/abstractmps.jl")
include("states/infinitemps.jl")
include("states/mpsmultiline.jl")
include("states/multilinemps.jl")
include("states/finitemps.jl")
include("states/windowmps.jl")
include("states/orthoview.jl")
Expand All @@ -93,7 +93,7 @@ include("states/ortho.jl")
include("operators/abstractmpo.jl")
include("operators/mpo.jl")
include("operators/mpohamiltonian.jl") # the mpohamiltonian objects
include("operators/mpomultiline.jl")
include("operators/multilinempo.jl")
include("operators/projection.jl")
include("operators/timedependence.jl")
include("operators/multipliedoperator.jl")
Expand Down
8 changes: 4 additions & 4 deletions src/algorithms/approximate/idmrg.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function approximate(ost::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMultiline},
function approximate(ost::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:MultilineMPS},
alg::IDMRG1, oenvs=environments(ost, toapprox))
ψ = copy(ost)
mpo, above = toapprox
Expand Down Expand Up @@ -52,12 +52,12 @@ function approximate(ost::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMult
end
end

nst = MPSMultiline(map(x -> x, ψ.AR); tol=alg.tol_gauge)
nst = MultilineMPS(map(x -> x, ψ.AR); tol=alg.tol_gauge)
nenvs = environments(nst, toapprox)
return nst, nenvs, ϵ
end

function approximate(ost::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMultiline},
function approximate(ost::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:MultilineMPS},
alg::IDMRG2, oenvs=environments(ost, toapprox))
length(ost) < 2 && throw(ArgumentError("unit cell should be >= 2"))
mpo, above = toapprox
Expand Down Expand Up @@ -139,7 +139,7 @@ function approximate(ost::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMult
end
end

nst = MPSMultiline(map(x -> x, ψ.AR); tol=alg.tol_gauge)
nst = MultilineMPS(map(x -> x, ψ.AR); tol=alg.tol_gauge)
nenvs = environments(nst, toapprox)
return nst, nenvs, ϵ
end
14 changes: 7 additions & 7 deletions src/algorithms/approximate/vomps.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
function approximate::InfiniteMPS,
toapprox::Tuple{<:InfiniteMPO,<:InfiniteMPS}, algorithm,
envs=environments(ψ, toapprox))
# PeriodicMPO's always act on MPSMultiline's. To avoid code duplication, define everything in terms of MPSMultiline's.
multi, envs = approximate(convert(MPSMultiline, ψ),
(convert(MPOMultiline, toapprox[1]),
convert(MPSMultiline, toapprox[2])), algorithm, envs)
# PeriodicMPO's always act on MultilineMPS's. To avoid code duplication, define everything in terms of MultilineMPS's.
multi, envs = approximate(convert(MultilineMPS, ψ),
(convert(MultilineMPO, toapprox[1]),
convert(MultilineMPS, toapprox[2])), algorithm, envs)
ψ = convert(InfiniteMPS, multi)
return ψ, envs
end

Base.@deprecate(approximate::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMultiline},
Base.@deprecate(approximate::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:MultilineMPS},
alg::VUMPS, envs...; kwargs...),
approximate(ψ, toapprox,
VOMPS(; alg.tol, alg.maxiter, alg.finalize,
alg.verbosity, alg.alg_gauge, alg.alg_environments),
envs...; kwargs...))

function approximate::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMultiline},
function approximate::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:MultilineMPS},
alg::VOMPS, envs=environments(ψ, toapprox))
ϵ::Float64 = calc_galerkin(ψ, envs)
temp_ACs = similar.(ψ.AC)
Expand All @@ -38,7 +38,7 @@ function approximate(ψ::MPSMultiline, toapprox::Tuple{<:MPOMultiline,<:MPSMulti
end

alg_gauge = updatetol(alg.alg_gauge, iter, ϵ)
ψ = MPSMultiline(temp_ACs, ψ.CR[:, end]; alg_gauge.tol, alg_gauge.maxiter)
ψ = MultilineMPS(temp_ACs, ψ.CR[:, end]; alg_gauge.tol, alg_gauge.maxiter)

alg_environments = updatetol(alg.alg_environments, iter, ϵ)
recalculate!(envs, ψ; alg_environments.tol)
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/changebonds/changebonds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function _expand!(ψ::InfiniteMPS, AL′::PeriodicVector, AR′::PeriodicVector)
end
return normalize!(ψ)
end
function _expand!::MPSMultiline, AL′::PeriodicMatrix, AR′::PeriodicMatrix)
function _expand!::MultilineMPS, AL′::PeriodicMatrix, AR′::PeriodicMatrix)
for i in 1:size(ψ, 1)
_expand!(ψ[i], AL′[i, :], AR′[i, :])
end
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/changebonds/optimalexpand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ end

function changebonds::InfiniteMPS, H::DenseMPO, alg::OptimalExpand,
envs=environments(ψ, H))
(nmψ, envs) = changebonds(convert(MPSMultiline, ψ), convert(MPOMultiline, H), alg, envs)
(nmψ, envs) = changebonds(convert(MultilineMPS, ψ), convert(MultilineMPO, H), alg, envs)
return (convert(InfiniteMPS, nmψ), envs)
end

function changebonds::MPSMultiline, H, alg::OptimalExpand, envs=environments(ψ, H))
function changebonds::MultilineMPS, H, alg::OptimalExpand, envs=environments(ψ, H))
TL = eltype.AL)
AL′ = PeriodicMatrix{TL}(undef, size.AL))
TR = tensormaptype(spacetype(TL), 1, numind(TL) - 1, storagetype(TL))
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/changebonds/randexpand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function changebonds(ψ::InfiniteMPS, alg::RandExpand)
return _expand(ψ, AL′, AR′)
end

function changebonds::MPSMultiline, alg::RandExpand)
function changebonds::MultilineMPS, alg::RandExpand)
return Multiline(map(x -> changebonds(x, alg), ψ.data))
end

Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/changebonds/svdcut.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ end
function changebonds::InfiniteMPO, alg::SvdCut)
return convert(InfiniteMPO, changebonds(convert(InfiniteMPS, ψ), alg))
end
function changebonds::MPOMultiline, alg::SvdCut)
return convert(MPOMultiline, changebonds(convert(MPSMultiline, ψ), alg))
function changebonds::MultilineMPO, alg::SvdCut)
return convert(MultilineMPO, changebonds(convert(MultilineMPS, ψ), alg))
end
function changebonds::MPSMultiline, alg::SvdCut)
function changebonds::MultilineMPS, alg::SvdCut)
return Multiline(map(x -> changebonds(x, alg), ψ.data))
end
function changebonds::InfiniteMPS, alg::SvdCut)
Expand Down
12 changes: 6 additions & 6 deletions src/algorithms/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ Base.:*(h::Union{MPO_∂∂C,MPO_∂∂AC,MPO_∂∂AC2}, v) = h(v);
function ∂∂C(pos::Int, mps, operator::AbstractMPO, cache)
return MPO_∂∂C(leftenv(cache, pos + 1, mps), rightenv(cache, pos, mps))
end
function ∂∂C(col::Int, mps, operator::MPOMultiline, envs)
function ∂∂C(col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂C(leftenv(envs, col + 1, mps), rightenv(envs, col, mps))
end
function ∂∂C(row::Int, col::Int, mps, operator::MPOMultiline, envs)
function ∂∂C(row::Int, col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂C(leftenv(envs, row, col + 1, mps), rightenv(envs, row, col, mps))
end

function ∂∂AC(pos::Int, mps, operator::AbstractMPO, cache)
return MPO_∂∂AC(operator[pos], leftenv(cache, pos, mps), rightenv(cache, pos, mps))
end
function ∂∂AC(row::Int, col::Int, mps, operator::MPOMultiline, envs)
function ∂∂AC(row::Int, col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂AC(operator[row, col], leftenv(envs, row, col, mps),
rightenv(envs, row, col, mps))
end
function ∂∂AC(col::Int, mps, operator::MPOMultiline, envs)
function ∂∂AC(col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂AC(envs.operator[:, col], leftenv(envs, col, mps),
rightenv(envs, col, mps))
end;
Expand All @@ -57,11 +57,11 @@ function ∂∂AC2(pos::Int, mps, operator::AbstractMPO, cache)
return MPO_∂∂AC2(operator[pos], operator[pos + 1], leftenv(cache, pos, mps),
rightenv(cache, pos + 1, mps))
end;
function ∂∂AC2(col::Int, mps, operator::MPOMultiline, envs)
function ∂∂AC2(col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂AC2(operator[:, col], operator[:, col + 1], leftenv(envs, col, mps),
rightenv(envs, col + 1, mps))
end
function ∂∂AC2(row::Int, col::Int, mps, operator::MPOMultiline, envs)
function ∂∂AC2(row::Int, col::Int, mps, operator::MultilineMPO, envs)
return MPO_∂∂AC2(operator[row, col], operator[row, col + 1],
leftenv(envs, row, col, mps), rightenv(envs, row, col + 1, mps))
end
Expand Down
20 changes: 10 additions & 10 deletions src/algorithms/excitation/quasiparticleexcitation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ end
# Statmech Excitations #
################################################################################

function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP},
function excitations(H::MultilineMPO, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP},
lenvs, renvs; num=1, solver=Defaults.linearsolver)
qp_envs(ϕ) = environments(ϕ, H, lenvs, renvs; solver)
function H_eff(ϕ′)
Expand All @@ -194,13 +194,13 @@ function excitations(H::InfiniteMPO, alg::QuasiparticleAnsatz, ϕ₀::InfiniteQP
return Es, ϕs
end

function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP},
function excitations(H::MultilineMPO, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP},
lenvs; num=1, solver=Defaults.linearsolver)
# Infer `renvs` in function body as it depends on `solver`.
renvs = ϕ₀.trivial ? lenvs : environments(ϕ₀.right_gs, H; solver)
return excitations(H, alg, ϕ₀, lenvs, renvs; num, solver)
end
function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP};
function excitations(H::MultilineMPO, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP};
num=1, solver=Defaults.linearsolver)
# Infer `lenvs` in function body as it depends on `solver`.
lenvs = environments(ϕ₀.left_gs, H; solver)
Expand All @@ -212,19 +212,19 @@ function excitations(H::DenseMPO, alg::QuasiparticleAnsatz, momentum::Real,
lenvs=environments(lmps, H), rmps::InfiniteMPS=lmps,
renvs=lmps === rmps ? lenvs : environments(rmps, H);
sector=one(sectortype(lmps)), num=1, solver=Defaults.linearsolver)
multiline_lmps = convert(MPSMultiline, lmps)
multiline_lmps = convert(MultilineMPS, lmps)
if lmps === rmps
excitations(convert(MPOMultiline, H), alg, momentum, multiline_lmps, lenvs,
excitations(convert(MultilineMPO, H), alg, momentum, multiline_lmps, lenvs,
multiline_lmps,
lenvs; sector, num, solver)
else
excitations(convert(MPOMultiline, H), alg, momentum, multiline_lmps, lenvs,
convert(MPSMultiline, rmps), renvs; sector, num, solver)
excitations(convert(MultilineMPO, H), alg, momentum, multiline_lmps, lenvs,
convert(MultilineMPS, rmps), renvs; sector, num, solver)
end
end

function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, momentum::Real,
lmps::MPSMultiline,
function excitations(H::MultilineMPO, alg::QuasiparticleAnsatz, momentum::Real,
lmps::MultilineMPS,
lenvs=environments(lmps, H), rmps=lmps,
renvs=lmps === rmps ? lenvs : environments(rmps, H);
sector=one(sectortype(lmps)), num=1, solver=Defaults.linearsolver)
Expand Down Expand Up @@ -263,7 +263,7 @@ function effective_excitation_hamiltonian(H::Union{InfiniteMPOHamiltonian,
return ϕ′
end

function effective_excitation_hamiltonian(H::MPOMultiline, ϕ::Multiline{<:InfiniteQP},
function effective_excitation_hamiltonian(H::MultilineMPO, ϕ::Multiline{<:InfiniteQP},
envs=environments(ϕ, H))
ϕ′ = Multiline(similar.(ϕ.data))
left_gs = ϕ.left_gs
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/expval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ function expectation_value(ψ::FiniteQP, mpo::FiniteMPO)
return expectation_value(convert(FiniteMPS, ψ), mpo)
end
function expectation_value::InfiniteMPS, mpo::InfiniteMPO, envs...)
return expectation_value(convert(MPSMultiline, ψ), convert(MPOMultiline, mpo), envs...)
return expectation_value(convert(MultilineMPS, ψ), convert(MultilineMPO, mpo), envs...)
end
function expectation_value::MPSMultiline, O::MPOMultiline{<:Union{DenseMPO,SparseMPO}},
function expectation_value::MultilineMPS, O::MultilineMPO{<:Union{DenseMPO,SparseMPO}},
envs::InfiniteMPOEnvironments=environments(ψ, O))
return prod(product(1:size(ψ, 1), 1:size(ψ, 2))) do (i, j)
GL = leftenv(envs, i, j, ψ)
Expand All @@ -130,7 +130,7 @@ function expectation_value(ψ::MPSMultiline, O::MPOMultiline{<:Union{DenseMPO,Sp
conj.AC[i + 1, j][1 4; 8])
end
end
function expectation_value::MPSMultiline, mpo::MPOMultiline, envs...)
function expectation_value::MultilineMPS, mpo::MultilineMPO, envs...)
# TODO: fix environments
return prod(x -> expectation_value(x...), zip(parent(ψ), parent(mpo)))
end
Expand Down
14 changes: 7 additions & 7 deletions src/algorithms/grassmann.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ function ManifoldPoint(state::Union{InfiniteMPS,FiniteMPS}, envs)
return ManifoldPoint(state, envs, g, Rhoreg)
end

function ManifoldPoint(state::MPSMultiline, envs)
function ManifoldPoint(state::MultilineMPS, envs)
# FIXME: add support for unitcells
@assert length(state.AL) == 1 "GradientGrassmann only supports MPSMultiline without unitcells for now"
@assert length(state.AL) == 1 "GradientGrassmann only supports MultilineMPS without unitcells for now"

# TODO: this really should not use the operator from the environment
f = expectation_value(state, envs.operator, envs)
Expand Down Expand Up @@ -128,8 +128,8 @@ function fg(x::ManifoldPoint{T}) where {T<:Union{InfiniteMPS,FiniteMPS}}

return real(f), g_prec
end
function fg(x::ManifoldPoint{<:MPSMultiline})
@assert length(x.state) == 1 "GradientGrassmann only supports MPSMultiline without unitcells for now"
function fg(x::ManifoldPoint{<:MultilineMPS})
@assert length(x.state) == 1 "GradientGrassmann only supports MultilineMPS without unitcells for now"
# the gradient I want to return is the preconditioned gradient!
g_prec = map(enumerate(x.g)) do (i, cg)
return PrecGrad(rmul!(copy(cg), x.state.CR[i]'), x.Rhoreg[i])
Expand All @@ -145,9 +145,9 @@ function fg(x::ManifoldPoint{<:MPSMultiline})
end

"""
Retract a left-canonical MPSMultiline along Grassmann tangent `g` by distance `alpha`.
Retract a left-canonical MultilineMPS along Grassmann tangent `g` by distance `alpha`.
"""
function retract(x::ManifoldPoint{<:MPSMultiline}, tg, alpha)
function retract(x::ManifoldPoint{<:MultilineMPS}, tg, alpha)
g = reshape(tg, size(x.state))

nal = similar(x.state.AL)
Expand All @@ -157,7 +157,7 @@ function retract(x::ManifoldPoint{<:MPSMultiline}, tg, alpha)
h[i] = PrecGrad(th)
end

nstate = MPSKit.MPSMultiline(nal, x.state.CR[:, end])
nstate = MPSKit.MultilineMPS(nal, x.state.CR[:, end])
newpoint = ManifoldPoint(nstate, x.envs)

return newpoint, h[:]
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/statmech/gradient_grassmann.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function leading_boundary(state::InfiniteMPS, H::DenseMPO, alg::GradientGrassmann,
envs=environments(state, H))
(multi, envs, err) = leading_boundary(convert(MPSMultiline, state),
convert(MPOMultiline, H), alg, envs)
(multi, envs, err) = leading_boundary(convert(MultilineMPS, state),
convert(MultilineMPO, H), alg, envs)
state = convert(InfiniteMPS, multi)
return (state, envs, err)
end

function leading_boundary(state::MPSMultiline, H, alg::GradientGrassmann,
function leading_boundary(state::MultilineMPS, H, alg::GradientGrassmann,
envs=environments(state, H))
res = optimize(GrassmannMPS.fg,
GrassmannMPS.ManifoldPoint(state, envs),
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/statmech/vomps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Power method algorithm for infinite MPS.
alg_environments = Defaults.alg_environments()
end

function leading_boundary::MPSMultiline, O::MPOMultiline, alg::VOMPS,
function leading_boundary::MultilineMPS, O::MultilineMPO, alg::VOMPS,
envs=environments(ψ, O))
ϵ::Float64 = calc_galerkin(ψ, envs)
temp_ACs = similar.(ψ.AC)
Expand Down Expand Up @@ -62,7 +62,7 @@ function leading_boundary(ψ::MPSMultiline, O::MPOMultiline, alg::VOMPS,

regauge!.(temp_ACs, temp_Cs; alg=TensorKit.QRpos())
alg_gauge = updatetol(alg.alg_gauge, iter, ϵ)
ψ = MPSMultiline(temp_ACs, ψ.CR[:, end]; alg_gauge.tol, alg_gauge.maxiter)
ψ = MultilineMPS(temp_ACs, ψ.CR[:, end]; alg_gauge.tol, alg_gauge.maxiter)

alg_environments = updatetol(alg.alg_environments, iter, ϵ)
recalculate!(envs, ψ; alg_environments.tol)
Expand Down
Loading

0 comments on commit a868108

Please sign in to comment.