Skip to content

Commit a4e6fd3

Browse files
committed
test: fix some testing
1 parent 4bff986 commit a4e6fd3

File tree

4 files changed

+85
-51
lines changed

4 files changed

+85
-51
lines changed

test/classicalmodels.jl

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function classicalisingmpo(β; J=1.0, h=0.0)
3030
return statmechmpo(β, (s1, s2) -> -J * (-1)^(s1 != s2) - h / 2 * (s1 == 1 + s2 == 1), 2)
3131
end
3232

33-
3433
function exactZ(β)
3534
function quad_midpoint(f, a, b, N)
3635
h = (b - a) / N
@@ -80,8 +79,8 @@ end
8079
@testset "Using $(typeof(alg)) with χ = $(alg.bonddim)" for (alg, tol) in zip(
8180
algs, (1e-3, 1e-6, 1e-9, 1e-3, 1e-6, 1e-9)
8281
)
83-
rt = @constinferred(initialize(alg, zbulk))
84-
st = @constinferred(newproblem(alg, zbulk, rt))
82+
rt = @constinferred(initialize(zbulk, alg))
83+
st = @constinferred(newcontraction(zbulk, rt; alg=alg))
8584

8685
runcontraction!(st)
8786

@@ -101,8 +100,8 @@ end
101100
@testset "Using $(typeof(alg)) with χ = $(alg.trunc.dim)" for (alg, tol) in zip(
102101
trgalgs, (1e-2, 1e-3, 1e-4)
103102
)
104-
rt = @constinferred(initialize(alg, zbulk))
105-
st = @constinferred(newproblem(alg, zbulk, rt))
103+
rt = @constinferred(initialize(zbulk, alg))
104+
st = @constinferred(newcontraction(zbulk, rt; alg=alg))
106105

107106
runcontraction!(st)
108107

@@ -111,58 +110,59 @@ end
111110
@test abs(z_val[1, 1]) z_exact atol = tol
112111
end
113112
end
114-
115-
@testset "Interacting dimers" verbose = true begin
116-
β = 1 / 0.85
117-
118-
a = zeros(4, 4, 4, 4)
119-
b = zeros(4, 4, 4, 4)
120-
121-
for I in CartesianIndices(a)
122-
if I[1] == mod(I[2] + 1, 1:4) == mod(I[3] + 2, 1:4) == mod(I[4] + 3, 1:4)
123-
a[I] = 1
113+
#=
114+
@testset "Interacting dimers" verbose = true begin
115+
β = 1 / 0.85
116+
117+
a = zeros(4, 4, 4, 4)
118+
b = zeros(4, 4, 4, 4)
119+
120+
for I in CartesianIndices(a)
121+
if I[1] == mod(I[2] + 1, 1:4) == mod(I[3] + 2, 1:4) == mod(I[4] + 3, 1:4)
122+
a[I] = 1
123+
end
124+
if I[1] == mod(I[2] - 1, 1:4) == mod(I[3] - 2, 1:4) == mod(I[4] - 3, 1:4)
125+
b[I] = 1
126+
end
124127
end
125-
if I[1] == mod(I[2] - 1, 1:4) == mod(I[3] - 2, 1:4) == mod(I[4] - 3, 1:4)
126-
b[I] = 1
127-
end
128-
end
129128
130-
q = sqrt([1 0 0 0; 0 exp/ 2) 1 1; 0 1 1 1; 0 1 1 exp/ 2)])
129+
q = sqrt([1 0 0 0; 0 exp(β / 2) 1 1; 0 1 1 1; 0 1 1 exp(β / 2)])
131130
132-
qh = diagm([1, -1, 1, -1]) * q
133-
qv = diagm([-1, 1, -1, 1]) * q
131+
qh = diagm([1, -1, 1, -1]) * q
132+
qv = diagm([-1, 1, -1, 1]) * q
134133
135-
@tensoropt aa[ii, jj, kk, ll] :=
136-
a[i, j, k, l] * q[i, ii] * q[j, jj] * q[k, kk] * q[l, ll]
137-
@tensoropt bb[ii, jj, kk, ll] :=
138-
b[i, j, k, l] * q[i, ii] * q[j, jj] * q[k, kk] * q[l, ll]
134+
@tensoropt aa[ii, jj, kk, ll] :=
135+
a[i, j, k, l] * q[i, ii] * q[j, jj] * q[k, kk] * q[l, ll]
136+
@tensoropt bb[ii, jj, kk, ll] :=
137+
b[i, j, k, l] * q[i, ii] * q[j, jj] * q[k, kk] * q[l, ll]
139138
140-
δa = zeros(4, 4)
141-
δa[1, 1] = δa[3, 3] = 1
142-
δa[2, 2] = δa[4, 4] = -1
139+
δa = zeros(4, 4)
140+
δa[1, 1] = δa[3, 3] = 1
141+
δa[2, 2] = δa[4, 4] = -1
143142
144-
@tensoropt aad[i, j, k, l] := a[ii, j, k, l] * δa[i, ii]
145-
@tensoropt bbd[i, j, k, l] := b[ii, j, k, l] * δa[i, ii]
143+
@tensoropt aad[i, j, k, l] := a[ii, j, k, l] * δa[i, ii]
144+
@tensoropt bbd[i, j, k, l] := b[ii, j, k, l] * δa[i, ii]
146145
147-
s =^4
146+
s = ℂ^4
148147
149-
A = TensorMap(aa, one(s), s * s * s' * s')
150-
B = TensorMap(bb, one(s), s * s * s' * s')
148+
A = TensorMap(aa, one(s), s * s * s' * s')
149+
B = TensorMap(bb, one(s), s * s * s' * s')
151150
152-
AD = TensorMap(aad, one(s), s * s * s' * s')
153-
BD = TensorMap(bbd, one(s), s * s * s' * s')
151+
AD = TensorMap(aad, one(s), s * s * s' * s')
152+
BD = TensorMap(bbd, one(s), s * s * s' * s')
154153
155-
alg = VUMPS(; bonddim=5, maxiter=1000)
154+
alg = VUMPS(; bonddim=5, maxiter=1000)
156155
157-
bulk = UnitCell(([A B; B A]))
158-
dbulk = UnitCell(([AD BD; BD AD]))
156+
bulk = UnitCell(([A B; B A]))
157+
dbulk = UnitCell(([AD BD; BD AD]))
159158
160-
st = initialize(bulk, alg)
161-
dst = initialize(dbulk, alg)
159+
st = initialize(bulk, alg)
160+
dst = initialize(dbulk, alg)
162161
163-
sto = calculate(st)
164-
contract(sto.tensors, dbulk) ./ contract(sto.tensors, bulk)
165-
end
162+
sto = calculate(st)
163+
contract(sto.tensors, dbulk) ./ contract(sto.tensors, bulk)
164+
end
165+
=#
166166
end
167167

168168
#=

test/misc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
p2 = TensorMap(rand, ComplexF64, d, dom)
1515
p3 = TensorMap(rand, ComplexF64, d * d', dom)
1616

17-
tp = TensorPair(p3, p3)
17+
tp = CompositeTensor(p3, p3')
1818

1919
test_t = (p1, p2, p3)
2020

@@ -55,7 +55,7 @@
5555
t = TensorMap(rand, ComplexF64, one(d), dom)
5656
p = TensorMap(rand, ComplexF64, cod, dom)
5757

58-
tp = TensorPair(p, p)
58+
tp = CompositeTensor(p, p')
5959

6060
up = UnitCell([p p; p p])
6161
ut = UnitCell([t t; t t])

test/networks.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@testset verbose = true begin
2+
e =^2
3+
s =^3
4+
w =^4
5+
n =^5
6+
7+
p =^6
8+
9+
t = TensorMap(rand, p * p', e * s * w' * n')
10+
11+
@test virtualspace(t) == domain(t)
12+
13+
@test swapaxes(t) == permute(t, (4, 3, 6, 5))
14+
@test invertaxes(t) == permutedom(t, (5, 6, 3, 4))
15+
16+
ct2 = CompositeTensor(t, t')
17+
18+
@test ct[1] == ct[2]'
19+
@test @constinferred(first(ct)) === parent(@constinferred(last(ct)))
20+
21+
@test @constinferred(copy(ct)) == ct
22+
@test !(copy(ct) === ct)
23+
24+
@test virtualspace(ct, 1) == e * e'
25+
@test virtualspace(ct, 2) == s * s'
26+
@test virtualspace(ct, 3) == w' * n
27+
@test virtualspace(ct, 4) == n' * n
28+
end

test/runtests.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ using TensorKit
66
using LinearAlgebra
77

88
@testset "All tests" verbose = true begin
9-
include("unitcell.jl")
10-
include("misc.jl")
11-
include("vumps.jl")
12-
include("ctmrg.jl")
13-
include("classicalmodels.jl")
9+
if isempty(ARGS)
10+
include("unitcell.jl")
11+
include("misc.jl")
12+
include("vumps.jl")
13+
include("ctmrg.jl")
14+
include("classicalmodels.jl")
15+
else
16+
for file in ARGS
17+
include(file)
18+
end
19+
end
1420
end

0 commit comments

Comments
 (0)