Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
qmortier committed Jun 20, 2024
2 parents 93b3c65 + 996893a commit 559633d
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 27 deletions.
39 changes: 32 additions & 7 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
name: CompatHelper

on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
4 changes: 4 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Documentation

permissions:
contents: write
pages: write

on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Accessors = "0.1"
ChainRulesCore = "1.0"
Compat = "3.46, 4.2"
KrylovKit = "0.6, 0.7"
KrylovKit = "0.6, 0.7, 0.8"
LinearAlgebra = "1"
MPSKit = "0.10"
OptimKit = "0.3"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/quantumghent/PEPSKit.jl/blob/master/docs/src/assets/logo-dark.svg">
<img alt="PEPSKit.jl logo" src="https://github.com/quantumghent/PEPSKit.jl/blob/master/docs/src/assets/logo.svg" width="150">
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/QuantumKitHub/PEPSKit.jl/blob/master/docs/src/assets/logo-dark.svg">
<img alt="PEPSKit.jl logo" src="https://github.com/QuantumKitHub/PEPSKit.jl/blob/master/docs/src/assets/logo.svg" width="150">
</picture>

# PEPSKit.jl

[![docs][docs-dev-img]][docs-dev-url] ![CI][ci-url] [![codecov][codecov-img]][codecov-url]

[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
[docs-dev-url]: https://quantumghent.github.io/PEPSKit.jl/dev/
[docs-dev-url]: https://QuantumKitHub.github.io/PEPSKit.jl/dev/

[codecov-img]: https://codecov.io/gh/quantumghent/PEPSKit.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/quantumghent/PEPSKit.jl
[codecov-img]: https://codecov.io/gh/QuantumKitHub/PEPSKit.jl/graph/badge.svg?token=1OBDY03SUP
[codecov-url]: https://codecov.io/gh/QuantumKitHub/PEPSKit.jl

[ci-url]: https://github.com/quantumghent/PEPSKit.jl/workflows/CI/badge.svg
[ci-url]: https://github.com/QuantumKitHub/PEPSKit.jl/workflows/CI/badge.svg

**Tools for working with projected entangled-pair states**

Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ makedocs(;
],
)

