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
8 changes: 0 additions & 8 deletions .github/workflows/Format.yml

This file was deleted.

27 changes: 6 additions & 21 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@ name: FormatCheck
on:
push:
branches:
- 'main'
- 'master'
tags: '*'
pull_request:
branches:
- 'main'
- 'master'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1' # automatically expands to the latest stable 1.x release of Julia
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}

- uses: actions/checkout@v4
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
jobs:
formatcheck:
name: "Format Check"
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/FormatCheck.yml@main"
78 changes: 46 additions & 32 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=(@__DIR__) * "/../"))
Pkg.develop(PackageSpec(; path = (@__DIR__) * "/../"))
Pkg.resolve()
Pkg.instantiate()
end
Expand All @@ -23,41 +23,55 @@ end

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

# interlinks
links = InterLinks("TensorKit" => "https://jutho.github.io/TensorKit.jl/stable/",
"TensorOperations" => "https://jutho.github.io/TensorOperations.jl/stable/",
"KrylovKit" => "https://jutho.github.io/KrylovKit.jl/stable/",
"BlockTensorKit" => "https://lkdvos.github.io/BlockTensorKit.jl/dev/")
links = InterLinks(
"TensorKit" => "https://jutho.github.io/TensorKit.jl/stable/",
"TensorOperations" => "https://jutho.github.io/TensorOperations.jl/stable/",
"KrylovKit" => "https://jutho.github.io/KrylovKit.jl/stable/",
"BlockTensorKit" => "https://lkdvos.github.io/BlockTensorKit.jl/dev/"
)

# include MPSKit in all doctests
DocMeta.setdocmeta!(MPSKit, :DocTestSetup, :(using MPSKit, TensorKit); recursive=true)
DocMeta.setdocmeta!(MPSKit, :DocTestSetup, :(using MPSKit, TensorKit); recursive = true)

mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/physics"]),
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"tags" => "ams",
"packages" => ["base", "ams", "autoload", "physics"])))
mathengine = MathJax3(
Dict(
:loader => Dict("load" => ["[tex]/physics"]),
:tex => Dict(
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"tags" => "ams",
"packages" => ["base", "ams", "autoload", "physics"]
)
)
)
makedocs(;
sitename="MPSKit.jl",
format=Documenter.HTML(;
prettyurls=true,
mathengine,
assets=["assets/custom.css"],
size_threshold=1024000,),
pages=["Home" => "index.md",
"Manual" => ["man/intro.md",
"man/states.md",
"man/operators.md",
"man/algorithms.md",
# "man/environments.md",
"man/parallelism.md",
"man/lattices.md"],
"Examples" => "examples/index.md",
"Library" => "lib/lib.md",
"References" => "references.md"],
checkdocs=:exports,
doctest=true,
plugins=[bib, links])
sitename = "MPSKit.jl",
format = Documenter.HTML(;
prettyurls = true,
mathengine,
assets = ["assets/custom.css"],
size_threshold = 1024000,
),
pages = [
"Home" => "index.md",
"Manual" => [
"man/intro.md",
"man/states.md",
"man/operators.md",
"man/algorithms.md",
# "man/environments.md",
"man/parallelism.md",
"man/lattices.md",
],
"Examples" => "examples/index.md",
"Library" => "lib/lib.md",
"References" => "references.md",
],
checkdocs = :exports,
doctest = true,
plugins = [bib, links]
)

deploydocs(; repo="github.com/QuantumKitHub/MPSKit.jl.git", push_preview=true)
deploydocs(; repo = "github.com/QuantumKitHub/MPSKit.jl.git", push_preview = true)
26 changes: 14 additions & 12 deletions examples/classic2d/1.hard-hexagon/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function virtual_space(D::Integer)
return Vect[FibonacciAnyon](sector => _D for sector in (:I, :τ))
end

@assert isapprox(dim(virtual_space(100)), 100; atol=3)
@assert isapprox(dim(virtual_space(100)), 100; atol = 3)

