Skip to content
Open
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
43 changes: 10 additions & 33 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,20 @@
name: CI
name: Tests

on:
push:
branches:
- 'master'
branches: [main]
tags: '*'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- 'min'
- '1'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v6
with:
files: lcov.info
token: "${{ secrets.CODECOV_TOKEN }}"

tests:
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/TestGroups.yml@main"
with:
fast: ${{ github.event.pull_request.draft == true }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Zygote = "0.7.7"
julia = "1.11"

[extras]
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "QuadGK"]
test = ["Test", "ParallelTestRunner"]
5 changes: 5 additions & 0 deletions test/algebras.jl → test/algebras/algebras.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using Test
using TNRKit
using TensorKit
using TensorKitSectors

@testset "Q-system property of FunZN ∈ Rep[DN]" begin
for N in 2:7
FunZN, m = TNRKit.FunZN_Dihedral(N)
Expand Down
4 changes: 4 additions & 0 deletions test/entropies.jl → test/entropies/entropies.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
using Test
using TNRKit
using TensorKit

println("-----------------------")
println(" Testing all entropies ")
println("-----------------------")
Expand Down
4 changes: 4 additions & 0 deletions test/fermions.jl → test/fermions/fermions.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
using Test
using TNRKit
using TensorKit

f_bench = -1.4515448845652446
T = gross_neveu_start(0, 0, 0)

Expand Down
5 changes: 5 additions & 0 deletions test/models.jl → test/models/models.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using Test
using TNRKit
using TensorKit
using TensorKitSectors

println("--------------------")
println(" Testing all models ")
println("--------------------")
Expand Down
16 changes: 4 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
using Test
using TNRKit
using TensorKit
using TensorKitSectors
using QuadGK
using ParallelTestRunner

include("spaces.jl") # do they give spacemismatches?
include("schemes.jl") # do they give the correct results (with the expected accuracy)?
include("schemes_triangular.jl") # do they give the correct results (with the expected accuracy)?
include("schemes_honeycomb.jl") # do they give the correct results (with the expected accuracy)?
include("models.jl") # do they give the correct results (with the expected accuracy)?
include("fermions.jl") # do they give the correct results (with the expected accuracy)?
include("entropies.jl") # do they work?
include("algebras.jl")
testsuite = find_tests(@__DIR__)
args = parse_args(ARGS)
ParallelTestRunner.runtests(TNRKit, args)
112 changes: 111 additions & 1 deletion test/schemes.jl → test/schemes/schemes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# This tests every scheme in the library on the Z2 symmetric Ising model.
using Test
using TNRKit
using TensorKit

# This tests every scheme in the library on the Z2 symmetric Ising model.
println("---------------------")
println(" Testing all schemes ")
println("---------------------")
Expand Down Expand Up @@ -530,3 +533,110 @@ end
lowT = norm(@tensor scheme.Timp_final[1 2; 2 1]) / norm(@tensor scheme.Tpure[1 2; 2 1])
@test lowT ≈ 1 rtol = 1.0e-4
end

# c6vCTM_triangular
@testset "c6vCTM_triangular - Ising Model" begin
for sym in [Trivial, Z2Irrep]
for projectors in [:twothirds :full]
for conditioning in [true false]
T_flipped = classical_ising_triangular(sym, ising_βc_triangular)

scheme = c6vCTM_triangular(T_flipped)
lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning)

fs = lz * -1 / ising_βc_triangular
@test fs ≈ f_onsager_triangular rtol = 1.0e-4
end
end
end
end

# CTM_triangular
@testset "CTM_triangular - Ising Model" begin
for sym in [Trivial, Z2Irrep]
for projectors in [:twothirds :full]
for conditioning in [true false]
T_flipped = classical_ising_triangular(sym, ising_βc_triangular)

scheme = CTM_triangular(T_flipped)
lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning)

fs = lz * -1 / ising_βc_triangular
@test fs ≈ f_onsager_triangular rtol = 1.0e-4
end
end
end
end

using StableRNGs
@testset "Honeycomb schemes - Ising Model" begin
for sym in [Trivial, Z2Irrep]
for alg in [:CTM_honeycomb, :c3vCTM_honeycomb]
T_flipped = classical_ising_honeycomb(sym, ising_βc_honeycomb; T = ComplexF64)
scheme = eval(alg)(T_flipped)
lz = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)

fs = lz * -1 / ising_βc_honeycomb
@test fs ≈ f_onsager_honeycomb rtol = 1.0e-2
end
end
end

# Test honeycomb CTM by converting it to CTM on a square lattice
@testset "Honeycomb CTM C3 - Random Model" begin
rng = StableRNG(1234)
for sym in [Trivial, Z2Irrep]
for alg in [:CTM_honeycomb, :c3vCTM_honeycomb]
A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2)
A.data .= rand(rng, length(A.data))
A /= norm(A)

if alg == :c3vCTM_honeycomb
scheme = eval(alg)(A; symmetrize = true)
else
scheme = eval(alg)(A)
end
lz_honeycomb = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)

@tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(A, [1 2 3])[-3 -4 1]
scheme_square = CTM(pf_square)
lz_square = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)

@test lz_square ≈ lz_honeycomb rtol = 1.0e-3
end
end
end

# Test CTM_honeycomb for A ≠ B by converting it to CTM on a square lattice
@testset "Honeycomb CTM - Random Model" begin
rng = StableRNG(1234)
for sym in [Trivial, Z2Irrep]
A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4)
B = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4)
A.data .= rand(rng, length(A.data))
B.data .= rand(rng, length(B.data))
A /= norm(A)
B /= norm(B)

@test_throws ArgumentError c3vCTM_honeycomb(A)
scheme = CTM_honeycomb(A; B)
lz_honeycomb = run!(scheme, truncrank(40), convcrit(-Inf, (steps, data) -> data) & maxiter(500); verbosity = 1)

@tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(B, [1 2 3])[-3 -4 1]
scheme_square = CTM(pf_square)
lz_square = run!(scheme, truncrank(40), convcrit(1.0e-14, (steps, data) -> data) & maxiter(500); verbosity = 1)

@test lz_square ≈ lz_honeycomb rtol = 1.0e-2
end
end

@testset "Rotations for honeycomb lattice" begin
rng = StableRNG(1234)
A_flipped = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2)
A = permute(flip(A_flipped, [1 2]; inv = true), ((), (3, 2, 1)))
A.data .= rand(rng, length(A.data))

@test TNRKit.rotl120_pf_honeycomb(A, 3) ≈ A
@test TNRKit.rotl120_pf_honeycomb(A, 1) ≈ TNRKit.rotl120_pf_honeycomb(A)
@test TNRKit.is_C3_symmetric(TNRKit.symmetrize_C3_honeycomb(A))
end
72 changes: 0 additions & 72 deletions test/schemes_honeycomb.jl

This file was deleted.

33 changes: 0 additions & 33 deletions test/schemes_triangular.jl

This file was deleted.

4 changes: 4 additions & 0 deletions test/spaces.jl → test/spaces/spaces.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
using Test
using TNRKit
using TensorKit

println("--------")
println(" spaces ")
println("--------")
Expand Down
Loading