diff --git a/src/algorithms/groundstate/find_groundstate.jl b/src/algorithms/groundstate/find_groundstate.jl index 30a5abcfd..493dbdc45 100644 --- a/src/algorithms/groundstate/find_groundstate.jl +++ b/src/algorithms/groundstate/find_groundstate.jl @@ -26,7 +26,7 @@ function find_groundstate( tol = Defaults.tol, maxiter = Defaults.maxiter, verbosity = Defaults.verbosity, trscheme = nothing ) - if isa(ψ, InfiniteMPS) + if GeometryStyle(ψ) == InfiniteChainStyle() alg = VUMPS(; tol = max(1.0e-4, tol), verbosity, maxiter) if tol < 1.0e-4 alg = alg & GradientGrassmann(; tol = tol, maxiter, verbosity) @@ -34,7 +34,7 @@ function find_groundstate( if !isnothing(trscheme) alg = IDMRG2(; tol = min(1.0e-2, 100tol), verbosity, trscheme) & alg end - elseif isa(ψ, AbstractFiniteMPS) + elseif GeometryStyle(ψ) == FiniteChainStyle() alg = DMRG(; tol, maxiter, verbosity) if !isnothing(trscheme) alg = DMRG2(; tol = min(1.0e-2, 100tol), verbosity, trscheme) & alg diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 6cb71afd3..801b868c4 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -72,6 +72,7 @@ end function find_groundstate(mps, operator, alg::alg_type, envs = environments(mps, operator)) where {alg_type <: Union{<:IDMRG, <:IDMRG2}} (length(mps) ≤ 1 && alg isa IDMRG2) && throw(ArgumentError("unit cell should be >= 2")) + GeometryStyle(operator, mps) != InfiniteChainStyle() && throw(ArgumentError("IDMRG only supports infinite systems.")) log = alg isa IDMRG ? IterLog("IDMRG") : IterLog("IDMRG2") mps = copy(mps) iter = 0 diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index 99da8234c..5199b4ad4 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -46,7 +46,7 @@ struct VUMPSState{S, O, E} end function find_groundstate( - mps::InfiniteMPS, operator, alg::VUMPS, envs = environments(mps, operator) + mps, operator, alg::VUMPS, envs = environments(mps, operator) ) return dominant_eigsolve(operator, mps, alg, envs; which = :SR) end @@ -55,6 +55,7 @@ function dominant_eigsolve( operator, mps, alg::VUMPS, envs = environments(mps, operator); which ) + GeometryStyle(operator, mps) != InfiniteChainStyle() && throw(ArgumentError("VUMPS only supports infinite systems.")) log = IterLog("VUMPS") iter = 0 ϵ = calc_galerkin(mps, operator, mps, envs) diff --git a/src/operators/lazysum.jl b/src/operators/lazysum.jl index 7bb2b5ce8..366a221d7 100644 --- a/src/operators/lazysum.jl +++ b/src/operators/lazysum.jl @@ -30,6 +30,9 @@ Base.complex(x::LazySum) = LazySum(complex.(x.ops)) TimeDependence(x::LazySum) = istimed(x) ? TimeDependent() : NotTimeDependent() istimed(x::LazySum) = any(istimed, x) +OperatorStyle(::Type{LazySum{O}}) where {O} = OperatorStyle(O) +GeometryStyle(::Type{LazySum{O}}) where {O} = GeometryStyle(O) + # constructors LazySum(x) = LazySum([x]) LazySum(ops::AbstractVector, fs::AbstractVector) = LazySum(map(MultipliedOperator, ops, fs))