-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
centralize
finalize!()
and add finalize_two_by_two!()
- Loading branch information
1 parent
f0cfe11
commit e586eed
Showing
8 changed files
with
145 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const simple_scheme = Union{TRG} | ||
const turning_scheme = Union{HOTRG,ATRG} | ||
|
||
# 1x1 unitcell finalize | ||
function finalize!(scheme::simple_scheme) | ||
n = norm(@tensor scheme.T[1 2; 1 2]) | ||
scheme.T /= n | ||
return n | ||
end | ||
|
||
function finalize!(scheme::turning_scheme) | ||
n = norm(@tensor scheme.T[1 2; 1 2]) | ||
scheme.T /= n | ||
|
||
# turn the tensor by 90 degrees | ||
scheme.T = permute(scheme.T, ((2, 3), (4, 1))) | ||
return n | ||
end | ||
|
||
function finalize!(scheme::BTRG) | ||
n = norm(@tensor scheme.T[1 2; 3 4] * scheme.S1[4; 2] * scheme.S2[3; 1]) | ||
scheme.T /= n | ||
return n | ||
end | ||
|
||
# 2x2 unitcell finalize | ||
function finalize_two_by_two!(scheme::simple_scheme) | ||
n = norm(@tensor scheme.T[2 5; 1 7] * scheme.T[1 6; 2 8] * scheme.T[3 8; 4 6] * | ||
scheme.T[4 7; 3 5]) | ||
scheme.T /= (n^(1 / 4)) | ||
return n | ||
end | ||
|
||
function finalize_two_by_two!(scheme::turning_scheme) | ||
n = norm(@tensor scheme.T[2 5; 1 7] * scheme.T[1 6; 2 8] * scheme.T[3 8; 4 6] * | ||
scheme.T[4 7; 3 5]) | ||
scheme.T /= (n^(1 / 4)) | ||
|
||
# turn the tensor by 90 degrees | ||
scheme.T = permute(scheme.T, ((2, 3), (4, 1))) | ||
return n | ||
end | ||
|
||
function finalize_two_by_two!(scheme::BTRG) | ||
n′ = @tensor begin | ||
scheme.T[3 7; 1 11] * | ||
scheme.S2[1; 2] * | ||
scheme.T[2 9; 3 12] * | ||
scheme.S1[10; 9] * | ||
scheme.T[5 12; 6 10] * | ||
scheme.S2[4; 5] * | ||
scheme.T[6 11; 4 8] * | ||
scheme.S1[8; 7] | ||
end | ||
n = norm(n′) | ||
scheme.T /= (n^(1 / 4)) | ||
return n | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
println("---------------------") | ||
println(" two by two finalize ") | ||
println("---------------------") | ||
|
||
# Onsager solution | ||
function onsager_integrand(θ, T) | ||
k = 1 / sinh(2 / T)^(2) | ||
integrand = 1 / (2π) * log(cosh(2 / T)^2 + 1 / k * sqrt(1 + k^2 - 2k * cos(2 * θ))) | ||
return integrand | ||
end | ||
|
||
function onsager_free_energy(β) | ||
return -(quadgk(θ -> onsager_integrand(θ, 1 / β), 0, π)[1] + log(2) / 2) / β | ||
end | ||
|
||
criterion_f(steps::Int, data) = abs(log(data[end]) * 2.0^(1 - steps)) | ||
|
||
T = classical_ising_symmetric(Ising_βc) | ||
fs_onsager = onsager_free_energy(Ising_βc) | ||
|
||
# TRG | ||
@testset "TRG - Ising Model" begin | ||
scheme = TRG(T; finalize=finalize_two_by_two!) | ||
data = run!(scheme, truncdim(24), maxiter(25)) | ||
|
||
lnz = 0 | ||
for (i, d) in enumerate(data) | ||
lnz += log(d) * 2.0^(1 - i) | ||
end | ||
|
||
fs = lnz * -1 / Ising_βc | ||
|
||
relerror = abs((fs - fs_onsager) / fs_onsager) | ||
@test relerror < 2e-6 | ||
end | ||
|
||
# BTRG | ||
@testset "BTRG - Ising Model" begin | ||
scheme = BTRG(T, -0.5; finalize=finalize_two_by_two!) | ||
data = run!(scheme, truncdim(24), maxiter(25)) | ||
|
||
lnz = 0 | ||
for (i, d) in enumerate(data) | ||
lnz += log(d) * 2.0^(1 - i) | ||
end | ||
|
||
fs = lnz * -1 / Ising_βc | ||
|
||
relerror = abs((fs - fs_onsager) / fs_onsager) | ||
@test relerror < 6e-8 | ||
end | ||
|
||
# HOTRG | ||
@testset "HOTRG - Ising Model" begin | ||
scheme = HOTRG(T; finalize=finalize_two_by_two!) | ||
data = run!(scheme, truncdim(16), maxiter(25)) | ||
|
||
lnz = 0 | ||
for (i, d) in enumerate(data) | ||
lnz += log(d) * 2.0^(1 - i) | ||
end | ||
|
||
fs = lnz * -1 / Ising_βc | ||
|
||
relerror = abs((fs - fs_onsager) / fs_onsager) | ||
@test relerror < 6e-7 | ||
end | ||
|
||
# ATRG | ||
@testset "ATRG - Ising Model" begin | ||
scheme = ATRG(T; finalize=finalize_two_by_two!) | ||
data = run!(scheme, truncdim(24), maxiter(25)) | ||
|
||
lnz = 0 | ||
for (i, d) in enumerate(data) | ||
lnz += log(d) * 2.0^(1 - i) | ||
end | ||
|
||
fs = lnz * -1 / Ising_βc | ||
|
||
relerror = abs((fs - fs_onsager) / fs_onsager) | ||
@test relerror < 3e-6 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters