From d9c93e353397ec83c34b2bb67b079a27dd29183d Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 15:54:07 -0400 Subject: [PATCH 1/3] Start using ITensorMPS --- Project.toml | 10 +++++----- README.md | 4 ++-- examples/README.jl | 4 ++-- examples/apply_gates.jl | 2 +- examples/directions.jl | 2 +- examples/orthogonalize_MPO_demo.jl | 2 +- examples/pprintH_demo.jl | 2 +- examples/pseudo2D_demo.jl | 2 +- examples/szparity.jl | 2 +- examples/test_2bodyH.jl | 2 +- examples/test_3bodyH.jl | 2 +- examples/truncate_MPO_demo.jl | 2 +- examples/two_component-BH_model.jl | 2 +- src/ITensorMPOCompression.jl | 2 +- src/orthogonalize.jl | 4 ++-- src/qx.jl | 2 +- src/truncate.jl | 2 +- src/util.jl | 2 +- test/blocking.jl | 2 +- test/gauge_fix.jl | 2 +- test/hamiltonians.jl | 2 +- test/orthogonalize.jl | 2 +- test/qx_unittests.jl | 2 +- test/runtests.jl | 2 +- test/truncate.jl | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Project.toml b/Project.toml index bd23052..f562f81 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,7 @@ authors = ["Jan Reimers and contributors"] version = "0.3.1" [deps] -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" @@ -13,11 +13,11 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -Documenter = "0.27" -ITensors = "0.3" -NDTensors = "0.1.45" -julia = "1" +ITensorMPS = "0.1" +ITensors = "0.3, 0.4, 0.5, 0.6" +NDTensors = "0.1.45, 0.2, 0.3" StaticArrays = "0.12, 1.0" +julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/README.md b/README.md index e8cfe18..2d3a272 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ julia> ] add ITensorMPOCompression Here are is an example of orthogonalizing an hand generated (not using AutoMPO) MPO ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression @@ -125,7 +125,7 @@ julia> pprint(H) #High level view of what is in the MPO. Here are is an example of truncating an hand generated (not using AutoMPO) MPO ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression diff --git a/examples/README.jl b/examples/README.jl index 50b9ae9..d4dd892 100644 --- a/examples/README.jl +++ b/examples/README.jl @@ -28,7 +28,7 @@ #' #' Here are is an example of orthogonalizing an hand generated (not using AutoMPO) MPO #+ term=true -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl"); @@ -50,7 +50,7 @@ pprint(H) #High level view of what is in the MPO. #' Here are is an example of truncating an hand generated (not using AutoMPO) MPO #+ term=true -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl"); diff --git a/examples/apply_gates.jl b/examples/apply_gates.jl index c0cea32..89a09a7 100644 --- a/examples/apply_gates.jl +++ b/examples/apply_gates.jl @@ -1,5 +1,5 @@ # Define the nearest neighbor term `S⋅S` for the Heisenberg model -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Printf Base.show(io::IO, f::Float64) = @printf(io, "%1.5f", f) diff --git a/examples/directions.jl b/examples/directions.jl index 0a22edf..cd9a68f 100644 --- a/examples/directions.jl +++ b/examples/directions.jl @@ -1,4 +1,4 @@ -using ITensors, ITensorMPOCompression +using ITensors, ITensorMPS, ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl") N = 10 diff --git a/examples/orthogonalize_MPO_demo.jl b/examples/orthogonalize_MPO_demo.jl index e86f805..d63f1b2 100644 --- a/examples/orthogonalize_MPO_demo.jl +++ b/examples/orthogonalize_MPO_demo.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl") diff --git a/examples/pprintH_demo.jl b/examples/pprintH_demo.jl index eda6f4d..e9b0451 100644 --- a/examples/pprintH_demo.jl +++ b/examples/pprintH_demo.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl") diff --git a/examples/pseudo2D_demo.jl b/examples/pseudo2D_demo.jl index 6b249e2..2b64670 100644 --- a/examples/pseudo2D_demo.jl +++ b/examples/pseudo2D_demo.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Printf Base.show(io::IO, f::Float64) = @printf(io, "%1.3f", f) diff --git a/examples/szparity.jl b/examples/szparity.jl index d3bd8c7..641176b 100644 --- a/examples/szparity.jl +++ b/examples/szparity.jl @@ -1,4 +1,4 @@ -using ITensors, ITensorMPOCompression +using ITensors, ITensorMPS, ITensorMPOCompression import ITensorMPOCompression: assign!, slice diff --git a/examples/test_2bodyH.jl b/examples/test_2bodyH.jl index 4557c4c..8fa47dc 100644 --- a/examples/test_2bodyH.jl +++ b/examples/test_2bodyH.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test diff --git a/examples/test_3bodyH.jl b/examples/test_3bodyH.jl index 1a5456d..27b172e 100644 --- a/examples/test_3bodyH.jl +++ b/examples/test_3bodyH.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test diff --git a/examples/truncate_MPO_demo.jl b/examples/truncate_MPO_demo.jl index ce64954..b774b98 100644 --- a/examples/truncate_MPO_demo.jl +++ b/examples/truncate_MPO_demo.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl") diff --git a/examples/two_component-BH_model.jl b/examples/two_component-BH_model.jl index 13cddd8..bd61f60 100644 --- a/examples/two_component-BH_model.jl +++ b/examples/two_component-BH_model.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS function two_component_BH(N::Int64;U=1.0,U12=-0.5,t1=0.5,t2=0.25,kwargs...) sites = siteinds("Boson",N;conserve_qns=true,conserve_number=false) op = OpSum() diff --git a/src/ITensorMPOCompression.jl b/src/ITensorMPOCompression.jl index e7aa2cd..a701901 100644 --- a/src/ITensorMPOCompression.jl +++ b/src/ITensorMPOCompression.jl @@ -1,6 +1,6 @@ module ITensorMPOCompression -using ITensors +using ITensors, ITensorMPS using NDTensors import ITensors: addqns, isortho, orthocenter, setinds , linkind, data, permute, checkflux diff --git a/src/orthogonalize.jl b/src/orthogonalize.jl index b4ebc4f..e1cb2fd 100644 --- a/src/orthogonalize.jl +++ b/src/orthogonalize.jl @@ -20,7 +20,7 @@ atol=`-1.0 and rtol=`-1.0 indicates no rank reduction. # Examples ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl"); julia> N=10; #10 sites @@ -98,7 +98,7 @@ atol=`-1.0 and rtol=`-1.0 indicates no rank reduction. # Examples ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl"); julia> N=10; #10 sites diff --git a/src/qx.jl b/src/qx.jl index cc11570..e9ec1a6 100644 --- a/src/qx.jl +++ b/src/qx.jl @@ -26,7 +26,7 @@ Hilbert space. # Example ```julia -julia>using ITensors +julia>using ITensors, ITensorMPS julia>using ITensorMPOCompression julia>N=5; #5 sites julia>NNN=2; #Include 2nd nearest neighbour interactions diff --git a/src/truncate.jl b/src/truncate.jl index 9dc3b55..63aa09c 100644 --- a/src/truncate.jl +++ b/src/truncate.jl @@ -19,7 +19,7 @@ Compress an MPO using block respecting SVD techniques as described in # Example ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression include("../test/hamiltonians/hamiltonians.jl") julia> N=10; #10 sites diff --git a/src/util.jl b/src/util.jl index 4138298..415b102 100644 --- a/src/util.jl +++ b/src/util.jl @@ -166,7 +166,7 @@ for Lower in the other two columns. # Examples ```julia -julia> using ITensors +julia> using ITensors, ITensorMPS julia> using ITensorMPOCompression julia> N=10; #10 sites julia> NNN=7; #Include up to 7th nearest neighbour interactions diff --git a/test/blocking.jl b/test/blocking.jl index f44bacb..7aebcf5 100644 --- a/test/blocking.jl +++ b/test/blocking.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test diff --git a/test/gauge_fix.jl b/test/gauge_fix.jl index b67d378..1a3b947 100644 --- a/test/gauge_fix.jl +++ b/test/gauge_fix.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test using Revise, Printf, SparseArrays diff --git a/test/hamiltonians.jl b/test/hamiltonians.jl index 6714248..cbc0366 100644 --- a/test/hamiltonians.jl +++ b/test/hamiltonians.jl @@ -1,5 +1,5 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Revise using Test diff --git a/test/orthogonalize.jl b/test/orthogonalize.jl index 18fc64c..e59a813 100644 --- a/test/orthogonalize.jl +++ b/test/orthogonalize.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Revise using Test diff --git a/test/qx_unittests.jl b/test/qx_unittests.jl index 6494326..7df12a9 100644 --- a/test/qx_unittests.jl +++ b/test/qx_unittests.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test using Printf diff --git a/test/runtests.jl b/test/runtests.jl index eea6cb6..ffcac8b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Test using Revise diff --git a/test/truncate.jl b/test/truncate.jl index d9b0f57..d15160f 100644 --- a/test/truncate.jl +++ b/test/truncate.jl @@ -1,4 +1,4 @@ -using ITensors +using ITensors, ITensorMPS using ITensorMPOCompression using Revise using Test From 66c5877a0a45c83108c6ddf79aedf62518c5d8ce Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 16:29:34 -0400 Subject: [PATCH 2/3] Remove unnecessary test dependencies --- test/blocking.jl | 2 +- test/gauge_fix.jl | 2 +- test/hamiltonians.jl | 2 -- test/orthogonalize.jl | 1 - test/runtests.jl | 1 - test/truncate.jl | 2 -- 6 files changed, 2 insertions(+), 8 deletions(-) diff --git a/test/blocking.jl b/test/blocking.jl index 7aebcf5..3b0e62d 100644 --- a/test/blocking.jl +++ b/test/blocking.jl @@ -2,7 +2,7 @@ using ITensors, ITensorMPS using ITensorMPOCompression using Test -using Revise, Printf +using Printf include("hamiltonians/hamiltonians.jl") Base.show(io::IO, f::Float64) = @printf(io, "%1.3f", f) #dumb way to control float output diff --git a/test/gauge_fix.jl b/test/gauge_fix.jl index 1a3b947..cc05566 100644 --- a/test/gauge_fix.jl +++ b/test/gauge_fix.jl @@ -1,7 +1,7 @@ using ITensors, ITensorMPS using ITensorMPOCompression using Test -using Revise, Printf, SparseArrays +using Printf, SparseArrays include("hamiltonians/hamiltonians.jl") import ITensorMPOCompression: gauge_fix!, is_gauge_fixed diff --git a/test/hamiltonians.jl b/test/hamiltonians.jl index cbc0366..9a5f339 100644 --- a/test/hamiltonians.jl +++ b/test/hamiltonians.jl @@ -1,7 +1,5 @@ - using ITensors, ITensorMPS using ITensorMPOCompression -using Revise using Test include("hamiltonians/hamiltonians.jl") diff --git a/test/orthogonalize.jl b/test/orthogonalize.jl index e59a813..151e03e 100644 --- a/test/orthogonalize.jl +++ b/test/orthogonalize.jl @@ -1,6 +1,5 @@ using ITensors, ITensorMPS using ITensorMPOCompression -using Revise using Test using Printf diff --git a/test/runtests.jl b/test/runtests.jl index ffcac8b..39a77ac 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,6 @@ using ITensors, ITensorMPS using ITensorMPOCompression using Test -using Revise @testset "ITensorMPOCompression.jl" begin @testset verbose = true "$filename" for filename in [ diff --git a/test/truncate.jl b/test/truncate.jl index d15160f..5b7dc3f 100644 --- a/test/truncate.jl +++ b/test/truncate.jl @@ -1,9 +1,7 @@ using ITensors, ITensorMPS using ITensorMPOCompression -using Revise using Test using Printf -using Profile include("hamiltonians/hamiltonians.jl") From fc99648aeb881fca570e543e2f30e0ef0a270f6a Mon Sep 17 00:00:00 2001 From: mtfishman Date: Tue, 14 May 2024 19:39:40 -0400 Subject: [PATCH 3/3] Change ITensor constructor to use storage, not Tensor --- src/subtensor.jl | 2 +- test/Project.toml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/Project.toml diff --git a/src/subtensor.jl b/src/subtensor.jl index 35370cb..9b977e3 100644 --- a/src/subtensor.jl +++ b/src/subtensor.jl @@ -171,7 +171,7 @@ end function get_subtensor_wrapper( T::DenseTensor{ElT,N}, new_inds, rs::UnitRange{Int64}... ) where {ElT,N} - return ITensor(T[rs...], new_inds) + return ITensor(storage(T[rs...]), new_inds) end function get_subtensor_wrapper( diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..b8914e1 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,5 @@ +[deps] +ITensorMPOCompression = "03645d51-6a26-4d1e-b9a1-035dc79d88e7" +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" +ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" +NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"