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
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
TensorKitManifolds = "11fa318c-39cb-4a83-b1ed-cdc7ba1e3684"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
Expand All @@ -30,9 +29,13 @@ VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[extensions]
MPSKitAdaptExt = "Adapt"
MPSKitMakieExt = "Makie"
MPSKitPlotsExt = "RecipesBase"

[compat]
Accessors = "0.1"
Expand All @@ -44,6 +47,7 @@ HalfIntegers = "1.6.0"
KrylovKit = "0.8.3, 0.9.2, 0.10"
LinearAlgebra = "1.6"
LoggingExtras = "1"
Makie = "0.24.11"
MatrixAlgebraKit = "0.6.5"
OhMyThreads = "0.7, 0.8"
OptimKit = "0.4, 0.5"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
Expand Down
9 changes: 9 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
`expectation_value(::InfiniteMPS, ::InfiniteMPO)` forwards here. ([#508](https://github.com/QuantumKitHub/MPSKit.jl/pull/508))
- `InfiniteMultilineMPS`/`FiniteMultilineMPS` and `InfiniteMultilineMPO`/`FiniteMultilineMPO`
aliases for multiline objects with infinite or finite lines. ([#508](https://github.com/QuantumKitHub/MPSKit.jl/pull/508))
- Makie.jl plotting functions `entanglement_plot` and `transfer_plot`, and their mutating
counterparts `entanglement_plot!` and `transfer_plot!`, through a new `MPSKitMakieExt` package
extension that is loaded with any Makie backend (e.g. `using CairoMakie`). ([#428](https://github.com/QuantumKitHub/MPSKit.jl/pull/428))

### Changed

Expand Down Expand Up @@ -200,6 +203,10 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
### Deprecated

- `DynamicTols.updatetol(alg, iter, ϵ)`; use `DynamicTols.adapt_solver(alg; iter, g_global = ϵ)` instead. ([#455](https://github.com/QuantumKitHub/MPSKit.jl/pull/455))
- The Plots.jl recipes `entanglementplot` and `transferplot`, in favor of the Makie.jl based
`entanglement_plot` and `transfer_plot`. RecipesBase is now a weak dependency, so these are
only available once Plots.jl is loaded. ([#428](https://github.com/QuantumKitHub/MPSKit.jl/pull/428))

### Removed

- The custom `MPSTensor` constructors; construct `TensorMap`s with explicit `TensorMapSpace`s instead. ([#475](https://github.com/QuantumKitHub/MPSKit.jl/pull/475))
Expand Down Expand Up @@ -232,6 +239,8 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
matching tensors of a line, and accepts any row due to periodicity.
`checkbounds(Bool, ::PeriodicArray, I...)` now also accepts any index, matching `getindex`. ([#508](https://github.com/QuantumKitHub/MPSKit.jl/pull/508))
- `size`/`axes` for a `CView` over a `Multiline` with finite lines were missing. ([#508](https://github.com/QuantumKitHub/MPSKit.jl/pull/508))
- `transferplot` shifted the angles the wrong way for a nonzero `thetaorigin`, moving eigenvalues
outside the plotted range. ([#428](https://github.com/QuantumKitHub/MPSKit.jl/pull/428))
- `excitations(::InfiniteMPO, ::QuasiparticleAnsatz, ::InfiniteQP, lenvs, renvs)` referenced `H_eff` before assigning. ([#489](https://github.com/QuantumKitHub/MPSKit.jl/pull/489))
- `Base.:+`/`-` on `FiniteMPS` returned a wrong state for near-parallel operands carried by
different tensor networks, e.g. `norm(E₀ * gs - H * gs)` coming out as `2 * norm(gs) * E₀`
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/dynamics/ising-dqpt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ dot(ψ₀, ψ₀)
````

````
0.9999999999999999 + 6.62289120209154e-17im
1.0000000000000002 - 4.9391993181912504e-17im
````

so the Loschmidt echo takes on the pleasant form
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/dynamics/ising-dqpt/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.13.1",
"display_name": "Julia 1.13.3",
"language": "julia",
"name": "julia-1.13"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.13.1"
"version": "1.13.3"
}
},
"nbformat": 4,
Expand Down
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/examples/dynamics/xy-finiteT/figure-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
184 changes: 58 additions & 126 deletions docs/src/examples/dynamics/xy-finiteT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using .ExampleModels
using MPSKit: infinite_temperature_density_matrix
using QuadGK: quadgk
using SpecialFunctions: ellipe
using Plots
using CairoMakie
using LinearAlgebra
using BenchmarkFreeFermions
````
Expand Down Expand Up @@ -119,7 +119,7 @@ println("Exact (N=Inf):\t", groundstate_energy(J, Inf))
````

````
Numerical: -0.15637803047011115
Numerical: -0.1563780304701102
Exact (N=32): -0.15637803047254015
Exact (N=Inf): -0.15915494309189535

Expand Down Expand Up @@ -207,23 +207,39 @@ Z_taylor = map(Iterators.product(βs, expansion_orders)) do (β, expansion_order
end
F_taylor = -(1 ./ βs) .* Z_taylor

p_taylor = let
labels = reshape(
map(expansion_orders) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, Z_analytic; label = "analytic", title = "Partition function",
xlabel = "β", ylabel = "Z(β)"
)
plot!(p1, βs, Z_taylor; label = labels)
p2 = plot(
βs, F_analytic; label = "analytic", title = "Free energy",
xlabel = "β", ylabel = "F(β)"
)
plot!(p2, βs, F_taylor; label = labels)
plot(p1, p2)
# Makie skips NaN, but picks wrong limits for infinite or (on a log scale) zero values
nan_unless(f, ys) = [f(y) ? y : NaN for y in ys]

# Plot the errors of several methods side by side, given as `label => (βs, ΔZ, ΔF)`.
function plot_errors(errors; position = :lt, yscale = identity)
fig = Figure(; size = (800, 400))
axZ = Axis(fig[1, 1]; title = "Partition function error", xlabel = "β", ylabel = "ΔZ(β)", yscale)
axF = Axis(fig[1, 2]; title = "Free energy error", xlabel = "β", ylabel = "ΔF(β)", yscale)
valid = yscale === identity ? isfinite : y -> isfinite(y) && y > 0
for (label, (β, ΔZ, ΔF)) in errors
lines!(axZ, β, nan_unless(valid, ΔZ); label)
lines!(axF, β, nan_unless(valid, ΔF); label)
end
axislegend(axZ; position)
return fig
end

taylor_errors(Z, F, orders) = [
"Taylor N=$N" => (βs, abs.(Z[:, i] .- Z_analytic), abs.(F[:, i] .- F_analytic))
for (i, N) in enumerate(orders)
]

p_taylor = let fig = Figure(; size = (800, 400))
axZ = Axis(fig[1, 1]; title = "Partition function", xlabel = "β", ylabel = "Z(β)")
axF = Axis(fig[1, 2]; title = "Free energy", xlabel = "β", ylabel = "F(β)")
lines!(axZ, βs, Z_analytic; label = "analytic")
lines!(axF, βs, nan_unless(isfinite, F_analytic); label = "analytic")
for (i, N) in enumerate(expansion_orders)
lines!(axZ, βs, Z_taylor[:, i]; label = "Taylor N=$N")
lines!(axF, βs, nan_unless(isfinite, F_taylor[:, i]); label = "Taylor N=$N")
end
axislegend(axZ; position = :lt)
fig
end
````

Expand Down Expand Up @@ -261,23 +277,7 @@ expansion_orders = 2:3
Z_taylor = Z_taylor[:, 2:end]
F_taylor = F_taylor[:, 2:end]

p_taylor_diff = let
labels = reshape(
map(expansion_orders) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, abs.(Z_taylor .- Z_analytic);
label = labels, title = "Partition function error",
xlabel = "β", ylabel = "ΔZ(β)", legend = :topleft
)
p2 = plot(
βs, abs.(F_taylor .- F_analytic); label = labels,
xlabel = "β", ylabel = "ΔF(β)", title = "Free energy error", legend = :topleft
)
plot(p1, p2)
end
p_taylor_diff = plot_errors(taylor_errors(Z_taylor, F_taylor, expansion_orders))
````

![](figure-2.png)
Expand Down Expand Up @@ -312,23 +312,7 @@ Z_taylor2 = map(Iterators.product(βs, expansion_orders)) do (β, expansion_orde
end
F_taylor2 = -(1 ./ βs) .* Z_taylor2

p_taylor2_diff = let
labels = reshape(
map(expansion_orders[2:end]) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, abs.(Z_taylor2 .- Z_analytic);
label = labels, title = "Partition function error",
xlabel = "β", ylabel = "ΔZ(β)", legend = :topleft
)
p2 = plot(
βs, abs.(F_taylor2 .- F_analytic); label = labels,
xlabel = "β", ylabel = "ΔF(β)", title = "Free energy error", legend = :topleft
)
plot(p1, p2)
end
p_taylor2_diff = plot_errors(taylor_errors(Z_taylor2, F_taylor2, expansion_orders))
````

![](figure-3.png)
Expand Down Expand Up @@ -380,32 +364,12 @@ for i in 3:length(βs)
end
F_mpo_mul = -(1 ./ βs) .* Z_mpo_mul

p_mpo_mul_diff = let
labels = reshape(
map(expansion_orders) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, abs.(Z_taylor2 .- Z_analytic);
label = labels, title = "Partition function error",
xlabel = "β", ylabel = "ΔZ(β)", legend = :bottomright, yscale = :log10
)
plot!(
p1, βs, abs.(Z_mpo_mul .- Z_analytic);
label = "MPO multiplication"
)
p2 = plot(
βs, abs.(F_taylor2 .- F_analytic); label = labels,
xlabel = "β", ylabel = "ΔF(β)", title = "Free energy error", legend = nothing,
yscale = :log10
)
plot!(
p2, βs, abs.(F_mpo_mul .- F_analytic);
label = "MPO multiplication"
)
plot(p1, p2)
end
p_mpo_mul_diff = plot_errors(
[
taylor_errors(Z_taylor2, F_taylor2, expansion_orders);
"MPO multiplication" => (βs, abs.(Z_mpo_mul .- Z_analytic), abs.(F_mpo_mul .- F_analytic))
]; position = :rb, yscale = log10
)
````

![](figure-4.png)
Expand Down Expand Up @@ -464,28 +428,13 @@ for i in 2:length(βs_exp)
end
F_mpo_mul_exp = -(1 ./ βs_exp) .* Z_mpo_mul_exp

p_mpo_mul_exp_diff = let
labels = reshape(
map(expansion_orders[2:end]) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, abs.(Z_taylor2 .- Z_analytic);
label = labels, title = "Partition function error", xlabel = "β", ylabel = "ΔZ(β)",
legend = :bottomright, yscale = :log10
)
plot!(p1, βs, abs.(Z_mpo_mul .- Z_analytic); label = "MPO multiplication")
plot!(p1, βs_exp, abs.(Z_mpo_mul_exp .- Z_analytic_exp); label = "MPO multiplication exp")

p2 = plot(
βs, abs.(F_taylor2 .- F_analytic); label = labels, xlabel = "β", ylabel = "ΔF(β)",
title = "Free energy error", legend = nothing, yscale = :log10
)
plot!(p2, βs, abs.(F_mpo_mul .- F_analytic); label = "MPO multiplication")
plot!(p2, βs_exp, abs.(F_mpo_mul_exp .- F_analytic_exp); label = "MPO multiplication exp")
plot(p1, p2)
end
p_mpo_mul_exp_diff = plot_errors(
[
taylor_errors(Z_taylor2, F_taylor2, expansion_orders);
"MPO multiplication" => (βs, abs.(Z_mpo_mul .- Z_analytic), abs.(F_mpo_mul .- F_analytic))
"MPO multiplication exp" => (βs_exp, abs.(Z_mpo_mul_exp .- Z_analytic_exp), abs.(F_mpo_mul_exp .- F_analytic_exp))
]; position = :rb, yscale = log10
)
````

![](figure-5.png)
Expand Down Expand Up @@ -531,31 +480,14 @@ for i in 2:length(βs)
end
F_tdvp = -(1 ./ βs) .* Z_tdvp

p_mpo_mul_diff = let
labels = reshape(
map(expansion_orders) do N
return "Taylor N=$N"
end, 1, :
)
p1 = plot(
βs, abs.(Z_taylor2 .- Z_analytic); label = labels,
title = "Partition function error", xlabel = "β", ylabel = "ΔZ(β)",
legend = :bottomright, yscale = :log10
)
plot!(p1, βs, abs.(Z_mpo_mul .- Z_analytic); label = "MPO multiplication")
plot!(p1, βs_exp, abs.(Z_mpo_mul_exp .- Z_analytic_exp); label = "MPO multiplication exp")
plot!(p1, βs, abs.(Z_tdvp .- Z_analytic); label = "TDVP")

p2 = plot(
βs, abs.(F_taylor2 .- F_analytic); label = labels, xlabel = "β", ylabel = "ΔF(β)",
title = "Free energy error", legend = nothing, yscale = :log10
)
plot!(p2, βs, abs.(F_mpo_mul .- F_analytic); label = "MPO multiplication")
plot!(p2, βs_exp, abs.(F_mpo_mul_exp .- F_analytic_exp); label = "MPO multiplication exp")
plot!(p2, βs, abs.(F_tdvp .- F_analytic); label = "TDVP")

plot(p1, p2)
end
p_mpo_mul_diff = plot_errors(
[
taylor_errors(Z_taylor2, F_taylor2, expansion_orders);
"MPO multiplication" => (βs, abs.(Z_mpo_mul .- Z_analytic), abs.(F_mpo_mul .- F_analytic))
"MPO multiplication exp" => (βs_exp, abs.(Z_mpo_mul_exp .- Z_analytic_exp), abs.(F_mpo_mul_exp .- F_analytic_exp))
"TDVP" => (βs, abs.(Z_tdvp .- Z_analytic), abs.(F_tdvp .- F_analytic))
]; position = :rb, yscale = log10
)
````

![](figure-6.png)
Expand Down
Loading
Loading