Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Oct 17, 2024
2 parents 90c7251 + 35d139c commit 86f3087
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensorNetworks"
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
authors = ["Matthew Fishman <[email protected]>, Joseph Tindall <[email protected]> and contributors"]
version = "0.11.19"
version = "0.11.21"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down Expand Up @@ -64,7 +64,7 @@ Graphs = "1.8"
GraphsFlows = "0.1.1"
ITensorMPS = "0.2.2"
ITensors = "0.6.8"
IsApprox = "0.1, 1"
IsApprox = "0.1, 1, 2"
IterTools = "1.4.0"
KrylovKit = "0.6, 0.7, 0.8"
MacroTools = "0.5"
Expand All @@ -75,7 +75,7 @@ Observers = "0.2.4"
PackageExtensionCompat = "1"
SerializedElementArrays = "0.1"
SimpleTraits = "0.9"
SparseArrayKit = "0.3"
SparseArrayKit = "0.3, 0.4"
SplitApplyCombine = "1.2"
StaticArrays = "1.5.12"
StructWalk = "0.2"
Expand Down
6 changes: 3 additions & 3 deletions src/solvers/alternating_update/alternating_update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function alternating_update(
nsites, # define default for each level of solver implementation
updater, # this specifies the update performed locally
outputlevel=default_outputlevel(),
region_printer=nothing,
sweep_printer=nothing,
region_printer=default_region_printer,
sweep_printer=default_sweep_printer,
(sweep_observer!)=nothing,
(region_observer!)=nothing,
root_vertex=GraphsExtensions.default_root_vertex(init_state),
Expand Down Expand Up @@ -59,7 +59,7 @@ function alternating_update(
(sweep_observer!)=nothing,
sweep_printer=default_sweep_printer,#?
(region_observer!)=nothing,
region_printer=nothing,
region_printer=default_region_printer,
)
state = copy(init_state)
@assert !isnothing(sweep_plans)
Expand Down
18 changes: 11 additions & 7 deletions src/solvers/defaults.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Printf: @printf
using Printf: @printf, @sprintf
using ITensorMPS: maxlinkdim
default_outputlevel() = 0
default_nsites() = 2
Expand All @@ -7,10 +7,12 @@ default_extracter() = default_extracter
default_inserter() = default_inserter
default_checkdone() = (; kws...) -> false
default_transform_operator() = nothing

format(x) = @sprintf("%s", x)
format(x::AbstractFloat) = @sprintf("%.1E", x)

function default_region_printer(;
cutoff,
maxdim,
mindim,
inserter_kwargs,
outputlevel,
state,
sweep_plan,
Expand All @@ -23,9 +25,11 @@ function default_region_printer(;
region = first(sweep_plan[which_region_update])
@printf("Sweep %d, region=%s \n", which_sweep, region)
print(" Truncated using")
@printf(" cutoff=%.1E", cutoff)
@printf(" maxdim=%d", maxdim)
@printf(" mindim=%d", mindim)
for key in [:cutoff, :maxdim, :mindim]
if haskey(inserter_kwargs, key)
print(" ", key, "=", format(inserter_kwargs[key]))
end
end
println()
if spec != nothing
@printf(
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
OMEinsumContractionOrders = "6f22d1fd-8eed-4bb7-9776-e7d684900715"
Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OrdinaryDiffEq: ODEProblem, Tsit5, solve
using ITensors: ITensor
using ITensorNetworks: TimeDependentSum, to_vec
using ITensors: ITensor
using KrylovKit: exponentiate
using OrdinaryDiffEqTsit5: ODEProblem, Tsit5, solve

function ode_solver(
H::TimeDependentSum,
Expand Down
3 changes: 2 additions & 1 deletion test/test_treetensornetworks/test_solvers/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
28 changes: 27 additions & 1 deletion test/test_treetensornetworks/test_solvers/test_dmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using KrylovKit: eigsolve
using NamedGraphs.NamedGraphGenerators: named_comb_tree
using Observers: observer
using StableRNGs: StableRNG
using Suppressor: @capture_out
using Test: @test, @test_broken, @testset

# This is needed since `eigen` is broken
Expand Down Expand Up @@ -76,6 +77,31 @@ ITensors.disable_auto_fermion()
new_E = inner(psi', H, psi)
@test new_E ≈ orig_E
=#

#
# Test outputlevels are working
#
prev_output = ""
for outputlevel in 0:2
output = @capture_out begin
e, psi = dmrg(
H,
psi;
outputlevel,
nsweeps,
maxdim,
cutoff,
nsites,
updater_kwargs=(; krylovdim=3, maxiter=1),
)
end
if outputlevel == 0
@test length(output) == 0
else
@test length(output) > length(prev_output)
end
prev_output = output
end
end

@testset "Observers" begin
Expand Down Expand Up @@ -139,7 +165,7 @@ end
nsweeps,
maxdim,
cutoff,
outputlevel=2,
outputlevel=0,
transform_operator=ITensorNetworks.cache_operator_to_disk,
transform_operator_kwargs=(; write_when_maxdim_exceeds=11),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@eval module $(gensym())
using ITensors: contract
using ITensorNetworks: ITensorNetworks, TimeDependentSum, ttn, mpo, mps, siteinds, tdvp
using ITensorNetworks.ModelHamiltonians: ModelHamiltonians
using OrdinaryDiffEq: Tsit5
using ITensors: contract
using KrylovKit: exponentiate
using LinearAlgebra: norm
using NamedGraphs: AbstractNamedEdge
using NamedGraphs.NamedGraphGenerators: named_comb_tree
using OrdinaryDiffEqTsit5: Tsit5
using Test: @test, @test_broken, @testset

include(
Expand Down

0 comments on commit 86f3087

Please sign in to comment.