Skip to content

Commit 99cbea3

Browse files
leburgelclaude
andauthored
Fix the interactions in qstate_clock (#89)
Couple neighbouring legs W - S - E - N of the `W ⊗ S ← N ⊗ E` tensor instead of the opposite pairs. This broke in b608f72, which adapted the transfer matrices to MPSKit's new leg order but missed the clock tensor. Add tests against the Onsager free energy for q = 2 and q = 4. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3778994 commit 99cbea3

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎src/models/transfermatrices.jl‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,16 @@ end
111111
"""
112112
qstate_clock([elt::Type{<:Number}=ComplexF64], [symmetry::Type{<:Sector}=Trivial]; beta::Number=1.0, q::Integer=3)
113113
114-
MPO for the partition function of the two-dimensional discrete clock model with ``q`` states.
114+
MPO for the partition function of the two-dimensional discrete clock model with ``q`` states,
115+
116+
```math
117+
\\mathcal{Z}(\\beta) = \\sum_{\\{s\\}} \\exp(-\\beta H(s)) \\text{ with } H(s) = -\\sum_{\\langle i, j \\rangle} \\cos\\left(\\frac{2\\pi (s_i - s_j)}{q}\\right),
118+
```
119+
120+
where each classical spin can take the values ``s = 0, …, q - 1``. The spins live on the
121+
legs of the MPO tensor, which carries the interactions between neighbouring legs
122+
`W - S - E - N - W` (legs ordered as `W ⊗ S ← N ⊗ E`). Every tensor therefore contains two
123+
spins, and the partition function per tensor is the square of the partition function per spin.
115124
"""
116125
function qstate_clock(
117126
elt::Type{<:Number} = ComplexF64, ::Type{Trivial} = Trivial;
@@ -120,7 +129,7 @@ function qstate_clock(
120129
comega(d) = cos(2 * pi * d / q)
121130
O = zeros(elt, q, q, q, q)
122131
for i in 1:q, j in 1:q, k in 1:q, l in 1:q
123-
O[i, j, k, l] = exp(beta * (comega(i - j) + comega(j - k) + comega(k - l) + comega(l - i)))
132+
O[i, j, k, l] = exp(beta * (comega(i - j) + comega(j - l) + comega(l - k) + comega(k - i)))
124133
end
125134

126135
return InfiniteMPO([TensorMap(O, ℂ^q * ℂ^q, ℂ^q * ℂ^q)])

‎test/qstate_clock.jl‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Test
2+
using TensorKit
3+
using QuadGK
4+
using MPSKit
5+
using MPSKitModels
6+
7+
# Onsager free energy per spin of the 2D classical Ising model with coupling J = 1
8+
function classical_ising_free_energy(; beta)
9+
k = 1 / sinh(2 * beta)^2
10+
F = quadgk(
11+
θ -> log(cosh(2 * beta)^2 + 1 / k * sqrt(1 + k^2 - 2 * k * cos(2 * θ))),
12+
0, pi
13+
)[1]
14+
return -1 / beta * (log(2) / 2 + 1 / (2 * pi) * F)
15+
end
16+
17+
alg = VUMPS(; tol = 1.0e-10, maxiter = 100, verbosity = 0)
18+
19+
# Every MPO tensor contains two spins, so the free energy per spin is -log(λ) / (2β).
20+
function clock_free_energy(q, beta; D = 16)
21+
O = qstate_clock(; beta, q)
22+
ψ, envs, = leading_boundary(InfiniteMPS(ℂ^q, ℂ^D), O, alg)
23+
λ = expectation_value(ψ, O, envs)
24+
return -log(abs(λ)) / (2 * beta)
25+
end
26+
27+
@testset "q = 2 is the Ising model (β = $beta)" for beta in (0.3, 0.6)
28+
@test clock_free_energy(2, beta) ≈ classical_ising_free_energy(; beta) atol = 1.0e-6
29+
end
30+
31+
# cos(θ - θ') = (σσ' + ττ') / 2 for σ = cos θ + sin θ and τ = cos θ - sin θ, so the q = 4 clock
32+
# model is two decoupled Ising models at half the coupling.
33+
@testset "q = 4 is two Ising models (β = $beta)" for beta in (0.6, 1.2)
34+
f_ising = classical_ising_free_energy(; beta = beta / 2) * (beta / 2)
35+
@test clock_free_energy(4, beta) * beta ≈ 2 * f_ising atol = 1.0e-6
36+
end

0 commit comments

Comments
 (0)