-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ITensor/v3' into v3
- Loading branch information
Showing
8 changed files
with
246 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "src/ctmrg.h" | ||
#include "src/ising.h" | ||
#include "itensor/util/print_macro.h" | ||
|
||
int | ||
main() | ||
{ | ||
Real betac = 0.5 * log(sqrt(2) + 1.0); | ||
Real beta = 1.1 * betac; | ||
int maxdim = 20; | ||
int nsteps = 20; | ||
|
||
auto dim0 = 2; | ||
|
||
// Define an initial Index making up | ||
// the Ising partition function | ||
auto s = Index(dim0, "Site"); | ||
|
||
// Define the indices of the scale-0 | ||
// Boltzmann weight tensor "A" | ||
auto sh = addTags(s, "horiz"); | ||
auto sv = addTags(s, "vert"); | ||
|
||
auto T = ising(sh, sv, beta); | ||
|
||
auto l = Index(1, "Link"); | ||
auto lh = addTags(l, "horiz"); | ||
auto lv = addTags(l, "vert"); | ||
auto Clu0 = ITensor(lv, lh); | ||
Clu0.set(1, 1, 1.0); | ||
auto Al0 = ITensor(lv, prime(lv), sh); | ||
Al0.set(lv = 1, prime(lv) = 1, sh = 1, 1.0); | ||
|
||
auto [Clu, Al] = ctmrg(T, Clu0, Al0, maxdim, nsteps); | ||
|
||
lv = commonIndex(Clu, Al); | ||
lh = uniqueIndex(Clu, Al); | ||
|
||
auto Au = replaceInds(Al, {lv, prime(lv), sh}, | ||
{lh, prime(lh), sv}); | ||
|
||
auto ACl = Al * Clu * dag(prime(Clu)); | ||
|
||
auto ACTl = prime(ACl * dag(prime(Au)) * T * Au, -1); | ||
auto kappa = elt(ACTl * dag(ACl)); | ||
|
||
auto Tsz = ising(sh, sv, beta, true); | ||
auto ACTszl = prime(ACl * dag(prime(Au)) * Tsz * Au, -1); | ||
auto m = elt(ACTszl * dag(ACl)) / kappa; | ||
|
||
printfln("beta = %.12f", beta); | ||
printfln("beta/betac = %.12f", beta / betac); | ||
println("maxdim = ", maxdim); | ||
println("niters = ", nsteps); | ||
printfln("kappa = %.12f", kappa); | ||
printfln("m = %.12f", m); | ||
|
||
return 0; | ||
} | ||
|
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,60 @@ | ||
#include "itensor/all.h" | ||
|
||
using namespace itensor; | ||
|
||
std::tuple<ITensor, ITensor> | ||
ctmrg(ITensor T, | ||
ITensor Clu, | ||
ITensor Al, | ||
int maxdim, | ||
int nsteps, | ||
Real cutoff = 0.0) | ||
{ | ||
auto sh = commonIndex(T, Al); | ||
auto sv = uniqueIndex(T, {Al, prime(Al)}, "0"); | ||
auto lv = commonIndex(Clu, Al); | ||
auto lh = uniqueIndex(Clu, Al); | ||
auto Au = replaceInds(Al, {lv, prime(lv), sh}, | ||
{lh, prime(lh), sv}); | ||
ITensor Uv; | ||
for(auto i : range1(nsteps)) | ||
{ | ||
// Get the grown corner transfer matrix (CTM) | ||
auto Clu_new = Al * Clu * Au * T; | ||
|
||
Clu_new.noPrime(); | ||
Clu_new.replaceInds({lh, sh}, {prime(lv), prime(sv)}); | ||
|
||
// Diagonalize the grown CTM | ||
std::tie(Uv, Clu) = diagPosSemiDef(Clu_new, | ||
{"MaxDim = ", maxdim, | ||
"Tags = ", tags(lv), | ||
"Cutoff = ", cutoff}); | ||
|
||
lv = commonIndex(Clu, Uv); | ||
lh = setTags(lv, tags(lh)); | ||
|
||
Clu = toDense(Clu); | ||
Clu.replaceInds({prime(lv)}, {lh}); | ||
|
||
// The renormalized CTM is the diagonal matrix of eigenvalues | ||
// Normalize the CTM | ||
auto Cl = Clu * prime(dag(Clu), lh); | ||
auto normC = pow(elt(Cl * dag(Cl)), 0.25); | ||
Clu /= normC; | ||
|
||
// Calculate the renormalized half row transfer matrix (HRTM) | ||
Uv.noPrime(); | ||
Al = Al * Uv * T * dag(prime(Uv)); | ||
Al = replaceInds(Al, {prime(sh)}, {sh}); | ||
|
||
// Normalize the HRTM | ||
auto ACl = Al * Clu * prime(dag(Clu)); | ||
auto normA = sqrt(elt(ACl * dag(ACl))); | ||
Al /= normA; | ||
Au = replaceInds(Al, {lv, prime(lv), sh}, | ||
{lh, prime(lh), sv}); | ||
} | ||
return std::tuple<ITensor, ITensor>({Clu, Al}); | ||
} | ||
|
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