ITensor Support Q&A - Recent questions
http://itensor.org/support/questions
Powered by Question2AnswerPeriodic MPO
http://itensor.org/support/2953/periodic-mpo
<p>I am studying a 1d quantum chain by DMRG, and want to measure (psi, O * psi) for a periodic MPO O.</p>
<p>I know that ITensor is mainly designed for open chains, but for my current project it is quite important that I study the periodic chain, even if I am limited to short chains due to the much worse computational efficiency.</p>
<p>I am currently trying to construct a periodic MPO, where every site is the same tensor T, but I do not know how to link the leftmost site 1 to the rightmost site N. Can I add fictitious links for all neighboring pairs (1,2) (2,3) (3,4) ... (N-1,N) to connect 1 and N?</p>
<p>AutoMPO is able to construct an MPO even when there is an interaction involving sites 1 and N, so I wonder if there is some universal way to do this for any MPO. AutoMPO assumes that we have a sum of tensor products of 1-site operators, but I hope to relax this assumption.</p>
<p>I also tried the following and failed: act twice by a right-moving translation MPO constructed out of swaps, and then setting sites 2 and 3 to be T. I surmise that the failure is because after acting translation, the physical link (N,1) is now represented by numerous links involving all sites in the open MPO representation, and setting 2 and 3 to T destroyed some of those links.</p>
<p>Another workaround is try to represent my MPO as a product of few-site gates, say 2-site. In this case, the leftmost and rightmost sites can be linked by a translation(+1)---gate(1,2)---translation(-1) sequence. But generally finding such a product representation for an arbitrary all-site operator may be quite difficult, so I am hoping that there is some alternative.</p>
<p>Thank you very much!</p>
http://itensor.org/support/2953/periodic-mpoMon, 12 Apr 2021 03:11:52 +0000How to use ITensor to simulate doped spinful Hubbard chain ?
http://itensor.org/support/2950/how-to-use-itensor-to-simulate-doped-spinful-hubbard-chain
<p>Dear ITensor Team, <br>
Thanks for your reply. Recently, I want to repeat entanglement entropy calculation as Fig.1 in Phys. Rev. Lett. 110, 115701 by using ITensor v3, which is just simulate 1/4 doped hubbard chain. I followed the tutorial <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=formulas/entanglement_mps">http://itensor.org/docs.cgi?vers=cppv3&page=formulas/entanglement_mps</a></p>
<p>But i find my results(entropy and energy) are not converge ( we get different results every time )when i increase bond dimension. Is there any bug in my naive code? Please help me. Many thanks!</p>
<p>There is my naive code:</p>
<p>int main()<br>
{<br>
int Nx = 24;</p>
<p>auto N = Nx;<br>
auto sites = Electron(N);</p>
<p>auto t = 1.0;</p>
<p>auto ampo = AutoMPO(sites);</p>
<p>for(int j=1; j<N; ++j)<br>
{<br>
ampo += -t, "Cdagup",j,"Cup",j+1;<br>
ampo += -t, "Cdagdn",j,"Cdn",j+1;<br>
}</p>
<p>for(int j=1; j<=N;++j)<br>
{<br>
ampo +=UU, "Nupdn",j;<br>
}</p>
<p>auto H = toMPO(ampo);</p>
<p>auto state = InitState(sites,"Emp");<br>
// for this part, naively, i want to doped my hubbard chain, is that correct?<br>
for(int i=1; i<=Nx/4; ++i)<br>
{<br>
state.set(i,"Up");<br>
}<br>
for(int i=Nx/4+1; i<=Nx/2; ++i)<br>
{<br>
state.set(i,"Dn");<br>
}</p>
<p>auto sweeps = Sweeps(10);<br>
sweeps.maxdim() = 10, 20, 50,500;<br>
sweeps.noise() = 1E-7, 1E-8, 1E-10, 0;<br>
sweeps.cutoff() = 1E-10;</p>
<p>PrintData(sweeps);</p>
<p>auto psi0 = MPS(state);<br>
auto [energy,psi] = dmrg(H,psi0,sweeps,{"Quiet=",true});</p>
<p>PrintData(Nx);<br>
PrintData(UU);<br>
PrintData(t);<br>
PrintData(totalQN(psi));<br>
PrintData(maxLinkDim(psi));<br>
PrintData(energy);</p>
<p>//Given an MPS called "psi",<br>
//and some particular bond "b" (1 <= b < length(psi))<br>
//across which we want to compute the von Neumann entanglement<br>
auto b = Nx/2;</p>
<p>//"Gauge" the MPS to site b<br>
psi.position(b); </p>
<p>//SVD this wavefunction to get the spectrum<br>
//of density-matrix eigenvalues<br>
auto l = leftLinkIndex(psi,b);<br>
auto s = siteIndex(psi,b);<br>
auto [U,S,V] = svd(psi(b),{l,s});<br>
auto u = commonIndex(U,S);</p>
<p>//Apply von Neumann formula<br>
//to the squares of the singular values<br>
Real SvN = 0.;<br>
for(auto n : range1(dim(u)))<br>
{<br>
auto Sn = elt(S,n,n);<br>
auto p = sqr(Sn);<br>
if(p > 1E-12) SvN += -p<em>log(p);<br>
}<br>
printfln("Across bond b=%d, SvN = %.10f",b,SvN-2</em>log(Nx)/3.0);<br>
printfln("Across bond b=%d, SvN = %.10f",b,SvN);</p>
<p>return 0;<br>
}</p>
http://itensor.org/support/2950/how-to-use-itensor-to-simulate-doped-spinful-hubbard-chainFri, 09 Apr 2021 07:56:39 +0000Discrepancy in correlation functions calculated from ED and DMRG for free fermions
http://itensor.org/support/2935/discrepancy-correlation-functions-calculated-free-fermions
<p>I was wondering if you could help me with the following issue: For the sake of benchmarking my code, I am considering free fermions hopping on a 1D lattice, and set the filling to 2 fermions only. I furthermore set the spins of both electrons to be up. I use DMRG to solve this problem.<br>
On the other hand, I solve it by diagonalizing the Hamiltonian matrix.</p>
<p>Then I look at correlation functions such as $\langle \psi | c^\dagger<em>i c</em>j | \psi \rangle$ in the above two cases, but the off-diagonal elements of such matrix differ in the two cases. </p>
<p>Could you please check and let me know how I can resolve this problem? I provided a minimal code below, sorry it got long. I used your own example of DMRG for the extended Hubbard model.</p>
<p>Thank you</p>
<pre><code>using ITensors
using LinearAlgebra
N = 10
Npart = 2
t1 = 1.0
sites = siteinds("Electron", N;
conserve_qns = true)
ampo = AutoMPO()
for b=1:N-1
ampo += -t1, "Cdagup", b, "Cup", b+1
ampo += -t1, "Cdagup", b+1, "Cup", b
ampo += -t1, "Cdagdn", b, "Cdn", b+1
ampo += -t1, "Cdagdn", b+1, "Cdn", b
end
H = MPO(ampo,sites)
sweeps = Sweeps(6)
maxdim!(sweeps,50,100,200,400,800,800)
cutoff!(sweeps,1E-12)
state = ["Emp" for n=1:N]
for i=1:Npart
state[i] = "Up"
end
psi0 = randomMPS(sites, state, min(10, floor(Int,N/2) ))
# Check total number of particles:
@show flux(psi0)
# Start DMRG calculation:
energy, psi = dmrg(H, psi0, sweeps)
println("\nGround State Energy = $energy")
#Below, correlation functions using the DMRG solution are calculated:
cor_mat_mps = zeros(N,N);
for i = 1:N
orthogonalize!(psi,i)
s_ind_i = siteind(psi,i);
for j =1:N
if j < i
continue
end
s_ind_j = siteind(psi,j);
if i == j
cor_mat_mps[i,i] = scalar(
psi[i] * prime( dag(psi[i]) , s_ind_i ) * op(s_ind_i,"Nup")
);
else
prod_aux = psi[i];
for n = i+1:j
prod_aux *= psi[n];
end
cor_mat_mps[i,j]= scalar(
prod_aux * prime( dag(prod_aux) , s_ind_i, s_ind_j) *
op(s_ind_i,"Cdagup")*op(s_ind_j,"Cup")
);
cor_mat_mps[j,i]= scalar(
prod_aux * prime( dag(prod_aux) , s_ind_i, s_ind_j) *
op(s_ind_j,"Cdagup")*op(s_ind_i,"Cup")
) ;
end
end
end
# The same Hamiltonian is diagonalized below and correlation functions are calculated.
h_nonint = zeros(N,N);
for n = 1:N
for m = 1:N
# h_nonint[n,m] = 0.01*rand();
if abs(m-n) == 1
h_nonint[n,m] = -1. ;
end
end
end
diagonalization_energy = sum( eigen(Hermitian(h_nonint)).values[1:2] );
println("\nGround State Energy from diagonalization = $diagonalization_energy")
vecs = eigen(Hermitian(h_nonint)).vectors;
cor_direct = zeros( N,N );
for m = 1:N
for n = 1:N
cor_direct[m,n] = conj(vecs[m,1]) * vecs[n,1];
cor_direct[m,n] += conj(vecs[m,2]) * vecs[n,2];
end
end
println()
# below, the difference between correaltion functions calcualted in the two ways is shown, first only the diagonal terms and then all the correlation matrix.
println( norm(diag(cor_direct-cor_mat_mps)) )
println( norm(cor_direct-cor_mat_mps) )
</code></pre>
http://itensor.org/support/2935/discrepancy-correlation-functions-calculated-free-fermionsWed, 31 Mar 2021 05:17:29 +0000Calculating fidelity with iMPS
http://itensor.org/support/2931/calculating-fidelity-with-imps
<p>Edit: I have made some progress with this but I'm on holiday at the moment. I will add something in the next couple of weeks.</p>
<p>Dear Miles/Matt/ITensor,</p>
<p>I've been using your iDMRG example code (idmrg.h etc) and I've adapted it to some models I'm interested in. My goal is to use the fidelity and fidelity per site (and their susceptibilities) to examine the phase diagram. For a finite system, the fidelity is simply the overlap of the ground states at two different values of some parameter of the Hamiltonian. I'm able to calculate the "overlap" of two iMPS's with some code adapted from your examples - this required some modifications to make the site indices match if they were created from different SiteSet instances. I believe this is appropriate for the fidelity but I'm not sure, and it offers no way to calculate the fidelity per site. I've added this code below.</p>
<p>In McCulloch's, "Infinite size density matrix renormalization group, revisited" (section D. Fidelity), he suggests a method using the eigenvalues of a transfer matrix Eq. (39). I'm having difficulty understanding this section, in particular what 'E' denotes in Eq. (39). I've gone through the references but I haven't been able to decipher it. However, McCulloch seems to imply the procedure is fairly simple.</p>
<p>So, I was wondering if you have any suggestions on how to calculate the fidelity (per site) from iMPS's.</p>
<p>Cheers,<br>
Alex Henry</p>
<pre><code>Complex ioverlap(MPS &psi1, MPS &psi2, bool same) {
if (same) {
// if psi1 and psi2 already have the same site indices
auto O = dag(psi1(1)) * psi2(1);
for (auto n : range1(2, length(psi2)))
O = O * dag(psi1(n)) * psi2(n);
auto ovrlap = real(eltC(O));
return ovrlap;
}
auto O = dag(psi1(1)) * psi2(1);
auto l1 = findIndex(dag(psi1(1)), "Site");
auto l2 = findIndex(psi2(1), "Site");
O = O * delta(l1, l2);
for (auto n : range1(2, length(psi2))) {
auto a = dag(psi1(n));
auto b = psi2(n);
l1 = findIndex(a, "Site");
l2 = findIndex(b, "Site");
auto link = delta(l1, l2);
a = a * link;
O = O * a * b;
}
auto overlap = real(eltC(O));
return overlap;
}
</code></pre>
http://itensor.org/support/2931/calculating-fidelity-with-impsThu, 25 Mar 2021 03:13:30 +0000Is it normal that the Julia version gives different results on AMD cores from those on intel cores?
http://itensor.org/support/2929/normal-version-gives-different-results-cores-those-intel-cores
<p>Hi,</p>
<p>I noticed that ITensors.jl gives different results on AMD cores from those on intel cores. In some calculations, this small discrepancy may results in very different results in the large volume limit, that is, the RG flow goes to the wrong fixed point.</p>
<p>Sorry I didn't prepare the sample code for this question. I wonder if this is normal or not before doing that. Thanks.</p>
<p>Jin</p>
http://itensor.org/support/2929/normal-version-gives-different-results-cores-those-intel-coresTue, 23 Mar 2021 02:07:54 +0000Specific Questions about Constructing MPOs by hand in iDMRG
http://itensor.org/support/2926/specific-questions-about-constructing-mpos-by-hand-in-idmrg
<p>Hi Miles,</p>
<p>I have been recently trying doing some iDMRG simulations (C++v3). It is super nice of you to give sample codes in <a rel="nofollow" href="https://github.com/ITensor/iDMRG.">https://github.com/ITensor/iDMRG.</a> And for others who might be interested, here is a great brief introduction to the algorithm - <a rel="nofollow" href="http://itensor.org/docs.cgi?page=tutorials/iDMRG&vers=cppv2.">http://itensor.org/docs.cgi?page=tutorials/iDMRG&vers=cppv2.</a></p>
<p>But since I don't find any documentations about the implementation of the codes, it is a bit hard for me to modify based on that. And I think you might be I have some naive technical questions regarding how to construct a general Hamiltonian (to be specific, biquadratic Heisenberg model for my purpose).</p>
<p>$$H=\sum_{}\alpha s_i\cdot s_j+\beta(s_i\cdot s_j)^2$$</p>
<p>In the <a rel="nofollow" href="https://github.com/ITensor/iDMRG/blob/master/sample/Heisenberg.h">Heisenberg.h</a>, </p>
<p>Question 1<br>
How is the size for each QN block being decided? (3, 1, 1) in the following code.</p>
<pre><code> auto ts = format("Link,l=%d",l);
links.at(l) = Index(QN({"Sz", 0}),3,
QN({"Sz",-2}),1,
QN({"Sz",+2}),1,
Out,
ts);
</code></pre>
<p>Question 2</p>
<p>I guess the following codes are the ones that deal with the construction of Heisenberg MPO. But could you explain how these columns and rows correspond to the MPO of the Heisenberg MPO? And in general, how do you specify the row and column indices?</p>
<pre><code> W = ITensor(dag(sites_(n)),prime(sites_(n)),row,col);
W += sites_.op("Id",n) * setElt(row(1)) * setElt(col(1)); //ending state
W += sites_.op("Id",n) * setElt(row(2)) * setElt(col(2)); //starting state
W += sites_.op("Sz",n) * setElt(row(3)) * setElt(col(1));
W += sites_.op("Sz",n) * setElt(row(2)) * setElt(col(3)) * Jz_;
W += sites_.op("Sm",n) * setElt(row(4)) * setElt(col(1));
W += sites_.op("Sp",n) * setElt(row(2)) * setElt(col(4)) * J_/2;
W += sites_.op("Sp",n) * setElt(row(5)) * setElt(col(1));
W += sites_.op("Sm",n) * setElt(row(2)) * setElt(col(5)) * J_/2;
</code></pre>
<p>Thank you very much!</p>
<p>Best,<br>
Yi</p>
http://itensor.org/support/2926/specific-questions-about-constructing-mpos-by-hand-in-idmrgMon, 22 Mar 2021 17:04:29 +0000Playing with MPS/ ITensors Indexing
http://itensor.org/support/2925/playing-with-mps-itensors-indexing
<p>Hi,</p>
<p>I have a couple of questions which relate to indexing in ITensor.</p>
<p>Firstly, I have an MPS in a spin-1/2 1D chain denoted by T. I can get the local 2-D tensors (at each) by doing setting the site-index to 1 or 2. I am pretty sure about this but can you confirm that this would give me the components in the computational (S<em>z) basis ? Now, I would like to change modify the tensor so that I can get this in the (S</em>x) basis. This basically amounts to adding and subtracting the local 2-D tensors. However, I am not sure how to put them back in the original tensor without messing up the indexing. Here is some minimal code:</p>
<pre><code>using ITensors
N=20
sites = siteinds("S=1/2",N)
bond_dim=24
T = randomMPS(sites,bond_dim);
for j=1:length(T)
T0=T[j]*setelt(sites[j]=>1)
T1=T[j]*setelt(sites[j]=>2)
Tx0=(T0+T1)/sqrt(2)
Tx1=(T0-T1)/sqrt(2)
#I would like to assign Tx0 to something like T[j]*setelt(sites[j]=>1) but how?
end
</code></pre>
<p>Finally, I have been recently doing a lot of calculations involving contraction of ITensor objects and I was wondering if there is some in-built function that returns the different index of any ITensor object ( somewhat like how "linkind" works for MPS objects ).</p>
<p>In general, is the handling of ITensor indexing in Julia well documented somewhere?</p>
http://itensor.org/support/2925/playing-with-mps-itensors-indexingMon, 22 Mar 2021 16:40:05 +0000Change the size of the Index (the dimension of the vector space that the Index defines) but don't change the id
http://itensor.org/support/2919/change-size-index-dimension-vector-space-index-defines-change
<p>Excuse me,I want to change the size of the Index (the dimension of the vector space that the Index defines) but don't change the id.For example,if I create a Index a(auto a = Index(2)),then I want to convert the size of index a to 3 and keep the old id.</p>
<pre><code>auto a=Index(2);
a=Index(dim(a)+1);
</code></pre>
<p>If I do this,the id of index a will be changed.This result is not what I want.What should I do?Thank you!</p>
http://itensor.org/support/2919/change-size-index-dimension-vector-space-index-defines-changeSun, 21 Mar 2021 12:23:34 +0000MPS for MixedSiteSet with different QN conservation on subsystems
http://itensor.org/support/2917/for-mixedsiteset-with-different-conservation-subsystems
<p>Hi everyone,</p>
<p>I am trying to implement a system with mixed Sites ( two bosonic sites at positions i, j, the rest fermionic spin 1/2 sites). The bosonic sites should not conserve QNs, the fermionic sites do. <br>
I pass arguments like {"ConserveQNs",true} to the fermionic subsystem and {"ConserveQNs", false, "MaxOcc", MaxOcc} to the bosonic subsystem.</p>
<p>Creating the SiteSet, creating an initial state InitState(siteset) and setting the different sites also works without an problem. <br>
However the created state does not seem to work with the function MPS(state) to create an MPS from it. It gives a segmentation fault.<br>
Is this because of the different QN conservation on the subsystems? And is there an easy fix/ alternative way to create an MPS from the SiteSet?</p>
<p>Thank you very much in advance for any help!</p>
http://itensor.org/support/2917/for-mixedsiteset-with-different-conservation-subsystemsFri, 19 Mar 2021 16:17:28 +0000Valence bond - fast implementation (2)
http://itensor.org/support/2911/valence-bond-fast-implementation-2
<p>Hi everyone,</p>
<p>I actually have a follow-up question about this: <br>
<a rel="nofollow" href="https://itensor.org/support/1920/valence-bond-states-fast-implementation">https://itensor.org/support/1920/valence-bond-states-fast-implementation</a></p>
<p>So I have created a state like <a rel="nofollow" href="https://i.ibb.co/sm84GVm/equation.jpg">this</a>. It is basically a product of 2-site states, which can either be nearest neighbors or arbitrary sites i,j (for arbitrary sites I need to change the site indices after I generate a nearest-neighbor product state, we discussed that in the previous thread).</p>
<p>My question is, after I have created an MPS state that represents the equation above, how can I change the coefficients u and d, without needing to generate the state from scratch? Is there a way?</p>
<p>Thank you very much in advance.</p>
http://itensor.org/support/2911/valence-bond-fast-implementation-2Sat, 13 Mar 2021 01:38:55 +0000Error: Index::write: Index is default initialized
http://itensor.org/support/2902/error-index-write-index-is-default-initialized
<p>Hi,</p>
<p>I am not able to save a state using the WriteToFile function.<br>
The code returns the following error:<br>
<strong>Index::write: Index is default initialized</strong></p>
<p>It's not clear to me why it's happening. <br>
I have a bosonic system of size N with a certain cut-off to the Fock space.<br>
The state is the following:<br>
$$<br>
|\psi\rangle = |0 0 ...\rangle \otimes |\psi<em>0\rangle \otimes |00..0\rangle<br>
$$<br>
where @@|\psi</em>0\rangle@@ is a certain state. Since I am able to compute local quantites and perform a TEBD real time evolution I don't see any issue with the state itself (e.g. mismatch with indices). <br>
Could you help me?</p>
<p>Thank you in advance.<br>
Riccardo</p>
http://itensor.org/support/2902/error-index-write-index-is-default-initializedMon, 08 Mar 2021 17:28:28 +0000[Julia] Defining custom MPOs using op vs. op!
http://itensor.org/support/2897/julia-defining-custom-mpos-using-op-vs-op
<p>Hi,</p>
<p>I have defined a custom local Hilbert space given by one electron tensored with one (truncated) boson. I conserve two quantum numbers, Nf and Sz for the electronic degrees of freedom. </p>
<p>I was trying to use the op function to define my custom MPOs in the same manner ElectronSite MPOs are defined in ITensor: </p>
<pre><code>function ITensors.op(::SiteType"MySite", s::Index,
opname::AbstractString)::ITensor
Op = ITensor(prime(s), dag(s))
if opname == "A"
Op[1, 2] = A12
elseif opname == "B"
Op[1, 3] = B12
return Op
end
</code></pre>
<p>(In the above hypothetical example, A and B have different QN fluxes, which is the case for me.) <br>
However, this threw me a QN-conservation error: </p>
<pre><code>ERROR: In setindex!, the element you are trying to
set is in a block that does not have the same flux
as the other blocks of the ITensor. You may be
trying to create an ITensor that does not have a
well-defined quantum number flux.
</code></pre>
<p>I'm pretty sure I'm conserving QN for both operators. In particular, when I define A and B separately using op!, ITensors does not complain:</p>
<pre><code>function ITensors.op!(Op::ITensor, ::OpName"A",
::SiteType"MySite", s::Index)
Op[1, 2] = A12
end
function ITensors.op!(Op::ITensor, ::OpName"B",
::SiteType"MySite", s::Index)
Op[1, 3] = B13
end
</code></pre>
<p>What might be the issue here? Why does op! work but not op? Is op not intended to be used this way for custom sites? (But then, how does this work for in-built site sets such as ElectronSite?)</p>
<p>Thanks!</p>
http://itensor.org/support/2897/julia-defining-custom-mpos-using-op-vs-opTue, 02 Mar 2021 23:04:58 +0000Converting ITensors to matrices in Julia
http://itensor.org/support/2885/converting-itensors-to-matrices-in-julia
<p>Hi,</p>
<p>Sorry if this has been answered already but I am trying to do some post-processing with the MPS Tensor components and it would be really helpful to just convert them into regular matrices. Specifically, I have some MPS tensor "T" on N sites on a spin-1/2 chain. I can grab the two local components of the MPS using commands like -</p>
<pre><code>using ITensors
N =10
sites = siteinds("S=1/2", N)
T = randomMPS(sites, 20)
T5_1=T[5]*setelt(sites[5]=>1)
T5_2=T[5]*setelt(sites[5]=>2)
</code></pre>
<p>However, I would like to be able to perform matrix multiplications like (T5<em>1).\rho.(T5</em>1)^{\dagger} (where \rho is a suitable density matrix) and for this it would be best to have them converted into matrices.</p>
<p>PS: I know that the other way of doing this is to encode the density matrix into an ITensor object and change the link indices suitably to get the multiplication to work out.</p>
http://itensor.org/support/2885/converting-itensors-to-matrices-in-juliaMon, 01 Mar 2021 09:37:54 +0000Flip in the indices order of Hermitian conjugate of a two qubit quantum state.
http://itensor.org/support/2884/flip-indices-order-hermitian-conjugate-qubit-quantum-state
<p>Hello people! I have just started exploring Tensor Networks. I am referring to <a rel="nofollow" href="https://itensor.org/miles/BrazilLectures/TNAndApplications01.pdf">These Lecture notes</a> by ITensor.</p>
<p>On slide 32, reduced density matrix is calculated for 1st qubit of an entangled state,<br>
psi = (|01> - |10>) / 2^(1/2)</p>
<p>While calculating reduced density matrix of 1st qubit of psi , 2nd qubit of tensor psi should be contracted over 2nd qubit of tensor psi* (Hermitian conjugate). </p>
<p>But according to given matrix multiplication, I think the 2nd qubit of tensor psi is contracting over 1st qubit of tensor psi* which should not be the case. </p>
<p>I want to know if the indices order is flipped while taking the transpose or not. </p>
http://itensor.org/support/2884/flip-indices-order-hermitian-conjugate-qubit-quantum-stateThu, 25 Feb 2021 18:51:49 +0000Turning a randomITensor into a periodic MPS description
http://itensor.org/support/2882/turning-a-randomitensor-into-a-periodic-mps-description
<p>Hi,</p>
<p>This is somewhat closely related to the other discussions on the difficulty of implementing periodic MPS even in 1D systems. A command like:</p>
<pre><code>psi_approx = MPS(A, sites; cutoff = accuracy)
</code></pre>
<p>turns a randomITensor (that potentially contains the amplitudes of a quantum state) into an efficient MPS description (upto some accuracy) with open boundary conditions. My first guess would be this works by using SVD (or equivalently Schmidt decomposition) along some partition and then one repeats the process for other partitions. Is this so?</p>
<p>Now coming to the more important question: is there any way of generalizing this approximation for MPS with periodic boundary conditions? (It may be worth mentioning that for the setting I am looking at, I am guaranteed that such a description exists and the final MPS is translationally invariant.) I don't believe that SVDs would do it as the entanglement between two sites in this setting will be kind of distributed between "two" paths (one along the usual chain and the other along the ring). </p>
<p>For motivation let me say, when I employ the "MPS" routine for the amplitudes of a cluster state on a ring, I get a bond dimension of 4 rather than the usual D=2. I would think this is because the entanglement between site 1 and N now has to be pushed through along the chain. So, my question in this context would be: how do I get back the well known 2*2 matrix description of the components of the local tensors?</p>
http://itensor.org/support/2882/turning-a-randomitensor-into-a-periodic-mps-descriptionWed, 24 Feb 2021 19:41:37 +0000Extract/Project IQTensor on a QN subspace
http://itensor.org/support/2879/extract-project-iqtensor-on-a-qn-subspace
<p>Hi all,</p>
<p>I am fairly new to ITensor and C++. <br>
Thus if you have any advice that can be easier implemented in Julia I could take it into account, too.</p>
<p>First let me describe the system I am dealing with:<br>
I consider a Bosonic chain of N sites: Boson(N,{"ConserveQNs=",true,"MaxOcc",1})). <br>
I would like to construct the reduced density matrix of the system and project it on a given subspace.<br>
In formulas, given the reduced density matrix @@\rho_A=Tr(|\psi><\psi|)@@<br>
I would like <br>
$$<br>
\rho_A(q)=\frac{P_q \rho_A P_q}{Tr(\rho_A P_q)}<br>
$$<br>
Where @@P_q@@ is the projector on the subspace with a given number of particles<br>
$$<br>
\sum_{i=1}^{l}n_i=q.<br>
$$<br>
Here @@n_i@@ is the number of Bosons at site i and l is the length of the subsystem.</p>
<p>The question is the following: is there a way to do obtain @@\rho_A(q)@@, using IQTensor, without computing explicitly the reduced density matrix and the projector, since it is very inefficient?</p>
<p>I saw in the source code of qutil.h the function getBlock, but I'm not used to C++ and I could not deduce its functionalities.</p>
<p>Thank you for your time.</p>
<p>Best,<br>
Vittorio</p>
http://itensor.org/support/2879/extract-project-iqtensor-on-a-qn-subspaceTue, 23 Feb 2021 15:45:31 +0000TDVP with time dependent term
http://itensor.org/support/2878/tdvp-with-time-dependent-term
<p>Hi all,<br>
I was trying to use the one center TDVP algorithm to study a system with a time-dependent term that is not part of the Hamiltonian. The overall system evolution is described by <br>
$$\dot y = H y + f(t)$$<br>
where y is the state, H the Hamiltonian, and f(t) is a time dependent vector. How should I modify the original TDVP code to treat this case?</p>
<p>Thanks,<br>
Raffaele</p>
http://itensor.org/support/2878/tdvp-with-time-dependent-termSun, 21 Feb 2021 09:12:32 +0000Applying local MPOs in Julia
http://itensor.org/support/2869/applying-local-mpos-in-julia
<p>Hi,</p>
<p>I am trying to apply a local MPO at a single site on a MPS. This seems to be easy enough in Julia but I am not sure if the answer I get is sensible. </p>
<pre><code>using ITensors
N = 6
bond_dim=24
sites = siteinds("S=1/2",N)
psi = randomMPS(sites, bond_dim);
psi1 = randomMPS(sites, bond_dim);
j=3 #Choose where to apply the 1-local MPO
#First way (Don't know why this doesn't work)
s = siteind(psi,j)
newpsi= 2*op(s,"Sx") * psi[j]
noprime!(newpsi)
psi[j]= newpsi
println("Firstvalue is ", inner(psi1, psi))
#Second way (This works)
sample = AutoMPO()
sample += 2,"Sx", j;
Operator= MPO(sample,sites);
secondvalue=inner(psi1,Operator,psi)
</code></pre>
<p>However the two give different outputs:</p>
<pre><code>Firstvalue is -0.04429389151813912
0.27968037863018275
</code></pre>
<p>I am sure I am missing something trivial here but can you point me to why the first method doesn't work?</p>
http://itensor.org/support/2869/applying-local-mpos-in-juliaSat, 13 Feb 2021 16:49:31 +0000Making Initial Product States in 2D
http://itensor.org/support/2848/making-initial-product-states-in-2d
<p>Dear all,</p>
<p>First, the background is that I am currently trying performing some DMRG calculation for the 2-Dimensional Spin-1 BBH model "on a cylinder" (periodic in y direction) with only nearest neighbor interaction, which goes as follows.</p>
<p>$$<br>
\hat{H} = \sum_{i, j} \cos\theta \vec{S}_i\cdot \vec{S}_j + \sin\theta (\vec{S}_i\cdot \vec{S}_j)^2<br>
$$</p>
<p>Now, I want to start with different types of initial states, such as Neel-like state, dimer(spin-singlet) state, or other initial states of interests. There are already a number of great discussions about how to set a product initial state in 1D, as shown in the following links,</p>
<p><a rel="nofollow" href="http://itensor.org/support/1357/setting-random-initial-product-state">http://itensor.org/support/1357/setting-random-initial-product-state</a></p>
<p><a rel="nofollow" href="http://itensor.org/support/1359/how-to-create-a-particular-initial-state-as-a-mps">http://itensor.org/support/1359/how-to-create-a-particular-initial-state-as-a-mps</a></p>
<p>Also, as previously pointed by Miles, there is a very good example in the "finiteT/ancilla.cc". <a rel="nofollow" href="https://github.com/ITensor/ITensor/blob/v3/tutorial/finiteT/ancilla.cc">https://github.com/ITensor/ITensor/blob/v3/tutorial/finiteT/ancilla.cc</a></p>
<p>But after reading these answers, now I want to construct a dimer state as follow.</p>
<p>$$<br>
\left| Initial\right>=\otimes_{1\leq n\leq N_x, 1\leq m\leq N_y} (2n-1, 2n; m)<br>
$$</p>
<p>here my notation is that I use @@(2n-1, 2n; m)@@ to indicate a spin-singlet (dimer) state between site (x=2n-1, y=m) and site (x=2n, y=m). A spin-singlet state is like @@1/\sqrt{3} (\left|+1\right>_i\otimes\left|-1\right>_j+\left|-1\right>_i\otimes\left|+1\right>_j-\left|0\right>_i\otimes\left|0\right>_j)@@, if you wish.</p>
<p>And a naive thought of mine is just to do something similar in 1D case that I product all the pairs of site and make a product state. Here're my codes in c++ v3. </p>
<pre><code>auto psi0 = MPS(sites);
for (int n = 1; n < N; n += 2 * Ny)
{
for (int m = 0; m < Ny; m++)
{
auto s1 = sites(n + m);
auto s2 = sites(n + m + Ny);
auto wf = ITensor(s1, s2);
wf.set(s1(1), s2(3), ISqrt3); // 1- Up; 2- Z0; 3 - Dn; ISqrt=1/\sqrt{3}
wf.set(s1(3), s2(1), ISqrt3);
wf.set(s1(2), s2(2), -ISqrt3);
ITensor D;
psi0.ref(n + m) = ITensor(s1);
psi0.ref(n + m + Ny) = ITensor(s2);
svd(wf, psi0.ref(n + m), D, psi0.ref(n + m + Ny));
psi0.ref(n + m) *= D;
}
}
</code></pre>
<p>But it returns some error as follow.</p>
<pre><code>davidson: size of initial vector should match linear matrix size
</code></pre>
<p>I guess that since in ITensor, a 2D model is simply mapped into a snake-like 1D chain, I should have not made such naive generalization from 1D to 2D. So, I hope someone can help me figure out why this does not work from the perspective of building a product state in ITensor, as well as how to realize the setup of a product state in 2D. Btw, I think this question can also be generalized to how to set an general initial product state in the case of 2D models.</p>
<p>Thank you very much!</p>
<p>Best,<br>
Yi</p>
http://itensor.org/support/2848/making-initial-product-states-in-2dWed, 10 Feb 2021 07:13:38 +0000Is there a method that gives the quantum number flux of a particular element in an ITensor
http://itensor.org/support/2844/there-method-gives-quantum-number-particular-element-itensor
<p>From this answer</p>
<p><a rel="nofollow" href="http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo">http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo</a></p>
<p>I realized that one can use the "flux" function to get the quantum number flux of an ITensor. However I wonder if there is a method to get the quantum number flux <em>for a particular element</em> in an ITensor?</p>
http://itensor.org/support/2844/there-method-gives-quantum-number-particular-element-itensorSun, 07 Feb 2021 16:11:38 +0000A partial fix of arnoldi
http://itensor.org/support/2843/a-partial-fix-of-arnoldi
<p>Hi Matthew,</p>
<p>The <a rel="nofollow" href="https://github.com/ITensor/ITensor/issues/360">issue#360</a> in <code>arnoldi</code> function is because of an extra multiplication of <code>A</code> in <a rel="nofollow" href="https://github.com/ITensor/ITensor/blob/fb83fde4a07f2122cf56f9a79f8e8ec01c7cad18/itensor/iterativesolvers.h#L809">the deflation</a>.</p>
<p>The current (incorrect) <code>arnoldi</code> calculates instead the first eigenvalues of <code>A</code> and <code>A-A^2</code>. That's why in <a rel="nofollow" href="https://github.com/ITensor/ITensor/issues/360">issue#360</a> the two eigenvectors are identical and the eigenvalues <br>
<code>lambda0 = (0.598975,0)
lambda1 = (0.240204,0)</code><br>
satisfy <code>lambda1 = lambda0 - lambda0^2</code>.</p>
<p>A minor pull request has been submitted <a rel="nofollow" href="https://github.com/ITensor/ITensor/pull/382">here</a>.</p>
<p>However, even after this fix the <code>arnoldi</code> function can only deal with Hermitian operator. Because the current deflation process cannot project to the correct subspace if the previously calculated eigenvectors are not orthogonal.</p>
<p>Ce</p>
http://itensor.org/support/2843/a-partial-fix-of-arnoldiSun, 07 Feb 2021 03:13:35 +0000initialize an ITensor from allocated memory
http://itensor.org/support/2842/initialize-an-itensor-from-allocated-memory
<p>Hi, </p>
<p>Is there any way to create an ITensor "in place" from some already allocated memory?</p>
<p>For example</p>
<pre><code>const int nx = 10;
const int ny = 10;
double* arr = new double[nx * ny] ;
Index i(nx);
Index j(ny);
ITensor A(i, j); //the storage is not yet initialized.
</code></pre>
<p>Currently I only know how to copy this allocated memory to the data vector of A as following</p>
<pre><code>vector_no_init<double>& dvec = (*((ITWrap<Dense<double>>*) & (*A.store()))).d.store;
dvec.assign(arr, arr + nx*ny);
</code></pre>
<p>What I'd like to do is to "steal" the allocated memory from <code>arr</code> and use that as the internal data vector of <code>A</code>. Although <code>memcpy</code> is in general very fast, sometimes we still want to avoid this overhead in case it is a huge <code>for</code> loop.</p>
<p>There's <a rel="nofollow" href="https://stackoverflow.com/questions/21917529/is-it-possible-to-initialize-stdvector-over-already-allocated-memory">some instruction</a> on how to steal the memory by overloading the allocator. But the data vector's allocator has already been overloaded as in the definition of <a rel="nofollow" href="https://github.com/ITensor/ITensor/blob/fb83fde4a07f2122cf56f9a79f8e8ec01c7cad18/itensor/util/vector_no_init.h#L24">vector no init</a>. </p>
<p>Do you have any idea how to combine the two overloaded versions of allocator, s.t. it can work as described above?</p>
<p>Ce</p>
http://itensor.org/support/2842/initialize-an-itensor-from-allocated-memorySun, 07 Feb 2021 02:51:04 +0000Matrix element of (tensor products of) Pauli operators in Julia
http://itensor.org/support/2824/matrix-element-tensor-products-of-pauli-operators-in-julia
<p>Hi,</p>
<p>Is there an easy way of calculating 2^N matrix elements like: </p>
<p>A(i<em>1,i</em>2,...,i<em>N)= < phi| X^(i</em>1)⊗X^(i<em>2),...,⊗X^(i</em>N))|psi> ?</p>
<p>where X denotes the spin 1/2 Pauli X matrix and I get the 1D MPS phi and psi from a DMRG optimization routine. Also note i is a N-component binary vector.</p>
<p>Thanks in advance,<br>
Arnab</p>
http://itensor.org/support/2824/matrix-element-tensor-products-of-pauli-operators-in-juliaThu, 04 Feb 2021 20:08:50 +0000Canonical MPS representation given an initial state in Julia
http://itensor.org/support/2820/canonical-mps-representation-given-an-initial-state-julia
<p>Hi,</p>
<p>I was wondering if there is any inbuilt script to automatically get the canonical MPS representation from a given state using Schmidt decomposition. </p>
<p>If not, how would one go about doing this?</p>
http://itensor.org/support/2820/canonical-mps-representation-given-an-initial-state-juliaWed, 03 Feb 2021 21:58:59 +0000[Julia] Largest truncation error in DMRG output
http://itensor.org/support/2818/julia-largest-truncation-error-in-dmrg-output
<p>Hi,</p>
<p>I've been using the julia version of ITensor lately, and I noticed that calling DMRG by default does not print any information regarding the maximum truncation error for each sweep, unlike the C++ version. I've searched the documentation but could not find anything related to the truncation error. Is there some way to turn this feature on? Or is it just not implemented yet?</p>
<p>Best,</p>
<p>Rafael</p>
http://itensor.org/support/2818/julia-largest-truncation-error-in-dmrg-outputTue, 02 Feb 2021 23:59:38 +0000[Julia] QN Block Sparse ITensor gives wrong results for multiplying the delta tensor
http://itensor.org/support/2814/block-sparse-itensor-wrong-results-multiplying-delta-tensor
<p>Hi,</p>
<p>For the following code, the answer should be "4.0", but it gives "2.0". Maybe it is a bug. Thanks.</p>
<pre><code>s = Index([QN(("N",i,1))=>1 for i = 1:2];dir = ITensors.Arrow(1))
l = dag(addtags(s,"left"))
r = addtags(s,"right")
u = addtags(s,"up")
d = dag(addtags(s,"down"))
A = emptyITensor(l,r,u,d)
A[1,1,1,1] = 1.0
A[1,1,2,2] = 1.0
A[2,2,1,1] = 1.0
A[2,2,2,2] = 1.0
println(A*delta(dag(l),dag(r))*delta(dag(u),dag(d)))
</code></pre>
<p>Jin</p>
http://itensor.org/support/2814/block-sparse-itensor-wrong-results-multiplying-delta-tensorTue, 02 Feb 2021 07:00:24 +0000Computational cost of ITensor permute method
http://itensor.org/support/2810/computational-cost-of-itensor-permute-method
<p>Hi, I am curious about what is the computational cost of the permute method. Does it involve copies of all the elements (slower), or does it just somehow affect only the index level and does not touch the data (fast)? Thank you!</p>
http://itensor.org/support/2810/computational-cost-of-itensor-permute-methodThu, 21 Jan 2021 21:04:19 +0000Are there methods for returning QN value for an MPS or QN flux for an MPO?
http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo
<p>Is there a method that can accept an MPS (where the indices have been defined with quantum numbers) and return the total quantum number of that state, or even the individual quantum number values of the ITensor objects within that state? Similarly, is there a method that can accept an MPO and return its QN flux? I know that you can compute this manually, but it would be nice to have a method that can make sure that it is doing what I intend it to do. I couldn't find such methods when looking through the Julia code on the GitHub page, but it's possible I just missed them.</p>
http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpoFri, 15 Jan 2021 18:19:06 +0000M1 processor compatibility
http://itensor.org/support/2796/m1-processor-compatibility
<p>Hello,</p>
<p>Does the iTensor C++ version runs without any issue with Apple's new M1 processor? Or is there any possible decrease in performance?</p>
<p>Thank you!<br>
Jun</p>
http://itensor.org/support/2796/m1-processor-compatibilityThu, 14 Jan 2021 18:04:21 +0000[julia] Initial state for DMRG
http://itensor.org/support/2780/julia-initial-state-for-dmrg
<p>Hello,</p>
<p>I'm trying to use DMRG to calculate the ground state of a Bose-Hubbard model. I created my own site type of spinless bosons and followed some DMRG examples to perform QN conserved DMRG with <code>randomMPS</code> with specific QN. It worked pretty well. </p>
<p>The problem happens when I saved the ground state <code>psi</code> in an hdf5 file and then tried to load this psi and use it as the initial state <code>psi0</code> to run the same DMRG. However, I got the error saying the order of this tensor <code>is greater than or equal to the ITensor order warning threshold 14</code>. I made sure the maxlinkdim is 200 starting from the first sweep. It's a warning but it seems <code>dmrg</code> is not running as what I expected like with just <code>randomMPS</code> initial state. </p>
<p>I have two related questions:</p>
<ol>
<li>Is there a limit on what initial state I can use for <code>dmrg</code>? I thought it would be more efficient if I use the ground state of the same model but slightly different parameters as the initial state of the next DMRG run, instead of having a completely cold start.</li>
<li>If I have the ground state at hand but somehow lost the energy (it's actually how I started to see this problem), what would be the most efficient way of calculating the energy of this state?</li>
</ol>
<p>Thanks,<br>
Sherry</p>
http://itensor.org/support/2780/julia-initial-state-for-dmrgTue, 12 Jan 2021 19:31:30 +0000[julia] DMRGObserver not working
http://itensor.org/support/2779/julia-dmrgobserver-not-working
<p>Hello, </p>
<p>I'm new to ITensors and try to mainly use the DMRG features here. I found the DMRGObserver feature pretty useful and was trying to implement it according to the documentation <a rel="nofollow" href="https://itensor.github.io/ITensors.jl/stable/DMRGObserver.html#ITensors.DMRGObserver-Tuple%7BFloat64,Int64%7D">here</a> . However, I saw an error while trying to create the DMRGObserver.</p>
<pre><code>DMRGObserver(energy_tol = 1e-5, minsweeps = 2)
</code></pre>
<p>The error reads:</p>
<pre><code> ERROR: MethodError: no method matching DMRGObserver(; energy_tol=1.0e-5, minsweeps=2)
Closest candidates are:
DMRGObserver() at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:33 got unsupported keyword arguments "energy_tol", "minsweeps"
DMRGObserver(::Array{String,1}, ::Array{var"#s305",1} where var"#s305"<:Index; energy_tol, minsweeps) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:38
DMRGObserver(::Any) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:33 got unsupported keyword arguments "energy_tol", "minsweeps"
</code></pre>
<p>Then I simply tried <code>DMRGObserver()</code>, still it gives the error</p>
<pre><code>ERROR: MethodError: no method matching Array{var"#s305",1} where var"#s305"<:Index(::Array{Any,1})
Stacktrace:
[1] convert(::Type{Array{var"#s305",1} where var"#s305"<:Index}, ::Array{Any,1}) at .\array.jl:554
[2] DMRGObserver(::Float64, ::Int64) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:35 (repeats 2 times)
[3] top-level scope at REPL[8]:1
</code></pre>
<p>I'm using the most up-to-date version of ITensors (0.1.34). I don't have a good idea on how to fix it from here on. Please let me know if you have any suggestions.</p>
<p>Thanks,<br>
Sherry</p>
http://itensor.org/support/2779/julia-dmrgobserver-not-workingTue, 12 Jan 2021 18:55:34 +0000leftlim and rightlim initialization present in randomizeMPS! but not productMPS
http://itensor.org/support/2771/rightlim-initialization-present-randomizemps-productmps
<p>I happened to notice that, in ITensors.jl/mps.jl, the randomizeMPS! function has lines of code that initialize leftlim and rightlim to 0 and 2, respectively, while the productMPS function does not.</p>
<p>Tto the best of my understanding, leftlim and rightlim are supposed to represent the boundaries of the region currently being optimized. So for 2-site DMRG, for example, leftlim and rightlim start out as 0 and 2 at the beginning of a sweep, and in the forward sweep change to 1 and 3, then 2 and 4, and so on, until N-1 and N+1 (where N is the length of the MPS), and then they shift back during the backward sweep. (Please correct me if I am wrong about this claimed purpose of leftlim and right lim.)</p>
<p>However, based on the existing code in the replacebond! function in mps.jl, this shifting only happens if the initialization is done properly, since leftlim and rightlim will only shift at all if they are in the positions they are supposed to be in earlier. For reference, I have included the code below that specifies this:</p>
<pre><code>if ortho == "left"
leftlim(M) == b-1 && setleftlim!(M, leftlim(M)+1)
rightlim(M) == b+1 && setrightlim!(M, rightlim(M)+1)
normalize && (M[b+1] ./= norm(M[b+1]))
elseif ortho == "right"
leftlim(M) == b && setleftlim!(M, leftlim(M)-1)
rightlim(M) == b+2 && setrightlim!(M, rightlim(M)-1)
normalize && (M[b] ./= norm(M[b]))
else
error("In replacebond!, got ortho = $ortho, only currently supports `left` and `right`.")
end
</code></pre>
<p>Because of all of this, it seems that leftlim and rightlim only shift in the way I think they are supposed to if you construct your initial state using randomMPS, not if you use productMPS. Is there a reason for this? This seems to be a mistake to me, but I can't be totally sure.</p>
http://itensor.org/support/2771/rightlim-initialization-present-randomizemps-productmpsSat, 09 Jan 2021 10:59:22 +0000convergence problem for small lattice
http://itensor.org/support/2766/convergence-problem-for-small-lattice
<p>I was using the following code for simulating 1D Hubbard model in presence of magnetic field.</p>
<pre><code>int main(int argc, char* argv[])
{
//
//Parse the input file
//
if(argc != 2) { printfln("Usage: %s inputfile_newcode",argv[0]); return 0; }
auto input = InputGroup(argv[1],"input");
auto N = input.getInt("N");
auto Npart = input.getInt("Npart",N); //number of particles, default is N (half filling)
auto nsweeps = input.getInt("nsweeps");
auto t1 = 1;
auto U1 = 1;
auto mu = 2;
auto quiet = input.getYesNo("quiet",false);
auto table = InputGroup(input,"sweeps");
auto sweeps = Sweeps(nsweeps,table);
//
// Initialize the site degrees of freedom.
//
auto sites = Electron(N,{"ConserveSz=",false});
auto ampo = AutoMPO(sites);
for(int i = 1; i <= N; ++i)
{
ampo += U1,"Nupdn",i;
}
for(int i = 1; i <= N; ++i)
{
ampo += -mu,"Sz",i;
}
for(int b = 1; b < N; ++b)
{
ampo += -t1,"Cdagup",b,"Cup",b+1;
ampo += -t1,"Cdagup",b+1,"Cup",b;
ampo += -t1,"Cdagdn",b,"Cdn",b+1;
ampo += -t1,"Cdagdn",b+1,"Cdn",b;
}
auto H = toMPO(ampo);
//
// Set the initial wavefunction matrix product state
// to be a Neel state.
//
auto state = InitState(sites);
int p = Npart;
for(int i = N; i >= 1; --i)
{
if(p > 0)
{
println("Singly occupying site ",i);
state.set(i,(i%2==1 ? "Up" : "Dn")); //state.set(i,"Dn");
p -= 1;
}
}
auto psi0 = MPS(state);
//An alternate state initial state
/*for(int i = N; i >= 1; --i)
{
if(p > i)
{
println("Doubly occupying site ",i);
state.set(i,"UpDn");
p -= 2;
}
else
if(p > 0)
{
println("Singly occupying site ",i);
state.set(i,(i%2==1 ? "Up" : "Dn"));
p -= 1;
}
else
{
state.set(i,"Emp");
}
}
auto psi0 = MPS(state);*/
// Begin the DMRG calculation
auto [energy,psi] = dmrg(H,psi0,sweeps,{"Quiet",quiet});
Energy << mu << "\t" << energy << endl;
</code></pre>
<p>I was matching the data obtained by DMRG with the exact diagonalization of the Hamiltonian. For this I used half-filled 2-site Hubbard model. The exact diagonalization was showing that the magnetically saturated phase (all spins up or down) was reaching around "mu=1.6". But the DMRG data was not showing any change of eigenvalue in the range mu=0 to mu=2. For example, when mu=1.6, for 10 sweeps, the data is below:</p>
<pre><code>vN Entropy at center bond b=1 = 1.356587261479
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 1/10 was 4
Largest truncation error: 0
Energy after sweep 1/10 is -1.561552812809
Sweep 1/10 CPU time = 0.00107s (Wall time = 0.00115s)
vN Entropy at center bond b=1 = 1.356587241339
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 2/10 was 4
Largest truncation error: 0
Energy after sweep 2/10 is -1.561552812809
Sweep 2/10 CPU time = 0.000803s (Wall time = 0.000813s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 3/10 was 4
Largest truncation error: 0
Energy after sweep 3/10 is -1.561552812809
Sweep 3/10 CPU time = 0.000795s (Wall time = 0.000806s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 4/10 was 4
Largest truncation error: 0
Energy after sweep 4/10 is -1.561552812809
Sweep 4/10 CPU time = 0.000936s (Wall time = 0.000971s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 5/10 was 4
Largest truncation error: 0
Energy after sweep 5/10 is -1.561552812809
Sweep 5/10 CPU time = 0.000794s (Wall time = 0.000807s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 6/10 was 4
Largest truncation error: 0
Energy after sweep 6/10 is -1.561552812809
Sweep 6/10 CPU time = 0.000785s (Wall time = 0.000796s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 7/10 was 4
Largest truncation error: 0
Energy after sweep 7/10 is -1.561552812809
Sweep 7/10 CPU time = 0.000785s (Wall time = 0.000798s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 8/10 was 4
Largest truncation error: 0
Energy after sweep 8/10 is -1.561552812809
Sweep 8/10 CPU time = 0.000793s (Wall time = 0.000803s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 9/10 was 4
Largest truncation error: 0
Energy after sweep 9/10 is -1.561552812809
Sweep 9/10 CPU time = 0.000761s (Wall time = 0.000770s)
vN Entropy at center bond b=1 = 1.356587239124
Eigs at center bond b=1: 0.3106 0.3106 0.1894 0.1894
Largest link dim during sweep 10/10 was 4
Largest truncation error: 0
Energy after sweep 10/10 is -1.561552812809
Sweep 10/10 CPU time = 0.000761s (Wall time = 0.000771s)
</code></pre>
<p>It seems that the nergy is converged, but this is not the correct magnetically saturated state. Then I changed the input file with larger bond-dimension and huge number of sweeps:</p>
<pre><code>N = 2
Npart = 2
nsweeps = 4000
sweeps
{
maxdim mindim cutoff niter noise
50 10 1E-12 2 1E-7
100 20 1E-12 2 1E-8
200 20 1E-12 2 1E-10
400 20 1E-12 2 1E-10
800 20 1E-12 2 1E-10
1600 20 1E-12 2 1E-10
3200 20 1E-12 2 1E-2
6400 20 1E-12 2 1E-2
12800 20 1E-12 2 1E-1
}
</code></pre>
<p>Now it gives the correct energy:</p>
<pre><code>vN Entropy at center bond b=1 = 0.518448864409
Eigs at center bond b=1: 0.8534 0.0733 0.0733
Largest link dim during sweep 3999/4000 was 4
Largest truncation error: 0
Energy after sweep 3999/4000 is -1.600000000000
Sweep 3999/4000 CPU time = 0.000662s (Wall time = 0.000671s)
vN Entropy at center bond b=1 = 0.518448864409
Eigs at center bond b=1: 0.8534 0.0733 0.0733
Largest link dim during sweep 4000/4000 was 4
Largest truncation error: 0
Energy after sweep 4000/4000 is -1.600000000000
Sweep 4000/4000 CPU time = 0.000766s (Wall time = 0.000776s)
</code></pre>
<p>I have also used an alternate initial state but this feature does not improve. My questions are:</p>
<ol>
<li>Is this problem because of very small lattice size?</li>
<li>Is there any way to fix this problem by tweaking the input file parameters?</li>
<li>I will be actually working with higher number of sites of the order of 10. Is there any chance that there also the correct transition value of the parameter "mu" may not reflect?</li>
</ol>
http://itensor.org/support/2766/convergence-problem-for-small-latticeTue, 05 Jan 2021 15:11:28 +0000Non-contracting product in ITensor Julia
http://itensor.org/support/2762/non-contracting-product-in-itensor-julia
<p>Hi,</p>
<p>I know that the C++ ITensor versions overload the "/" operator to do non-contracting product between itensors. Is there a similar functionality in Julia? I couldn't find it very easily.</p>
<p>Thanks,<br>
Amartya</p>
http://itensor.org/support/2762/non-contracting-product-in-itensor-juliaThu, 24 Dec 2020 15:45:22 +0000Questions about "Observer" Feature in ITensors.jl
http://itensor.org/support/2751/questions-about-observer-feature-in-itensors-jl
<p>I noticed just now that the Julia code has this AbstractObserver data type (defined at <a rel="nofollow" href="https://github.com/ITensor/ITensors.jl">https://github.com/ITensor/ITensors.jl</a> under ITensors.jl/src/mps/observer.jl). It seems to have methods to call early termination if a nonzero imaginary part is detected in the expectation values for certain specified operators on the MPS, or if convergence has occurred to within a certain allowed error. To understand this better, I have a few questions:</p>
<p>(1) Can this observer feature be adapted to some broader set of reasons for early termination, or can it realistically only be used for these two things?</p>
<p>(2) What exactly is the point of specifically detecting imaginary parts of these expectations? I'm guessing it's because one can specify an operator representing an observable, meaning its expectation must be real. But could this functionality be expanded to, say, terminating early if any nonnegligible expectation (real or imaginary) shows up for a local operator?</p>
<p>(3) Suppose one detects one of these nonneglible imaginary parts in some operator. Is there a viable way to "correct" this, or is early termination the only practical answer here?</p>
<p>(4) If one terminates DMRG in the middle of a sweep, are there "side effects" that one should be aware of, since this isn't normally the way DMRG works?</p>
http://itensor.org/support/2751/questions-about-observer-feature-in-itensors-jlFri, 18 Dec 2020 09:56:32 +0000Random Initial state for julia version?
http://itensor.org/support/2748/random-initial-state-for-julia-version
<p>I am trying to find the ground state for a 2D Heisenberg hamiltonian. I want to use different initial states. I read the answers/ discussions regarding the same.</p>
<p>How can I build the random state on X basis? ( maybe using Hadamard as mentioned in other discussions) for the Julia version?</p>
http://itensor.org/support/2748/random-initial-state-for-julia-versionTue, 15 Dec 2020 22:04:49 +0000convert an ITensor to fewer quantum number
http://itensor.org/support/2732/convert-an-itensor-to-fewer-quantum-number
<p>Hi. I wonder if it is possible to convert an ITensor with 2 quantum numbers, say total Sz and particle number, to which with only 1 quantum number, say total Sz. It would be equally good if I can contract two tensors with different number of quantum numbers. Thank you.</p>
<p>BTW I am using ITensor3 C++ interface.</p>
http://itensor.org/support/2732/convert-an-itensor-to-fewer-quantum-numberFri, 11 Dec 2020 20:58:51 +0000Error after updating ITensors.jl
http://itensor.org/support/2726/error-after-updating-itensors-jl
<p>Hi,</p>
<p>My code has an error after updating the new ITensors.jl. The sample code is as follows,</p>
<pre><code>s = Index([QN(("N",i,3))=>1 for i = 0:(2)];dir = ITensors.Arrow(1))
l = setdir(addtags(s,"left"),ITensors.Arrow(-1))
r = addtags(s,"right")
A = emptyITensor(l,r)
A[l(1),r(1)] = 1.0
</code></pre>
<p>It throws an error saying "no method matching ValLength(::Index{Array{Pair{QN,Int64},1}})". What is changed for the new version? Thanks.</p>
<p>Jin</p>
http://itensor.org/support/2726/error-after-updating-itensors-jlThu, 10 Dec 2020 21:18:19 +0000Replace siteIndex of MPO
http://itensor.org/support/2724/replace-siteindex-of-mpo
<p>Hi<br>
I tried to use the wave function obtained form previous calculation as an initial wave function of dmrg calculation(I stored the wave function in the hard disk "./Wave/Psi", but the MPO is not stored), and I obtained MPO via AutoMPO by using the same rules as before. The id in site-indices of MPO is different form the ones of MPS read form disk, I met some problems in replacing the site-indices of MPO by the ones of MPS. The key code is as follow</p>
<pre><code>auto psi = readFromFile<MPS>("./Wave/Psi");
auto newIndexSet = siteInds(psi);
vector<Index> indexMPO;
for (auto i : range1(length(H)))
{
auto siteIndexSet = siteInds(H, i);
indexMPO.push_back(siteIndexSet[1]);
}
auto oldIndexSet = IndexSet(indexMPO);
H.replaceSiteInds(oldIndexSet, newIndexSet); // out arrow indices of MPO
H.replaceSiteInds(oldIndexSet.dag(), newIndexSet.dag()); // in arrow indices of MPO
</code></pre>
<p>But the code do not change the id in site-indices of MPO, could you give me some help?, thanks .</p>
http://itensor.org/support/2724/replace-siteindex-of-mpoWed, 09 Dec 2020 06:14:26 +0000Spinless Fermionic Correlator Across a 1-d Lattice
http://itensor.org/support/2722/spinless-fermionic-correlator-across-a-1-d-lattice
<p>I'm failing to generalize the example in the sample code <a rel="nofollow" href="https://www.itensor.org/docs.cgi?vers=cppv3&page=formulas/correlator_mps">Measure a correlator from an MPS wavefunction</a> to assign the entries across the lattice in the C++ version. When applying to say, the Kitaev wire model, I can create the MPS and calculate one correlation, but when I try to generalize to measuring it across the lattice and assigning that to a 1-d array, I get an error <code>Wrong number of IndexVals passed to elt/eltC. (expected 0, got 4)</code>, with that error having been expected 2 at some version for debugging. Additionally, when I attempt to do this, I get the following before that error message:<br>
<code>inds () =
(dim=2|id=943|"n=2,Site,Fermion") <Out>
1: 1 QN({"Pf"}, 0, -2})
2: 1 QN({"Pf"}, 1, -2})
(dim=2|id=173|"n=2,Site,Fermion") <In>
1: 1 QN({"Pf"}, 0, -2})
2: 1 QN({"Pf"}, 1, -2})
(dim=2|id=173|"n=2,Site,Fermion") <Out>
1: 1 QN({"Pf"}, 0, -2})
2: 1 QN({"Pf"}, 1, -2})
(dim=2|id=943|"n=2,Site,Fermion") <In>
1: 1 QN({"Pf"}, 0, -2})
2: 1 QN({"Pf"}, 1, -2})</code><br>
Which clearly has something to do with the QN Objects, but I'm not sure exactly what. It doesn't help that I haven't used C/C++ in a <em>long</em> time, so having most everything listed as <code>auto</code> for the datatype is somewhat dissatisfying. I attempted to use <code>typeid</code> to determine what I should be using for datatypes in these examples, but that failed fantastically. My guess is that there is an issue when I attempt to put the left and right index linking in multiple times? Then the operators that I stick into <code>elt</code> are defined properly? </p>
<p>I've attached two basic codes, a "Good" single correlation calculation, and a "Bad" multiple-site calculation. To keep things simple, I haven't tried to optimize the bad example, which will come after I get something to work. You'll also notice that I assign the correlation for site <code>jj=3</code> to element 3 of the 1D array but L=20 here so it's not something I'm worried about. Though it is so embarrassing when my Fortran slips out in public.</p>
<p>Here is the "Good" implementation that runs, computes the ground state energy, and spits out a single correlation:</p>
<p>`<br>
#include "itensor/all.h" <br>
using namespace itensor;</p>
<pre><code> int main()
{
int L = 20;
auto psites = Fermion(L,{"ConserveNf",false});
auto mu = 0.1;
auto t = 1.0 ;
auto Delta = 1.0;
// Create the operators for building the Hamiltonian
auto ampo = AutoMPO(psites);
for( auto ii:range1(L-1))
{
ampo += mu, "N", ii;
// ampo += mu, "N"-0.5, ii;
ampo += -t, "Cdag", ii, "C", ii+1;
ampo += -t, "Cdag", ii+1, "C", ii;
ampo += Delta, "Cdag", ii, "Cdag", ii+1;
ampo += Delta, "C", ii+1, "C", ii;
}
// Add the final site's chemical potential term
ampo += mu,"N",L;
// Generate the Hamiltonian
auto H = toMPO(ampo);
auto state = InitState(psites);
// Set the initial state to be a product state
// such that it is within the symmetry sector
// OLD for Fermion Hopping: auto state = InitState(psites,"Emp");
for(int is = 1; is <= L; ++is)
{
state.set(is, is%2==1 ? "1" : "0");
}
auto psi0 = randomMPS(state);
for( auto ii : range1(L) ) if( ii%2==0 ) state.set(ii,"Occ");
// Set the number of DMRG sweeps
auto sweeps = Sweeps(5);
// Set the maximum bond dimension per sweep
// Setting it low initially allows the computation to be much faster
sweeps.maxdim() = 10,20,100,100,200;
// Set the cutoff for the bond dimension
sweeps.cutoff() = 1E-10;
// Run the DMRG
auto [energy,psi] = dmrg(H,psi0,sweeps,"Silent");
// Calculate the energy and state
println("Ground state energy is ", energy) ;
auto ii = 1;
auto jj = 3;
auto Adag_ii = op(psites,"Adag",ii);
auto A_jj = op(psites,"A",jj);
// 'gauge' the MPS to site i
// any 'position' between i and j, inclusive, would work here
psi.position(ii);
auto psidag = dag(psi);
psidag.prime();
// index linking ii to ii-1:
auto lii_1 = leftLinkIndex(psi,ii);
auto Cij = prime(psi(ii),lii_1)*Adag_ii*psidag(ii);
for(int kk = ii+1; kk < jj; ++kk)
{
Cij *= psi(kk);
Cij *= op(psites,"F",kk); // J-W string - need to add the "F" argument in between
Cij *= psidag(kk);
}
// index linking jj to jj+1
auto ljj = rightLinkIndex(psi,jj);
Cij *= prime(psi(jj),ljj);
Cij *= A_jj;
Cij *= psidag(jj);
float GFjjresult = elt(Cij); // use eltC if expecting complex
std::cout << GFjjresult << ' ';
return 0;
}
</code></pre>
<p>`</p>
<p>And here is the "Bad" implementation where everything goes to heck:<br>
`<br>
#include "itensor/all.h" <br>
using namespace itensor;</p>
<pre><code> int main()
{
int L = 20;
auto psites = Fermion(L,{"ConserveNf",false});
auto mu = 0.1;
auto t = 1.0 ;
auto Delta = 1.0;
// Create the operators for building the Hamiltonian
auto ampo = AutoMPO(psites);
for( auto ii:range1(L-1))
{
ampo += mu, "N", ii;
// ampo += mu, "N"-0.5, ii;
ampo += -t, "Cdag", ii, "C", ii+1;
ampo += -t, "Cdag", ii+1, "C", ii;
//
ampo += Delta, "Cdag", ii, "Cdag", ii+1;
ampo += Delta, "C", ii+1, "C", ii;
}
// Add the final site's chemical potential term
ampo += mu,"N",L;
// Generate the Hamiltonian
auto H = toMPO(ampo);
auto state = InitState(psites);
// Set the initial state to be a product state
// such that it is within the symmetry sector
// OLD for Fermion Hopping: auto state = InitState(psites,"Emp");
for(int is = 1; is <= L; ++is)
{
state.set(is, is%2==1 ? "1" : "0");
}
auto psi0 = randomMPS(state);
for( auto ii : range1(L) ) if( ii%2==0 ) state.set(ii,"Occ");
// Set the number of DMRG sweeps
auto sweeps = Sweeps(5);
// Set the maximum bond dimension per sweep
// Setting it low initially allows the computation to be much faster
sweeps.maxdim() = 10,20,100,100,200;
// Set the cutoff for the bond dimension
sweeps.cutoff() = 1E-10;
// Run the DMRG
auto [energy,psi] = dmrg(H,psi0,sweeps,"Silent");
// Calculate the energy and state
println("Ground state energy is ", energy) ;
auto ii = 1;
Real GF1jj[L];
auto jj = 3;
auto Adag_ii = op(psites,"Adag",ii);
auto A_jj = op(psites,"A",jj);
// 'gauge' the MPS to site i
// any 'position' between i and j, inclusive, would work here
psi.position(ii);
auto psidag = dag(psi);
psidag.prime();
// index linking ii to ii-1:
for(int jj=ii+1; jj < L; ++jj)
{
auto lii_1 = leftLinkIndex(psi,ii);
auto Cij = prime(psi(ii),lii_1)*Adag_ii*psidag(ii);
for(int kk = ii+1; kk < jj; ++kk)
{
Cij *= psi(kk);
Cij *= op(psites,"F",kk); // J-W string - need to add the "F" argument in between
Cij *= psidag(kk);
}
// index linking jj to jj+1
auto ljj = rightLinkIndex(psi,jj);
Cij *= prime(psi(jj),ljj);
Cij *= A_jj;
Cij *= psidag(jj);
Real GFjjresult = elt(Cij); // use eltC if expecting complex
GF1jj[jj] = GFjjresult;
}
std::cout << GF1jj[3] << ' ';
return 0;
}
</code></pre>
<p>`</p>
http://itensor.org/support/2722/spinless-fermionic-correlator-across-a-1-d-latticeFri, 04 Dec 2020 20:25:40 +0000set ITensor elements Array-wise
http://itensor.org/support/2713/set-itensor-elements-array-wise
<p>HI!<br>
I was wondering if it is possible to set ITensor elements Array-wise instead of element-wise, something like:</p>
<pre><code>using ITensors
i = Index(2)
j = Index(2)
k = Index(2)
l = Index(2)
A = randomITensor(i,j,k)
A[i=>1, j=>2, :, :] = [0 0; 0 0]
</code></pre>
<p>The use case is that I would like to "diagonalize" a Tensor with (2+n) indices, in the sense that all entries of the Tensor should become zero when the values of the first two indices (which have the same dimensions) are not equal.</p>
<p>I am using Julia v1.5.2 and ITensors v0.1.24.</p>
<p>Thanks for any reply!</p>
http://itensor.org/support/2713/set-itensor-elements-array-wiseTue, 01 Dec 2020 09:50:34 +0000Calculating correlations for fermions with spin
http://itensor.org/support/2707/calculating-correlations-for-fermions-with-spin
<p>Hi!<br>
I'm using the following code to calculate correlations of the type cdagup(i) cup(j) and take its log. I'm using Electron sites with {"ConserveSz=",false}</p>
<pre><code>auto ampo2 = AutoMPO(sites);
auto i = 100;
for(auto j=200;j<250;j++)
{
ampo2 += 1,"Cdagup",i,"Cup",j;
auto mpo = toMPO(ampo2);
auto result = innerC(psi,mpo,psi);
outfile<<i<<", "<<j<<", "<<log(abs(i-j))<<", "<<log(abs(result))<<"\n";
ampo2 = AutoMPO(sites);
}
outfile.close();
</code></pre>
<p>The answer depends on whether j is even or odd for a fixed i. Here is a small excerpt from the output. The log of the correlations are higher when j is odd.</p>
<p>i, j, Log(|i-j|), Log|cdagup(i) cup(j)| are printed below</p>
<p>100, 200, 4.60517, -8.32898<br>
100, 201, 4.61512, -6.1358<br>
100, 202, 4.62497, -8.33054<br>
100, 203, 4.63473, -6.1581<br>
100, 204, 4.64439, -8.33459<br>
100, 205, 4.65396, -6.17968<br>
100, 206, 4.66344, -8.34129<br>
100, 207, 4.67283, -6.20057</p>
<p>What is the reason for this? Is this a proper way to calculate the correlations?</p>
http://itensor.org/support/2707/calculating-correlations-for-fermions-with-spinSun, 29 Nov 2020 13:02:47 +0000What is the point of the space() method used in siteind()?
http://itensor.org/support/2699/what-is-the-point-of-the-space-method-used-in-siteind
<p>I was looking at various parts of the ITensors.jl code, and I happened to notice something I really don't understand.</p>
<p>In the file ITensors.jl/src/physics/sitetype.jl, it seems that the more involved siteind() methods calls this space() method (and the other siteind() methods call one of these more involved ones). But the first space() method just returns nothing, and the second one seems to just call the first one. As such, I really don't know what the point of this method is.</p>
<p>Could someone clarify what is going on here? For convenience, I have put below the entire block of code for the siteind system. Any help on this would be greatly appreciated.</p>
<pre><code>#---------------------------------------
#
# siteind system
#
#---------------------------------------
space(st::SiteType; kwargs...) = nothing
space(st::SiteType, n::Int; kwargs...) =
space(st; kwargs...)
function space_error_message(st::SiteType)
return "Overload of \"space\",\"siteind\", or \"siteinds\" functions not found for Index tag: $(tag(st))"
end
function siteind(st::SiteType; addtags = "", kwargs...)
sp = space(st; kwargs...)
isnothing(sp) && return nothing
return Index(sp, "Site, $(tag(st)), $addtags")
end
function siteind(st::SiteType, n; kwargs...)
s = siteind(st; kwargs...)
!isnothing(s) && return addtags(s, "n=$n")
sp = space(st, n; kwargs...)
isnothing(sp) && error(space_error_message(st))
return Index(sp, "Site, $(tag(st)), n=$n")
end
siteind(tag::String; kwargs...) =
siteind(SiteType(tag); kwargs...)
siteind(tag::String, n; kwargs...) =
siteind(SiteType(tag), n; kwargs...)
# Special case of `siteind` where integer (dim) provided
# instead of a tag string
siteind(d::Integer,n::Integer; kwargs...) = Index(d,"Site,n=$n")
</code></pre>
http://itensor.org/support/2699/what-is-the-point-of-the-space-method-used-in-siteindTue, 17 Nov 2020 20:30:17 +0000Problem with nmultMPO on large Fermionic chain
http://itensor.org/support/2698/problem-with-nmultmpo-on-large-fermionic-chain
<p>Hi Miles&Matt,</p>
<p>I am encountering a problem with the nmultMPO function on the following minimal example:</p>
<pre><code> auto N=257;
auto sites = Electron(N);
auto ampo = AutoMPO(sites);
ampo += 1.0, "Ntot",2;
auto H = toMPO(ampo);
auto H2 = nmultMPO(H,prime(H));
</code></pre>
<p>For me this code works for N<257, but nmultMPO fails for N>=257 with the error message:<br>
terminate called after throwing an instance of 'std::runtime_error'<br>
what(): Error condition in diagHermitian<br>
Aborted (core dumped)</p>
<p>The same also happens for a less artificial Hamiltonian. For the Fermion SiteSet<br>
I observe something similar. However, instead of an error message nmultMPO seems to return just a zero MPO here (again, small systems work fine).<br>
Do you know where the problem could come from?<br>
I would appreciate any help.</p>
<p>Best regards,<br>
Lucas</p>
http://itensor.org/support/2698/problem-with-nmultmpo-on-large-fermionic-chainSun, 15 Nov 2020 00:45:35 +0000Can we use Intel MKL libraries on systems with new AMD processors ?
http://itensor.org/support/2695/can-use-intel-mkl-libraries-systems-with-new-amd-processors
<p>Will Intel MKL libraries, work in non-intel hardwares? </p>
<p>I am about to buy a new system/laptop. I currently have intel processor on my system but just wished to ask about new AMDs so, that I don't face any issue when using and compiling tensor networks codes on those systems. Needed some help/suggestion, etc.</p>
http://itensor.org/support/2695/can-use-intel-mkl-libraries-systems-with-new-amd-processorsFri, 13 Nov 2020 18:53:07 +0000Unknown issue concerning diagITensor with adding MPSs?
http://itensor.org/support/2686/unknown-issue-concerning-diagitensor-with-adding-mpss
<p>I am trying to add two MPSs in a relatively straightforward fashion, as follows:</p>
<pre><code>error_component = G*psi_temp
psi_temp_corrected = add(psi_temp, -1*error_component; maxdim=100, cutoff=1E-12)
</code></pre>
<p>I verified that both of these terms are of type MPS and have index agreement. Despite this, I am getting this error:</p>
<pre><code>ERROR: LoadError: MethodError: no method matching diagITensor(::Float64,
::IndexSet{2,Index,Tuple{Index{Array{Pair{QN,Int64},1}},Index{Int64}}})
Closest candidates are:
diagITensor(::Number, ::Union{Tuple{Vararg{IndexT,N}},
IndexSet{N,IndexT,Tuple{Vararg{IndexT,N}}}} where IndexT where N) at
C:\Users\user\.julia\dev\ITensors\src\itensor.jl:358
diagITensor(::Number, ::Index...) at C:\Users\user\.julia\dev\ITensors\src\itensor.jl:363
</code></pre>
<p>By the way, I get this same error whether I use the "add" method or the "sum" method.</p>
<p>I tried to look into abstractmps.jl and itensor.jl to understand this, but I don't really understand what relevance these diagITensor methods play in addition. Any help on this would be appreciated.</p>
http://itensor.org/support/2686/unknown-issue-concerning-diagitensor-with-adding-mpssTue, 10 Nov 2020 20:06:57 +0000iDMRG for spinful fermions
http://itensor.org/support/2683/idmrg-for-spinful-fermions
<p>H!<br>
I would like to do an infinite DMRG implementation for a fermionic Hamiltonian with spin. It is not clear to me how to construct an MPO for this model. I have gone through the sample file Heisenberg .h, but it would be really helpful if you could point me to some documentation or sample code on implementing iDMRG for fermions. </p>
<p>I want to be able to get the correlations in the asymptotic limit so is it better to do finite DMRG and a finite-size scaling or should I use infinite dmrg for this purpose? Also will iDMRG algorithm work for systems with impurities ?</p>
<p>Thank You!</p>
http://itensor.org/support/2683/idmrg-for-spinful-fermionsSun, 08 Nov 2020 07:39:52 +0000Changing basis in DMRG
http://itensor.org/support/2676/changing-basis-in-dmrg
<p>Hello!</p>
<p>So I was thinking whether I can modify iTensor's implementation of DMRG so that the basis is not Slater determinants but some other states. </p>
<p>In other words, let's say I have a bunch of states that are othonormal. Can I implement DMRG in terms of those states?</p>
<p>Once again, thanks so much.</p>
http://itensor.org/support/2676/changing-basis-in-dmrgThu, 05 Nov 2020 20:14:50 +00002d hamiltonian in julia
http://itensor.org/support/2670/2d-hamiltonian-in-julia
<p>There is no example given in the ITensor Julia version for a sample code for a 2 dimensional hamiltonian. I want to find the 2D hamiltonian. What function for the Julia Version can be used to make a square lattice, similar to C++ ITensor version, whose example is also mentioned in the website.<br>
<a rel="nofollow" href="https://itensor.org/docs.cgi?vers=cppv3&page=formulas/2d_dmrg">https://itensor.org/docs.cgi?vers=cppv3&page=formulas/2d_dmrg</a></p>
http://itensor.org/support/2670/2d-hamiltonian-in-juliaThu, 05 Nov 2020 07:25:09 +0000Applying projective operator to MPS
http://itensor.org/support/2668/applying-projective-operator-to-mps
<p>In the iTensor documentation, a default projective operator is mentioned, with the example code</p>
<pre><code>auto sites = SpinHalf(N);
//Projects site 3 onto state 2 (i.e. the down state)
auto P3_2 = op(sites,"Proj",3,{"State",2});
</code></pre>
<p>However, I'm confused as to what form this operator is in, and how it can be actually applied to a spin-half MPS. Treating <code>P3_2</code> as an MPO and running <code>applyMPO(P3_2, psi)</code> gives an error, as are my attempts to package <code>P3_2</code> into an <code>AutoMPO</code> object somehow. What does the intended usage of these operators look like?</p>
http://itensor.org/support/2668/applying-projective-operator-to-mpsWed, 04 Nov 2020 19:38:06 +0000