ITensor Support Q&A - Recent questions
http://itensor.org/support/questions
Powered by Question2AnswerExponential of MPO
http://itensor.org/support/3928/exponential-of-mpo
<p>Hi,</p>
<p>So I've been trying to use this function: expHermitian(ITensor H, Cplx tau = 1)<br>
but the operator that I want to exponentiate is the total Sz. Here is the code that I have so far:</p>
<p><code>auto ampo2 = AutoMPO(sites);
for(auto k : range1(Nspins))
{
ampo2 += "Sz",k;
}
auto proj = toMPO(ampo2);
auto exp2H = expHermitian(proj,2);</code></p>
<p>but I get an error that the function expects an ITensor object as the first argument (as expected). Is it possible to somehow do what I am trying to do?</p>
<p>Thank you.</p>
http://itensor.org/support/3928/exponential-of-mpoFri, 23 Sep 2022 16:22:44 +0000Adding a field to Hamiltonian to form gates
http://itensor.org/support/3926/adding-a-field-to-hamiltonian-to-form-gates
<p>I would like to perform TEBD with the Hamiltonian,<br>
$$<br>
H=\sum^{N-1}<em>{i} (XX + YY) + \sum</em>{i=1}^{N} V(i)Z<br>
$$<br>
Where V(i) is just some function that depends on the site. I want this written as a gate but when I compare numerics to small system size ED they do not match. Here is the code for creating my gates. Help is much appreciated</p>
<pre><code>function Gates(N::Int, dt::Float64, J, λ, q, phi, sindex)
gates = ITensor[]
for j=1:N-1
s1 = sindex[j]
s2 = sindex[j+1]
if j != (N-1)
Wj = 2*λ*cos(2*pi*q*j + phi)
hj = J[j]*0.5*(op("S+", s1)*op("S-", s2) + op("S-", s1)*op("S+", s2)) + Wj*op("Sz", s1)*op("Id", s2)
Gj = exp(-1.0im*0.5*dt*hj)
elseif j==(N-1)
WjN = 2*λ*cos(2*pi*q*N + phi)
Wj = 2*λ*cos(2*pi*q*j + phi)
hj = J[j]*0.5*(op("S+", s1)*op("S-", s2) + op("S-", s1)*op("S+", s2)) + WjN*op("Id", s1)*op("Sz", s2) + Wj*op("Sz", s1)*op("Id", s2)
Gj = exp(-1.0im*0.5*dt*hj)
end
push!(gates, Gj)
end
append!(gates, reverse(gates))
</code></pre>
<p>end</p>
http://itensor.org/support/3926/adding-a-field-to-hamiltonian-to-form-gatesWed, 24 Aug 2022 19:36:54 +0000"No space left on device" error when using write_to_disk feature in Itensor Julia
http://itensor.org/support/3923/space-device-error-using-write_to_disk-feature-itensor-julia
<p>Hi there,</p>
<p>I'm using write<em>when</em>maxdim_exceeds keyword in dmrg to implement writing to disk, but I met the error message shown below. It says that there is not space left on the disk, but I checked that there is enough space in the directory (there is 2TB available space and the tensors are expected to occupy around 400GB). Can anyone help?</p>
<p><strong>DMRG Command:</strong><br>
energy,psi = dmrg(H,psi,sweeps; write<em>when</em>maxdim_exceeds=10000)</p>
<p><strong>Space of the Directory</strong><br>
Filesystem 1K-blocks Used Available Use% Mounted on<br>
/dev/md2 15625699328 13595822844 2029876484 88% /scratch</p>
<p><strong>Error Message:</strong><br>
ERROR: LoadError: SystemError: close: No space left on device<br>
Stacktrace:<br>
[1] systemerror(p::String, errno::Int32; extrainfo::Nothing)<br>
@ Base ./error.jl:174<br>
[2] #systemerror#68<br>
@ ./error.jl:173 [inlined]<br>
[3] systemerror<br>
@ ./error.jl:173 [inlined]<br>
[4] close<br>
@ ./iostream.jl:63 [inlined]<br>
[5] open(::Serialization.var"#1#2"{ITensor}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})<br>
@ Base ./io.jl:332<br>
[6] open<br>
@ ./io.jl:328 [inlined]<br>
[7] serialize<br>
@ ~/julia-1.7.2/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:775 [inlined]<br>
[8] setindex!<br>
@ ~/.julia/packages/SerializedElementArrays/cdFxy/src/SerializedElementArrays.jl:78 [inlined]<br>
[9] <em>makeL!(P::ITensors.DiskProjMPO, psi::MPS, k::Int64)<br>
@ ITensors ~/.julia/dev/ITensors/src/mps/abstractprojmpo.jl:164<br>
[10] makeL!<br>
@ ~/.julia/dev/ITensors/src/mps/diskprojmpo.jl:103 [inlined]<br>
[11] position!<br>
@ ~/.julia/dev/ITensors/src/mps/abstractprojmpo.jl:219 [inlined]<br>
[12] macro expansion<br>
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:206 [inlined]<br>
[13] macro expansion<br>
@ ~/.julia/packages/TimerOutputs/LDL7n/src/TimerOutput.jl:252 [inlined]<br>
[14] macro expansion<br>
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:205 [inlined]<br>
[15] macro expansion<br>
@ ./timing.jl:299 [inlined]<br>
[16] dmrg(PH::ProjMPO, psi0::MPS, sweeps::Sweeps; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:write</em>when<em>maxdim</em>exceeds,), Tuple{Int64}}})<br>
@ ITensors ~/.julia/dev/ITensors/src/mps/dmrg.jl:186<br>
[17] #dmrg#958<br>
@ ~/.julia/dev/ITensors/src/mps/dmrg.jl:47 [inlined]</p>
http://itensor.org/support/3923/space-device-error-using-write_to_disk-feature-itensor-juliaThu, 28 Jul 2022 06:37:29 +0000about MixedSiteSet for electron and spin
http://itensor.org/support/3922/about-mixedsiteset-for-electron-and-spin
<p>Dear there,<br>
I want to use dmrg to solve a Hamiltonian which has couplied spin 1/2 operator and electron operator on same site. <br>
For example: H= a \sum{n} {Sx(n)C^dag<em>up(n)C</em>up(n)} + b\sum{n} {Sz(n)}.</p>
<p>After some searching, I found I need use MixedSiteSet. But so far, I only find a previous example for a Holstein-type new site set , which is: <br>
using Holstein = MixedSiteSet(ElectronSite,BosonSite);</p>
<p>And I saw in that answer, it mentions "the odd numbered sites will be electron sites and the even numbered sites will be boson sites". But in my case, I need electron and spin on same site. I'm not sure if this kind of MixedSiteSet already exits in Itensor or how could I construct this?</p>
<p>Thank you so much!!</p>
http://itensor.org/support/3922/about-mixedsiteset-for-electron-and-spinWed, 27 Jul 2022 23:59:53 +0000Coupling a spin to heat bath
http://itensor.org/support/3920/coupling-a-spin-to-heat-bath
<p>Hey, can someone help me in how to write an initial state of heat but coupled to a spin ? can I just treat this as a spin chain and couple in the N+1 site a spin ? or should I do otherwise ?</p>
http://itensor.org/support/3920/coupling-a-spin-to-heat-bathTue, 24 May 2022 06:35:58 +0000New Forum Launched!
http://itensor.org/support/3913/new-forum-launched
<p>We are happy to announce a brand new ITensor Support Forum based on the Discourse software. Please post all new questions there. The new address is:</p>
<p><a rel="nofollow" href="https://itensor.discourse.group">https://itensor.discourse.group</a> </p>
<p>You should be able to register a new account there yourself, but if you have any difficulties feel free to email support@itensor.org for help. </p>
<p>We will definitely leave this page up so that you can search through previous questions, but we request that you please post any future questions at the new forum.</p>
http://itensor.org/support/3913/new-forum-launchedThu, 14 Apr 2022 21:48:08 +0000how to measure correlator of two point with 4 operators in two component bose-hubbard model(c++)
http://itensor.org/support/3898/measure-correlator-point-operators-component-hubbard-model
<p>Dear ITensor users</p>
<p>I have tried to obtain two correlation functions in a two component bose-hubbard model. But I got nothing about correlation function in my output files and the output file reported errors as the following:</p>
<pre><code>Mismatched QN Index from set 1 (dim=6|id=345|"n=32,Site,Boson")' <Out>
1: 1 QN({"Nb",0})
2: 1 QN({"Nb",1})
3: 1 QN({"Nb",2})
4: 1 QN({"Nb",3})
5: 1 QN({"Nb",4})
6: 1 QN({"Nb",5})
Mismatched QN Index from set 2 (dim=6|id=345|"n=32,Site,Boson")' <Out>
1: 1 QN({"Nb",0})
2: 1 QN({"Nb",1})
3: 1 QN({"Nb",2})
4: 1 QN({"Nb",3})
5: 1 QN({"Nb",4})
6: 1 QN({"Nb",5})
Mismatched QN Index arrows
From line 912, file itensor.cc
</code></pre>
<p>You can obtain the Hamiltonian of two component bose-hubbard model from equation (1) in this paper: <a rel="nofollow" href="https://doi.org/10.1103/PhysRevA.80.023619">https://doi.org/10.1103/PhysRevA.80.023619</a><br>
Or you can see it in the question posted before in the community：<a rel="nofollow" href="http://itensor.org/support/2973/two-component-bose-hubbard-model?show=2973#q2973">http://itensor.org/support/2973/two-component-bose-hubbard-model?show=2973#q2973</a></p>
<p>I want to measure two different correlation functions of two point with 4 operators as the followings.<br>
1. $$\braket{\hat{a}^{\dagger }<em>i\hat{b}^{\dagger}</em>i\hat{a}<em>j\hat{b}</em>j }$$<br>
2. $$\braket{\hat{a}^{\dagger }<em>i\hat{b}</em>i\hat{a}<em>j\hat{b}^{\dagger }</em>j }$$<br>
They were also presented in the paper I mentioned above.(equation (13) (14)) </p>
<p>In my codes, I made a copy of boson.h and called it a<em>boson.h, and I renamed all operators in a</em>boson.h as "Aa", "Aadag", "Na". Also, I rename its class as "ABosonSite".</p>
<p><strong>Here is my codes for groundstate</strong></p>
<pre><code>float t=atof(argv[1]);
float U_12=atof(argv[2]);
int L = atof(argv[3]);
int max = atof(argv[4]);
using twocom=MixedSiteSet<ABosonSite,BosonSite>;
autosites=twocom(L,{"ConserveQNs",true,"ConserveQNs",true,
"ConserveNb",true,"ConserveNb",true,"MaxOcc=",max});
auto sweeps = Sweeps(8);
sweeps.maxdim() = 100,200,400,400,800,800,1000,1000;
sweeps.cutoff() = 1E-12;
float U = 1;
float t_1=t;
float t_2=t;
auto ampo = AutoMPO(sites);
for (int i = 1;i <= L-3; i += 2)
{
ampo += -U/2, "Na", i;
ampo += U/2, "Na", i,"Na",i;
ampo += -t_1, "Aa", i, "Aadag", i + 2;
ampo += -t_1, "Aadag", i, "Aa", i + 2;
}
ampo += -U/2, "Na", L-1;
ampo += U/2, "Na", L-1,"Na",L-1;
for (int i = 2;i <= L-2; i += 2)
{
ampo += -U/2, "N", i;
ampo += U/2, "N", i,"N",i;
ampo += -t_2, "A", i, "Adag", i + 2;
ampo += -t_2, "Adag", i, "A", i + 2;
}
ampo += -U/2, "N", L;
ampo += U/2, "N", L,"N",L;
for (int i = 1;i < L; i += 2)
{
ampo +=U_12, "Na", i,'N',i+1;
ampo += V, "N", i, "N", i + 1;
}
auto H = toMPO(ampo);
auto state = InitState(sites);
for (int i = 1; i <= L; i += 4)
{
state.set(i,"1");
}
for (int i = 4; i <= L; i += 4)
{
state.set(i,"1");
}
PrintData(sweeps);
auto psi0 = randomMPS(state);
auto [energy, psi] = dmrg(H, psi0, sweeps, {"Quiet=",true})
</code></pre>
<p><strong>And here is my codes for one of two correlation functions</strong>.(sorry for my long codes)<br>
To minimize the effect of boundary condition, I place i and j symmetrically around the center.</p>
<pre><code>int j_p;
j_p=L/2-1;
int i_p;
i_p=L/2-1;
for (auto r : range1(1,L))
{
auto corf_op1=op(sites,"Aadag",i_p);
auto corf_op2=op(sites,"Adag",i_p+1);
auto corf_op3=op(sites,"Aa",j_p);
auto corf_op4=op(sites,"A",j_p+1);
if (r%2==1)
{
j_p=j_p+2;
psi.position(j_p+1);
ITensor C=psi(j_p+1);
C *= corf_op4;
double corf=0;
if (r==1)
{
auto il = commonIndex(psi(j_p+1),psi(j_p),"Link");
C *=dag(prime(prime(psi(j_p+1),"Site"),il));
C *=psi(j_p);
C *=corf_op3;
auto ill = commonIndex(psi(j_p),psi(i_p+1),"Link");
C *=dag(prime(prime(psi(j_p),"Site"),ill));
C *=psi(i_p+1);
C *=corf_op2;
auto illl = commonIndex(psi(i_p+1),psi(i_p),"Link");
C *=dag(prime(prime(psi(i_p+1),"Site"),illl));
C *=psi(i_p);
C *=corf_op1;
auto ir =commonIndex(psi(i_p),psi(i_p+1),"Link");
C *=dag(prime(prime(psi(i_p),"Site"),ir));
corf=elt(C);
}
if (r>=2)
{
auto il = commonIndex(psi(j_p+1),psi(j_p),"Link");
C *=dag(prime(prime(psi(j_p+1),"Site"),il));
C *=psi(j_p);
C *=corf_op3;
auto ill = commonIndex(psi(j_p),psi(j_p-1),"Link");
C *=dag(prime(prime(psi(j_p),"Site"),ill));
for(int k=1;k<(j_p-i_p-1);k++)
{
C *= psi(j_p-k);
C *= dag(prime(psi(j_p-k),"Link"));
}
C *=psi(i_p+1);
C *=corf_op2;
auto illl = commonIndex(psi(i_p+1),psi(i_p),"Link");
C *=dag(prime(prime(psi(i_p+1),"Site"),illl));
C *=psi(i_p);
C *=corf_op1;
auto ir =commonIndex(psi(i_p),psi(i_p+1),"Link");
C *=dag(prime(prime(psi(i_p),"Site"),ir));
corf=elt(C);
}
fprintf(fp2,"%i,%i,%i,%f\n",r,i_p,j_p,corf);
}
else
{
i_p=i_p-2;
psi.position(j_p+1);
ITensor C=psi(j_p+1);
C *= corf_op4;
double corf=0;
auto il = commonIndex(psi(j_p+1),psi(j_p),"Link");
C *=dag(prime(prime(psi(j_p+1),"Site"),il));
C *=psi(j_p);
C *=corf_op3;
auto ill = commonIndex(psi(j_p),psi(j_p-1),"Link");
C *=dag(prime(prime(psi(j_p),"Site"),ill));
for(int k=1;k<(j_p-i_p-1);k++)
{
C *= psi(j_p-k);
C *= dag(prime(psi(j_p-k),"Link"));
}
C *=psi(i_p+1);
C *=corf_op2;
auto illl = commonIndex(psi(i_p+1),psi(i_p),"Link");
C *=dag(prime(prime(psi(i_p+1),"Site"),illl));
C *=psi(i_p);
C *=corf_op1;
auto ir =commonIndex(psi(i_p),psi(i_p+1),"Link");
C *=dag(prime(prime(psi(i_p),"Site"),ir));
corf=elt(C);
fprintf(fp2,"%i,%i,%i,%f\n",r,i_p,j_p,corf);
}
}
</code></pre>
<p>Another correlation function is the same thing but with different operators.<br>
After calculation, I got energies and density distributions but without correlation functions.<br>
Are there some mistakes I make in my codes? </p>
<p>Looking forward to your response and suggestions.<br>
Thank you very much!</p>
http://itensor.org/support/3898/measure-correlator-point-operators-component-hubbard-modelTue, 12 Apr 2022 08:42:27 +0000Julia related error in purification.jl code
http://itensor.org/support/3897/julia-related-error-in-purification-jl-code
<p>Hello,<br>
I am getting the following error while running <code>purification.jl</code>, strangely, it is working in REPL "<a rel="nofollow" href="https://replit.com/@scin/EnragedJadedNasm#main.jl">https://replit.com/@scin/EnragedJadedNasm#main.jl</a>". Could you please help me out in this ?</p>
<pre><code>β = 0.00 energy = 0.00000000
************
ERROR:
LoadError: MethodError: no method matching /(::MPO, ::Float64)
Closest candidates are:
/(::StridedArray{P, N} where N, ::Real) where P<:Dates.Period at /buildworker
/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates
/src/deprecated.jl:44
/(::Union{SparseArrays.SparseVector{Tv, Ti}, SubArray{Tv, 1, var"#s814",
Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false} where var"#s814"
<:SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, SubArray{Tv, 1, var"#s814",
Tuple{Base.Slice{Base.OneTo{Int64}}}, false} where var"#s814"
<:SparseArrays.AbstractSparseVector{Tv, Ti}} where {Tv, Ti}, ::Number) at
/buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/SparseArrays
/src/sparsevector.jl:1450
/(::Complex, ::Real) at complex.jl:333
...
Stacktrace:
[ 1] main(; N::Int64, cutoff::Float64, δτ::Float64, beta_max::Float64)
@ Main /media/test.jl:26
[2] main()
@ Main /media/test.jl:11
[3] top-level scope
@ /media/test.jl:30
in expression starting at /media/test.jl:30
</code></pre>
http://itensor.org/support/3897/julia-related-error-in-purification-jl-codeTue, 12 Apr 2022 06:56:14 +0000[JULIA] Strange Error concerning my external file of S=2 spin system
http://itensor.org/support/3896/julia-strange-error-concerning-my-external-file-spin-system
<p>Hello iTensor team, </p>
<p>First i have to thank all iTensor team for keep this incredible package alive and growing.</p>
<p>Secondly, I'm trying to use an external file to study a ferrimagnetic system with Spin S=2. I follow the correct structure of external file, which give the following simple code</p>
<pre><code>using ITensors
function ITensors.space(::SiteType"S=2"; conserve_qns=false)
if conserve_qns
return [QN("Sz",4)=>1,QN("Sz",2)=>1,
QN("Sz",0)=>1,QN("Sz",-2)=>1,QN("Sz",-4)=>1]
end
return 5
end
function ITensors.op!(Op::ITensor, ::OpName"Sz",
::SiteType"S=2", s::Index)
Op[s'=>1,s=>1] = +2
Op[s'=>2,s=>2] = +1
Op[s'=>3,s=>3] = +0
Op[s'=>4,s=>4] = -1
Op[s'=>5,s=>5] = -2
end
function ITensors.op!(Op::ITensor, ::OpName"S+",
::SiteType"S=2", s::Index)
Op[s'=>1,s=>2] = 2
Op[s'=>2,s=>3] = sqrt(6)
Op[s'=>3,s=>4] = sqrt(6)
Op[s'=>4,s=>5] = 2
end
function ITensors.op!(Op::ITensor, ::OpName"S-",
::SiteType"S=2", s::Index)
Op[s'=>2,s=>1] = 2
Op[s'=>3,s=>2] = sqrt(6)
Op[s'=>4,s=>3] = sqrt(6)
Op[s'=>5,s=>4] = 2
end
ITensors.state(::StateName"Up+", ::SiteType"S=2") = [1.0, 0.0, 0.0, 0.0, 0.0]
ITensors.state(::StateName"Up", ::SiteType"S=2") = [0.0, 1.0, 0.0, 0.0, 0.0]
ITensors.state(::StateName"Z0", ::SiteType"S=2") = [0.0, 0.0, 1.0, 0.0, 0.0]
ITensors.state(::StateName"Dn", ::SiteType"S=2") = [0.0, 0.0, 0.0, 1.0, 0.0]
ITensors.state(::StateName"Dn-", ::SiteType"S=2") = [0.0, 0.0, 0.0, 0.0, 1.0]
</code></pre>
<p>The interesting part is, I'm receiving an error message "InexactError" from the line concerning the value of Sqrt(6). The funny part is when I tried using the same structure to construct the same external file for different spins (S=3/2, 5/2) everyting works fine. I'm not using the convert Julia function to convert any float number to an integer, so I don't know exactly what i had to change to make my code work.<br>
Here follow the error message :</p>
<p>ERROR: LoadError: InexactError: Int64(2.449489742783178)<br>
Stacktrace:<br>
[1] Int64<br>
@ ./float.jl:723 [inlined]<br>
[2] convert<br>
@ ./number.jl:7 [inlined]<br>
[3] setindex!<br>
@ ./array.jl:839 [inlined]<br>
[4] setindex!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/tensorstorage.jl:25 [inlined]<br>
[5] setindex!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/blocksparse/blocksparsetensor.jl:266 [inlined]<br>
[6] setindex!!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/NDTensors/tensor.jl:325 [inlined]<br>
[7] <em>setindex!!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/qn/qnitensor.jl:11 [inlined]<br>
[8] _setindex!!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:855 [inlined]<br>
[9] _setindex!!(::ITensors.NDTensors.BlockSparseTensor{Int64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, ITensors.NDTensors.BlockSparse{Int64, Vector{Int64},<br>
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:911<br>
[10] setindex!<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/itensor.jl:919 [inlined]<br>
[11] op!(Op::ITensor, #unused#::OpName{Symbol("S+")}, #unused#::SiteType{S=2}, s::Index{Vector{Pair{QN, Int64}}})<br>
@ Main /scratch/lmverissimo/Top2/2/N=128/S=2.jl:29<br>
[12] op(name::String, s::Index{Vector{Pair{QN, Int64}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})<br>
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:256<br>
[13] op<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:221 [inlined]<br>
[14] #op#902<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:332 [inlined]<br>
[15] op<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/sitetype.jl:332 [inlined]<br>
[16] (::ITensors.var"#calcQN#1004"{Vector{Index{Vector{Pair{QN, Int64}}}}, Dict{Pair{String, Int64}, ITensor}})(term::Vector{ITensors.SiteOp})<br>
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:668<br>
[17] qn</em>svdMPO(ampo::OpSum, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})<br>
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:676<br>
[18] qn_svdMPO<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:632 [inlined]<br>
[19] #MPO#1007<br>
@ /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:973 [inlined]<br>
[20] MPO(ampo::OpSum, sites::Vector{Index{Vector{Pair{QN, Int64}}}})<br>
@ ITensors /scratch/lmverissimo/.julia/packages/ITensors/XnM47/src/physics/autompo.jl:966</p>
<p>Any help will be appreciated, Thank you ! </p>
http://itensor.org/support/3896/julia-strange-error-concerning-my-external-file-spin-systemTue, 12 Apr 2022 00:22:36 +0000von Neumann entanglement entropy of 1D hubbard model (Julia)
http://itensor.org/support/3895/von-neumann-entanglement-entropy-of-1d-hubbard-model-julia
<p>Hi all,<br>
I got a question when calculating von Neumann entanglement entropy of a simple 1D hubbard model... I use the sample code (<a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/blob/main/examples/dmrg/1d_hubbard_extended.jl),">https://github.com/ITensor/ITensors.jl/blob/main/examples/dmrg/1d_hubbard_extended.jl),</a> keep only t1 and U and change sweep setting a little bit (attached below in code) because I have a longer chain (100sites). And I combined it with another sample code for the entropy calculation which I find here (<a rel="nofollow" href="http://itensor.org/support/2423/entanglement-entropy-julia).">http://itensor.org/support/2423/entanglement-entropy-julia).</a> </p>
<p>I use a loop for that index b which labels a cut at bond b, so that I can plot this entropy as a function of the site number. I expect the order of magnitude of S(b) to be O(1), but the results I got are all very samll numbers ~10^(-6)... I'm confused...Did I do anything wrong in my code?</p>
<p>Thank you so much! ! <br>
(I attched my complete code and printed entropy at each b below.)</p>
<p>Code:<br>
using ITensors</p>
<p>let<br>
N = 100<br>
Npart = 100<br>
t1 = 1.0<br>
t2 = 0.0<br>
U = -5.0<br>
V1 = 0.0</p>
<p>s = siteinds("Electron", N; conserve_qns=true)</p>
<p>ampo = OpSum()<br>
for b in 1:(N - 1)<br>
ampo += -t1, "Cdagup", b, "Cup", b + 1<br>
ampo += -t1, "Cdagup", b + 1, "Cup", b<br>
ampo += -t1, "Cdagdn", b, "Cdn", b + 1<br>
ampo += -t1, "Cdagdn", b + 1, "Cdn", b<br>
ampo += V1, "Ntot", b, "Ntot", b + 1<br>
end<br>
for b in 1:(N - 2)<br>
ampo += -t2, "Cdagup", b, "Cup", b + 2<br>
ampo += -t2, "Cdagup", b + 2, "Cup", b<br>
ampo += -t2, "Cdagdn", b, "Cdn", b + 2<br>
ampo += -t2, "Cdagdn", b + 2, "Cdn", b<br>
end<br>
for i in 1:N<br>
ampo += U, "Nupdn", i<br>
end<br>
H = MPO(ampo, s)</p>
<p>sweeps = Sweeps(30)<br>
setmaxdim!(sweeps, 500)<br>
setcutoff!(sweeps, 1E-7)<br>
@show sweeps</p>
<p>state = ["Emp" for n in 1:N]<br>
p = Npart<br>
for i in N:-1:1<br>
if p > i<br>
println("Doubly occupying site $i")<br>
state[i] = "UpDn"<br>
p -= 2<br>
elseif p > 0<br>
println("Singly occupying site $i")<br>
state[i] = (isodd(i) ? "Up" : "Dn")<br>
p -= 1<br>
end<br>
end<br>
# Initialize wavefunction to be bond <br>
# dimension 10 random MPS with number<br>
# of particles the same as <code>state</code><br>
psi0 = randomMPS(s, state, 10)</p>
<p># Check total number of particles:<br>
@show flux(psi0)</p>
<p># Start DMRG calculation:<br>
energy, psi = dmrg(H, psi0, sweeps)</p>
<p>upd = fill(0.0, N)<br>
dnd = fill(0.0, N)<br>
for j in 1:N<br>
orthogonalize!(psi, j)<br>
psidag<em>j = dag(prime(psi[j], "Site"))<br>
upd[j] = scalar(psidag</em>j * op(s, "Nup", j) * psi[j])<br>
dnd[j] = scalar(psidag_j * op(s, "Ndn", j) * psi[j])<br>
end</p>
<p>println("Up Density:")<br>
for j in 1:N<br>
println("$j $(upd[j])")<br>
end<br>
println()</p>
<p>println("Dn Density:")<br>
for j in 1:N<br>
println("$j $(dnd[j])")<br>
end<br>
println()</p>
<p>println("Total Density:")<br>
for j in 1:N<br>
println("$j $(upd[j]+dnd[j])")<br>
end<br>
println()</p>
<p>println("\nGround State Energy = $energy")</p>
<p>function entropy<em>von</em>neumann(psi::MPS, N::Int)<br>
SvN = fill(0.0, N)<br>
for b in 2:N-1<br>
orthogonalize!(psi, b)<br>
_,S = svd(psi[b], (linkind(psi, b-1), s[b]))<br>
for n in dim(S, 1)<br>
p = S[n,n]^2<br>
SvN[b] -= p * log(p)<br>
end<br>
println("$(SvN[b])")<br>
end<br>
return SvN<br>
end</p>
<p>SvN = entropy<em>von</em>neumann(psi, N)</p>
<p>end</p>
<hr>
<p>The entropy S(b):<br>
0.09070691669706957<br>
0.001332649961200171<br>
1.3686167960001409e-6<br>
4.359976386344567e-6<br>
6.733373654214966e-6<br>
1.3372604646791153e-7<br>
1.5001040623576317e-5<br>
5.058686612647704e-7<br>
2.5543410516658077e-5<br>
1.0639655773856194e-6<br>
3.829868192360102e-5<br>
1.4027735830778272e-7<br>
2.0115153047422772e-7<br>
2.2972119655530066e-7<br>
3.4283980977130424e-7<br>
3.115574369307899e-7<br>
4.871244534235853e-7<br>
3.9846497809687774e-7<br>
6.440428978804487e-7<br>
4.885839791828351e-7<br>
8.217896181088025e-7<br>
5.822938107843419e-7<br>
1.060520215982716e-6<br>
6.831068268753088e-7<br>
1.3465796889154753e-6<br>
1.4128831887793594e-7<br>
1.6578331240586298e-6<br>
1.6817179418251726e-7<br>
1.9086191014162828e-6<br>
1.9218002525787778e-7<br>
2.1334820606118912e-6<br>
2.1459105376943014e-7<br>
2.3313186179033887e-6<br>
2.3442546255436683e-7<br>
2.5091554302506395e-6<br>
2.5148073806805365e-7<br>
2.6629455105823636e-6<br>
2.675461252705469e-7<br>
2.7969288395425305e-6<br>
2.820721836141702e-7<br>
2.908469131486962e-6<br>
2.940051897395952e-7<br>
2.9878629561903115e-6<br>
3.0171249585454165e-7<br>
3.0612731469971742e-6<br>
3.083795037091508e-7<br>
3.100147849310539e-6<br>
3.123873318518695e-7<br>
3.1099061931736388e-6<br>
3.123841279545293e-7<br>
3.0987763981597106e-6<br>
3.0976940496368236e-7<br>
3.063501520406781e-6<br>
3.0449799942869857e-7<br>
3.001787667600418e-6<br>
2.957587377413038e-7<br>
2.918827460496549e-6<br>
2.847481294234705e-7<br>
2.808596119674664e-6<br>
2.7068863487085386e-7<br>
2.6786544449685913e-6<br>
2.5486386260203346e-7<br>
2.524835813245228e-6<br>
2.3709999310016173e-7<br>
2.3417164843292646e-6<br>
2.154108041515205e-7<br>
2.1471156146958798e-6<br>
1.9392643033737067e-7<br>
1.9277674229420978e-6<br>
1.6959635573688854e-7<br>
1.6764798541578795e-6<br>
1.4214995738633714e-7<br>
1.3460961878017196e-6<br>
6.8199231820002e-7<br>
1.0490130295538297e-6<br>
5.814456742233713e-7<br>
8.18106307245907e-7<br>
4.878329051121316e-7<br>
6.425305910731801e-7<br>
3.9783346478151117e-7<br>
4.842645529017947e-7<br>
3.105588577603732e-7<br>
3.2992276174983606e-7<br>
2.099190336426272e-7<br>
1.9297394199410213e-7<br>
1.3973463812131638e-7<br>
3.825571380443112e-5<br>
1.059329165404299e-6<br>
2.554198355682492e-5<br>
4.920291374342437e-7<br>
1.4994953866517857e-5<br>
1.3062726493860295e-7<br>
6.736631969987577e-6<br>
4.323008567401327e-6<br>
1.3668060657135116e-6<br>
0.0013324848707008954<br>
0.09070625418213862<br>
0.3597747329567827</p>
http://itensor.org/support/3895/von-neumann-entanglement-entropy-of-1d-hubbard-model-juliaMon, 11 Apr 2022 09:23:09 +0000Finite Temperature Properties of the Spin Systems
http://itensor.org/support/3893/finite-temperature-properties-of-the-spin-systems
<p>Hello, </p>
<p>Zero Temperature magnetization can be found by <code>mgn=(inner(psi,Mz,psi))</code> <br>
Where Mz is uniform magnetization operator. Now my question is how can I find the finite temperature magnetization or other T dependent properties.</p>
<p>Thanks</p>
http://itensor.org/support/3893/finite-temperature-properties-of-the-spin-systemsWed, 06 Apr 2022 07:45:07 +0000Unsuccesful TEBD for Time Independent Fermi-Hubbard Model
http://itensor.org/support/3883/unsuccesful-tebd-for-time-independent-fermi-hubbard-model
<p>I have been trying to recreate the dynamics of a driven Fermi-Hubbard Hamiltonian in Julia:</p>
<p>$$<br>
\hat{H}=-t_0 \sum_{j,\sigma}\left( e^{-i\Phi(t)}\hat{c}^{\dag}_{j,\sigma}\hat{c}<em>{j+1,\sigma} + h.c. \right)+\sum_{j} \hat{n}_{j,\uparrow}\hat{n}</em>{j,\downarrow}<br>
$$<br>
(don't know why this isn't formatting this is the Hamiltonian given by equation 12 in <a rel="nofollow" href="https://journals.aps.org/pra/abstract/10.1103/PhysRevA.101.053408">https://journals.aps.org/pra/abstract/10.1103/PhysRevA.101.053408</a> )</p>
<p>where @@ \sigma @@ is spin, but my first step is attempting this with @@\Phi(t)@@ set to 0, which results in an undriven, time independent model. I have successfully performed DMRG to obtain the ground state (which I know because I have compared energies to exact calculations in the QuSpin package), but I have been unsuccessful in using TEBD (and RK2 and RK4) to evolve the ground state using the time independent Hamiltonian. I know applying the time evolution operator as an exponential of the TI Hamiltonian to the ground state should preserve the ground state, but instead the energy of the state resulting from the application of the time evolution operator increases throughout the evolution. Though I have not tested dependence rigorously, the energy increase seems to be mostly independent of the time step even though it should be @@\mathcal{O}(\delta t)@@ according to <a rel="nofollow" href="https://www.sciencedirect.com/science/article/pii/S0003491619302532.">https://www.sciencedirect.com/science/article/pii/S0003491619302532.</a> I have implemented a dynamic time step as well, and tested a couple different maximum bond dimensions in DMRG, as well as decreasing the cutoff for both DMRG and the apply function. Any help is greatly appreciated, thanks in advance! My code is below:</p>
<pre><code>"""
Use second order TEBD to evolve psi(t) to psi (t + dt)
"""
function TEBD(psi, dt, time, params, independent, cutoff)
phi = phi_tl(time + dt / 2, params, independent)
# odd gates (1,2),(3,4),(5,6),...
ogates = ITensor[]
# even gates (2,3),(4,5),(6,7),...
egates = ITensor[]
for j=1:params.nsites
s1 = params.space[j]
#periodic BC
if j == params.nsites
s2 = params.space[1]
else
s2 = params.space[j+1]
end
# we have to define the two site operator so contributions
# of each site will be counted twice
ul = ur = params.U / 2
# exp(i phi(t)) and exp(-i phi(t))
eiphi = exp(1.0im * phi)
eiphiconj = conj(eiphi)
# create operator (only scaled parameters are passed in so t is always 1)
hj = -eiphiconj * op("Cdagup",s1) * op("Cup",s2) +
-eiphiconj * op("Cdagdn",s1) * op("Cdn",s2) +
-eiphi * op("Cdagup",s2) * op("Cup",s1) +
-eiphi * op("Cdagdn",s2) * op("Cdn",s1) +
ul * op("Nupdn", s1) * op("Id",s2) +
ur * op("Id",s1) * op("Nupdn", s2)
# odd gate
if j % 2 == 1
Gj = exp(-1.0im * dt * hj)
push!(ogates, Gj)
# even gate
else
Gj = exp(-1.0im * dt / 2 * hj)
push!(egates, Gj)
end
end
gates = ITensor[]
append!(gates, egates)
append!(gates, ogates)
append!(gates, egates)
return apply(gates, psi; cutoff=cutoff)
end
"""
Propogates ground from 0 to tf using method to propogate by an adaptive timestep
Parameters:
ground - ground state (MPS)
tf - final time
method - the function used to propogate a wavefunction over single dt
dti - initial guess for timestep
epsilon - total change allowed in a single time step
independent - boolean that is True if we are evolving with a time independent
Hamiltonian, and False otherwise
"""
function propogation(ground::MPS, params, tf, method, dti, epsilon, independent, cutoff)
# error measures (en is for current step, en1 is for previous step)
en = en1 = 0.0
time = 0.0
# copy states
psi = deepcopy(ground)
# set dt and previous dt
dt = pdt = dti
# initialize vectors for saving times and expectation values
times = [0]
energies = [inner(ground, get_ham(0, params, independent), ground)]
currents = [inner(ground, get_current(0, params, independent), ground)]
# run for the entire time interval
while time < tf
# get the MPS at time + dt
next_psi = method(psi, dt, time, params, independent, cutoff)
# calculate difference between current and next psi
en = difference(psi, next_psi)
# run propogation while the difference is greater than acceptable error
while en > epsilon
# adjust time step
dt *= epsilon / en
# get the next MPS and calculate difference
next_psi = method(psi, dt, time, params, independent, cutoff)
en = difference(psi, next_psi)
end
# incremement time and add it to the array
time += dt
times = vcat(times, [time])
# accept wavefunction
psi = deepcopy(next_psi)
# calculate expectations
energies = vcat(energies, [inner(psi, get_ham(time, params, independent), psi)])
currents = vcat(currents, [inner(psi, get_current(time, params, independent), psi)])
en1 = (en1 > 0) ? en1 : en
# adjust for next time step
# https://www.sciencedirect.com/science/article/pii/S0377042705001123
ndt = dt * ((epsilon^2 * dt)/ (en * en1 * pdt))^(1/12)
# update values for next iteration e_{n-1} -> e_n, dt_{n-1} = dt_n,
# dt_n -> dt_{n+1}
en1 = en
pdt = dt
dt = ndt
end
return times, energies, currents
end
</code></pre>
http://itensor.org/support/3883/unsuccesful-tebd-for-time-independent-fermi-hubbard-modelTue, 29 Mar 2022 23:17:57 +0000AutoMPO using operators with more arguments
http://itensor.org/support/3879/autompo-using-operators-with-more-arguments
<p>[Using Julia]</p>
<p>Hi! I am hoping to construct an ampo using operators that contain extra arguments. For example, </p>
<pre><code>function ITensors.op(::OpName"Nup", st::SiteType"HubHolst"; max_phonons::Int=1)
</code></pre>
<p>Initially I just had a global MAX_PHONONS variable defined in the HubHolst site type file, but for the sake of making the code more hygienic I was hoping to explicitly pass in max_phonons as an argument to specify the dimension of the phonon Hilbert space whenever I construct the operators. Alternatively (and preferably), the st variable could also carry this information. However, I am not sure whether it is possible (that is to say, internally compatible) to modify the SiteType struct to contain more fields, such as the dimension of the phonon hilbert space on each site. </p>
<p>Thanks so much for the help! I really appreciate it</p>
http://itensor.org/support/3879/autompo-using-operators-with-more-argumentsTue, 29 Mar 2022 16:15:46 +0000Infinite MPS TEBD in Julia
http://itensor.org/support/3871/infinite-mps-tebd-in-julia
<p>Hi! Previously I asked about apply function in Julia. I have succesfully implemented a finite MPS TEBD time evolution. Now I am moving to the infinite case. I just found that there is a package currently under developed called ITensorInfiniteMPS.jl by ITensor developers. I am trying to understand how it works, and how to perform Trotter-like gate evolution using it. May I ask what c means in the MPS index?</p>
<p>InfiniteMPS<br>
[1] IndexSet{3} (dim=1|id=317|"Link,c=0,l=3") (dim=2|id=652|"S=1/2,Site,c=1,n=1") (dim=1|id=77|"Link,c=1,l=1")<br>
[2] IndexSet{3} (dim=1|id=77|"Link,c=1,l=1") (dim=2|id=984|"S=1/2,Site,c=1,n=2") (dim=1|id=868|"Link,c=1,l=2")<br>
[3] IndexSet{3} (dim=1|id=868|"Link,c=1,l=2") (dim=2|id=569|"S=1/2,Site,c=1,n=3") (dim=1|id=317|"Link,c=1,l=3")</p>
<p>Also, I understand that to perform time evolution with infinite MPS, one essentially evolves the unit cell. We are using an OBC MPS which contains one unit cell to do such a task. One needs to deal with the sites at the boundary, i.e. site=n, and site=n+1 which goes back to site=1, assuming the unit cell contains n sites. To write such a function 'apply', we just include an additional term h[n,1] into the gates, is that correct?</p>
<p>Thank you!</p>
<p>Best regards,<br>
Tianqi</p>
http://itensor.org/support/3871/infinite-mps-tebd-in-juliaFri, 25 Mar 2022 06:18:33 +0000How to add a constant term in Hamiltonian(julia)
http://itensor.org/support/3864/how-to-add-a-constant-term-in-hamiltonian-julia
<p>I have a dumb question... When constructing ampo, how to add a constant term? For example, in a 1D spin model, that 1/4 in terms like 0.5(Sz<em>i Sz</em>i+1 -1/4)? </p>
<p>I tried:<br>
ampo = OpSum()<br>
for i in 1:(N - 1)<br>
ampo += 0.5, "Sz", i, "Sz", i + 1<br>
ampo += -0.5/4<br>
end</p>
<p>But doesn't work... I know the overall constant is trivial, but just want to know...<br>
Thank you!</p>
http://itensor.org/support/3864/how-to-add-a-constant-term-in-hamiltonian-juliaThu, 24 Mar 2022 10:22:46 +0000[Julia]3-sites MPS Time Evolution
http://itensor.org/support/3862/julia-3-sites-mps-time-evolution
<p>Hi Miles</p>
<p>If my Hamiltonian is a 3-sites interaction, Is it useful to only add a<br>
<code>s3 = s[j+2]</code><br>
and use<br>
<code>hj= op("xx",s1) * op("xx",s2)*op("xx",s3)</code><br>
compared with example from document?<br>
I have tried it and the code evaluating time is much longer than 2-sites. </p>
http://itensor.org/support/3862/julia-3-sites-mps-time-evolutionThu, 24 Mar 2022 08:51:00 +0000Where can I find the proper syntax required to perform SVD in dmrg tutorial ?
http://itensor.org/support/3859/where-find-proper-syntax-required-perform-svd-dmrg-tutorial
<p>I am trying to finish the tutorial 06 on dmrg. However, I am not able to find the help section on the website. I am facing issues in implementing SVD. Where can I find the proper syntax required to perform SVD in dmrg tutorial?<br>
Note: that I am the c++ version of the ITensor package.</p>
http://itensor.org/support/3859/where-find-proper-syntax-required-perform-svd-dmrg-tutorialWed, 23 Mar 2022 10:06:05 +0000[C++] OMP vs. MKL parallelization
http://itensor.org/support/3852/c-omp-vs-mkl-parallelization
<p>In the <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=install/install_with_openmp">documentation</a>, the parallelization is controlled by two environment variables, <code>MKL_NUM_THREADS</code> and <code>OMP_NUM_THREADS</code>. However in my benchmark, changing <code>MKL_NUM_THREADS</code> has no effect, and the number of CPU is fully controlled by <code>OMP_NUM_THREADS</code>. With this observation I have the following questions.</p>
<p>Is it correct that, <code>MKL_NUM_THREADS</code> controls the number of CPU used in a matrix-matrix multiplication, and <code>OMP_NUM_THREADS</code> controls the parallelization among different quantum number blocks? If this is true, does the current version of ITensor only support the parallelization among quantum number blocks?</p>
http://itensor.org/support/3852/c-omp-vs-mkl-parallelizationTue, 22 Mar 2022 02:17:32 +0000fail to reproduce results of 1D Bose-Hubbard model
http://itensor.org/support/3851/fail-to-reproduce-results-of-1d-bose-hubbard-model
<p>Dear Itensor users</p>
<p>I have tried to reproduce the density of the 1D Bose-Hubbard model using dmrg without success. Following are the Hamiltonian and the measurements I used for the simulations (I skip some not relevant parts).</p>
<pre><code>auto sites = Boson(L, {"MaxOcc=", 5, "ConserveQNs", true, "ConserveNb", false});
auto ampo = AutoMPO(sites);
for (int i = 1; i < L; i += 1)
{
ampo += - U / 2, "N", i;
ampo += -mu, "N", i;
ampo += U / 2, "N", i, "N", i;
ampo += -t, "Adag", i + 1, "A", i;
ampo += -t, "Adag", i, "A", i + 1;
}
ampo += U/2, "N", L, "N", L;
ampo += - U/2, "N", L;
ampo += -mu, "N", L;
auto H = toMPO(ampo);
auto state = InitState(sites);
for (int i : range1(L))
{
state.set(i, "1");
}
auto psi0 = randomMPS(state);
auto [energy, psi] = dmrg(H, psi0, sweeps, "Quiet");
fptr = fopen(argv[6],"a");
auto ampo_a = AutoMPO(sites);
auto ampo_1 = AutoMPO(sites);
for (int i = 1; i <= L; i++)
{
ampo_a += 1, "N", i;
ampo_1 += 1, "A", i;
}
auto ope = toMPO(ampo_a);
auto ope1 = toMPO(ampo_1);
fprintf(fptr,"%.12f %.12f\n",inner(psi,ope,psi),inner(psi,ope1,psi));
</code></pre>
<p>Any help will be greatly appreciated.</p>
<p>Sincerely,<br>
FJ</p>
http://itensor.org/support/3851/fail-to-reproduce-results-of-1d-bose-hubbard-modelTue, 22 Mar 2022 01:52:03 +0000Measure multi-point correlation in 2D lattice
http://itensor.org/support/3825/measure-multi-point-correlation-in-2d-lattice
<p>Hi everyone</p>
<p>Recently I've been trying to calculate some observable in Kitaev honeycomb model (Kitaev 2006) using ITensor DMRG. One important result to check out is the flux operator Wp whose ground state expectation should be Wp = +1 as calculated analytically by Kitaev himself. </p>
<p>However, I found that sometimes I cannot retrieve this number in dmrg. For example, in a 24-site system shown below:<br>
<img src="https://github.com/fengshi96/KSL_ML/blob/30ec802bf0b5737f78b505f4f1bbb0bd83e88efe/Plots/24input_a.png?raw=true" alt="Wp consists of the 6 sites on the boundary of the shaded region"><br>
following the <a rel="nofollow" href="http://itensor.org/docs.cgi?page=tutorials/correlations">tutorial</a> and <a rel="nofollow" href="http://itensor.org/support/1228/measure-multi-site-more-than-2-correlation">other advices</a>, the multi-point correlation for [s2 s3 s4 s7 s8 s9] is calculated using the following code:</p>
<pre><code> ITensor Sz_2 = op(sites, "Sx", 2);
ITensor Sz_3 = op(sites, "Sy", 3);
ITensor Sz_4 = op(sites, "Sz", 4);
ITensor Sz_7 = op(sites, "Sz", 7);
ITensor Sz_8 = op(sites, "Sy", 8);
ITensor Sz_9 = op(sites, "Sx", 9);
psi.position(2);
ITensor C = psi(2);
C *= Sz_2; // with primed physical index
auto ir = commonIndex(psi(2),psi(3),"Link");
C *= dag(prime(prime(psi(2), "Site"), ir));
C *= psi(3);
C *= Sz_3;
C *= dag(prime(prime(psi(3), "Site"), "Link"));
C *= psi(4);
C *= Sz_4;
C *= dag(prime(prime(psi(4), "Site"), "Link"));
C *= psi(5);
C *= dag(prime(psi(5), "Link"));
C *= psi(6);
C *= dag(prime(psi(6), "Link"));
C *= psi(7);
C *= Sz_7;
C *= dag(prime(prime(psi(7), "Site"), "Link"));
C *= psi(8);
C *= Sz_8;
C *= dag(prime(prime(psi(8), "Site"), "Link"));
C *= psi(9);
C *= Sz_9;
auto il = commonIndex(psi(8),psi(9),"Link");
C *= dag(prime(prime(psi(9), "Site"), il));
auto results = eltC(C * 64); // spin-1/2 to pauli matrix by 2^6
</code></pre>
<p>where I have contracted site 5,6 directly since there's no operator acting on them. But this gives a wrong number Wp = -0.18 instead of +1; even though all 2-site operator are correct. </p>
<p>On the other hand, if I reorder the site indices so that the first 6 continuous sites in MPS correspond to the Wp operator, as shown below:<br>
<img src="https://raw.githubusercontent.com/fengshi96/KSL_ML/30ec802bf0b5737f78b505f4f1bbb0bd83e88efe/Plots/24input_b.png" alt="enter image description here"> <br>
where Wp = [s1 s2 s3 s4 s5 s6], then I got the correct expectation Wp = +1 by the same token. </p>
<p>It is curious to me that the order of sites makes such a huge difference, though both ordering gave the same ground state energy. I would like to understand the crux of this problem (maybe I missed some trivial stuff) before I implement more nested correlators in dmrg. </p>
<p>Could someone give any suggestions? Thank you. </p>
http://itensor.org/support/3825/measure-multi-point-correlation-in-2d-latticeTue, 15 Mar 2022 21:48:09 +0000Entanglement Entropy near phase transition in 1D
http://itensor.org/support/3823/entanglement-entropy-near-phase-transition-in-1d
<p>Hi,</p>
<p>I am trying to evaluate entanglement entropy for 1D system with OBC by keeping fix J and variable t2. There is a phase transition from 2-Majorana phase to 4-Majorana phase. For J=0, entanglement entropy is non-vanishing and there is a peak in entanglement entropy at phase transition but as soon as I turn on J, entanglement entropy turns out to be zero (near 10^(-7)). I used DMRG (ITensor Julia) to calculate ground state wavefunction and it seems like it is choosing a state with least entanglement for non-zero J interaction. Is there any way to force dmrg in ITensor Julia to get correct entangled ground state? I would really appreciate any help or suggestions.</p>
<p>Thank you so much!</p>
<p>I am using following Hamiltonian: </p>
<p>sites = siteinds("S=1/2",N1)</p>
<p>for j=1:N1-1<br>
ampo += -1/2,"Sx",j,"Sx",j+1<br>
ampo += J/4,"Sz",j,"Sz",j+1<br>
end<br>
for j=1:N1-2<br>
ampo += t2,"Sx",j,"Sz",j+1,"Sx",j+2<br>
end</p>
http://itensor.org/support/3823/entanglement-entropy-near-phase-transition-in-1dTue, 15 Mar 2022 07:52:17 +0000SPIN-SPIN CORREALTION FOR A TWO LEG LADDER MODEL
http://itensor.org/support/3821/spin-spin-correaltion-for-a-two-leg-ladder-model
<p>Hii,</p>
<p>I am doing DMRG of a two leg ladder model in ITensor julia.</p>
<p>I have calculated the ground sate energy and spin-spin correlation in 1D Heisenberg model and 1D Hubbard model and it gives correct ground state energy and spin-spin(Total spin on each site) .</p>
<p>However, when i calculated DMRG for a two leg ladder model (for 48*2 sites) , it appears the ground state energy is correct, but the spin-spin correlation is antiferromagnetic while the actual correlation should be ferromagnetic.</p>
<p>Here is the Hamiltonian of the code with parameters</p>
<pre><code>Nx=48
N= 2*Nx
sites=siteinds("Electron",N,conserve_qns=true,conserve_nf = true,conserve_sz=true,conserve_nfparity=false)
ampo =AutoMPO()
#intra-leg hopping
for j=1:2:(N-3)
ampo += -t,"Cdagup",j,"Cup",j+2
ampo += -t,"Cdagup",j+2,"Cup",j
ampo += -t,"Cdagdn",j,"Cdn",j+2
ampo += -t,"Cdagdn",j+2,"Cdn",j
ampo += -t,"Cdagup",j+1,"Cup",j+3
ampo += -t,"Cdagup",j+3,"Cup",j+1
ampo += -t,"Cdagdn",j+1,"Cdn",j+3
ampo += -t,"Cdagdn",j+3,"Cdn",j+1
end
#inter-leg hopping
p=1
for j =1:2:(N-1)
ampo += Q(p),"Cdagup",j,"Cup",j+1
ampo += conj(Q(p)),"Cdagup",j+1,"Cup",j
ampo += Q(p),"Cdagdn",j,"Cdn",j+1
ampo += conj(Q(p)),"Cdagdn",j+1,"Cdn",j
p=p+1
end
# On-site interaction
for j=1:N
ampo += U,"Nupdn",j
end
</code></pre>
<p>I kept the particle number fixed as i want to calculate ground sate energy at some particular electron density.</p>
<p>After performing the DMRG with the above Hamiltonian i calculate the spin-spin correlation in the following way</p>
<pre><code>xxcorr = correlation_matrix(psi,"S+","S-")
yycorr = correlation_matrix(psi,"S-","S+")
zzcorr = correlation_matrix(psi,"Sz","Sz")
zz = 0.5* xxcorr + 0.5 * yycorr + zzcorr
</code></pre>
<p>I calculate the spin-spin correlation for a reference site away from the boundary.</p>
<p>But as i mentioned i am not getting the correct spin-spin correlations(which is ferromagnetic for some given parameters).</p>
<p>So ,is there anything wrong in writing the Hamiltonian or in the correlation matrix ?</p>
<p>Thanks</p>
http://itensor.org/support/3821/spin-spin-correaltion-for-a-two-leg-ladder-modelMon, 14 Mar 2022 19:02:11 +0000Computing the transfer matrix for iDMRG
http://itensor.org/support/3820/computing-the-transfer-matrix-for-idmrg
<p>I would like to extract the correlation length from the transfer matrix using iDMRG with a given unit cell, preferably using the C++ version. Is there any simple way to compute it from the MPS ?<br>
Thanks in advance for any advice,</p>
http://itensor.org/support/3820/computing-the-transfer-matrix-for-idmrgMon, 14 Mar 2022 18:32:37 +0000[C++] Convert an MPS with quantum number to an MPS without quantum number
http://itensor.org/support/3818/convert-mps-with-quantum-number-mps-without-quantum-number
<p>Suppose I have an MPS with conserved particle number. Is there an easy way to convert this MPS to one with no particle-number (but replaced by parity) quantum number?</p>
http://itensor.org/support/3818/convert-mps-with-quantum-number-mps-without-quantum-numberMon, 14 Mar 2022 16:43:39 +0000[Julia]using a periodic boundary condition
http://itensor.org/support/3811/julia-using-a-periodic-boundary-condition
<p>Hi Miles</p>
<p>I want do time evolution in PBC with two sites Hamiltonian . For example, a chain made of 12 sites whose first site is related to the 12. I can only find code example in "Make a 2D Hamiltonian for DMRG" that uses<br>
<code>lattice = square_lattice(Nx, Ny; yperiodic = false)</code><br>
If I imitate the code from "MPS Time Evolution" in document with my own Hamiltonian, how can I add PBC?</p>
http://itensor.org/support/3811/julia-using-a-periodic-boundary-conditionSun, 13 Mar 2022 09:16:18 +0000C++ version, complex matrix-vector multiplication
http://itensor.org/support/3809/c-version-complex-matrix-vector-multiplication
<p>I found that in C++ version, the function operator* for matrix-vector multiplication seems not implemented for complex matrix CMatrix and complex vector CVector. The sample code is as follows.</p>
<pre><code>CMatrix a (2,2);
CVector v (2);
auto b = a * v;
</code></pre>
<p>The error message is</p>
<blockquote>
<p>error: no match for ‘operator*’ (operand types are ‘itensor::CMatrix’ {aka ‘itensor::Ten<itensor::MatRangeT<0>, std::complex >’} and ‘itensor::CVector’ {aka ‘itensor::Ten<itensor::VecRangeT<0>, std::complex >’})</p>
</blockquote>
<p>Is there a chance that it will be implemented?</p>
http://itensor.org/support/3809/c-version-complex-matrix-vector-multiplicationSun, 13 Mar 2022 06:18:50 +0000[Julia]define the state in different Hilbert space
http://itensor.org/support/3799/julia-define-the-state-in-different-hilbert-space
<p>Hi Miles</p>
<p>I want to use operators which is not included in "electron" or "boson" and so on. The document has used the example "S=3/2" to tell me how to define operators I need. I also need a initial state I set to do time evolution. For example, the "Up" and "Dn" are MPS in "S=1/2" and we can use it to set initial state. How can I define something like "Dn" or "Up" I need? </p>
http://itensor.org/support/3799/julia-define-the-state-in-different-hilbert-spaceThu, 10 Mar 2022 07:55:53 +0000Time dependent correlations
http://itensor.org/support/3798/time-dependent-correlations
<p>Hi miles,<br>
I am using Itensor C++ code.<br>
I am interested to find correlation between Sz<em>1(t) and Sz</em>4 for L=10 sites Heisenberg spin(1/2) chain.<br>
So first I calculated psi0 then by using trotter gate psi0<em>t. Next I obtained new1</em>psi0<em>t=Sz</em>1*psi0_t(1) (operating Sz_1 at psi0_t(1)). Similarly by operating other operator Sz_4 at psi0(4), new state new4_psi0 calculated. Then I did time evolution of new4_psi0 to get new4_psi0_t and finally innerC(new1_psi0_t,new4_psi0_t). Is it right? </p>
http://itensor.org/support/3798/time-dependent-correlationsWed, 09 Mar 2022 08:01:52 +0000Time evolution under periodic Hamiltoian
http://itensor.org/support/3796/time-evolution-under-periodic-hamiltoian
<p>Hi Miles</p>
<p>I was trying to implement the time evolution of a direct product initial state under periodic Hamiltonian. Using the autoMPO method, I constructed the Hamiltonian, but when I compared the result with the exact diagonalization, I saw inconsistency between MPS and ED results. </p>
<p>My initial state was with an open boundary condition. I think I will not face any issues using MPS with closed boundary conditions. Can we construct MPS with closed boundary conditions in iTensor? I went through the documentation, but I could not find any details regarding MPS with closed boundary.</p>
<p>I appreciate any help you can provide.</p>
http://itensor.org/support/3796/time-evolution-under-periodic-hamiltoianTue, 08 Mar 2022 08:28:49 +0000Computing correlation function
http://itensor.org/support/3795/computing-correlation-function
<p>Hi there! I am using Julia to compute the one-particle spectral function for the Hubbard Holstein system. While I have some degree of confidence in my DMRG calculation (I get the same results as ED) and time evolution (the entropy of the unmodified ground state function, evolved in time, remains very flat), I am getting correlation results that are exactly sign flipped relative to the ED calculation. I've attached a plot of the results for the case where @@N=8, t=1, U=8, \Delta t=0.01, T=1@@. The correlation function I (believe I am) plotting is @@\langle c_j^\dagger (t) c_i(0)\rangle@@ for @@i=j=4@@, the midpoint. </p>
<p><img src="https://ibb.co/xM0K11V" alt="Calculating the one-particle correlation function for the midsite, comparing my results to ED"></p>
<p>As you can see, there is an exact sign flip between the ED analysis and the results I've obtained by running the algorithm described <a rel="nofollow" href="https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.93.076401">here</a> on my DMRG ground state. Here is a plot showing the corresponding entropy of both wavefunctions: </p>
<p><img src="https://ibb.co/ZYyk1s4" alt="Entropy for time evolution"></p>
<p>Because I think the issue might be localized to how I am computing the correlation function, I tried a few different ways of doing so, but ultimately was unable to fix the problem. Here is a snippet of the code I am using to time-evolve the wavefunction and compute the correlation function:</p>
<pre><code>function apply_onesite_operator(ϕ::MPS, opname::String, sites, siteidx::Int)
ϕ = copy(ϕ)
## Account for fermion sign using Jordan-Wigner strings ##
if opname == "Cup" || opname == "Cdn"
ϕ = apply_op(ϕ, opname, sites, siteidx)
for i in reverse(1:(siteidx-1)) # Don't act with string on-site
ϕ = apply_op(ϕ, "F", sites, i)
end
return ϕ
elseif opname == "Cdagup" || opname == "Cdagdn"
for i in 1:(siteidx-1) # Don't act with string on-site
ϕ = apply_op(ϕ, "F", sites, i)
end
ϕ = apply_op(ϕ, opname, sites, siteidx)
return ϕ
end
# Otherwise, just apply the operator as usual
return apply_op(ϕ, opname, sites, siteidx)
end
function apply_op(ϕ::MPS, opname::String, sites, siteidx::Int)
ϕ = copy(ϕ) # Make a copy of the original state
orthogonalize!(ϕ, siteidx)
new_ϕj = op(opname,sites[siteidx]) * ϕ[siteidx] # Apply the local operator
noprime!(new_ϕj)
ϕ[siteidx] = new_ϕj
return ϕ
end
</code></pre>
<p>And now for the compute_correlation functions itself:</p>
<pre><code>function compute_correlations(dmrg_results::DMRGResults, A_t0::String, A_t::String, HH::HubbardHolsteinModel, p::Parameters)
# Results
corrs = []
# The wavefunction being acted upon at t=0, |ψ⟩ = A_t0|ϕ⟩
ϕ = copy(dmrg_results.ground_state)
ψ = copy(ϕ)
# Apply A_t0 to middle site
ψ = apply_onesite_operator(ψ, A_t0, HH.sites, p.mid)
nsteps = floor(p.T/p.τ) # Number of time steps for time evolution
t = 0.0
for step in 1:nsteps
ϕ = apply(HH.gates, ϕ; maxdim=p.TEBD_maxdim, cutoff=p.TEBD_cutoff)
ψ = apply(HH.gates, ψ; maxdim=p.TEBD_maxdim, cutoff=p.TEBD_cutoff) # evolve forward
t += p.τ
function measure_corr(j::Int)
A_tψ = apply_onesite_operator(ψ, A_t, HH.sites, j)
return inner(ϕ,A_tψ)
end
# Measure the correlation fcn
push!(corrs,measure_corr.(collect(1:p.N)))
end
hcat(corrs...)
end
</code></pre>
<p>Due to how I've set up the code, I pass in Cdagup for A<em>t and Cup for A</em>t0. Here is the Hamiltonian AMPO, which I use during DMRG:</p>
<pre><code>ampo = OpSum()
for j=1:N-1
ampo += -t,"Cdagup",j,"Cup",j+1
ampo += -t,"Cdagup",j+1,"Cup",j
ampo += -t,"Cdagdn",j,"Cdn",j+1
ampo += -t,"Cdagdn",j+1,"Cdn",j
ampo += U,"Nupdn",j,"I",j
ampo += ω,"Nb",j
ampo += g0,"Ntot(Bd+B)",j
ampo += g1,"Ntot",j,"Bdag+B",j+1
ampo += g1,"Ntot",j+1,"Bdag+B",j
end
# Edge site
ampo += U,"Nupdn",N
ampo += ω,"Nb",N
ampo += g0,"Ntot(Bd+B)",N
H = MPO(ampo,sites)
</code></pre>
<p>And the trotter gates for time evolution: </p>
<pre><code>gates = ITensor[]
for j=1:N-1
s1 = sites[j] # site j
s2 = sites[j+1] # site j+1
hj_twosite = -t*(op("Cdagup*F",s1) * op("Cup",s2) # t * (c^†_jσ c_{j+1}σ + h.c.)
-op("Cup*F",s1) * op("Cdagup",s2)
+op("Cdagdn*F",s1) * op("Cdn",s2)
-op("Cdn*F",s1) * op("Cdagdn",s2))
+ g1*(op("Ntot",s1) * op("Bdag+B",s2))
+ g1*(op("Bdag+B",s1) * op("Ntot",s2))
hj_onesite = U*(op("Nupdn",s1) * op("I",s2))
+ ω*(op("Nb",s1) * op("I",s2))
+ g0*(op("Ntot(Bd+B)",s1) * op("I",s2))
Gj_twosite = exp(-1.0im * τ/2 * hj_twosite)
Gj_onesite = exp(-1.0im * τ/2 * hj_onesite)
push!(gates,Gj_twosite)
push!(gates,Gj_onesite)
end
# End site
hn = U*op("Nupdn",sites[N])
+ ω*op("Nb",sites[N])
+ g0*op("Ntot(Bd+B)",sites[N])
Gn = exp(-1.0im * τ/2 * hn)
push!(gates,Gn)
append!(gates,reverse(gates))
</code></pre>
<p>Thanks so much for the help!</p>
http://itensor.org/support/3795/computing-correlation-functionThu, 03 Mar 2022 18:23:09 +0000DMRG for 2D lattices with rotational symmetry
http://itensor.org/support/3794/dmrg-for-2d-lattices-with-rotational-symmetry
<p>Dear community,</p>
<p>I am trying to simulate a 2D Hamiltonian on a rectangular lattice geometry using DMRG in Julia, and I expect the ground state of my system to be invariant under a pi rotation of the lattice.</p>
<p>I was wondering if just performing the DMRG sweeps on half of the MPS and copying the resulting ITensors on the other side of the system could help enforce this symmetry.</p>
<p>Would it be useful (and efficient) compared to performing the whole sweep?</p>
<p>Looking at the <a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/blob/10d870155ef78ee6c1257ea07f9c1571a651c3bc/src/mps/dmrg.jl#L20-L39">dmrg.jl</a> file it looks like I would just have to change the for loop in line 201 to <code>for (b, ha) in sweepnext(Int(N/2))</code> and then do something like <code>psi[end] = psi[1]</code>, <code>psi[end-1] = psi[2]</code> and so on.</p>
<p>For this last point, is there a way to efficiently replace the values of one ITensor with the ones of another without changing the indices? I tried using <code>replacebond!</code> without success as there is a mismatch in the indices of the two tensors.</p>
<p>Best, <br>
Niccolò</p>
http://itensor.org/support/3794/dmrg-for-2d-lattices-with-rotational-symmetryWed, 02 Mar 2022 15:24:22 +0000The principle of calculating excited states using DMRG
http://itensor.org/support/3784/the-principle-of-calculating-excited-states-using-dmrg
<p>In ITensor we can use 'DMRG' to target excited states using ground state and Hamiltonian. <br>
I am curious about the principle of it.<br>
Would you please share the papers to calculate excited state that ITensor referred to?<br>
Thank you so much for your sharing and this wonderful ITensor library. </p>
http://itensor.org/support/3784/the-principle-of-calculating-excited-states-using-dmrgSun, 20 Feb 2022 13:41:49 +0000Spontaneous symmetry breaking and ground state
http://itensor.org/support/3783/spontaneous-symmetry-breaking-and-ground-state
<p>Hi, </p>
<p>I am using dmrg in the ITensor Julia version to calculate various excited states in the 1D spin system. There is a Z2 spontaneous symmetry breaking which should lead to two ground states. I was wondering whether dmrg output for ground state energy in ITensor provides both of these ground states ( one as ground state and the second ground state as an excited state) or a linear combination of them leads to ground state. I would like to know if there is any way to get both ground states rather than a linear combination. </p>
<p>Also, while calculating excited state energy using dmrg, how does the choice of "Weight" will impact the answer? What would be a good guess ( or approach) for choosing the value of "Weight" if a gap is closing between the excited state and ground state or the gap is very small?</p>
<p>Thank you so much,</p>
<p>Best,<br>
Ajit</p>
http://itensor.org/support/3783/spontaneous-symmetry-breaking-and-ground-stateSun, 20 Feb 2022 02:52:36 +0000DMRG FOR TWO LEG LADDER MODEL
http://itensor.org/support/3780/dmrg-for-two-leg-ladder-model
<p>i am trying to calculate the ground state energy of a two leg ladder model by DMRG method using ITensor(Julia), but i have some doubts regarding this. the questions are as follows.</p>
<p>a)How to introduce the electron density parameter in the code ? For example : At Half filling of 1D Hubbard model(Spin-1/2 electrons) the electron density is 1/2. ( I know one can calculate total no. of electrons from electron density ,put it in the initial state of the code and keep the filling quantum number fixed, but i am asking can i put the electron density parameter directly in the code?)</p>
<p>b) Is there anyway to calculate the expectation values("Sz" or "Ntot" or anyother ) after each sweep rather then after all sweeps?</p>
<p>Sorry if i have asked very basic questions.</p>
<p>Thanks</p>
<p>Paban</p>
http://itensor.org/support/3780/dmrg-for-two-leg-ladder-modelMon, 14 Feb 2022 19:44:54 +0000Customising the 'Custom SiteSet' in the Site set class ?
http://itensor.org/support/3762/customising-the-custom-siteset-in-the-site-set-class
<p>Hi,</p>
<p>I was wondering If it is possible to create a single site set that describes 2 ( or possibly three) particles ( spin one-half, electrons, bosons etc.) in the current version of ITensor (C++). An example to this would be trying to create a ladder system of particles, but instead of the Zigzag method, could I create a single site set that supports 2 particles?</p>
<p>Cheers</p>
http://itensor.org/support/3762/customising-the-custom-siteset-in-the-site-set-classWed, 09 Feb 2022 09:37:40 +0000Stopping a DMRG Run "Gracefully"
http://itensor.org/support/3745/stopping-a-dmrg-run-gracefully
<p>Dear all,</p>
<p>I read this <a rel="nofollow" href="https://itensor.org/docs.cgi?vers=cppv3&page=formulas/stopping_dmrg">post</a> (C++ implementation) on how to stop dmrg sweeps without killing the entire program. Can this be implemented in Julia?</p>
<p>Cheers!</p>
http://itensor.org/support/3745/stopping-a-dmrg-run-gracefullyFri, 04 Feb 2022 22:18:41 +0000[julia] TEBD gates involving fermions
http://itensor.org/support/3743/julia-tebd-gates-involving-fermions
<p>Dear all,</p>
<p>I am trying to generalize the TEBD method mentioned <a rel="nofollow" href="https://itensor.github.io/ITensors.jl/stable/tutorials/MPSTimeEvolution.html">here</a> to a case involving fermions. When changing the following part</p>
<pre><code>gates = ITensor[]
for j=1:N-1
s1 = s[j]
s2 = s[j+1]
hj = op("Sz",s1) * op("Sz",s2) +
1/2 * op("S+",s1) * op("S-",s2) +
1/2 * op("S-",s1) * op("S+",s2)
Gj = exp(-1.0im * tau/2 * hj)
push!(gates,Gj)
end
</code></pre>
<p>to include some fermion operators, do we need to manually add JW strings? I am not sure whether these <code>gates</code> already implement JW string like <code>OpSum</code> or not.</p>
<p>Best,<br>
Junsen</p>
http://itensor.org/support/3743/julia-tebd-gates-involving-fermionsFri, 04 Feb 2022 18:19:13 +0000[julia] how to create local identity operator
http://itensor.org/support/3738/julia-how-to-create-local-identity-operator
<p>Dear all</p>
<p>How to create local identity operator at site j? Indirectly, one can use the identity "S^z<em>jS^z</em>j" or "projUp+projDn", which have built-in functions like <code>op("Z",sites,j)</code> and <code>op("projDn",sites,j)</code>. Is there a more standard way?</p>
<p>Moreover, how about high-spin sites, fermion/electron sites?</p>
<p>Best,<br>
Junsen</p>
http://itensor.org/support/3738/julia-how-to-create-local-identity-operatorThu, 03 Feb 2022 14:41:40 +0000DMRG for phase transitions
http://itensor.org/support/3730/dmrg-for-phase-transitions
<p>Hello,</p>
<p>My understanding is that DMRG can be successfully used to study phase transitions and calculating critical exponents, etc. Yet, I am having trouble getting sufficient convergence for a range of parameters, in order to properly find the critical point and extract critical exponents. This happens or several different models, so I suspect that I am simply not using it properly. So let me describe some specific issues I encounter.<br>
I am running DMRG (on the c++ version) for different parameters @@\lambda@@ and systems sizes @@L@@, recording the expectation value of the Z2 order parameter @@\phi@@.<br>
Here are 3 runs, relatively close to the phase transition:<br>
$$ <br>
\lambda =0.259592, \phi = 0.698822, E_GS =-7.39535 </p>
<p>\lambda =0.26, \phi = 0.0681269, E_GS =-7.39147 </p>
<p>\lambda =0.260816, \phi = 0.633245, E_GS = -7.37986 <br>
$$<br>
The second run @@\lambda=0.26@@, despite being very close in parameter space to the other two, ends up being stuck in the wrong phase (at least, I suspect that the outer two are correct and the middle one is wrong).</p>
<p>I am doing at least 40 sweeps, with the schedule below:</p>
<pre><code>sweeps
{
maxm minm cutoff niter noise
10 1 1E-5 3 1e-05
10 1 1E-5 3 1e-05
10 1 1E-6 3 1e-05
10 1 1E-7 3 1e-05
10 1 1E-7 3 1e-07
10 1 1E-7 3 1e-07
10 1 1E-7 3 1e-07
10 1 1E-7 3 1e-07
15 1 1E-7 3 1e-07
15 1 1E-7 3 1e-09
15 1 1E-7 3 1e-09
20 1 1E-7 2 1e-09
20 1 1E-8 2 1e-09
20 1 1E-8 2 1e-12
20 1 1E-8 2 1e-12
20 1 1E-8 2 1e-12
30 1 1E-9 2 1e-12
50 1 1E-9 2 1e-12
100 1 1e-9 2 1e-07
100 1 1E-9 2 0
}
</code></pre>
<p>I did vary all the seep parameters, without much success. <br>
The two outer runs seem to converge with a much smaller bond dimension. The largest m during the last 40th sweep was 37, 51, 34, respectively (which I think simply reflects the higher entanglement in the symmetric phase). In all cases, it is quite much smaller than the maxm I allow.<br>
For concreteness, this is a bosonic phi^4 model. The above is for @@L=100@@ and @@maxOcc=16@@. The starting state is a product state of coherent states on each site with finite @@\phi@@. This is an attempt starting close to one of the symmetry broken states. I think this generally works better than a randomMPS.</p>
<p>I suspect that for some system sizes I get an entire curve of @@\phi@@ vs @@\lambda@@ which are incorrect, whereas for other @@L@@, it seems to converge properly.<br>
Any tips are greatly appreciated!</p>
http://itensor.org/support/3730/dmrg-for-phase-transitionsSun, 30 Jan 2022 08:19:12 +0000Symmetry breaking in the transverse field Ising model/ Kitaev chain
http://itensor.org/support/3729/symmetry-breaking-transverse-field-ising-model-kitaev-chain
<p>I have been doing some simple experiments with the transverse field Ising model and its Jordan Wigner transformed version, the Kitaev chain, in the Julia version of ITensor. I am trying to understand how DMRG deals with ground state degeneracies/ topological degeneracies. I have a few questions about this:</p>
<ol>
<li><p>When the transverse field is zero or small, DMRG ends up picking one of the two ferromagnetically ordered states at random. Why does it not pick linear combinations? My guess would be: Linear combinations of the ordered states have long range entanglement. This cannot be captured by DMRG because it arrives at the ground state by optimizing local bonds. Is that correct?</p></li>
<li><p>Also, the MPS representation of these linear combinations would have a tiny bond dimension of 2. So what is the signature of long range entanglement in the MPS representation if it is not a large bond dimension?</p></li>
<li><p>Is there any way though to force the DMRG to pick up one of the cat states? </p></li>
<li><p>One possibility is to Jordan Wigner transform the Ising model to a Kitaev chain. When I compute ground states for the Kitaev chain with open boundary conditions in the topological phase, DMRG always picks up a uniform superposition of the even and odd parity states. This would correspond to the ordered states in the spin language. Again, why does DMRG do this? Does the long range entanglement argument translate into the fermion language as well?</p></li>
<li><p>A side comment/ question about this: Even though DMRG picks up the "ordered" state, when I compute the expectation value of the Jordan Wigner spin sz, I get zero instead of +1 or -1 which is expected of the ordered state.</p></li>
<li><p>Upon adding periodic or anti-periodic boundary terms, DMRG ends up picking the even or odd parity state (and this would correspond to picking up a cat state in the spin language). My question about this is the following: For the DMRG to successfully pick a definite parity state, I need a large enough bond dimension for the initial state psi0 (the number of sweeps does not matter so much). Why is this the case when the final bond dimension of the cat state is just 2? And how should the bond dimension of the initial state scale with system size to enable the DMRG to converge to a definite parity ground state?</p></li>
</ol>
<p>Thank you! </p>
http://itensor.org/support/3729/symmetry-breaking-transverse-field-ising-model-kitaev-chainFri, 28 Jan 2022 17:36:38 +0000Time evolution of local green function using two applyMPO for spinless-fermions.
http://itensor.org/support/3725/evolution-local-green-function-applympo-spinless-fermions
<p>Hi,<br>
I am trying to calculate the local green function G<em>ii(t)= <\psi</em>0|Cdag<em>i(t)C</em>i|\psi<em>0> at site i=N, using two applyMPO for one-dimensional Kitaev model [equation 1 of PRB 88, 161103(R) (2013)]. For this I am doing following steps:<br>
(i) I am calculating |\phi>=C</em>i |\psi<em>0> by applying local operator C</em>i to the ground state |psi<em>0>. <br>
(ii) Time evolution of |\phi> using applyMPO: |phi(t)>=exp(-iHt)|\phi>.<br>
(iii) Application of local operator Cdag</em>i to |\phi(t): Cdag<em>i|phi(t)>. <br>
(iv)Time evolution of |psi</em>0> using applyMPO: |psi(t)>=exp(-iHt)|\psi_0>.<br>
(v) Overlap of <psi(t)|phi(t)> using innerC. </p>
<p>After running the code, I am getting non-zero values for the odd time steps and zero for even number of time steps:<br>
0.001 -0.000605309 -0.671164<br>
0.002 0 -0<br>
0.003 0.00300302 0.671158<br>
0.004 0 -0<br>
0.005 -0.00540069 -0.671143</p>
<p>Here is the code: </p>
<p>`//-------------Creating |phi> = C_i1|Psig>--------</p>
<pre><code> auto i1=N; // for site i1=N.
psig.position(i1);
auto newpsi = noPrime(psig(i1)*op(sites,"A",i1));
psig.set(N, newpsi);
</code></pre>
<p>//--------------Jordan-Wigner string----------------------</p>
<pre><code> for(int k = i1-1; k >=1; k--)
{
psig.position(k);
auto newpsi1 = noPrime(psig(k)*op(sites,"F",k));
psig.set(k, newpsi1);
}
psig.noPrime().normalize();
</code></pre>
<p>auto tau=0.001;<br>
auto ii = Complex<em>i;<br>
auto args = Args("Method=","DensityMatrix","Cutoff=",1E-14,"MaxDim=",7000);<br>
auto expH = toExpH(ampo,tstep*Cplx</em>i);<br>
//-------------Time Evolution-------------------------- </p>
<pre><code>auto nt = int(ttotal/tau+(1e-9*(ttotal/tau)));
for(int n = 1; n <= nt;++n)
{
psig = applyMPO(expH,psig,args);
psig.noPrime().normalize();
</code></pre>
<p>//--Jordan-Wigner string</p>
<pre><code> for(int k = 1; k <i1; ++k)
{
psig.position(k);
auto newpsi2 = noPrime(psig(k)*op(sites,"F",k));
psig.set(k, newpsi2);
}
</code></pre>
<p>// ----------------- Cdag|phi(t)>--------------------</p>
<pre><code> psig.position(i1);
auto newpsi3 = noPrime(psig(i1)*op(sites,"Adag",i1));
psig.set(i1, newpsi3);
psig.noPrime().normalize();
</code></pre>
<p>//------------------psi(t)>=exp(-iHt)|psig>----------------------- </p>
<pre><code> psi = applyMPO(expH,psi,args);
psi.noPrime().normalize();
auto result2 = -ii*innerC(psi,psig);
file2<<float(n*tstep)<<' '<< result2.real()<<' ' <<result2.imag() <<std::endl;
</code></pre>
http://itensor.org/support/3725/evolution-local-green-function-applympo-spinless-fermionsTue, 25 Jan 2022 14:29:18 +0000Spatial parity inversion of MPS using SWAP gates
http://itensor.org/support/3719/spatial-parity-inversion-of-mps-using-swap-gates
<p>I have a model of two sets of energy levels coupled to an impurity (like a two channel Kondo model). The MPO is implemented such that the MPS has a L(eft channel) - imp(urity) - R(ight channel) geometry. I am using the c++ version of ITensor. </p>
<p>When the physical parameters are symmetric, this system has spatial inversion symmetry. To measure it, I want to implement a parity operator that swaps the L and R channels in the MPS. For 7 sites the action of this operator would transform the mps (1, 2, 3) - 4 - (5, 6, 7) into (5, 6, 7) - 4 - (1, 2, 3). Measuring the overlap of the new state with the original should give me parity. </p>
<p>I implemented the permutation of channels by using SWAP gates to permute neighbouring sites so that the channels get swapped. I tried using the BongGate class and also the svd trick mentioned in Miles' comment from Sep 13, 2019 <a rel="nofollow" href="http://itensor.org/support/760/swap-gates-for-non-identical-sites">here</a>. I check that the permutation is correct by comparing occupation numbers (or even local density matrices) of sites in the old and new state. Then, I compute parity as inner(psi, newpsi). </p>
<p>There are two problems:</p>
<p>a) The approach does not seem to be correct. For symmetrical parameters, the parity should be 1 or -1, but the result is typically at least a few percent off (depends on physical parameters and symmetry sector chosen - I have observed that taking half-filling gives results closer to 1 (but still on the order of 0.98), but am not sure whether this is relevant). I also tried permuting the siteIndeces of the MPS using the delta tensor as indicated <a rel="nofollow" href="http://itensor.org/support/375/reflecting-an-mps">here</a>, but it does not seem to do anything - the overlap always gives 1, even with asymmetric physical parameters. </p>
<p>b) The approach will not work for large system sizes, as permuting the levels with SWAP gates blows up the MPS in memory. </p>
<p>My question is two-fold.<br>
What is wrong with my approach? <br>
And what would be a better way to obtain parity? </p>
http://itensor.org/support/3719/spatial-parity-inversion-of-mps-using-swap-gatesMon, 24 Jan 2022 09:02:18 +0000toExpH in Julia
http://itensor.org/support/3718/toexph-in-julia
<p>Hi, </p>
<p>does there exist a toExpH analog in the Julia version?</p>
<p>Best,<br>
Andreas</p>
http://itensor.org/support/3718/toexph-in-juliaMon, 24 Jan 2022 05:18:52 +0000Possible bug in on-site terms - AutoMPO (C++)
http://itensor.org/support/3716/possible-bug-in-on-site-terms-autompo-c
<p>I am noticing a bug when I use AutoMPO for building the following bosonic Hamiltonian<br>
$$ <br>
H = \sum_j n_j n_j <br>
$$ <br>
Essentially, it looks like it does not do the square correctly. For example, if I run the following code (I don't impose conservation of particles, since in the actual model I have been investigating it is not conserved)</p>
<pre><code>int size = 2;
int cutoff = 3;
SiteSet sites = Boson(size,{"ConserveQNs",false,"MaxOcc=",cutoff});
auto ampo = AutoMPO(sites);
for(int j = 1 ; j <= size ; j++) ampo += 1 , "N", j , "N", j ;
MPO H = toMPO(ampo,{"Exact=",true});
PrintData(H(1));
</code></pre>
<p>The output does not appear to be n^2:</p>
<p>H(1) = <br>
ITensor ord=3: (dim=4|id=952|"n=1,Site,Boson") (dim=4|id=952|"n=1,Site,Boson")' (dim=3|id=827|"l=1,Link") <br>
{norm=8.60 (Dense Real)}<br>
(1,1,1) 1.0000000<br>
(2,2,1) 1.0000000<br>
(3,3,1) 1.0000000<br>
(4,4,1) 1.0000000<br>
(2,2,2) 2.0000000<br>
(3,3,2) 4.0000000<br>
(4,4,2) 6.0000000<br>
(2,2,3) 1.0000000<br>
(3,3,3) 2.0000000<br>
(4,4,3) 3.0000000</p>
<p>Am I missing something?</p>
<p>Thank you in advance!</p>
http://itensor.org/support/3716/possible-bug-in-on-site-terms-autompo-cFri, 21 Jan 2022 19:13:50 +0000How to calculate string operator in ITensor-3 C version
http://itensor.org/support/3715/how-to-calculate-string-operator-in-itensor-3-c-version
<p>Dear ITensor team,<br>
Thanks for the reply. Recently, I want to calculate string operator in Haldane phase., e.g. <s^{z}<em>{I}exp(I\pi\sum</em>{k}<em>{i=<k<j}s^{z}</em>{k})s^{z}_{j}>, but in ITensor doc, I just find time evolution exponential operation (for t must be small) but not find exponential the ordinary autoMPO. So I want to ask how do we calculate the string operator in the simple way ? Many thanks ! <br>
Best regards,<br>
sugar</p>
http://itensor.org/support/3715/how-to-calculate-string-operator-in-itensor-3-c-versionThu, 20 Jan 2022 03:51:56 +0000[julia] Out of memory problem
http://itensor.org/support/3700/julia-out-of-memory-problem
<p>Dear all,</p>
<p>I have obtained the ground state MPS wavefunction, Now the problem is: when calculating the correlators, I encounter the "out of memory error" and the program get killed.</p>
<p>Note this problem is similar to <a rel="nofollow" href="http://itensor.org/support/3528/out-of-memory-error-when-using-correlation_matrix?show=3528#q3528">this one</a>, but in my case the correct code for calculating the correlator has been implemented, but the problem remains...</p>
<p>I guess there may be some way to save the intermediate data into disk? Can someone give me more details on how to do it, or give me some links about this method.</p>
http://itensor.org/support/3700/julia-out-of-memory-problemTue, 18 Jan 2022 16:47:34 +0000Working in different subspace
http://itensor.org/support/3699/working-in-different-subspace
<p>Dear ITensor comminuty </p>
<p>I am interested to probe the minimum energy of a general many-body Hamiltonian, let's say spin models, in different subspaces. For example, plotting the E<em>{min} versos S^z</em>{total} }.</p>
<p>any comments and help would be appreciated</p>
<p>Regards<br>
Javad </p>
http://itensor.org/support/3699/working-in-different-subspaceTue, 18 Jan 2022 13:50:00 +0000[julia] unexpected fermion density configuration in CDW phase
http://itensor.org/support/3692/julia-unexpected-fermion-density-configuration-cdw-phase
<p>Dear all,</p>
<p>As a simple exercise, I examine the CDW phase of the spinless fermion chian (with nearest neighbor interaction) at half filling.</p>
<p>For @@U@@ small, the fermion density configuration is almost flat, with something like Friedel oscillation at two ends.</p>
<p>However, for @@U@@ large, the fermion density configuration is not a standard CDW, but forming a symmetric crossing at the center site, like this:<br>
<img src="https://i.ibb.co/k3xqC1p/1642406625-1.png" alt="large U"></p>
<p>This configuration is somehow expected, since it is more symmetric than the usual 101010,<br>
but how can i recover this standard result?</p>
<p>In case needed, the code I use is given below:</p>
<pre><code>using LinearAlgebra
using MKL
using ITensors
using HDF5
let
N = 20
t1 = 1.0
U = 50
sites = siteinds("Fermion", N; conserve_qns=true)
ampo = OpSum()
for j in 1:(N-1)
ampo += -t1, "Cdag", j+1, "C", j
ampo += -t1, "Cdag", j, "C", j+1
end
for j in 1:(N-1)
ampo += U, "N", j, "N",j+1
end
H = MPO(ampo, sites)
nthreads = 8
BLAS.set_num_threads(nthreads)
sweeps = Sweeps(300)
etol = 1E-9
obs1 = DMRGObserver(;energy_tol=etol,minsweeps=20)
obs2 = DMRGObserver(;energy_tol=etol,minsweeps=10)
obs3 = DMRGObserver(;energy_tol=etol,minsweeps=10)
setmaxdim!(sweeps, 20, 30, 50, 100, 200, 300, 500, 1000, 2000)
setcutoff!(sweeps, 1E-10)
vnoi = [1E-5 for i in 1:10]
setnoise!(sweeps, 1E-3, 1E-4, vnoi...,
1E-6, 1E-7, 1E-8, 1E-9, 1E-10,
1E-11, 1E-12, 0.0)
state = [isodd(n) ? "Emp" : "Occ" for n in 1:N]
psii = randomMPS(sites, state, 10)
energy0, psi0 = dmrg(H, psii, sweeps;observer=obs1)
n = expect(psi0,"N")
end
</code></pre>
http://itensor.org/support/3692/julia-unexpected-fermion-density-configuration-cdw-phaseMon, 17 Jan 2022 08:00:07 +0000[C++ ITensor 3] MPO time evolution does not work for large interactions
http://itensor.org/support/3691/itensor-time-evolution-does-not-work-for-large-interactions
<p>Hi,</p>
<p>It seems the MPO time evolution gives wrong results for large interactions. The sample code is below.</p>
<pre><code>#include "itensor/all.h"
using namespace std;
using namespace itensor;
int
main(int argc, char* argv[])
{
int N = 10;
auto sites = Boson(N,{"MaxOcc=",1,"ConserveQNs=",false});
auto state = InitState(sites);
for(int i = 1; i <= N; ++i)
{
state.set(i,"0");
}
auto psi0 = MPS(state);
auto psi = MPS(state);
auto ampo = AutoMPO(sites);
//Make the Hamiltonian
for(int b = 1; b < N; ++b)
{
ampo += 10.0,"N",b,"N",b+1;
}
for(int b = 1; b <= N; ++b)
{
ampo += 0.5,"Adag",b;
ampo += 0.5,"A",b;
ampo += -2.0,"N",b;
}
auto H = toMPO(ampo);
auto tau = 0.1;
//auto expH = toExpH(ampo,tau);
auto expH = toExpH(ampo,tau*Cplx_i);
auto args = Args("Method=","DensityMatrix","Cutoff=",1E-9,"MaxDim=",3000);
auto ttotal = 3.0;
auto nt = int(ttotal/tau+(1e-9*(ttotal/tau)));
for(int n = 1; n <= nt; ++n)
{
psi = applyMPO(expH,psi,args);
psi.noPrime().normalize();
auto ovlp = norm(innerC(psi,psi0));
auto bb = n*tau;
printfln("\nOverlap at time %.4f %.20f",bb,ovlp);
}
return 0;
}
</code></pre>
<p>When the NN interaction is large, like 10.0, the overlap between the time-evolved psi and the initial psi will quickly become "0.00000000000000000000" and then keeps zero forever. This makes no sense. Is this due to the algorithm itself or some bug in the code? Thanks.</p>
<p>Jin</p>
http://itensor.org/support/3691/itensor-time-evolution-does-not-work-for-large-interactionsMon, 17 Jan 2022 05:42:44 +0000How to create a random state with definite fermion parity?
http://itensor.org/support/3690/how-to-create-a-random-state-with-definite-fermion-parity
<p>I wish to perform fermion parity conserving DMRG in Julia. In order to do this, I need to create an initial state psi0 with a definite fermion parity. I tried doing this by specifying input states with a definite number of fermonic sites being occupied. However, such input states are turning out to be too "regular" and lead to the DMRG getting stuck in a local minimum. How can I create random enough definite fermion parity states? Thank you! </p>
http://itensor.org/support/3690/how-to-create-a-random-state-with-definite-fermion-paritySun, 16 Jan 2022 16:26:44 +0000