md"""
## The leading boundary
Expand All @@ -39,10 +39,10 @@ Additionally, we can compute the entanglement entropy as well as the correlation
D = 10
V = virtual_space(D)
ψ₀ = InfiniteMPS([P], [V])
ψ, envs, = leading_boundary(ψ₀, mpo,
VUMPS(; verbosity=0,
alg_eigsolve=MPSKit.Defaults.alg_eigsolve(;
ishermitian=false))) # use non-hermitian eigensolver
ψ, envs, = leading_boundary(
ψ₀, mpo,
VUMPS(; verbosity = 0, alg_eigsolve = MPSKit.Defaults.alg_eigsolve(; ishermitian = false))
) # use non-hermitian eigensolver
F = real(expectation_value(ψ, mpo))
S = real(first(entropy(ψ)))
ξ = correlation_length(ψ)
Expand All @@ -57,8 +57,10 @@ First we need to know the entropy and correlation length at a bunch of different
According to the scaling hypothesis we should have ``S \propto \frac{c}{6} log(ξ)``. Therefore we should find ``c`` using
"""

function scaling_simulations(ψ₀, mpo, Ds; verbosity=0, tol=1e-6,
alg_eigsolve=MPSKit.Defaults.alg_eigsolve(; ishermitian=false))
function scaling_simulations(
ψ₀, mpo, Ds; verbosity = 0, tol = 1.0e-6,
alg_eigsolve = MPSKit.Defaults.alg_eigsolve(; ishermitian = false)
)
entropies = similar(Ds, Float64)
correlations = similar(Ds, Float64)
alg = VUMPS(; verbosity, tol, alg_eigsolve)
Expand All @@ -68,7 +70,7 @@ function scaling_simulations(ψ₀, mpo, Ds; verbosity=0, tol=1e-6,
correlations[1] = correlation_length(ψ)

for (i, d) in enumerate(diff(Ds))
ψ, envs = changebonds(ψ, mpo, OptimalExpand(; trscheme=truncdim(d)), envs)
ψ, envs = changebonds(ψ, mpo, OptimalExpand(; trscheme = truncdim(d)), envs)
ψ, envs, = leading_boundary(ψ, mpo, alg, envs)
entropies[i + 1] = real(entropy(ψ)[1])
correlations[i + 1] = correlation_length(ψ)
Expand All @@ -83,8 +85,8 @@ Ss, ξs = scaling_simulations(ψ₀, mpo, bond_dimensions)
f = fit(log.(ξs), 6 * Ss, 1)
c = f.coeffs[2]

#+
#+

p = plot(; xlabel="logarithmic correlation length", ylabel="entanglement entropy")
p = plot(log.(ξs), Ss; seriestype=:scatter, label=nothing)
plot!(p, ξ -> f(ξ) / 6; label="fit")
p = plot(; xlabel = "logarithmic correlation length", ylabel = "entanglement entropy")
p = plot(log.(ξs), Ss; seriestype = :scatter, label = nothing)
plot!(p, ξ -> f(ξ) / 6; label = "fit")
36 changes: 20 additions & 16 deletions examples/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=(@__DIR__) * "/../"))
Pkg.develop(PackageSpec(; path = (@__DIR__) * "/../"))
Pkg.resolve()
Pkg.instantiate()
end
Expand All @@ -17,21 +17,21 @@ using TOML, SHA

const CACHEFILE = joinpath(@__DIR__, "Cache.toml")

getcache() = isfile(CACHEFILE) ? TOML.parsefile(CACHEFILE) : Dict{String,Any}()
getcache() = isfile(CACHEFILE) ? TOML.parsefile(CACHEFILE) : Dict{String, Any}()

function iscached(root, name)
cache = getcache()
return haskey(cache, root) &&
haskey(cache[root], name) &&
cache[root][name] == checksum(root, name)
haskey(cache[root], name) &&
cache[root][name] == checksum(root, name)
end

function setcached(root, name)
cache = getcache()
if haskey(cache, root)
cache[root][name] = checksum(root, name)
else
cache[root] = Dict{String,Any}(name => checksum(root, name))
cache[root] = Dict{String, Any}(name => checksum(root, name))
end
return open(f -> TOML.print(f, cache), CACHEFILE, "w")
end
Expand Down Expand Up @@ -68,19 +68,23 @@ function build_example(root, name)
source_file = joinpath(source_dir, "main.jl")
target_dir = joinpath(@__DIR__, "..", "docs", "src", "examples", root, name)