deploydocs(; repo="https://github.com/quantumghent/PEPSKit.jl.git")
deploydocs(; repo="https://github.com/QuantumKitHub/PEPSKit.jl.git")
2 changes: 1 addition & 1 deletion docs/src/examples/index.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
For now, refer to the [examples folder](https://github.com/quantumghent/PEPSKit.jl/tree/master/examples) on GitHub.
For now, refer to the [examples folder](https://github.com/QuantumKitHub/PEPSKit.jl/tree/master/examples) on GitHub.
2 changes: 1 addition & 1 deletion src/environments/ctmrgenv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ VI.scale!!(env₁::CTMRGEnv, env₂::CTMRGEnv, α::Number) = scale!(env₁, env
function VI.add(env₁::CTMRGEnv, env₂::CTMRGEnv, α::Number, β::Number)
_add(x, y) = add(x, y, α, β)
return CTMRGEnv(
map(_add, env₁.corners, env₂.corners), map(_add, env₁.corners, env₂.corners)
map(_add, env₁.corners, env₂.corners), map(_add, env₁.edges, env₂.edges)
)
end
function VI.add!(env₁::CTMRGEnv, env₂::CTMRGEnv, α::Number, β::Number)
Expand Down
93 changes: 83 additions & 10 deletions src/operators/localoperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ operator_env

function operator_env(peps::InfinitePEPS, env::CTMRGEnv, ::OnSite)
return map(Iterators.product(axes(env.corners, 2), axes(env.corners, 3))) do (r, c)
@tensor ρ[-1; -2] :=
@tensor opt = true ρ[-1; -2] :=
env.corners[NORTHWEST, r, c][1; 2] *
env.edges[NORTH, r, c][2 3 4; 5] *
env.corners[NORTHEAST, r, c][5; 6] *
Expand All @@ -64,7 +64,7 @@ end
function operator_env(peps::InfinitePEPS, env::CTMRGEnv, ::NearestNeighbor)
return map(Iterators.product(axes(env.corners, 2), axes(env.corners, 3))) do (r, c)
cnext = _next(c, size(peps, 2))
@tensor ρ[-11 -20; -12 -18] :=
@tensor opt = true ρ[-12 -18; -11 -20] :=
env.corners[NORTHWEST, r, c][1; 3] *
env.edges[NORTH, r, c][3 5 8; 13] *
env.edges[NORTH, r, cnext][13 16 22; 23] *
Expand All @@ -89,22 +89,95 @@ Evaluate the expectation value of any `NLocalOperator` on each unit-cell entry
of `peps` and `env`.
""" MPSKit.expectation_value(::InfinitePEPS, ::Any, ::NLocalOperator)

# Optimal contraction order is obtained by manually trying out some space sizes and using costcheck = warn
# in principle, we would like to use opt = true, but this does not give optimal results without also supplying costs
# However, due to a bug in tensoroperations this is currently not possible with integer labels.
# Thus, this is a workaround until the bug is fixed. (otherwise we'd need to rewrite all the labels to symbols...)

# 1-site operator expectation values on unit cell
function MPSKit.expectation_value(peps::InfinitePEPS, env, O::NLocalOperator{OnSite})
return map(operator_env(peps, env, OnSite())) do ρ
o = @tensor ρ[-1; -2] * O.op[-1; -2]
n = @tensor ρ[-1; -1]
function MPSKit.expectation_value(
peps::InfinitePEPS, env::CTMRGEnv, O::NLocalOperator{OnSite}
)
return map(Iterators.product(axes(env.corners, 2), axes(env.corners, 3))) do (r, c)
o = @tensor order = (6, 2, 5, 10, 14, 13, 11, 15, 7, 9, 1, 3, 4, 8, 12, 16, 18, 17) begin
env.corners[NORTHWEST, r, c][1; 2] *
env.edges[NORTH, r, c][2 3 4; 5] *
env.corners[NORTHEAST, r, c][5; 6] *
env.edges[EAST, r, c][6 7 8; 9] *
env.corners[SOUTHEAST, r, c][9; 10] *
env.edges[SOUTH, r, c][10 11 12; 13] *
env.corners[SOUTHWEST, r, c][13; 14] *
env.edges[WEST, r, c][14 15 16; 1] *
peps[r, c][17; 3 7 11 15] *
conj(peps[r, c][18; 4 8 12 16]) *
O.op[18; 17]
end
n = @tensor order = (9, 13, 10, 5, 1, 2, 4, 16, 6, 8, 14, 12, 17, 3, 7, 11, 15) begin
env.corners[NORTHWEST, r, c][1; 2] *
env.edges[NORTH, r, c][2 3 4; 5] *
env.corners[NORTHEAST, r, c][5; 6] *
env.edges[EAST, r, c][6 7 8; 9] *
env.corners[SOUTHEAST, r, c][9; 10] *
env.edges[SOUTH, r, c][10 11 12; 13] *
env.corners[SOUTHWEST, r, c][13; 14] *
env.edges[WEST, r, c][14 15 16; 1] *
peps[r, c][17; 3 7 11 15] *
conj(peps[r, c][17; 4 8 12 16])
end
o / n
end
end

function MPSKit.expectation_value(peps::InfinitePEPS, env, O::NLocalOperator{NearestNeighbor})
return map(operator_env(peps, env, NearestNeighbor())) do ρ
o = @tensor ρ[1 2; 3 4] * O.op[1 2; 3 4]
n = @tensor ρ[1 2; 1 2]
#! format: off
function MPSKit.expectation_value(
peps::InfinitePEPS, env, O::NLocalOperator{NearestNeighbor}
)
return map(Iterators.product(axes(env.corners, 2), axes(env.corners, 3))) do (r, c)
cnext = _next(c, size(peps, 2))
o = @tensor order = (
28, 24, 23, 16, 25, 22, 26, 27, 17, 21, 4, 1, 3, 5, 7, 8, 9, 2, 6, 10, 14, 19,
15, 13, 31, 32, 29, 30,
) begin # physical spaces
env.corners[NORTHWEST, r, c][1; 3] *
env.edges[NORTH, r, c][3 5 8; 13] *
env.edges[NORTH, r, cnext][13 16 22; 23] *
env.corners[NORTHEAST, r, cnext][23; 24] *
env.edges[EAST, r, cnext][24 25 26; 27] *
env.corners[SOUTHEAST, r, cnext][27; 28] *
env.edges[SOUTH, r, cnext][28 17 21; 14] *
env.edges[SOUTH, r, c][14 6 10; 4] *
env.corners[SOUTHWEST, r, c][4; 2] *
env.edges[WEST, r, c][2 7 9; 1] *
peps[r, c][29; 5 15 6 7] *
conj(peps[r, c][31; 8 19 10 9]) *
peps[r, cnext][30; 16 25 17 15] *
conj(peps[r, cnext][32; 22 26 21 19]) *
O.op[31 32; 29 30]
end

n = @tensor order = (
2, 3, 1, 5, 7, 28, 24, 23, 16, 25, 30, 22, 26, 27, 17, 21, 14, 15, 6, 4, 13, 29,
8, 19, 10, 9,
) begin
env.corners[NORTHWEST, r, c][1; 3] *
env.edges[NORTH, r, c][3 5 8; 13] *
env.edges[NORTH, r, cnext][13 16 22; 23] *
env.corners[NORTHEAST, r, cnext][23; 24] *
env.edges[EAST, r, cnext][24 25 26; 27] *
env.corners[SOUTHEAST, r, cnext][27; 28] *
env.edges[SOUTH, r, cnext][28 17 21; 14] *
env.edges[SOUTH, r, c][14 6 10; 4] *
env.corners[SOUTHWEST, r, c][4; 2] *
env.edges[WEST, r, c][2 7 9; 1] *
peps[r, c][29; 5 15 6 7] *
conj(peps[r, c][29; 8 19 10 9]) *
peps[r, cnext][30; 16 25 17 15] *
conj(peps[r, cnext][30; 22 26 21 19])
end
o / n
end
end
#! format: on

"""
costfun(peps::InfinitePEPS, env, op::NLocalOperator{NearestNeighbor})
Expand Down

0 comments on commit 559633d

Please sign in to comment.