From 278ae98039167643dbc076463a9c279d74644cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brieuc=20Le=20D=C3=A9?= Date: Mon, 16 Dec 2024 11:23:59 +0100 Subject: [PATCH] Add compat in Project and applympo SDV extension --- Project.toml | 22 ++++++++++++++++++++-- src/mpsBasics.jl | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 8769cc2..c2df4ad 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,7 @@ name = "MPSDynamics" uuid = "8fc8f346-e1eb-498f-94db-02ffe92d8134" -authors = ["angus-dunnett ", "Thibaut Lacroix "] +authors = ["Angus Dunnett", "Thibaut Lacroix", "Brieuc Le Dé", "Angela Riva"] +maintainers = ["ShareLOQS "] version = "1.1.0" [deps] @@ -25,6 +26,23 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" [compat] +Dates = "1.1.0 - 1.11" +DelimitedFiles = "1.1.0 - 1.9" +Distributed = "1.1.0 - 1.11" +GraphRecipes = "0.4, 0.5" +HDF5 = "0.17.2" ITensors = "0.6" +Interpolations = "0.11, 0.15" +JLD = "0.13.5" +Jacobi = "0.7.0" +KrylovKit = "0.8.3" +LinearAlgebra = "1.0.0 - 1.11" +Logging = "1.5.0 - 1.11" +Plots = "1.35.0 - 1.40" +Preferences = "1.0.0 - 1.4" +Printf = "1.0.0 - 1.11" +QuadGK = "2.0.0 - 2.11" +Random = "1.0.0 - 1.11" +SpecialFunctions = "2.4.0" TensorOperations = "4.0.7" -julia = "1.7" +julia = "1.7 - 1.11" diff --git a/src/mpsBasics.jl b/src/mpsBasics.jl index 4d8bee6..57b10ed 100644 --- a/src/mpsBasics.jl +++ b/src/mpsBasics.jl @@ -540,12 +540,12 @@ Apply an operator O on the MPS A. O is acting on only one site ::Int. The result apply1siteoperator!(A, O, site::Int) = apply1siteoperator!(A, O, [site]) """ - applympo!(A, H) + applympo!(A, H; SVD=false, kwargs...) -Apply an MPO H on the MPS A. H must have the same number of site than A. The resulting MPS A is the MPS modified by the MPO H. +Apply an MPO H on the MPS A. H must have the same number of site than A. The resulting MPS A is the MPS modified by the MPO H. The argument SVD can be set to true if one wants the MPS to recover the same dimensions after having applied the MPO H. Further parameters for the SVD truncation can be added with the kwargs. """ -function applympo!(A, H) +function applympo!(A, H ; SVD=false, kwargs...) N = length(H) N == length(A) || throw(ArgumentError("MPO has $N site while MPS has $(length(A)) sites")) for i=1:N @@ -554,6 +554,17 @@ function applympo!(A, H) @tensor X[a',a,b',b,s] := H[i][a',b',s,s'] * A[i][a,b,s'] A[i] = reshape(X, Al*Hl, Ar*Hr, d) end + if SVD + for i in 2:N + Dl, Dr, d = size(A[i-1]) + U, S, Vt = svdtrunc(reshape(permutedims(A[i-1], [1,3,2]), Dl*d, Dr); kwargs...) + Dnew = size(S,1) + A[i-1] = permutedims(reshape(U, Dl, d, Dnew), [1,3,2]) + R = Diagonal(S)*Vt + @tensor AC[:] := R[-1,1] * A[i][1,-2,-3] + A[i] = AC + end + end end """