Skip to content

Commit

Permalink
Add compat in Project and applympo SDV extension
Browse files Browse the repository at this point in the history
  • Loading branch information
BrieucLD committed Dec 16, 2024
1 parent c4a4bf2 commit 278ae98
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
22 changes: 20 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name = "MPSDynamics"
uuid = "8fc8f346-e1eb-498f-94db-02ffe92d8134"
authors = ["angus-dunnett <[email protected]>", "Thibaut Lacroix <[email protected]>"]
authors = ["Angus Dunnett", "Thibaut Lacroix", "Brieuc Le Dé", "Angela Riva"]
maintainers = ["ShareLOQS <[email protected]>"]
version = "1.1.0"

[deps]
Expand All @@ -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"
17 changes: 14 additions & 3 deletions src/mpsBasics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

"""
Expand Down

0 comments on commit 278ae98

Please sign in to comment.