-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:quantumghent/PEPSKit.jl into pb-f…
…ull-inf-proj
- Loading branch information
Showing
24 changed files
with
926 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Test | ||
using Random | ||
using PEPSKit | ||
using TensorKit | ||
|
||
# random initialization of 2x2 iPEPS with weights and CTMRGEnv (using real numbers) | ||
Dcut, symm = 8, Trivial | ||
N1, N2 = 2, 2 | ||
Random.seed!(10) | ||
if symm == Trivial | ||
Pspace = Vect[fℤ₂](0 => 2, 1 => 2) | ||
Vspace = Vect[fℤ₂](0 => Dcut / 2, 1 => Dcut / 2) | ||
else | ||
error("Not implemented") | ||
end | ||
peps = InfiniteWeightPEPS(rand, Float64, Pspace, Vspace; unitcell=(N1, N2)) | ||
|
||
# normalize vertex tensors | ||
for ind in CartesianIndices(peps.vertices) | ||
peps.vertices[ind] /= norm(peps.vertices[ind], Inf) | ||
end | ||
|
||
# Hubbard model Hamiltonian at half-filling | ||
t, U = 1, 6 | ||
ham = hubbard_model(Float64, Trivial, Trivial, InfiniteSquare(N1, N2); t, U, mu=U / 2) | ||
|
||
# simple update | ||
dts = [1e-2, 1e-3, 4e-4, 1e-4] | ||
tols = [1e-6, 1e-8, 1e-8, 1e-8] | ||
maxiter = 10000 | ||
for (n, (dt, tol)) in enumerate(zip(dts, tols)) | ||
trscheme = truncerr(1e-10) & truncdim(Dcut) | ||
alg = SimpleUpdate(dt, tol, maxiter, trscheme) | ||
peps, = simpleupdate(peps, ham, alg; bipartite=false) | ||
end | ||
|
||
# absorb weight into site tensors | ||
peps = InfinitePEPS(peps) | ||
|
||
# CTMRG | ||
χenv0, χenv = 6, 20 | ||
Espace = Vect[fℤ₂](0 => χenv0 / 2, 1 => χenv0 / 2) | ||
envs = CTMRGEnv(randn, Float64, peps, Espace) | ||
for χ in [χenv0, χenv] | ||
ctm_alg = SequentialCTMRG(; maxiter=300, tol=1e-7) | ||
envs = leading_boundary(envs, peps, ctm_alg) | ||
end | ||
|
||
# Benchmark values of the ground state energy from | ||
# Qin, M., Shi, H., & Zhang, S. (2016). Benchmark study of the two-dimensional Hubbard | ||
# model with auxiliary-field quantum Monte Carlo method. Physical Review B, 94(8), 085103. | ||
Es_exact = Dict(0 => -1.62, 2 => -0.176, 4 => 0.8603, 6 => -0.6567, 8 => -0.5243) | ||
E_exact = Es_exact[U] - U / 2 | ||
|
||
# measure energy | ||
E = costfun(peps, envs, ham) / (N1 * N2) | ||
@info "Energy = $E" | ||
@info "Benchmark energy = $E_exact" | ||
@test isapprox(E, E_exact; atol=5e-2) |
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,52 @@ | ||
""" | ||
get_gate(dt::Float64, H::LocalOperator) | ||
Compute `exp(-dt * H)` from the nearest neighbor Hamiltonian `H`. | ||
""" | ||
function get_gate(dt::Float64, H::LocalOperator) | ||
@assert all([ | ||
length(op.dom) == 2 && norm(Tuple(terms[2] - terms[1])) == 1.0 for | ||
(terms, op) in H.terms | ||
]) "Only nearest-neighbour terms allowed" | ||
return LocalOperator( | ||
H.lattice, Tuple(sites => exp(-dt * op) for (sites, op) in H.terms)... | ||
) | ||
end | ||
|
||
""" | ||
is_equivalent(bond1::NTuple{2,CartesianIndex{2}}, bond2::NTuple{2,CartesianIndex{2}}, (Nrow, Ncol)::NTuple{2,Int}) | ||
Check if two 2-site bonds are related by a (periodic) lattice translation. | ||
""" | ||
function is_equivalent( | ||
bond1::NTuple{2,CartesianIndex{2}}, | ||
bond2::NTuple{2,CartesianIndex{2}}, | ||
(Nrow, Ncol)::NTuple{2,Int}, | ||
) | ||
r1 = bond1[1] - bond1[2] | ||
r2 = bond2[1] - bond2[2] | ||
shift_row = bond1[1][1] - bond2[1][1] | ||
shift_col = bond1[1][2] - bond2[1][2] | ||
return r1 == r2 && mod(shift_row, Nrow) == 0 && mod(shift_col, Ncol) == 0 | ||
end | ||
|
||
""" | ||
get_gateterm(gate::LocalOperator, bond::NTuple{2,CartesianIndex{2}}) | ||
Get the term of a 2-site gate acting on a certain bond. | ||
Input `gate` should only include one term for each nearest neighbor bond. | ||
""" | ||
function get_gateterm(gate::LocalOperator, bond::NTuple{2,CartesianIndex{2}}) | ||
label = findall(p -> is_equivalent(p.first, bond, size(gate.lattice)), gate.terms) | ||
if length(label) == 0 | ||
# try reversed site order | ||
label = findall( | ||
p -> is_equivalent(p.first, reverse(bond), size(gate.lattice)), gate.terms | ||
) | ||
@assert length(label) == 1 | ||
return permute(gate.terms[label[1]].second, ((2, 1), (4, 3))) | ||
else | ||
@assert length(label) == 1 | ||
return gate.terms[label[1]].second | ||
end | ||
end |
Oops, something went wrong.