Skip to content

Commit f3dd623

Browse files
committed
add distance to vidal gauge
1 parent 0e637df commit f3dd623

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

src/BPGauge.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export absorb!
1212
export apply_gauge!, gauge!
1313

1414
export square_lattice
15+
export dist_to_vidal
1516

1617
include("utils.jl")
1718

src/gauge.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,26 @@ function apply_gauge!(ansatz::TensorNetworkAnsatz{TA, TB}, s::Int, d::Int, M_sd:
8484
einsum!(eincode_d.ixs, eincode_d.iy, d_xs, ansatz.site_tensors[d], 1, 0, sdd)
8585

8686
nothing
87+
end
88+
89+
# check the distance from a gauged state to the vidal gauge
90+
function dist_to_vidal(tn::TensorNetworkAnsatz, bp_path::BPPath)
91+
Ts = tn.site_tensors
92+
Tcs = conj.(Ts)
93+
94+
err = 0.0
95+
for step in bp_path.bp_steps
96+
eincode = step.eincode
97+
Tid = step.Tid
98+
inputs = step.inputs
99+
output = step.output
100+
101+
T = Ts[Tid]
102+
Tc = Tcs[Tid]
103+
Λs2 = [tn.gauge_tensors[tn.gauge_tensors_map[(min(i, j), max(i, j))]] for (i, j) in inputs].^2
104+
105+
output_tensor = eincode(T, Tc, Λs2...)
106+
err = max(err, maximum(abs.(output_tensor - output_tensor[1, 1] * I(size(output_tensor, 1)))))
107+
end
108+
return err
87109
end

test/gauge.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,21 @@ end
104104
gauge!(tn, bp_state)
105105
@test inner_product(tn, adjoint(tn)) 1.0
106106

107-
for i in 1:nv(g) - 2
108-
j = i == nv(g) ? 1 : i + 1
109-
G = tn.gauge_tensors[tn.gauge_tensors_map[(min(i, j), max(i, j))]]
110-
T = tn.site_tensors[j]
111-
L = ein"ij, jk, jln, kmn -> lm"(G, G, T, conj(T))
112-
@test maximum(abs.(L ./ L[1, 1] - I(size(L, 1)))) < 2 * 1e-6
113-
end
107+
@test dist_to_vidal(tn, bp_path) < 1e-5
108+
end
109+
110+
@testset "rr3 graph gauge" begin
111+
g = random_regular_graph(20, 3)
112+
tn = random_state(g, d_virtual = 4)
113+
normalize_state!(tn)
114+
@test inner_product(tn, adjoint(tn)) 1.0
115+
116+
bp_state = BPState(tn)
117+
bp_path = BPPath(tn)
118+
bp!(bp_state, bp_path, tn, atol = 1e-8)
119+
120+
gauge!(tn, bp_state)
121+
@test inner_product(tn, adjoint(tn)) 1.0
122+
123+
@test dist_to_vidal(tn, bp_path) < 1e-5
114124
end

0 commit comments

Comments
 (0)