if !iscached(root, name)
Literate.markdown(source_file, target_dir; execute=true, name="index",
preprocess=attach_notebook_badge(root, name), mdstrings=true,
nbviewer_root_url="https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev",
binder_root_url="https://mybinder.org/v2/gh/QuantumKitHub/MPSKit.jl/gh-pages?filepath=dev",
credits=false,
repo_root_url="https://github.com/QuantumKitHub/MPSKit.jl")
Literate.notebook(source_file, target_dir; execute=false, name="main",
preprocess=str -> replace(str, r"(?<!`)``(?!`)" => "\$"),
mdstrings=true, credits=false)
return if !iscached(root, name)
Literate.markdown(
source_file, target_dir; execute = true, name = "index",
preprocess = attach_notebook_badge(root, name), mdstrings = true,
nbviewer_root_url = "https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev",
binder_root_url = "https://mybinder.org/v2/gh/QuantumKitHub/MPSKit.jl/gh-pages?filepath=dev",
credits = false,
repo_root_url = "https://github.com/QuantumKitHub/MPSKit.jl"
)
Literate.notebook(
source_file, target_dir; execute = false, name = "main",
preprocess = str -> replace(str, r"(?<!`)``(?!`)" => "\$"),
mdstrings = true, credits = false
)

foreach(filter(!=("main.jl"), readdir(source_dir))) do f
return cp(joinpath(source_dir, f), joinpath(target_dir, f); force=true)
return cp(joinpath(source_dir, f), joinpath(target_dir, f); force = true)
end
setcached(root, name)
end
Expand Down
37 changes: 20 additions & 17 deletions examples/quantum1d/1.ising-cft/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ tensor is equivalent to optimixing a state in the entire Hilbert space, as all o
are just unitary matrices that mix the basis.
"""

energies, states = exact_diagonalization(H; num=18, alg=Lanczos(; krylovdim=200));
plot(real.(energies);
seriestype=:scatter,
legend=false,
ylabel="energy",
xlabel="#eigenvalue")
energies, states = exact_diagonalization(H; num = 18, alg = Lanczos(; krylovdim = 200));
plot(
real.(energies);
seriestype = :scatter, legend = false, ylabel = "energy", xlabel = "#eigenvalue"
)

md"""
!!! note "Krylov dimension"
Expand Down Expand Up @@ -104,11 +103,13 @@ v = 2.0
Δ = real.(energies[1:18] .- energies[1]) ./ (2π * v / L)
S = momenta ./ (2π / L)

p = plot(S, real.(Δ);
seriestype=:scatter, xlabel="conformal spin (S)", ylabel="scaling dimension (Δ)",
legend=false)
vline!(p, -3:3; color="gray", linestyle=:dash)
hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash)
p = plot(
S, real.(Δ);
seriestype = :scatter, xlabel = "conformal spin (S)", ylabel = "scaling dimension (Δ)",
legend = false
)
vline!(p, -3:3; color = "gray", linestyle = :dash)
hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = "gray", linestyle = :dash)
p

md"""
Expand All @@ -129,7 +130,7 @@ ansatz. This returns quasiparticle states, which can be converted to regular `Fi
objects.
"""

E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num=18)
E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num = 18)
states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps))
energies_mps = map(x -> expectation_value(x, H_mps), states_mps)

Expand All @@ -148,9 +149,11 @@ v = 2.0
Δ_mps = real.(energies_mps[1:18] .- energies_mps[1]) ./ (2π * v / L_mps)
S_mps = momenta_mps ./ (2π / L_mps)

p_mps = plot(S_mps, real.(Δ_mps);
seriestype=:scatter, xlabel="conformal spin (S)",
ylabel="scaling dimension (Δ)", legend=false)
vline!(p_mps, -3:3; color="gray", linestyle=:dash)
hline!(p_mps, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash)
p_mps = plot(
S_mps, real.(Δ_mps);
seriestype = :scatter, xlabel = "conformal spin (S)",
ylabel = "scaling dimension (Δ)", legend = false
)
vline!(p_mps, -3:3; color = "gray", linestyle = :dash)
hline!(p_mps, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = "gray", linestyle = :dash)
p_mps
Loading
Loading