Skip to content

Commit

Permalink
Reorganize and limit exports
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jan 17, 2025
1 parent d0c4005 commit ee88fc2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 54 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.12.0"
[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
Expand All @@ -25,6 +26,7 @@ VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
Accessors = "0.1"
Aqua = "0.8.9"
BlockTensorKit = "0.1.1"
Compat = "3.47, 4.10"
DocStringExtensions = "0.9.3"
HalfIntegers = "1.6.0"
KrylovKit = "0.8.3"
Expand Down
102 changes: 59 additions & 43 deletions src/MPSKit.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
module MPSKit

# Public API
# ----------
# utility:
export PeriodicArray, PeriodicVector, PeriodicMatrix
export WindowArray
export left_virtualspace, right_virtualspace, physicalspace
export braille

# states:
export FiniteMPS
export InfiniteMPS
export WindowMPS
export MultilineMPS
export QP, LeftGaugedQP, RightGaugedQP

# operators:
export AbstractMPO
export MPO, FiniteMPO, InfiniteMPO
export MPOHamiltonian, FiniteMPOHamiltonian, InfiniteMPOHamiltonian
export MultilineMPO
export UntimedOperator, TimedOperator, MultipliedOperator, LazySum

# environments:
export environments
export leftenv, rightenv

# algorithms:
export find_groundstate, find_groundstate!
export leading_boundary
export approximate, approximate!
export VUMPS, VOMPS, DMRG, DMRG2, IDMRG1, IDMRG2, GradientGrassmann
export excitations
export FiniteExcited, QuasiparticleAnsatz, ChepigaAnsatz, ChepigaAnsatz2
export time_evolve, timestep, timestep!, make_time_mpo
export TDVP, TDVP2, WI, WII, TaylorCluster
export changebonds, changebonds!
export VUMPSSvdCut, OptimalExpand, SvdCut, RandExpand
export propagator
export DynamicalDMRG, NaiveInvert, Jeckelmann
export exact_diagonalization, fidelity_susceptibility

# toolbox:
export expectation_value, correlator, variance
export correlation_length, marek_gap, transfer_spectrum
export entropy, entanglement_spectrum
export open_boundary_conditions, periodic_boundary_conditions
export entanglementplot, transferplot
export r_LL, l_LL, r_RR, l_RR, r_RL, r_LR, l_RL, l_LR # TODO: rename

# unexported
using Compat: @compat
@compat public DynamicTols
@compat public VERBOSE_NONE, VERBOSE_WARN, VERBOSE_CONV, VERBOSE_ITER, VERBOSE_ALL
@compat public IterLog, loginit!, logiter!, logfinish!, logcancel!

# Imports
# -------
using TensorKit
using TensorKit: BraidingTensor
using BlockTensorKit
Expand All @@ -22,49 +79,8 @@ using Base: @kwdef
using LoggingExtras
using OhMyThreads

# bells and whistles for mpses
export InfiniteMPS, FiniteMPS, WindowMPS, MultilineMPS
export PeriodicArray, PeriodicVector, PeriodicMatrix, WindowArray
export MPSTensor
export QP, LeftGaugedQP, RightGaugedQP
export r_LL, l_LL, r_RR, l_RR, r_RL, r_LR, l_RL, l_LR # should be properties

# useful utility functions?
export add_util_leg, max_Ds, recalculate!
export left_virtualspace, right_virtualspace, physicalspace
export entanglementplot, transferplot
export braille

# hamiltonian things
export AbstractMPO
export MPO, FiniteMPO, InfiniteMPO
export MPOHamiltonian, FiniteMPOHamiltonian, InfiniteMPOHamiltonian
export SparseMPO, DenseMPO, MultilineMPO
export UntimedOperator, TimedOperator, MultipliedOperator, LazySum

export ∂C, ∂AC, ∂AC2, environments, expectation_value, effective_excitation_hamiltonian
export leftenv, rightenv

# algos
export find_groundstate!, find_groundstate, leading_boundary
export VUMPS, VOMPS, DMRG, DMRG2, IDMRG1, IDMRG2, GradientGrassmann
export excitations, FiniteExcited, QuasiparticleAnsatz, ChepigaAnsatz, ChepigaAnsatz2
export marek_gap, correlation_length, correlator
export time_evolve, timestep!, timestep
export TDVP, TDVP2, make_time_mpo, WI, WII, TaylorCluster
export entanglement_spectrum, transfer_spectrum, variance
export changebonds!, changebonds, VUMPSSvdCut, OptimalExpand, SvdCut, RandExpand
export entropy
export propagator, NaiveInvert, Jeckelmann, DynamicalDMRG
export fidelity_susceptibility
export approximate!, approximate
export periodic_boundary_conditions, open_boundary_conditions
export exact_diagonalization

# transfer matrix
export TransferMatrix
export transfer_left, transfer_right

# Includes
# --------
include("algorithms/algorithm.jl")

# submodules
Expand Down
3 changes: 2 additions & 1 deletion src/algorithms/grassmann.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ The module exports nothing, and all references to it should be qualified, e.g.
module GrassmannMPS

using ..MPSKit
using ..MPSKit: AbstractMPSEnvironments, InfiniteEnvironments, MultilineEnvironments, ∂∂AC
using ..MPSKit: AbstractMPSEnvironments, InfiniteEnvironments, MultilineEnvironments, ∂∂AC,
recalculate!
using TensorKit
using OhMyThreads
import TensorKitManifolds.Grassmann
Expand Down
6 changes: 3 additions & 3 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ end
Δt = 0.1
expH = make_time_mpo(H, Δt, WII())

O = DenseMPO(expH)
O = MPSKit.DenseMPO(expH)
Op = periodic_boundary_conditions(O, 10)
Op′ = changebonds(Op, SvdCut(; trscheme=truncdim(5)))

Expand Down Expand Up @@ -698,8 +698,8 @@ end
dt = 1e-3
sW1 = make_time_mpo(H, dt, TaylorCluster(; N=3))
sW2 = make_time_mpo(H, dt, WII())
W1 = DenseMPO(sW1)
W2 = DenseMPO(sW2)
W1 = MPSKit.DenseMPO(sW1)
W2 = MPSKit.DenseMPO(sW2)

ψ1, _ = approximate(ψ, (sW1, ψ), VOMPS(; verbosity))
ψ2, _ = approximate(ψ, (W2, ψ), VOMPS(; verbosity))
Expand Down
2 changes: 1 addition & 1 deletion test/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ end

ψ = InfiniteMPS([pspace], [ou pspace])

W = DenseMPO(make_time_mpo(ham, 1im * 0.5, WII()))
W = MPSKit.DenseMPO(make_time_mpo(ham, 1im * 0.5, WII()))
@test W * (W * ψ) (W * W) * ψ atol = 1e-2 # TODO: there is a normalization issue here
end

Expand Down
13 changes: 7 additions & 6 deletions test/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using ..TestSetup
using Test, TestExtras
using MPSKit
using MPSKit: _transpose_front, _transpose_tail
using MPSKit: TransferMatrix
using TensorKit
using TensorKit:

Expand Down Expand Up @@ -185,8 +186,8 @@ end
normalize!(ψ)

#rand_quasiparticle is a private non-exported function
ϕ₁ = MPSKit.LeftGaugedQP(rand, ψ)
ϕ₂ = MPSKit.LeftGaugedQP(rand, ψ)
ϕ₁ = LeftGaugedQP(rand, ψ)
ϕ₂ = LeftGaugedQP(rand, ψ)

@test norm(axpy!(1, ϕ₁, copy(ϕ₂))) norm(ϕ₁) + norm(ϕ₂)
@test norm(ϕ₁) * 3 norm(ϕ₁ * 3)
Expand All @@ -200,7 +201,7 @@ end
@test norm(ϕ₁_f) norm(ϕ₁) atol = 1e-5

ev_f = expectation_value(ϕ₁_f, H) - expectation_value(ψ, H)
ev_q = dot(ϕ₁, effective_excitation_hamiltonian(H, ϕ₁))
ev_q = dot(ϕ₁, MPSKit.effective_excitation_hamiltonian(H, ϕ₁))
@test ev_f ev_q atol = 1e-5
end

Expand All @@ -212,14 +213,14 @@ end
ψ = InfiniteMPS(fill(d, period), fill(D, period))

#rand_quasiparticle is a private non-exported function
ϕ₁ = MPSKit.LeftGaugedQP(rand, ψ)
ϕ₂ = MPSKit.LeftGaugedQP(rand, ψ)
ϕ₁ = LeftGaugedQP(rand, ψ)
ϕ₂ = LeftGaugedQP(rand, ψ)

@test norm(axpy!(1, ϕ₁, copy(ϕ₂))) norm(ϕ₁) + norm(ϕ₂)
@test norm(ϕ₁) * 3 norm(ϕ₁ * 3)

@test dot(ϕ₁,
convert(MPSKit.LeftGaugedQP, convert(MPSKit.RightGaugedQP, ϕ₁)))
convert(LeftGaugedQP, convert(RightGaugedQP, ϕ₁)))
dot(ϕ₁, ϕ₁) atol = 1e-10
end
end
Expand Down

0 comments on commit ee88fc2

Please sign in to comment.