Skip to content

Commit

Permalink
Merge branch 'master' into pb-improve-sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos authored Dec 4, 2024
2 parents 77fc207 + 36973e7 commit 9532507
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PEPSKit"
uuid = "52969e89-939e-4361-9b68-9bc7cde4bdeb"
authors = ["Maarten Vandamme", "Paul Brehmer", "Lander Burgelman", "Rui-Zhen Huang", "Daan Maertens", "Lukas Devos <[email protected]"]
version = "0.2.2"
authors = ["Paul Brehmer", "Lander Burgelman", "Lukas Devos <[email protected]>"]
version = "0.3.0"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down Expand Up @@ -40,7 +40,7 @@ Random = "1"
Statistics = "1"
TensorKit = "0.12.5"
TensorOperations = "4"
VectorInterface = "0.4"
VectorInterface = "0.4, 0.5"
Zygote = "0.6"
julia = "1.10"

Expand Down
6 changes: 4 additions & 2 deletions src/algorithms/contractions/localoperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ end
end
end

return quote
returnex = quote
@tensor opt = $opt_ex $multiplication_ex
end
return macroexpand(@__MODULE__, returnex)
end

"""
Expand Down Expand Up @@ -445,7 +446,8 @@ end
end
end

return quote
returnex = quote
@tensor opt = $opt_ex $multiplication_ex
end
return macroexpand(@__MODULE__, returnex)
end
13 changes: 10 additions & 3 deletions src/algorithms/peps_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ The function returns a `NamedTuple` which contains the following entries:
- `numfg`: total number of calls to the energy function
"""
function fixedpoint(
ψ₀::InfinitePEPS{T},
ψ₀::InfinitePEPS{F},
H,
alg::PEPSOptimize,
env₀::CTMRGEnv=CTMRGEnv(ψ₀, field(T)^20);
env₀::CTMRGEnv=CTMRGEnv(ψ₀, field(F)^20);
(finalize!)=OptimKit._finalize!,
symmetrization=nothing,
) where {T}
) where {F}
if isnothing(symmetrization)
retract = peps_retract
else
Expand All @@ -157,6 +157,13 @@ function fixedpoint(
finalize! = (x, f, g, numiter) -> fin!(symm_finalize!(x, f, g, numiter)..., numiter)
end

if scalartype(env₀) <: Real
env₀ = complex(env₀)
@warn "the provided real environment was converted to a complex environment since\
:fixed mode generally produces complex gauges; use :diffgauge mode instead to work\
with purely real environments"
end

(peps, env), E, ∂E, numfg, convhistory = optimize(
(ψ₀, env₀), alg.optimizer; retract, inner=real_inner, finalize!
) do (peps, envs)
Expand Down
3 changes: 3 additions & 0 deletions src/environments/ctmrg_environments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ function eachcoordinate(x::CTMRGEnv, dirs)
return collect(Iterators.product(dirs, axes(x, 2), axes(x, 3)))
end

Base.real(env::CTMRGEnv) = CTMRGEnv(real.(env.corners), real.(env.edges))
Base.complex(env::CTMRGEnv) = CTMRGEnv(complex.(env.corners), complex.(env.edges))

# In-place update of environment
function update!(env::CTMRGEnv{C,T}, env´::CTMRGEnv{C,T}) where {C,T}
env.corners .= env´.corners
Expand Down
26 changes: 8 additions & 18 deletions src/operators/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ end
(H::PEPS_∂∂C)(x) = MPSKit.∂C(x, H.GL, H.GR)
(H::PEPS_∂∂AC)(x) = MPSKit.∂AC(x, (H.top, H.bot), H.GL, H.GR)

function MPSKit.∂AC(x::RecursiveVec, O::Tuple, GL, GR)
return RecursiveVec(
circshift(
map((v, O1, O2, l, r) -> ∂AC(v, (O1, O2), l, r), x.vecs, O[1], O[2], GL, GR), 1
),
function MPSKit.∂AC(x::Vector, O::Tuple, GL, GR)
return circshift(
map((v, O1, O2, l, r) -> ∂AC(v, (O1, O2), l, r), x, O[1], O[2], GL, GR), 1
)
end

Expand Down Expand Up @@ -203,20 +201,12 @@ end
(H::PEPO_∂∂C)(x) = MPSKit.∂C(x, H.GL, H.GR)
(H::PEPO_∂∂AC)(x) = MPSKit.∂AC(x, (H.top, H.bot, H.mid), H.GL, H.GR)

function MPSKit.∂AC(x::RecursiveVec, O::Tuple{T,T,P}, GL, GR) where {T,P}
return RecursiveVec(
circshift(
map(
(v, O1, O2, O3, l, r) -> ∂AC(v, (O1, O2, O3), l, r),
x.vecs,
O[1],
O[2],
O[3],
GL,
GR,
),
1,
function MPSKit.∂AC(x::Vector, O::Tuple{T,T,P}, GL, GR) where {T,P}
return circshift(
map(
(v, O1, O2, O3, l, r) -> ∂AC(v, (O1, O2, O3), l, r), x, O[1], O[2], O[3], GL, GR
),
1,
)
end

Expand Down

0 comments on commit 9532507

Please sign in to comment.