diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0558597..5063ebf 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -39,22 +39,22 @@ jobs: - uses: codecov/codecov-action@v2 with: files: lcov.info - docs: - name: Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-docdeploy@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} - - run: | - julia --project=docs -e ' - using Documenter: DocMeta, doctest - using ITensorTDVP - DocMeta.setdocmeta!(ITensorTDVP, :DocTestSetup, :(using ITensorTDVP); recursive=true) - doctest(ITensorTDVP)' +## docs: +## name: Documentation +## runs-on: ubuntu-latest +## steps: +## - uses: actions/checkout@v2 +## - uses: julia-actions/setup-julia@v1 +## with: +## version: '1' +## - uses: julia-actions/julia-buildpkg@v1 +## - uses: julia-actions/julia-docdeploy@v1 +## env: +## GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +## DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} +## - run: | +## julia --project=docs -e ' +## using Documenter: DocMeta, doctest +## using ITensorTDVP +## DocMeta.setdocmeta!(ITensorTDVP, :DocTestSetup, :(using ITensorTDVP); recursive=true) +## doctest(ITensorTDVP)' diff --git a/Project.toml b/Project.toml index f16f2e6..9207780 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensorTDVP" uuid = "25707e16-a4db-4a07-99d9-4d67b7af0342" authors = ["Matthew Fishman and contributors"] -version = "0.3.0" +version = "0.3.1" [deps] ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" @@ -18,7 +18,7 @@ Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" ITensorTDVPObserversExt = "Observers" [compat] -ITensors = "0.3.58, 0.4, 0.5" +ITensors = "0.3.58, 0.4, 0.5, 0.6" KrylovKit = "0.6, 0.7" Observers = "0.2" PackageExtensionCompat = "1" diff --git a/README.md b/README.md index 098670b..d8d93aa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ +| :warning: WARNING | +|:---------------------------| +| The [ITensorTDVP.jl](https://github.com/ITensor/ITensorTDVP.jl) package will be deprecated in favor of the [ITensorMPS.jl](https://github.com/ITensor/ITensorMPS.jl) package. We plan to move all of the code from this package into ITensorMPS.jl. For now, to help with backwards compatability, ITensorMPS.jl simply re-exports the functionality of ITensorTDVP.jl. To prepare for the change, please change `using ITensorTDVP` to `using ITensorMPS` in your code. | + # ITensorTDVP -[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://mtfishman.github.io/ITensorTDVP.jl/stable) -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://mtfishman.github.io/ITensorTDVP.jl/dev) [![Build Status](https://github.com/mtfishman/ITensorTDVP.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/mtfishman/ITensorTDVP.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/mtfishman/ITensorTDVP.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/mtfishman/ITensorTDVP.jl) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) @@ -16,6 +18,7 @@ julia> ] pkg> add ITensorTDVP ``` +However, as noted above we now recommend installing and loading `ITensorMPS` instead of `ITensorTDVP`. ## News @@ -44,9 +47,3 @@ energy, psi = ITensorTDVP.dmrg(H, psi0; nsweeps=10, maxdim=100, cutoff=1e-6) - `svd_alg` now doesn't specify a default value, so the default value is set by the `svd` function in ITensors/NDTensors. This fixes an issue using ITensorTDVP.jl and GPU backends, where the default value being set in ITensorTDVP.jl wasn't compatible with the options available in some GPU backends like CUDA. - More generally, keyword arguments are handled better throughout the package, so default values are handled more systematically and keyword arguments are listed or forwarded more explicitly, so it should catch more mistakes like passing an incorrect keyword argument name. - -## About - -This package is effectively a generalization of the DMRG code in [ITensors.jl](https://github.com/ITensor/ITensors.jl), using the MPS/MPO types from that package. It provides a general MPS "solver" interface which allows us to implement a variety of MPS/MPO optimization/solver functionality like DMRG (`ITensorTDVP.dmrg`), TDVP (`ITensorTDVP.tdvp`), linear solving (`ITensorTDVP.linsolve`/`KrylovKit.linsolve`), DMRG-X (`ITensorTDVP.dmrg_x`), etc. while sharing most of the code across those different functions. Therefore, it effectively supercedes the DMRG functionality in ITensors.jl (`dmrg`), and provides its own `ITensorTDVP.dmrg` function that is essentially the same as the `dmrg` function from ITensors.jl (though for now it only outputs the state, while `ITensors.dmrg` outputs the energy and the state, likely we will make the interface more similar to `ITensors.dmrg` in future versions of the code). This package is fairly stable and appropriate for general use. The primary missing feature is a lack of modern subspace expansion tools for methods like TDVP and 1-site DMRG. However, 2-site TDVP or TEBD is often sufficient for performing subspace expansion (except when [it's not](https://arxiv.org/abs/2005.06104)). - -However, note that future developments, including modern subspace expansion tools, are being developed in our next-generation tensor network library [ITensorNetworks.jl](https://github.com/mtfishman/ITensorNetworks.jl). The goal of that package is to provide contraction, optimization, and evolution tools for general tensor networks, as well as methods like DMRG, TDVP, and linear solving for tree tensor networks, and the eventual goal is to replace this package which is limited to solvers for just MPS/MPO (linear/path graph) tensor networks. However, ITensorNetworks.jl is under heavy development and is _not_ meant for general usage at the moment, except for those who are brave enough to handle missing features and breaking interfaces. Basically, for the average user who wants stable and reliable code, if you need to use MPS-based TDVP or linear solving, you should use this package for the time being. diff --git a/examples/01_tdvp.jl b/examples/01_tdvp.jl index 26e6dc2..9297d47 100644 --- a/examples/01_tdvp.jl +++ b/examples/01_tdvp.jl @@ -1,5 +1,4 @@ -using ITensors: ITensors, MPO, OpSum, inner, randomMPS, siteinds -using ITensorTDVP: ITensorTDVP, tdvp +using ITensorMPS: MPO, OpSum, dmrg, inner, randomMPS, siteinds, tdvp function main() n = 10 @@ -31,16 +30,11 @@ function main() cutoff=1e-10, outputlevel=1, ) - @show inner(ϕ', H, ϕ) / inner(ϕ, ϕ) - e2, ϕ2 = ITensors.dmrg(H, ψ; nsweeps=10, maxdim=20, cutoff=1e-10) - + e2, ϕ2 = dmrg(H, ψ; nsweeps=10, maxdim=20, cutoff=1e-10) @show inner(ϕ2', H, ϕ2) / inner(ϕ2, ϕ2), e2 - e3, ϕ3 = ITensorTDVP.dmrg(H, ψ; nsweeps=10, maxdim=20, cutoff=1e-10, outputlevel=1) - - @show inner(ϕ3', H, ϕ3) / inner(ϕ3, ϕ3), e3 return nothing end diff --git a/examples/02_dmrg-x.jl b/examples/02_dmrg-x.jl index 77fc311..61b2aa4 100644 --- a/examples/02_dmrg-x.jl +++ b/examples/02_dmrg-x.jl @@ -1,5 +1,4 @@ -using ITensors: MPO, MPS, OpSum, inner, siteinds -using ITensorTDVP: dmrg_x +using ITensorMPS: MPO, MPS, OpSum, dmrg_x, inner, siteinds using Random: Random function main() diff --git a/examples/03_models.jl b/examples/03_models.jl index a205ed4..51f5aee 100644 --- a/examples/03_models.jl +++ b/examples/03_models.jl @@ -1,4 +1,4 @@ -using ITensors: OpSum +using ITensorMPS: OpSum function heisenberg(n; J=1.0, J2=0.0) ℋ = OpSum() diff --git a/examples/03_solvers.jl b/examples/03_solvers.jl index b31929a..8be73f7 100644 --- a/examples/03_solvers.jl +++ b/examples/03_solvers.jl @@ -1,8 +1,15 @@ -using ITensors: ITensor -using ITensorTDVP: TimeDependentSum, to_vec +using ITensors: ITensor, array, inds, itensor +using ITensorMPS: TimeDependentSum using KrylovKit: exponentiate using OrdinaryDiffEq: ODEProblem, Tsit5, solve +function to_vec(x::ITensor) + function to_itensor(x_vec) + return itensor(x_vec, inds(x)) + end + return vec(array(x)), to_itensor +end + function ode_solver( H::TimeDependentSum, time_step, diff --git a/examples/03_tdvp_time_dependent.jl b/examples/03_tdvp_time_dependent.jl index 21d86a5..963b180 100644 --- a/examples/03_tdvp_time_dependent.jl +++ b/examples/03_tdvp_time_dependent.jl @@ -1,5 +1,5 @@ -using ITensors: MPO, MPS, @disable_warn_order, inner, randomMPS, siteinds -using ITensorTDVP: tdvp +using ITensors: @disable_warn_order +using ITensorMPS: MPO, MPS, inner, randomMPS, siteinds, tdvp using LinearAlgebra: norm using Random: Random diff --git a/examples/04_tdvp_observers.jl b/examples/04_tdvp_observers.jl index f2c056d..52ffaa9 100644 --- a/examples/04_tdvp_observers.jl +++ b/examples/04_tdvp_observers.jl @@ -1,5 +1,4 @@ -using ITensors: MPO, MPS, OpSum, expect, siteinds -using ITensorTDVP: tdvp +using ITensorMPS: MPO, MPS, OpSum, expect, inner, siteinds, tdvp using Observers: observer function main() diff --git a/examples/Project.toml b/examples/Project.toml index 2e1c761..32d6e03 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -2,5 +2,6 @@ ITensorTDVP = "25707e16-a4db-4a07-99d9-4d67b7af0342" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" +Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/test/Project.toml b/test/Project.toml index 3e73a3e..76f5652 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,4 +1,5 @@ [deps] +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" ITensorTDVP = "25707e16-a4db-4a07-99d9-4d67b7af0342" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" diff --git a/test/test_contract_mpo.jl b/test/test_contract_mpo.jl index 8cb4e99..5e085fb 100644 --- a/test/test_contract_mpo.jl +++ b/test/test_contract_mpo.jl @@ -52,7 +52,7 @@ using Test: @test, @testset truncate!(psi_guess; maxdim=2) Hpsi = apply(H, psi; alg="fit", nsweeps=4, init_mps=psi_guess) @test ITensors.scalartype(Hpsi) == elt - @test inner(psit, Hpsi) ≈ inner(psit, H, psi) rtol = 3 * √eps(real(elt)) + @test inner(psit, Hpsi) ≈ inner(psit, H, psi) rtol = 20 * √eps(real(elt)) # Test with nsite=1 Hpsi_guess = apply(H, psi; alg="naive", cutoff=1e-4) Hpsi = apply(H, psi; alg="fit", init_mps=Hpsi_guess, nsite=1, nsweeps=2)