Skip to content

Commit d21b299

Browse files
Tests rework (#75)
* initial update of tests, adding cft tests * fix comment * LoopTNR cft methods test * update tolerances * test the models * add free_energy function * test using new free_energy function * test fermions * update test running * update ATRG3D test * fix deprecation warnings
1 parent 647433d commit d21b299

9 files changed

Lines changed: 287 additions & 175 deletions

File tree

.github/workflows/CI.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ jobs:
2222
- '1'
2323
os:
2424
- ubuntu-latest
25-
arch:
26-
- x64
25+
- macOS-latest
26+
- windows-latest
2727
steps:
2828
- uses: actions/checkout@v4
2929
- uses: julia-actions/setup-julia@v2
3030
with:
3131
version: ${{ matrix.version }}
32-
arch: ${{ matrix.arch }}
3332
- uses: julia-actions/cache@v2
3433
- uses: julia-actions/julia-buildpkg@latest
3534
- uses: julia-actions/julia-runtest@latest

src/TNRKit.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export run!
5151

5252
# models
5353
include("models/ising.jl")
54-
export classical_ising, classical_ising_symmetric, ising_βc, f_onsager,
54+
export classical_ising, classical_ising_symmetric, ising_βc, f_onsager, ising_cft_exact,
5555
ising_βc_3D, classical_ising_symmetric_3D, classical_ising_3D
5656

5757
include("models/gross-neveu.jl")
@@ -67,6 +67,9 @@ include("models/clock.jl")
6767
export classical_clock
6868

6969
# utility functions
70+
include("utility/free_energy.jl")
71+
export free_energy
72+
7073
include("utility/cft.jl")
7174
export cft_data, central_charge, cft_data!
7275

src/utility/cft.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function cft_data(scheme::TNRScheme; v = 1, unitcell = 1, is_real = true)
1212
outinds = Tuple(collect(1:unitcell))
1313
ininds = Tuple(collect((unitcell + 1):(2unitcell)))
1414

15-
T = permute(T, outinds, ininds)
15+
T = permute(T, (outinds, ininds))
1616
D, _ = eig(T)
1717

1818
data = zeros(ComplexF64, dim(space(D, 1)))
@@ -48,7 +48,7 @@ function cft_data(scheme::BTRG; v = 1, unitcell = 1, is_real = true)
4848
outinds = Tuple(collect(1:unitcell))
4949
ininds = Tuple(collect((unitcell + 1):(2unitcell)))
5050

51-
T = permute(T, outinds, ininds)
51+
T = permute(T, (outinds, ininds))
5252
D, _ = eig(T)
5353

5454
data = zeros(ComplexF64, dim(space(D, 1)))

src/utility/free_energy.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function free_energy(data, β; scalefactor = 2.0, unitcell = 1.0)
2+
lnz = 0.0
3+
x = 1.0 - log(unitcell) / log(scalefactor)
4+
for (i, z) in enumerate(data)
5+
lnz += log(z) * scalefactor^(x - i)
6+
end
7+
return -lnz / β
8+
end

test/fermions.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
f_bench = -1.4515448845652446
2+
T = gross_neveu_start(0, 0, 0)
3+
4+
# === TRG ===
5+
@testset "TRG - Gross-Neveu Model" begin
6+
scheme = TRG(T)
7+
data = run!(scheme, truncdim(16), maxiter(25))
8+
@test free_energy(data, 1.0) f_bench rtol = 1.0e-3
9+
end
10+
11+
# === BTRG ===
12+
@testset "BTRG - Gross-Neveu Model" begin
13+
scheme = BTRG(T)
14+
data = run!(scheme, truncdim(16), maxiter(25))
15+
@test free_energy(data, 1.0) f_bench rtol = 1.0e-4
16+
end
17+
18+
# === HOTRG ===
19+
@testset "HOTRG - Gross-Neveu Model" begin
20+
scheme = HOTRG(T)
21+
data = run!(scheme, truncdim(16), maxiter(25))
22+
@test free_energy(data, 1.0; scalefactor = 4.0) f_bench rtol = 1.0e-3
23+
end
24+
25+
# === ATRG ===
26+
@testset "ATRG - Gross-Neveu Model" begin
27+
scheme = ATRG(T)
28+
data = run!(scheme, truncdim(16), maxiter(25))
29+
@test free_energy(data, 1.0; scalefactor = 4.0) f_bench rtol = 1.0e-2
30+
end
31+
32+
# === LoopTNR ===
33+
@testset "LoopTNR - Gross-Neveu Model" begin
34+
scheme = LoopTNR(T)
35+
data = run!(scheme, truncdim(8), maxiter(10))
36+
@test free_energy(data, 1.0) f_bench rtol = 1.0e-3
37+
end

test/ising.jl

Lines changed: 0 additions & 167 deletions
This file was deleted.

test/models.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
println("--------------------")
2+
println(" Testing all models ")
3+
println("--------------------")
4+
5+
models_2D = [
6+
classical_ising(),
7+
classical_ising_symmetric(),
8+
gross_neveu_start(0, 0, 0),
9+
# classical_clock(), # TODO: find out how to test this model
10+
classical_potts(3),
11+
classical_potts_symmetric(3),
12+
sixvertex(Float64, Trivial),
13+
sixvertex(Float64, U1Irrep),
14+
sixvertex(Float64, CU1Irrep),
15+
]
16+
17+
temperatures = [
18+
ising_βc,
19+
ising_βc,
20+
1.0,
21+
potts_βc(3),
22+
potts_βc(3),
23+
1.0,
24+
1.0,
25+
1.0,
26+
]
27+
28+
answers = [
29+
f_onsager, # Hack because classical_ising starts from larger lattice
30+
f_onsager,
31+
-1.4515448845652446,
32+
-4.119552029995684, # This is an approximation!
33+
-4.119552029995684, # This is an approximation!
34+
3 / 2 * log(3 / 4),
35+
3 / 2 * log(3 / 4),
36+
3 / 2 * log(3 / 4),
37+
]
38+
39+
unitcells = vcat([2.0], fill(1.0, length(models_2D) - 1))
40+
41+
@testset "2D Models" begin
42+
for (model, temp, answer, unitcell) in zip(models_2D, temperatures, answers, unitcells)
43+
scheme = TRG(model)
44+
data = run!(scheme, truncdim(16), maxiter(25))
45+
@test free_energy(data, temp; unitcell = unitcell) answer rtol = 1.0e-3
46+
end
47+
end

test/runtests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ using PEPSKit: InfinitePartitionFunction, CTMRGEnv, SequentialCTMRG, leading_bou
55
using QuadGK
66

77
include("spaces.jl") # do they give spacemismatches?
8-
include("ising.jl") # do they give the correct results (with the expected accuracy)?
9-
include("finalize.jl") # do they give the correct results (with the expected accuracy)?
8+
include("schemes.jl") # do they give the correct results (with the expected accuracy)?
9+
include("models.jl") # do they give the correct results (with the expected accuracy)?
10+
include("fermions.jl") # do they give the correct results (with the expected accuracy)?

0 commit comments

Comments
 (0)