Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .JuliaFormatter.toml

This file was deleted.

12 changes: 7 additions & 5 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Format Check"
name: FormatCheck

on:
push:
Expand All @@ -7,10 +7,12 @@ on:
- 'master'
tags: '*'
pull_request:
branches:
- 'main'
- 'master'

jobs:
format-check:
formatcheck:
name: "Format Check"
uses: "QuantumKitHub/.github/.github/workflows/formatcheck.yml@main"
with:
juliaformatter-version: "2"
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/FormatCheck.yml@main"

20 changes: 10 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if Base.active_project() != joinpath(@__DIR__, "Project.toml")
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(; path=joinpath(@__DIR__, "..")))
Pkg.develop(PackageSpec(; path = joinpath(@__DIR__, "..")))
Pkg.resolve()
Pkg.instantiate()
end
Expand All @@ -15,7 +15,7 @@ using MPSKitModels: MPSKitModels # used for docstrings

# bibliography
bibpath = joinpath(@__DIR__, "src", "assets", "pepskit.bib")
bib = CitationBibliography(bibpath; style=:authoryear)
bib = CitationBibliography(bibpath; style = :authoryear)

# interlinks
# Zygote didn't update to documenter v1 yet...
Expand Down Expand Up @@ -53,12 +53,12 @@ examples_partition_functions = joinpath.(
examples_boundary_mps = joinpath.(["boundary_mps"], Ref("index.md"))

makedocs(;
modules=[PEPSKit, MPSKitModels],
sitename="PEPSKit.jl",
format=Documenter.HTML(;
prettyurls=true, mathengine, assets=["assets/custom.css"], size_threshold=1024000
modules = [PEPSKit, MPSKitModels],
sitename = "PEPSKit.jl",
format = Documenter.HTML(;
prettyurls = true, mathengine, assets = ["assets/custom.css"], size_threshold = 1024000
),
pages=[
pages = [
"Home" => "index.md",
"Manual" => ["man/models.md", "man/multithreading.md", "man/precompilation.md"],
"Examples" => [
Expand All @@ -72,9 +72,9 @@ makedocs(;
"Library" => "lib/lib.md",
"References" => "references.md",
],
checkdocs=:none,
checkdocs = :none,
# checkdocs_ignored_modules=[MPSKitModels], # doesn't seem to work...
plugins=[bib, links],
plugins = [bib, links],
)

deploydocs(; repo="github.com/QuantumKitHub/PEPSKit.jl.git", push_preview=true)
deploydocs(; repo = "github.com/QuantumKitHub/PEPSKit.jl.git", push_preview = true)
6 changes: 3 additions & 3 deletions examples/2d_ising_partition_function/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Since we later want to compute the magnetization and energy to check our results
the appropriate rank-4 tensors here as well while we're at it.
"""

function classical_ising(; beta=log(1 + sqrt(2)) / 2, J=1.0)
function classical_ising(; beta = log(1 + sqrt(2)) / 2, J = 1.0)
K = beta * J

## Boltzmann weights
Expand Down Expand Up @@ -92,7 +92,7 @@ settings:

Venv = ℂ^20
env₀ = CTMRGEnv(Z, Venv)
env, = leading_boundary(env₀, Z; tol=1e-8, maxiter=500);
env, = leading_boundary(env₀, Z; tol = 1.0e-8, maxiter = 500);

md"""
Note that CTMRG environments for partition functions differ from the PEPS environments only
Expand Down Expand Up @@ -125,7 +125,7 @@ magnetization and energy per site (where we use `quadgk` to perform integrals of
auxiliary variable from $0$ to $\pi/2$):
"""

function classical_ising_exact(; beta=log(1 + sqrt(2)) / 2, J=1.0)
function classical_ising_exact(; beta = log(1 + sqrt(2)) / 2, J = 1.0)
K = beta * J

k = 1 / sinh(2 * K)^2
Expand Down
30 changes: 15 additions & 15 deletions examples/3d_ising_partition_function/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lattice. To verify our example we will check the magnetization and energy, so we
the corresponding rank-6 tensors `M` and `E` while we're at it.
"""

function three_dimensional_classical_ising(; beta, J=1.0)
function three_dimensional_classical_ising(; beta, J = 1.0)
K = beta * J

## Boltzmann weights
Expand Down Expand Up @@ -150,9 +150,9 @@ we'll specify the specific reverse rule algorithm that will be used to compute t
of this cost function.
"""

boundary_alg = SimultaneousCTMRG(; maxiter=150, tol=1e-8, verbosity=1)
boundary_alg = SimultaneousCTMRG(; maxiter = 150, tol = 1.0e-8, verbosity = 1)
rrule_alg = EigSolver(;
solver_alg=KrylovKit.Arnoldi(; maxiter=30, tol=1e-6, eager=true), iterscheme=:diffgauge
solver_alg = KrylovKit.Arnoldi(; maxiter = 30, tol = 1.0e-6, eager = true), iterscheme = :diffgauge
)
T = InfinitePEPO(O)

Expand All @@ -167,7 +167,7 @@ function pepo_costfun((peps, env_double_layer, env_triple_layer))
env_double_layer,
n_double_layer,
boundary_alg;
alg_rrule=rrule_alg,
alg_rrule = rrule_alg,
)
## construct the PEPS-PEPO-PEPS overlap network
n_triple_layer = InfiniteSquareNetwork(ψ, T)
Expand All @@ -177,7 +177,7 @@ function pepo_costfun((peps, env_double_layer, env_triple_layer))
env_triple_layer,
n_triple_layer,
boundary_alg;
alg_rrule=rrule_alg,
alg_rrule = rrule_alg,
)
## update the environments for reuse
PEPSKit.ignore_derivatives() do
Expand Down Expand Up @@ -242,12 +242,12 @@ function pepo_retract((peps, env_double_layer, env_triple_layer), η, α)
return (peps´, env_double_layer´, env_triple_layer´), ξ
end
function pepo_transport!(
ξ,
(peps, env_double_layer, env_triple_layer),
η,
α,
(peps´, env_double_layer´, env_triple_layer´),
)
ξ,
(peps, env_double_layer, env_triple_layer),
η,
α,
(peps´, env_double_layer´, env_triple_layer´),
)
return PEPSKit.peps_transport!(
ξ, (peps, env_double_layer), η, α, (peps´, env_double_layer´)
)
Expand All @@ -268,15 +268,15 @@ psi0 = initializePEPS(T, Vpeps)
env2_0 = CTMRGEnv(InfiniteSquareNetwork(psi0), Venv)
env3_0 = CTMRGEnv(InfiniteSquareNetwork(psi0, T), Venv)

optimizer_alg = LBFGS(32; maxiter=100, gradtol=1e-5, verbosity=3)
optimizer_alg = LBFGS(32; maxiter = 100, gradtol = 1.0e-5, verbosity = 3)

(psi_final, env2_final, env3_final), f, = optimize(
pepo_costfun,
(psi0, env2_0, env3_0),
optimizer_alg;
inner=PEPSKit.real_inner,
retract=pepo_retract,
(transport!)=(pepo_transport!),
inner = PEPSKit.real_inner,
retract = pepo_retract,
(transport!) = (pepo_transport!),
);

md"""
Expand Down
8 changes: 4 additions & 4 deletions examples/bose_hubbard/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ optimization framework in the usual way to find the ground state. So, we first s
algorithms and their tolerances:
"""

boundary_alg = (; tol=1e-8, alg=:simultaneous, trscheme=(; alg=:fixedspace))
gradient_alg = (; tol=1e-6, maxiter=10, alg=:eigsolver, iterscheme=:diffgauge)
optimizer_alg = (; tol=1e-4, alg=:lbfgs, maxiter=150, ls_maxiter=2, ls_maxfg=2);
boundary_alg = (; tol = 1.0e-8, alg = :simultaneous, trscheme = (; alg = :fixedspace))
gradient_alg = (; tol = 1.0e-6, maxiter = 10, alg = :eigsolver, iterscheme = :diffgauge)
optimizer_alg = (; tol = 1.0e-4, alg = :lbfgs, maxiter = 150, ls_maxiter = 2, ls_maxfg = 2);

md"""
!!! note
Expand Down Expand Up @@ -118,7 +118,7 @@ And at last, we optimize (which might take a bit):
"""

peps, env, E, info = fixedpoint(
H, peps₀, env₀; boundary_alg, gradient_alg, optimizer_alg, verbosity=3
H, peps₀, env₀; boundary_alg, gradient_alg, optimizer_alg, verbosity = 3
)
@show E;

Expand Down
14 changes: 7 additions & 7 deletions examples/boundary_mps/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ boundary MPS fixed point, we call [`leading_boundary`](@ref) using the
[`MPSKit.VUMPS`](@extref) algorithm:
"""

mps, env, ϵ = leading_boundary(mps₀, T, VUMPS(; tol=1e-6, verbosity=2));
mps, env, ϵ = leading_boundary(mps₀, T, VUMPS(; tol = 1.0e-6, verbosity = 2));

md"""
The norm of the state per unit cell is then given by the expectation value
Expand All @@ -142,7 +142,7 @@ This can be compared to the result obtained using CTMRG, where we see that the r
match:
"""

env_ctmrg, = leading_boundary(CTMRGEnv(ψ, ComplexSpace(20)), ψ; tol=1e-6, verbosity=2)
env_ctmrg, = leading_boundary(CTMRGEnv(ψ, ComplexSpace(20)), ψ; tol = 1.0e-6, verbosity = 2)
norm_ctmrg = abs(norm(ψ, env_ctmrg))
@show abs(norm_vumps - norm_ctmrg) / norm_vumps;

Expand All @@ -162,19 +162,19 @@ argument and then define the corresponding transfer operator, where we again spe
direction which will be facing north:
"""

ψ_2x2 = InfinitePEPS(rand, ComplexF64, ComplexSpace(2), ComplexSpace(2); unitcell=(2, 2))
ψ_2x2 = InfinitePEPS(rand, ComplexF64, ComplexSpace(2), ComplexSpace(2); unitcell = (2, 2))
T_2x2 = PEPSKit.MultilineTransferPEPS(ψ_2x2, dir);

md"""
Now, the procedure is the same as before: We compute the norm once using VUMPS, once using CTMRG and then compare.
"""

mps₀_2x2 = initialize_mps(T_2x2, fill(ComplexSpace(20), 2, 2))
mps_2x2, = leading_boundary(mps₀_2x2, T_2x2, VUMPS(; tol=1e-6, verbosity=2))
mps_2x2, = leading_boundary(mps₀_2x2, T_2x2, VUMPS(; tol = 1.0e-6, verbosity = 2))
norm_2x2_vumps = abs(prod(expectation_value(mps_2x2, T_2x2)))

env_ctmrg_2x2, = leading_boundary(
CTMRGEnv(ψ_2x2, ComplexSpace(20)), ψ_2x2; tol=1e-6, verbosity=2
CTMRGEnv(ψ_2x2, ComplexSpace(20)), ψ_2x2; tol = 1.0e-6, verbosity = 2
)
norm_2x2_ctmrg = abs(norm(ψ_2x2, env_ctmrg_2x2))

Expand All @@ -196,7 +196,7 @@ T | \psi \rangle$.
The classical Ising PEPO is defined as follows:
"""

function ising_pepo(β; unitcell=(1, 1, 1))
function ising_pepo(β; unitcell = (1, 1, 1))
t = ComplexF64[exp(β) exp(-β); exp(-β) exp(β)]
q = sqrt(t)

Expand All @@ -223,7 +223,7 @@ As before, we converge the boundary MPS using VUMPS and then compute the expecta
"""

mps₀_pepo = initialize_mps(transfer_pepo, [ComplexSpace(20)])
mps_pepo, = leading_boundary(mps₀_pepo, transfer_pepo, VUMPS(; tol=1e-6, verbosity=2))
mps_pepo, = leading_boundary(mps₀_pepo, transfer_pepo, VUMPS(; tol = 1.0e-6, verbosity = 2))
norm_pepo = abs(prod(expectation_value(mps_pepo, transfer_pepo)));
@show norm_pepo;

Expand Down
8 changes: 4 additions & 4 deletions examples/fermi_hubbard/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Again, the procedure of ground state optimization is very similar to before. Fir
define all algorithmic parameters:
"""

boundary_alg = (; tol=1e-8, alg=:simultaneous, trscheme=(; alg=:fixedspace))
gradient_alg = (; tol=1e-6, alg=:eigsolver, maxiter=10, iterscheme=:diffgauge)
optimizer_alg = (; tol=1e-4, alg=:lbfgs, maxiter=80, ls_maxiter=3, ls_maxfg=3)
boundary_alg = (; tol = 1.0e-8, alg = :simultaneous, trscheme = (; alg = :fixedspace))
gradient_alg = (; tol = 1.0e-6, alg = :eigsolver, maxiter = 10, iterscheme = :diffgauge)
optimizer_alg = (; tol = 1.0e-4, alg = :lbfgs, maxiter = 80, ls_maxiter = 3, ls_maxfg = 3)

md"""
Second, we initialize a PEPS state and environment (which we converge) constructed from
Expand All @@ -89,7 +89,7 @@ And third, we start the ground state search (this does take quite long):
"""

peps, env, E, info = fixedpoint(
H, peps₀, env₀; boundary_alg, gradient_alg, optimizer_alg, verbosity=3
H, peps₀, env₀; boundary_alg, gradient_alg, optimizer_alg, verbosity = 3
)
@show E;

Expand Down
6 changes: 3 additions & 3 deletions examples/heisenberg/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ the `heisenberg_XYZ` method from [MPSKitModels](https://quantumkithub.github.io/
which is redefined for the `InfiniteSquare` and reexported in PEPSKit:
"""

H = heisenberg_XYZ(InfiniteSquare(); Jx=-1, Jy=1, Jz=-1)
H = heisenberg_XYZ(InfiniteSquare(); Jx = -1, Jy = 1, Jz = -1)

md"""
## Setting up the algorithms and initial guesses
Expand All @@ -63,7 +63,7 @@ arguments. To see a description of all arguments, see the docstring of
specific tolerance and during the CTMRG run keep all index dimensions fixed:
"""

boundary_alg = (; tol=1e-10, trscheme=(; alg=:fixedspace));
boundary_alg = (; tol = 1.0e-10, trscheme = (; alg = :fixedspace));

md"""
Let us also configure the optimizer algorithm. We are going to optimize the PEPS using the
Expand All @@ -72,7 +72,7 @@ the convergence tolerance (for the gradient norm) as well as the maximal number
and the BFGS memory size (which is used to approximate the Hessian):
"""

optimizer_alg = (; alg=:lbfgs, tol=1e-4, maxiter=100, lbfgs_memory=16);
optimizer_alg = (; alg = :lbfgs, tol = 1.0e-4, maxiter = 100, lbfgs_memory = 16);

md"""
Additionally, during optimization, we want to reuse the previous CTMRG environment to
Expand Down
28 changes: 14 additions & 14 deletions examples/heisenberg_su/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ no internal symmetries (`symm = Trivial`) or use the global $U(1)$ symmetry

symm = Trivial ## ∈ {Trivial, U1Irrep}
Nr, Nc = 2, 2
H = real(heisenberg_XYZ(ComplexF64, symm, InfiniteSquare(Nr, Nc); Jx=1, Jy=1, Jz=1));
H = real(heisenberg_XYZ(ComplexF64, symm, InfiniteSquare(Nr, Nc); Jx = 1, Jy = 1, Jz = 1));

md"""
## Simple updating
Expand All @@ -50,14 +50,14 @@ if symm == Trivial
bond_space = ℂ^Dbond
env_space = ℂ^χenv
elseif symm == U1Irrep
physical_space = ℂ[U1Irrep](1//2 => 1, -1//2 => 1)
bond_space = ℂ[U1Irrep](0 => Dbond ÷ 2, 1//2 => Dbond ÷ 4, -1//2 => Dbond ÷ 4)
env_space = ℂ[U1Irrep](0 => χenv ÷ 2, 1//2 => χenv ÷ 4, -1//2 => χenv ÷ 4)
physical_space = ℂ[U1Irrep](1 // 2 => 1, -1 // 2 => 1)
bond_space = ℂ[U1Irrep](0 => Dbond ÷ 2, 1 // 2 => Dbond ÷ 4, -1 // 2 => Dbond ÷ 4)
env_space = ℂ[U1Irrep](0 => χenv ÷ 2, 1 // 2 => χenv ÷ 4, -1 // 2 => χenv ÷ 4)
else
error("not implemented")
end

wpeps = InfiniteWeightPEPS(rand, Float64, physical_space, bond_space; unitcell=(Nr, Nc));
wpeps = InfiniteWeightPEPS(rand, Float64, physical_space, bond_space; unitcell = (Nr, Nc));

md"""
Next, we can start the `SimpleUpdate` routine, successively decreasing the time intervals
Expand All @@ -66,14 +66,14 @@ truncation schemes, which we use here to set a maximal bond dimension and at the
fix a truncation error (if that can be reached by remaining below `Dbond`):
"""

dts = [1e-2, 1e-3, 4e-4]
tols = [1e-6, 1e-8, 1e-8]
dts = [1.0e-2, 1.0e-3, 4.0e-4]
tols = [1.0e-6, 1.0e-8, 1.0e-8]
maxiter = 10000
trscheme_peps = truncerr(1e-10) & truncdim(Dbond)
trscheme_peps = truncerr(1.0e-10) & truncdim(Dbond)

for (dt, tol) in zip(dts, tols)
alg = SimpleUpdate(dt, tol, maxiter, trscheme_peps)
result = simpleupdate(wpeps, H, alg; bipartite=true)
result = simpleupdate(wpeps, H, alg; bipartite = true)
global wpeps = result[1]
end

Expand All @@ -86,14 +86,14 @@ on the evolved PEPS. Let's do so:

peps = InfinitePEPS(wpeps) ## absorb the weights
env₀ = CTMRGEnv(rand, Float64, peps, env_space)
trscheme_env = truncerr(1e-10) & truncdim(χenv)
trscheme_env = truncerr(1.0e-10) & truncdim(χenv)
env, = leading_boundary(
env₀,
peps;
alg=:sequential,
projector_alg=:fullinfinite,
tol=1e-10,
trscheme=trscheme_env,
alg = :sequential,
projector_alg = :fullinfinite,
tol = 1.0e-10,
trscheme = trscheme_env,
);

md"""
Expand Down
Loading
Loading