Skip to content

Commit

Permalink
Merge branch 'master' into ld-argorderswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed May 17, 2024
2 parents 332fa43 + 399425e commit 237d464
Show file tree
Hide file tree
Showing 14 changed files with 375 additions and 112 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: lcov.info
test-nightly:
Expand All @@ -61,11 +63,11 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CompatHelper

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

jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- 'release-'
tags: '*'
pull_request:
workflow_dispatch:

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: format-check
name: FormatCheck

on:
push:
Expand Down Expand Up @@ -35,7 +35,6 @@ jobs:
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
id: format
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
Expand All @@ -45,23 +44,4 @@ jobs:
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
- name: Create pull request
if: ${{ failure() && steps.format.conclusion == 'failure' }}
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Format .jl files
title: 'Automatic JuliaFormatter.jl run'
base: ${{ github.head_ref }}
branch: auto-juliaformatter-pr
delete-branch: true
labels: formatting, automated pr, no changelog

- name: Check outputs
if: ${{ success() && steps.cpr.conclusion == 'success' }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
end'
34 changes: 34 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3

permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read

jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
1 change: 1 addition & 0 deletions docs/src/lib/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

```@autodocs
Modules = [PEPSKit, PEPSKit.Defaults]
Filter = t -> !(t in [PEPSKit.PEPS_∂∂AC, PEPSKit.PEPS_∂∂C, PEPSKit.PEPO_∂∂AC, PEPSKit.PEPO_∂∂C])
```
86 changes: 86 additions & 0 deletions examples/boundary_mps.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Random
using PEPSKit
using TensorKit
using MPSKit
using LinearAlgebra

include("ising_pepo.jl")

# This example demonstrates some boundary-MPS methods for working with 2D projected
# entangled-pair states and operators.

## Computing a PEPS norm

# We start by initializing a random initial infinite PEPS
Random.seed!(29384293742893)
peps = InfinitePEPS(ComplexSpace(2), ComplexSpace(2))

# To compute its norm, we start by constructing the transfer operator corresponding to
# the partition function representing the overlap <peps|peps>
T = InfiniteTransferPEPS(peps, 1, 1)

# We then find its leading boundary MPS fixed point, where the corresponding eigenvalue
# encodes the norm of the state

# Fist we build an initial guess for the boundary MPS, choosing a bond dimension of 20
mps = PEPSKit.initializeMPS(T, [ComplexSpace(20)])

# We then find the leading boundary MPS fixed point using the VUMPS algorithm
mps, envs, ϵ = leading_boundary(mps, T, VUMPS())

# The norm of the state per unit cell is then given by the expectation value <mps|T|mps>
N = abs(prod(expectation_value(mps, T)))

# This can be compared to the result obtained using the CTMRG algorithm
ctm = leading_boundary(
peps, CTMRG(; verbosity=1, fixedspace=true), CTMRGEnv(peps; Venv=ComplexSpace(20))
)
= abs(norm(peps, ctm))

@show abs(N - N´) / N

## Working with unit cells

# For PEPS with non-trivial unit cells, the principle is exactly the same.
# The only difference is that now the transfer operator of the PEPS norm partition function
# has multiple lines, each of which can be represented by an `InfiniteTransferPEPS` object.
# Such a multi-line transfer operator is represented by a `TransferPEPSMultiline` object.
# In this case, the boundary MPS is an `MPSMultiline` object, which should be initialized
# by specifying a virtual space for each site in the partition function unit cell.

peps2 = InfinitePEPS(ComplexSpace(2), ComplexSpace(2); unitcell=(2, 2))
T2 = PEPSKit.TransferPEPSMultiline(peps2, 1)

mps2 = PEPSKit.initializeMPS(T2, fill(ComplexSpace(20), 2, 2))
mps2, envs2, ϵ = leading_boundary(mps2, T2, VUMPS())
N2 = abs(prod(expectation_value(mps2, T2)))

ctm2 = leading_boundary(
peps2, CTMRG(; verbosity=1, fixedspace=true), CTMRGEnv(peps2; Venv=ComplexSpace(20))
)
N2´ = abs(norm(peps2, ctm2))

@show abs(N2 - N2´) / N2

# Note that for larger unit cells and non-Hermitian PEPS the VUMPS algorithm may become
# unstable, in which case the CTMRG algorithm is recommended.

## Contracting PEPO overlaps

# Using exactly the same machinery, we can contract partition functions which encode the
# expectation value of a PEPO for a given PEPS state.
# As an example, we can consider the overlap of the PEPO correponding to the partition
# function of 3D classical ising model with our random PEPS from before and evaluate
# <peps|O|peps>.

pepo = ising_pepo(1)
T3 = InfiniteTransferPEPO(peps, pepo, 1, 1)

mps3 = PEPSKit.initializeMPS(T3, [ComplexSpace(20)])
mps3, envs3, ϵ = leading_boundary(mps3, T3, VUMPS())
@show N3 = abs(prod(expectation_value(mps3, T3)))

# These objects and routines can be used to optimize PEPS fixed points of 3D partition
# functions, see for example https://arxiv.org/abs/1805.10598

nothing
23 changes: 23 additions & 0 deletions examples/ising_pepo.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using TensorOperations
using TensorKit

"""
ising_pepo(beta; unitcell=(1, 1, 1))
Return the PEPO tensor for partition function of the 3D classical Ising model at inverse
temperature `beta`.
"""
function ising_pepo(beta; unitcell=(1, 1, 1))
t = ComplexF64[exp(beta) exp(-beta); exp(-beta) exp(beta)]
q = sqrt(t)

O = zeros(2, 2, 2, 2, 2, 2)
O[1, 1, 1, 1, 1, 1] = 1
O[2, 2, 2, 2, 2, 2] = 1
@tensor o[-1 -2; -3 -4 -5 -6] :=
O[1 2; 3 4 5 6] * q[-1; 1] * q[-2; 2] * q[-3; 3] * q[-4; 4] * q[-5; 5] * q[-6; 6]

O = TensorMap(o, ℂ^2 (ℂ^2)' ^2 ^2 (ℂ^2)' (ℂ^2)')

return InfinitePEPO(O; unitcell)
end
Loading

0 comments on commit 237d464

Please sign in to comment.