ITensor Support Q&A - Recent questions
http://itensor.org/support/questions
Powered by Question2AnswerGetting "Index does not contain given QN block" error
http://itensor.org/support/2638/getting-index-does-not-contain-given-qn-block-error
<p>Hi!<br>
I'm using AutoMPO to implement the following hamiltonian. Here is a snippet of my code</p>
<pre><code>int N = 12;
int Nc = N/2;
auto ampo = AutoMPO(sites);
auto Npart = N;
auto t1 = 1;
auto t2 = 0.5;
auto sites = Electron(N);
for(int b = 1; b < N; ++b)
{
ampo += t1,"Cdagup",b+1,"Cup",b;
ampo += -t1,"Cdagdn",b+1,"Cdn",b;
ampo += -t1,"Cdagup",b,"Cup",b+1;
ampo += t1,"Cdagdn",b,"Cdn",b+1;
}
ampo += t2,"Nup",Nc;
ampo += t2,"Ndn",Nc;
ampo += t2,"Cdagup",Nc,"Cdn",Nc;
ampo += t2,"Cdagdn",Nc,"Cup",Nc;
auto H = toMPO(ampo);
</code></pre>
<p>When I run my code I get the following error: "Index does not contain given QN block". When I remove the part containing the terms with 't2' the code runs fine. Is this due to some bug in AutoMPO or am I making some mistake when I do this? Is there anyway to get around this problem?</p>
<p>Best Regards<br>
NIkhil</p>
http://itensor.org/support/2638/getting-index-does-not-contain-given-qn-block-errorTue, 27 Oct 2020 11:51:34 +0000Thermal state missing/null link index
http://itensor.org/support/2637/thermal-state-missing-null-link-index
<p>I get the following error when calculating expectation values with an infinite temperature thermal state </p>
<p>"MPS or MPO has missing/null link index"</p>
<p>Everything is fine if I use gates to cool the state down from infinite temperature, but not at infinite temperature. The code was working fine before updating itensor today, it's probably been months since my last update. The following code reproduces the error.</p>
<pre><code>auto sites = SpinHalf(4);
auto state = MPS(sites);
auto N = sites.length();
for(int n = 1; n <= N; n += 2)
{
auto s1 = sites(n);
auto s2 = sites(n+1);
auto wf = ITensor(s1,s2);
wf.set(s1(1),s2(2), ISqrt2);
wf.set(s1(2),s2(1), -ISqrt2);
ITensor D;
state.ref(n) = ITensor(s1);
state.ref(n+1) = ITensor(s2);
svd(wf,state.ref(n),D,state.ref(n+1));
state.ref(n) *= D;
}
Print(inner(state,state));
</code></pre>
<p>The error occurs in the call to inner, it seems like it comes from the "linkInds" call in the line in inner of the form </p>
<pre><code>psidag.replaceLinkInds(sim(linkInds(psidag)));
</code></pre>
<p>Also, here is what I get if I call Print(state)</p>
<pre><code>ITensor ord=2:
(dim=2|id=798|"n=1,Site,S=1/2") <Out>
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1})
(dim=2|id=617|"V,Link") <Out>
1: 1 QN({"Sz",-1})
2: 1 QN({"Sz",1})
{norm=1.00 (QDense Real)}
ITensor ord=2:
(dim=2|id=243|"n=2,Site,S=1/2") <Out>
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1})
(dim=2|id=617|"V,Link") <In>
1: 1 QN({"Sz",-1})
2: 1 QN({"Sz",1})
{norm=1.41 (QDense Real)}
ITensor ord=2:
(dim=2|id=773|"n=3,Site,S=1/2") <Out>
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1})
(dim=2|id=610|"V,Link") <Out>
1: 1 QN({"Sz",-1})
2: 1 QN({"Sz",1})
{norm=1.00 (QDense Real)}
ITensor ord=2:
(dim=2|id=781|"n=4,Site,S=1/2") <Out>
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1})
(dim=2|id=610|"V,Link") <In>
1: 1 QN({"Sz",-1})
2: 1 QN({"Sz",1})
{norm=1.41 (QDense Real)}
</code></pre>
<p>As you can see, site 1 is connected to 2, and site 3 is connected to 4, but there is no link connected site 2 to 3, and I'm thinking this is the source of the error.</p>
<p>I'm wondering if this is a bug, or if I should be initializing the link indices somehow? Thank you for your time.</p>
<p>Best,<br>
Nick</p>
http://itensor.org/support/2637/thermal-state-missing-null-link-indexTue, 27 Oct 2020 02:13:01 +0000Exact MPO option for the julia version
http://itensor.org/support/2636/exact-mpo-option-for-the-julia-version
<p>Hi,</p>
<p>I have been looking for a way to create an exact MPO when using the julia version of ITensor. I know that in the C++ version, one can use the function toMPO with the argument "Exact", but I could not find a way to do this in the julia version. Is there already a way to do it? And if not, would it be possible to add one?</p>
<p>Best,</p>
<p>Rafael</p>
http://itensor.org/support/2636/exact-mpo-option-for-the-julia-versionTue, 27 Oct 2020 00:18:50 +0000How to calculate string operator in ITensor2?
http://itensor.org/support/2632/how-to-calculate-string-operator-in-itensor2
<p>Hi ITensor team,<br>
Thanks for your wonderful software ! I want to calculate Haldane string operator correlation function, so I want to define string operator, for example <\prod<em>{n<I}exp(I\pi S</em>{n}^{z})S^{z}_{I}>.if I have string operator, then I can calculate correlation function as spin correlation function. But I don't know how to exponential operator Sz(maybe MPO). my naive partial code as follow:</p>
<p>auto phi1=expHermitian(sites.op("Sz",1),PI<em>Cplx_i);<br>
auto phi2=expHermitian(sites.op("Sz",1),PI</em>Cplx_i);</p>
<p>for(int n = 2; n < N/4; ++n)<br>
{<br>
phi1 <em>=expHermitian(sites.op("Sz",n),PI</em>Cplx_i);<br>
print(phi1);<br>
}<br>
auto Ss1 = phi1*sites.op("Sz",N/4);</p>
<p>for(int n = 2; n < 3<em>N/4; ++n)<br>
{<br>
phi2 *=expHermitian(sites.op("Sz",n),PI</em>Cplx_i);<br>
}<br>
auto Ss2 = phi2*sites.op("Sz",3*N/4);</p>
<p>Ss1 and Ss2 is string operator at N/4 and 3*N/4. BUT this code does't work. Please help me to check. Thank you !</p>
http://itensor.org/support/2632/how-to-calculate-string-operator-in-itensor2Thu, 22 Oct 2020 13:21:57 +0000Spinless Fermion correlator in Julia
http://itensor.org/support/2629/spinless-fermion-correlator-in-julia
<p>Hi!<br>
I would like to know if there is any example code to measure spinless fermion correlator using the Julia version of ITensor?</p>
<p>Also I would like to know if using 'commonind(psi[i],psi[i-1])' in Julia the same as using 'leftLinkIndex(psi,i)' in C++ ?</p>
<p>Thank You</p>
http://itensor.org/support/2629/spinless-fermion-correlator-in-juliaWed, 21 Oct 2020 17:39:40 +0000The leading a few eigenvalues with arnoldi
http://itensor.org/support/2628/the-leading-a-few-eigenvalues-with-arnoldi
<p>Dear Itensor, </p>
<p>I'm trying to compute the entanglement entropy of a block of spin sites. To do that, I would like to compute the leading a few eigenvalues of the reduced density matrix with the arnoldi method. In iterativesolvers.h, the arnoldi method reads: </p>
<p>713 template <br>
714 std::vector <br>
715 arnoldi(const BigMatrixT& A, <br>
716 std::vector& phi, <br>
717 Args const& args)</p>
<p>I thought that if phi is a vector of n ITensors, the method would compute the leading n eigenvalues. I tried this way, but the method only computes the leading eigenvalue correct, all the other values in the std::vector returned by the method do not correspond to the other eigenvalues. </p>
<p>I'm wondering what one should do to compute the other eigenvalues? Also, do you know what the returned values really are, if they are not the leading eigenvalues? </p>
<p>(For example, for the reduced density matrix I have, the exact diagonalization gives the spectrum: 0.931117, 0.0342919, 0.0332737, ..., but the arnoldi returns 0.931117, 0.0641384, 0.0600246, ...) </p>
<p>Thanks, <br>
Yantao </p>
http://itensor.org/support/2628/the-leading-a-few-eigenvalues-with-arnoldiWed, 21 Oct 2020 15:20:32 +0000Misunderstanding about C/A operators in electron model
http://itensor.org/support/2626/misunderstanding-about-c-a-operators-in-electron-model
<p>Hi ITensor Support,</p>
<p>I am trying to construct and extended Hubbard model Hamiltonian with next-nearest-neighbour hopping but I am having some problems with the A/C operators while using the autoMPO functions.</p>
<p>As a minimal example, I have just considered the usual fermion hopping term </p>
<p>$$ H = - t_0 \sum_{i, s} c_{i, s}^\dagger c_{i+1,s} + c_{i+1, s}^\dagger c_{i,s} $$</p>
<p>I have represented this three different ways using autoMPO: <br>
-1st I just used the A operators without the Jordan-Wigner F operator (which I know should be wrong!)<br>
-2nd I used the C operators as is standard<br>
-3rd I used the A operators with the Jordan-Wigner F operators (this should be the same as above)</p>
<pre><code>int L = 4;
double t0 = 5;
//Set arguments
auto args = Args("Cutoff=",1E-15,"MaxDim=",5000);
//Initialise System
auto sites = Electron(L, {"ConserveQNs=",false});
// Build Evolution Operators
auto ampo = AutoMPO(sites);
auto ampo2 = AutoMPO(sites);
auto ampo3 = AutoMPO(sites);
//Effective Hamiltonian
//NN Hopping
for(int j = 1; j < L; ++j)
{
int s1 = j;
int s2 = j + 1;
ampo += (-t0) , "Adagup", s1, "Aup", s2;
ampo += (-t0) , "Adagup", s2, "Aup", s1;
ampo += (-t0) , "Adagdn", s1, "Adn", s2;
ampo += (-t0) , "Adagdn", s2, "Adn", s1;
ampo2 += (-t0) , "Cdagup", s1, "Cup", s2;
ampo2 += (-t0) , "Cdagup", s2, "Cup", s1;
ampo2 += (-t0) , "Cdagdn", s1, "Cdn", s2;
ampo2 += (-t0) , "Cdagdn", s2, "Cdn", s1;
ampo3 += (-t0) , "Adagup", s1, "F", s1, "Aup", s2;
ampo3 += -(-t0) , "Aup", s1,"F", s1, "Adagup", s2;
ampo3 += (-t0) , "Adagdn", s1, "F", s1+1, "Adn", s2;
ampo3 += -(-t0) , "Adn", s1,"F", s1+1, "Adagdn", s2;
}
</code></pre>
<p>I then compute the hopping amplitude between a state with a single spin down on the 2nd site and a single spin down on the 3rd site. By hand I get the following results:</p>
<p>$$ <br>
|\psi_0 \rangle = c_{2, \downarrow}^\dagger |0\rangle, \ |\psi_1 \rangle = c_{3, \downarrow}^\dagger |0\rangle, \ \langle \psi_1 |H|\psi_0 \rangle = -t_0 <br>
$$</p>
<p>However, performing the same thing in ITensor (with t_0 = 5) using </p>
<pre><code>auto Ham1 = toMPO(ampo, {"ConserveQNs", false});
auto Ham2 = toMPO(ampo2, {"ConserveQNs", false});
auto Ham3 = toMPO(ampo3, {"ConserveQNs", false});
auto states0 = InitState(sites);
states0.set(2, "Dn");
auto psi0 = MPS(states0);
psi0.orthogonalize();
psi0.normalize();
auto states1 = InitState(sites);
states1.set(3, "Dn");
auto psi1 = MPS(states1);
psi1.orthogonalize();
psi1.normalize();
cout << "Initial State Built" << endl;
auto test1 = innerC(psi1, Ham1, psi0);
auto test2 = innerC(psi1, Ham2, psi0);
auto test3 = innerC(psi1, Ham3, psi0);
Print(test1);
Print(test2);
Print(test3);
</code></pre>
<p>I get:<br>
test1 = (-5, 0)<br>
test2 = (5, 0)<br>
test3 = (5, 0)</p>
<p>Can you understand why these calculations are not agreeing with the theory? I have also tested these results against some exact diagonalisation calculations which agrees with the theory so I am rather confused. I'm sure I have just misunderstood something. I am hoping that by sorting out this bit I might be able to get my full model working.</p>
<p>Many thanks,<br>
Cameron</p>
http://itensor.org/support/2626/misunderstanding-about-c-a-operators-in-electron-modelTue, 20 Oct 2020 09:25:40 +0000Issue with size of the vector in large bond dimension
http://itensor.org/support/2604/issue-with-size-of-the-vector-in-large-bond-dimension
<p>Hi,<br>
I am doing DMRG calculation on nearest neighbor Fermi Hubbard model on triangular lattice with periodic boundary condition along y-direction. For smaller lattice sizes I have no issues. I tried doing same calculation for 6x6 size cluster on two different computers with RAM 128GB and 256 GB, but I got different error on each computer when the calculation reaches bond dimension of exactly 12000 on both (particularly at half filling or closer to it). At lower filling level (less electrons in the system) again I have no issues. <br>
Error on 128G computer:<br>
terminate called after throwing an instance of 'std::bad<em>alloc'<br>
what(): std::bad</em>alloc<br>
I think this is because of insufficient memory space in the ram.</p>
<p>Error on 256G computer:<br>
terminate called after throwing an instance of 'std::length<em>error'<br>
what(): cannot create std::vector larger than max</em>size()<br>
Here I think it is not a memory issue.</p>
<p>Surprisingly, both the error occur at same bond dim (i.e.12000). I found a paper <a rel="nofollow" href="https://journals.aps.org/prb/abstract/10.1103/PhysRevB.96.205130">https://journals.aps.org/prb/abstract/10.1103/PhysRevB.96.205130</a> in which people have done ground state dmrg calculation on 36 sites or larger size clusters and went upto bond dimension of 20000. So, I hope there should be a solution to my problem. Any help or suggestion please??</p>
<p>Best,<br>
Prakash </p>
http://itensor.org/support/2604/issue-with-size-of-the-vector-in-large-bond-dimensionSun, 11 Oct 2020 15:56:45 +0000Sharing a code for the iTDVP?
http://itensor.org/support/2595/sharing-a-code-for-the-itdvp
<p>Dear Matt and Miles, </p>
<p>I recently wrote a code for TDVP of infinite MPSs in part of my research. I see that in the external code section of iTensor, there is only TDVP for finite MPSs, so I thought it might be good to share the iTDVP code, which is here on github: <a rel="nofollow" href="https://github.com/yantaow/iTDVP/tree/master">https://github.com/yantaow/iTDVP/tree/master</a></p>
<p>The code is based on iTensor (C++, v3) and does not require any external libraries. It has a class for infinite MPSs, which can i) bring the iMPS to the canonical form iteratively, ii) compute the quasi-fixed point of the MPO-transfer matrix, and iii) perform the TDVP for iMPS. <br>
This code is also a good starting point to write, for example the VUMPS algorithm, because of its iMPS member functions. </p>
<p>I have benefited greatly from the codes from iTensor, so I thought it might be good to contribute back a tiny bit. </p>
<p>Anyways, please let me know whether you are interested. The final code on github is already in a pretty good shape. </p>
<p>Thanks, <br>
Yantao </p>
http://itensor.org/support/2595/sharing-a-code-for-the-itdvpFri, 09 Oct 2020 17:32:13 +0000How are hopping terms in the Hamiltonian stored in memory? Do they use a lot more memory?
http://itensor.org/support/2594/hopping-terms-hamiltonian-stored-memory-they-use-more-memory
<p>This is a question I probably should have asked a long time ago, but it didn't really occur to me until now.</p>
<p>For certain simple models, e.g. Ising spin models and J1-J2 models, there is a term (or multiple terms) in the Hamiltonian relating sites at the beginning and end of the chain. For example, the J1-J2 model on an N-site periodic chain has @@J<em>1\vec{S}</em>N\cdot\vec{S}<em>1@@, @@J</em>2\vec{S}<em>{N-1}\cdot\vec{S}</em>1@@, and @@J<em>2\vec{S}</em>N\cdot\vec{S}_2@@. However, when I add such terms in the Hamiltonian, no link is formed in the actual tensor network architecture, and the optimization works exactly as intended. Why is no such link needed when dealing with such terms in the Hamiltonian?</p>
<p>I'm kind of wondering the same thing for the terms that are just two sites apart, e.g. @@J<em>2\vec{S}</em>k\cdot\vec{S}_{k+2}@@, or for any distance for that matter. What's going on behind the scenes in how these terms are stored? For instance, is it true that the memory usage for a Hamiltonian term multiplying spins at two sites is larger the farther apart the two sites are?</p>
<p>When I use many such terms (e.g. putting a term between every pair of sites), then the code stops working and runs into memory errors, so I'm assuming that such terms do use more memory. But it seems to have no problem with a few terms of this form (as in the examples above with local interactions but periodic boundary conditions). Is this an accurate characterization?</p>
http://itensor.org/support/2594/hopping-terms-hamiltonian-stored-memory-they-use-more-memoryFri, 09 Oct 2020 15:51:32 +0000Is there some built-in generalization of KrylovKit.eigsolve that optimizes over multiple input vectors?
http://itensor.org/support/2593/generalization-krylovkit-eigsolve-optimizes-multiple-vectors
<p>I know that the KrylovKit.eigsolve Julia function can find a vector @@x@@ to maximize or minimize @@x^\dagger Ax@@ for a fixed matrix @@M@@. We can think of this in index notation as @@M_{\alpha\beta}x^\alpha\overline{x}^\beta@@, where the bar denotes complex conjugation.</p>
<p>What I am wondering is: does some common package in Julia have a built-in generalization of this method that optimizes over multiple input vectors? For instance, is there a built-in function that finds vectors @@x@@ and @@y@@ to maximize or minimize @@M_{\alpha\beta\gamma\delta}x^\alpha\overline{x}^\beta y^\gamma\overline{y}^\delta@@?</p>
<p>In case you're wondering why I'm asking, basically I am wondering whether it is possible to do a single optimization step over two non-adjacent sites in a way that keeps them unliked, because if you just multiply the two tensors together and then optimize that, then it will introduce a link between those sites. Basically I want to just do this step once in a while to see whether it is possible to fix some problems with my trial Schwinger model (as I have already discussed in some other questions on this website).</p>
http://itensor.org/support/2593/generalization-krylovkit-eigsolve-optimizes-multiple-vectorsFri, 09 Oct 2020 14:25:18 +0000Overlap between two MPS after time evolution
http://itensor.org/support/2591/overlap-between-two-mps-after-time-evolution
<p>Hi all, </p>
<p>fist of all, I am using the version 1.2. </p>
<p>I am trying to compute the following quantity: </p>
<p>G<em>{ij}(t)= < 0 | e^{iHt} * a</em>i * e^{-iHt} * a^{\dagger}_j | 0 > </p>
<p>where | 0 > is the ground state of the Kitaev chain with Hamiltonian H, and a and a^{\dagger} are the usual fermionic operator. My idea is to compute the two time evolution of the two states separately:</p>
<ul>
<li>a^{\dagger}_j | 0 > </li>
<li>|0></li>
</ul>
<p>in order to obtain:</p>
<ul>
<li>e^{-iHt} * a^{\dagger}_j | 0 > </li>
<li>e^{-iHt} | 0 >. </li>
</ul>
<p>Then I apply the operator a^{\dagger}<em>i on the second state in order to obtain the state a{\dagger}</em>i * e^{-iHt} | 0 >. Finally, I would like to take the bra - ket product between this two states for computing the previous quantity G_ij(t). </p>
<p>I attach the code: </p>
<pre><code> auto sites = Spinless(N,{"ConserveNf",false});
auto ampo = AutoMPO(sites);
for(int i=1; i<N; ++i) {
ampo += -1.0*w, "Cdag", i, "C", i+1;
ampo += -1.0*w, "Cdag", i+1, "C", i;
ampo += +1.0*delta, "C", i, "C", i+1;
ampo += +1.0*std::conj(delta), "Cdag", i+1,"Cdag", i;
ampo += +1.0*Uint, "Nint", i, "Nint", i+1;
}
for(int i = 1; i <= N; ++i) {
ampo += -1.0*mu, "N", i;
}
auto H = IQMPO(ampo);
auto state = InitState(sites);
auto psi = IQMPS(state);
auto energy = dmrg(psi,H,sweeps,{"Quiet",true});
// Print the final energy reported by DMRG
printfln("\nGround State Energy = %.10f \n\n", energy);
// Time Evolution
auto tau = 0.01;
auto expH = toExpH<IQTensor>(ampo,tau*Cplx_i);
auto args = Args("Cutoff=",1E-9,"Maxm=",3000);
auto ttotal = 3.0;
auto nt = int(ttotal/tau+(1e-9*(ttotal/tau)));
for(int n = 1; n <= nt; ++n) {
for(int i = 1; i <=N; ++i) {
for(int j = i; j <=N; ++j) {
if (j > i) {
auto op_i = sites.op("Cdag", i);
auto op_j = sites.op("Cdag", j);
// Creating the new MPS for the ket
auto psi_ket = psi;
psi_ket.position(j);
auto new_psi_ket = op_j*psi_ket.A(j);
new_psi_ket.noprime();
psi_ket.setA(j, new_psi_ket);
// Evolving the ket
psi_ket = exactApplyMPO<IQTensor>(expH,psi_ket,args);
normalize(psi_ket);
// Evolving the state for the bra
psi = exactApplyMPO<IQTensor>(expH,psi,args);
normalize(psi);
// Replace the operator CDag in the state for the bra
psi.position(i);
auto new_psi = op_i*psi_ket.A(i);
new_psi.noprime();
psi.setA(i, new_psi);
psi.position(1);
psi_ket.position(1);
auto result = overlapC(psi, psi_ket);
Print(result);
}
}
}
printfln("MPO: Time %d, Maximum MPS bond dimension after time evolution is %d", n*tau,maxM(psi));
}
</code></pre>
<p>The problem is that I obtain the following error: </p>
<p>From line 211, file /Users/giuseppe/Desktop/iTensor/ITensor/itensor/itensor_interface.ih</p>
<p>Wrong number of IndexVals passed to real/cplx (expected 2, got 0)</p>
<p>Wrong number of IndexVals passed to real/cplx (expected 2, got 0)</p>
<p>Any idea?</p>
<p>Thank you very much. </p>
http://itensor.org/support/2591/overlap-between-two-mps-after-time-evolutionFri, 09 Oct 2020 09:55:19 +0000Bug report in localop.h
http://itensor.org/support/2590/bug-report-in-localop-h
<p>Dear Itensor, </p>
<p>I believe there is a bug in localop.h. On line 234, nc_ is first set to 2, then line 239 says it can only be 1. </p>
<p>223 inline LocalOp::<br>
224 LocalOp(const ITensor& Op1,<br>
225 const ITensor& L, const ITensor& R,<br>
226 const Args& args)<br>
227 :<br>
228 Op1<em>(nullptr),<br>
229 Op2</em>(nullptr),<br>
230 L<em>(nullptr),<br>
231 R</em>(nullptr),<br>
232 size<em>(-1)<br>
233 {<br>
234 nc</em> = args.getInt("NumCenter",2);<br>
235 <br>
236 if(nc_ == 1)<br>
237 update(Op1,L,R);<br>
238 else<br>
239 Error("In LocalOp(ITensor,ITensor,ITensor), NumCenter cannot be set other than 1");<br>
240 }</p>
<p>Thanks, <br>
Yantao </p>
http://itensor.org/support/2590/bug-report-in-localop-hThu, 08 Oct 2020 01:04:29 +0000How can I converge to a continuum harmonic trap ground state?
http://itensor.org/support/2579/how-can-i-converge-to-a-continuum-harmonic-trap-ground-state
<p>I would like to investigate bosons in a 1D harmonic trap, and was hoping that this could be done by using DMRG in the continuum limit of having many more sites than particles.</p>
<p>As a test case, I have simulated one boson in a trap with the Hamiltonian</p>
<p><img src="https://latex.codecogs.com/gif.latex?%5Chat%20H_N%20=%20-t%20%5Csum_%7Bi=1%7D%5E%7BM-1%7D%20%28%5Chat%20a_i%5E%5Cdagger%20%5Chat%20a_%7Bi&plus;1%7D%20&plus;%20H.c.%29%20&plus;%20%5Csum_%7Bi=1%7D%5EM%20%5CBig%5B%20%5Cfrac%7B%5Comega%7D%7B2%7D%20%28x_i%20-%20x_c%29%5E2%20%5Chat%20n_i%5CBig%5D" alt="Hamiltonian"></p>
<p>However, the density, as measured with </p>
<p><img src="https://latex.codecogs.com/gif.latex?%5Clangle%20%5Cpsi%20%7C%20%5Chat%20n_i%20%7C%5Cpsi%20%5Crangle" alt="density"></p>
<p>does not converge towards the harmonic oscillator ground state for up to 100 sweeps on 1000 sites with small lattice constant in a system large enough that the particle does not feel the walls of the box. All other DMRG parameters were also generously set. It seems that for t >> \omega, the system tends towards the particle in a box ground state (which converges nicely if there is no trap), and for t <= \omega, the system tends towards a much more localized ground state than the harmonic oscillator ground state, see the figure which has \omega = 2t. Note that the DMRG potential is the potential felt at every point as output by the DMRG code.</p>
<p><img src="https://github.com/AndBM/andbm.github.io/blob/master/files/localized,%20omega%20eq%202%20t.png?raw=true" alt="enter image description here"></p>
<p>I am aware that iTensor DMRG is not designed for the continuum limit, but it has been used to investigate that limit in several published papers. I cannot find any DMRG parameters whose adjustment changes any of this, apart from those energies. Can you help me figure out what is going on?</p>
http://itensor.org/support/2579/how-can-i-converge-to-a-continuum-harmonic-trap-ground-stateFri, 02 Oct 2020 13:11:27 +0000How do I distinguish between right moving and left moving fermions in ITensor?
http://itensor.org/support/2577/distinguish-between-right-moving-moving-fermions-itensor
<p>Hi!<br>
I want to study a system with two species of fermions, that is right movers and left movers. I want to label the operators as c<em>{R} and c</em>{L} for right and left movers respectively . Is there any way to do this in ITensor?</p>
http://itensor.org/support/2577/distinguish-between-right-moving-moving-fermions-itensorThu, 01 Oct 2020 19:05:43 +0000How to define a new Class for particle like "Parafermions"?
http://itensor.org/support/2569/how-to-define-a-new-class-for-particle-like-parafermions
<p>Dear Itensor</p>
<p>Bellow is the list of collection of site objects (" corresponding Hilbert space and local operators"), which is included by default in the Itensor code. </p>
<pre><code>SpinHalf and SpinHalfSite
SpinOne and SpinOneSite
Spinless and SpinlessSite.
Hubbard and HubbardSite
tJ and tJSite. t-J model sites.
</code></pre>
<p>how can I extend it, for example the Spinless fermion one, bellow </p>
<pre><code>"Emp" — the vacuum (empty) state
"Occ" — the occupied state (one particle)
</code></pre>
<p>into something like this :</p>
<p>"Emp" — the vacuum (empty) state<br>
"Occ1" — the occupied state (one particle)<br>
"Occ2" — the occupied state (two particles)</p>
<p>it means the local dimension is $3\times 3$, <br>
and the particle operator cast as follows:</p>
<p>$N=F^\dagger F+F^\dagger^2+F^2$,<br>
with commutation relations </p>
<p>$[N,F^\dagger]= F^\dagger$<br>
$[N,F]= -F$</p>
<p>many thanks for comments and remarks </p>
<p>Regards<br>
Javad</p>
http://itensor.org/support/2569/how-to-define-a-new-class-for-particle-like-parafermionsTue, 29 Sep 2020 15:05:37 +0000Question of producing a product signlet state and measuring it.
http://itensor.org/support/2566/question-producing-product-signlet-state-and-measuring-it
<p>Dear All</p>
<p>I am trying to implement a product singlet state and measure the Sz of it. I tried tutorial/finiteT/ancilla.cc code as a start. My code is as follows:</p>
<pre><code>#include "./itensor/all.h"
#include "./itensor/util/print_macro.h"
using namespace itensor;
int main()
{
int N = 2; //number of sites
auto sites = tJ(N,{"ConserveQNs=",true});
auto psi = MPS(sites);
for(int n = 1; n < N; n += 2)
{
auto s1 = sites(n);
auto s2 = sites(n+1);
auto wf = ITensor(s1,s2);
wf.set(s1(1),s2(2), ISqrt2);
wf.set(s1(2),s2(1), -ISqrt2);
ITensor D;
psi.ref(n) = ITensor(s1);
psi.ref(n+1) = ITensor(s2);
svd(wf,psi.ref(n),D,psi.ref(n+1));
psi.ref(n) *= D;
}
for (auto i : range1(N-1))
{
psi.position(i);
auto bondket = psi(i)*psi(i+1);
auto bondbra = dag(prime(bondket,"Site"));
auto zzop = op(sites,"Sz",i)*op(sites,"Sz",i+1);
auto zz = eltC(bondbra*zzop*bondket).real();
printfln("%d Sz*Sz: %.12f",i,zz);
}
for(auto j : range1(N))
{
psi.position(j);
auto ket = psi(j);
auto bra = dag(prime(ket,"Site"));
auto Nupjop = op(sites,"Nup",j);
auto Nupj = eltC(bra*Nupjop*ket).real();
auto Ndnjop = op(sites,"Ndn",j);
auto Ndnj = eltC(bra*Ndnjop*ket).real();
auto szjop = op(sites,"Sz",j);
auto szj = eltC(bra*szjop*ket).real();
printfln("%d up:%.12f,dn:%.12f,tot:%.12f,sz:%.12f",j,Nupj,Ndnj,Nupj+Ndnj,szj);
}
return 0;
}
</code></pre>
<p>So above I produced the product of singlet states (|up dn>-|dn up>)/sqrt2. I measured the Sz<em>i*Sz</em>j, Nup<em>i, Ndn</em>i, Sz_i for this state. The result is :</p>
<pre><code>1 S*S: 0.000000000000 Sz*Sz: 0.000000000000
1 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
2 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
</code></pre>
<p>This is wrong but I don't know why. </p>
<p>I changed the number of sites to 4 and the result is:</p>
<pre><code>1 S*S: 0.000000000000 Sz*Sz: 0.000000000000
2 S*S: 0.062500000000 Sz*Sz: 0.062500000000
3 S*S: 0.000000000000 Sz*Sz: 0.000000000000
1 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
2 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
3 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
4 up:0.500000000000,dn:0.000000000000,tot:0.500000000000,sz:0.250000000000
</code></pre>
<p>Can you pls tell me what is the problem of it? Thanks!</p>
<p>Eric</p>
http://itensor.org/support/2566/question-producing-product-signlet-state-and-measuring-itTue, 29 Sep 2020 14:34:27 +0000SVD an ITensor with QN in Julia?
http://itensor.org/support/2560/svd-an-itensor-with-qn-in-julia
<p>Hi Miles,</p>
<p>I am using the latest Julia version ITensors.</p>
<p>1.I defined an Index with QN. When I set "dir = In", the Index is not ordered, e.g. qn(s(2)) = QN("N",4,5). When I set "dir = Neither", qn(s(j)) always gives QN("N",0,5). Is this a bug?</p>
<pre><code>s = Index([QN(("N",i,5)) => 1 for i = 0:4];dir = ITensors.Arrow(0))
qn(s(2))
</code></pre>
<p>BTW, the direction name "Out", "In" conflict with Out and In in Jupyter Notebook.</p>
<p>2.I wanted to svd an ITensor with QN, but it says "In <code>setindex!</code>, 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."</p>
<pre><code>dim0 = 4
s = Index([QN(("N",i,dim0))=>1 for i = 0:(dim0-1)];dir = ITensors.Arrow(1))
#s = Index(dim0)
l = addtags(s,"left")
r = addtags(s,"right")
u = addtags(s,"up")
d = addtags(s,"down")
A = emptyITensor(l,r,u,d)
for sl = 1:dim0, sd = 1:dim0, sr = 1:dim0, su = 1:dim0
#if sl+sd == sr+su || abs(sl+sd-sr-su) == dim0
if val(qn(l(sl))+qn(d(sd))-qn(r(sr))-qn(u(su)),"N") == 0
A[l(sl),r(sr),u(su),d(sd)] = 1
end
end
svd(A, (l,d))
</code></pre>
<p>Am I doing wrong?</p>
<p>Thanks.</p>
<p>Jin</p>
http://itensor.org/support/2560/svd-an-itensor-with-qn-in-juliaSun, 27 Sep 2020 06:50:37 +0000Can ITensor calculate 2D Heisenberg model real-time correlation function?
http://itensor.org/support/2558/itensor-calculate-heisenberg-model-correlation-function
<p>Hi, ITensor team,<br>
Thanks for your excellent library about Tensor Network. I can calculate 1D Heisenberg chain real-time correlation function by using Trotter gate method <a rel="nofollow" href="https://itensor.org/docs.cgi?vers=cppv3&page=formulas/tevol_trotter.">https://itensor.org/docs.cgi?vers=cppv3&page=formulas/tevol_trotter.</a> But this method only deal with NN interaction, right? <br>
I want to calculate 2D Heisenberg model real-time correlation function. my strategy is convert 2D lattice (e.g. square lattice) to 1D chain with <strong>effective LONG RANGE interaction</strong>. so in this case, can I use Trotter gate method to compute real-time correlation function ? Thanks! </p>
http://itensor.org/support/2558/itensor-calculate-heisenberg-model-correlation-functionFri, 25 Sep 2020 06:09:11 +0000Error loading MPS from file
http://itensor.org/support/2555/error-loading-mps-from-file
<p>Hello Miles and ITensor team!</p>
<p>Thanks for the great library for handling tensor network algorithms! I am using the lastest version of ITensor v3 in C++, Ubuntu 18.04 and using gcc. I made two programs, one that calculates the ground state of the Extended Hubbard Model and saves the variables <em>sites</em> (Hubbard object) and <em>mps</em> to the disk. The other program loads these objects to make another calculations. But, when I am loading these objects in the second program, I get and error in the execution that follows:</p>
<p>"terminate called after throwing an instance of 'std::length_error'<br>
what(): vector::_M_default_append"</p>
<p>I know the error is in the following line:</p>
<pre><code>MPS psi = readFromFile<MPS>(format("./data/obc/%s/N_%03d/psi",foldername,N)+append, sites);
</code></pre>
<p>At the moment, I was not able to reproduce the error without needing to use the specific mps that I have saved to disk, and the saved mps files may have been generated in a previous version of itensor. While I am trying to analyze in debug mode and create a code that reproduces the error, I would like some opinion about what it could be, since I don't know the conditions that this error happens, and ask two questions: (1) can previous versions of mps still be loaded in the most recent version of ITensor? (2) Is the old Hubbard siteset completely equivalent to Electron siteset (just a change in the name of the spinfull fermion sites object)? </p>
<p>The important parameters of my code are maxdim = 2000 (and the mps reaches this limit), and cutoff = 1E-20. Using a number of N = 20 sites this error occurs, but for N = 22 it no longer occurs.</p>
<p>I really appreciate any help and I will update this post as soon as I discover the reason for the error. Thanks.</p>
http://itensor.org/support/2555/error-loading-mps-from-fileWed, 23 Sep 2020 19:00:56 +0000error message in the code formula for DRMG computing excited states
http://itensor.org/support/2546/error-message-code-formula-for-drmg-computing-excited-states
<p>Dear ITesnor, </p>
<p>I recently compiled and ran the code formula here: <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=formulas/excited_dmrg">http://itensor.org/docs.cgi?vers=cppv3&page=formulas/excited_dmrg</a> </p>
<p>But upon running the line <br>
auto [en1,psi1] = dmrg(H,wfs,randomMPS(sites),sweeps,{"Quiet=",true,"Weight=",20.0});, </p>
<p>the code throws the error message <br>
"From line 1604, file itensor.cc</p>
<p>div(ITensor) not defined for non QN conserving ITensor</p>
<p>div(ITensor) not defined for non QN conserving ITensor"</p>
<p>Do you know how to solve this error? </p>
<p>Thanks! <br>
Yantao </p>
http://itensor.org/support/2546/error-message-code-formula-for-drmg-computing-excited-statesWed, 23 Sep 2020 15:59:02 +0000Contraction of Multiple ITensors?
http://itensor.org/support/2538/contraction-of-multiple-itensors
<p>Hi,</p>
<p>It seems the contraction * only works for two ITensors. If I have more than two ITensors that share one index, e.g. A(i,j)*B(i,k)*C(i,l) gives wrong results. Is there a function in this library doing this? Thanks.</p>
<p>Jin</p>
http://itensor.org/support/2538/contraction-of-multiple-itensorsTue, 22 Sep 2020 06:03:15 +0000How ITensor simulate Kitaev honeycomb model?
http://itensor.org/support/2532/how-itensor-simulate-kitaev-honeycomb-model
<p>Dear ITensor team,<br>
Thans for your excellent software. I am beginner of ITensor and my questions maybe silly, sorry about that. I think ITensor can realized small size (3X4 unit cell) Kitaev honeycomb model. But I don't know how to modify example code. Please give me some advices or sample code if possible, Thank you very much !</p>
http://itensor.org/support/2532/how-itensor-simulate-kitaev-honeycomb-modelSun, 20 Sep 2020 11:44:21 +0000Details of How DMRG works
http://itensor.org/support/2529/details-of-how-dmrg-works
<p>Hi,</p>
<p>I am trying to understand the inner workings of the DMRG algorithm implemented in ITensor. After going through a <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/DMRG">documentation page</a>, I gathered that it is about finding the variational minimum of the energy by optimizing over two sites. However, when I wanted to get detailed information on the <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=course">tutorial page</a> it doesn't load for me.</p>
<p>So, here is my question: in essence how is this different from a simple optimization routine like the gradient decent algorithm? If it is different, can the DMRG algorithm still get struck into a local minima and end up not finding the true ground state of a hamiltonian (although it satisfies the prescribed precision)?</p>
<p>Note: I am using the Julia version of the code.</p>
http://itensor.org/support/2529/details-of-how-dmrg-worksThu, 17 Sep 2020 21:47:23 +0000How to implement symmetry which anticommutes with hamiltonian
http://itensor.org/support/2510/how-implement-symmetry-which-anticommutes-with-hamiltonian
<p>Dear community,</p>
<p>How is it possible to implement the conservation of an anti-block structure for {H,U} = 0? </p>
<p>Let us consider for instance the example H = ∑ σˣᵢ + ∑ σˣᵢ σˣⱼ σˣₖ with U = ∏ σˣᵢ where the z-parity only anticommutes with the hamiltonian. Right now I am implementing this using the square of the Hamiltonian, since then [H²,U]=0 and we can use regular quantum numbers; however, this is a very bad solution. Can you think of a better way?</p>
<p>Best,</p>
<p>v.</p>
http://itensor.org/support/2510/how-implement-symmetry-which-anticommutes-with-hamiltonianFri, 11 Sep 2020 09:53:01 +0000How do we take into account QN conservation in self-writing an MPO?
http://itensor.org/support/2502/how-do-take-into-account-qn-conservation-self-writing-an-mpo
<p>I want to use the iDMRG code in a 2D system, so I am trying to write a 2D version of the Heisenberg.h file for my 2D spinless fermionic system. I managed to write the MPO with the W-matrices, similarly as in the Heisenberg.h code, and also taken into account the Jordan-Wigner transformation. </p>
<p>Still, I do not know how to handle QN conservation (I want the number of fermions to be conserved), and when I run the code I get an error related to the divergence of the IQTensors.</p>
<p>I understand that I should arrange the tensor in non-zero blocks, but in practice how can I do it when adding terms to the W-matrices? I do not see any special line in the Heisenberg.h file related to this (I see that from lines 84-94 the different terms are added and that's all), but I guess there is something more involved in my system, which is 2D and requires the Jordan-Wigner strings mediating interactions. </p>
<p>Thanks a lot for your time,</p>
<p>Sergi</p>
http://itensor.org/support/2502/how-do-take-into-account-qn-conservation-self-writing-an-mpoMon, 07 Sep 2020 13:57:42 +0000Implementing Jaynes–Cummings–Hubbard model using Julia
http://itensor.org/support/2491/implementing-jaynes-cummings-hubbard-model-using-julia
<p>Hello,</p>
<p>I am working with Julia version of ITensor and would like to know if Jaynes-Cummings-Hubbard (JCH) model can be implemented in it.</p>
<p>Cheers,<br>
Manpreet</p>
<p>Edit : The JCH model is given, for example, in this article <a rel="nofollow" href="https://arxiv.org/abs/1611.06404v2"></a><a rel="nofollow" href="https://arxiv.org/abs/1611.06404v2">https://arxiv.org/abs/1611.06404v2</a></p>
http://itensor.org/support/2491/implementing-jaynes-cummings-hubbard-model-using-juliaFri, 04 Sep 2020 17:19:39 +0000Inconsistency between DMRG ground state energy and <psi|H|psi>
http://itensor.org/support/2477/inconsistency-between-dmrg-ground-state-energy-and-psi-psi
<p>Using the packages developed for fermions, I wrote a very simple code to calculate the GS energy of free fermions.</p>
<h2>the code:</h2>
<p>using ITensors<br>
let<br>
N = 4<br>
numb<em>sweeps = 5<br>
sweeps = Sweeps(numb</em>sweeps)<br>
maxdim!(sweeps,10,20,100,300,500)<br>
cutoff!(sweeps,1e-10)</p>
<pre><code>sites = siteinds("Fermion",N; conserve_qns = true)
# initialize a state at half-filling
states = vcat(["Occ" for n = 1:N/2],["Emp" for n = 1:N/2])
psi0 = productMPS(sites,states)
ampo = AutoMPO()
for j = 1:N-1
ampo += "C",j,"Cdag",j+1
ampo += "Cdag",j,"C",j+1
end
H = MPO(ampo,sites)
energy,psi = dmrg(H,psi0,sweeps)
println(inner(psi,*(H,psi)))
return
</code></pre>
<p>end</p>
<p>However, the GS energy calculated from inner(psi,*(H,psi)) is quite different from the result from DMRG. I also tried this for Ising spin chain, and it checks out there. For the fermion case, I don't know where went wrong. Any help is greatly appreciated.</p>
http://itensor.org/support/2477/inconsistency-between-dmrg-ground-state-energy-and-psi-psiWed, 02 Sep 2020 22:18:28 +0000Create a symmetric copy of a MPS: How to transpose QN?
http://itensor.org/support/2460/create-a-symmetric-copy-of-a-mps-how-to-transpose-qn
<p>Hi folks, <br>
I am trying to copy the first 1...L÷2 matrices of an MPS to the last L÷2+1...L matrices (in order to get the symmetric copy of the MPS). the layout is as following:</p>
<pre><code>A - B - C - U λ - V - D - E - F
| | | | | | | |
=> A - B - C - U λ - U - C - B - A
| | | | | | | |
</code></pre>
<p>The problem I am having right now is that I am not able to link Uλ with U. However, since λ is diagonal, this should be possible in principle. In particular, this works without quantum numbers, but with quantum numbers somehow the order of the blocks is reversed. Do you have an idea how I could go on in that situation? Here some code:</p>
<pre><code>L = 8
maxdim = 20
sites = siteinds("S=1/2",L,conserve_szparity=true)
ψ = randomMPS(sites,[rand(Bool) ? "↑" : "↓" for i in 1:L]);
truncate!(ψ,maxdim=maxdim)
orthogonalize!(ψ,L÷2);
U, λ, V = svd(ψ[L÷2]*ψ[L÷2+1], uniqueinds(ψ[L÷2],ψ[L÷2+1]))
ψ_new = copy(ψ)
s_ind1 = siteindex(ψ,L)
s_ind2 = siteindex(ψ,1)
bondL = commonind(ψ[1],ψ[2])
ψ_new[L] = prime(replaceind(ψ[1],s_ind2,s_ind1),bondL)
for i in 2:L÷2-1
s_ind1 = siteindex(ψ,L-i+1)
s_ind2 = siteindex(ψ,i)
bondL = commonind(ψ[i],ψ[i+1])
bondR = commonind(ψ[i],ψ[i-1])
ψ_new[L-i+1] = replaceind(ψ[i],s_ind2,s_ind1)
prime!(ψ_new[L-i+1],bondL)
prime!(ψ_new[L-i+1],bondR)
end
ψ_new[L÷2] = U*λ
linku = commonind(U,λ)
linkv = commonind(V,λ)
bondL = commonind(ψ[L÷2],ψ[L÷2-1])
s_ind1 = siteindex(ψ,L÷2+1)
s_ind2 = siteindex(ψ,L÷2)
ψ_new[L÷2+1] = replaceind(U,s_ind2,s_ind1)
prime!(ψ_new[L÷2+1],bondL)
replaceind!(ψ_new[L÷2+1],linku,linkv)
</code></pre>
<p>The error I get in the last line here is</p>
<pre><code>Indices must have the same spaces to be replaced
</code></pre>
<p>If we look at linku and linkv, it becomes apparent that they do not coincide (in dimensionality and quantum numbers), even though λ is diagonal. This is something I do not quite understand, does this diagonality somehow change when using quantum numbers?</p>
<p>Best,</p>
<p>v.</p>
http://itensor.org/support/2460/create-a-symmetric-copy-of-a-mps-how-to-transpose-qnMon, 31 Aug 2020 10:11:05 +0000About the excited state of electron wave packet using the toMPO
http://itensor.org/support/2459/about-the-excited-state-electron-wave-packet-using-the-tompo
<p>Dear ITensor developers:</p>
<p>I am consider about the time evolution of electron wave packet in interacting model. First I got the ground state using static DMRG, the electron packet for example, </p>
<p>$$<br>
h^{\dagger}\left(k<em>{0}\right)=\sum_{j} a_{j} e^{i k</em>{0} j} c^{\dagger}_{j}<br>
$$</p>
<p>then I try to use the AutoMPO, toMPO, and applyMPO get the excited state $\left|\Psi<em>{e}\right\rangle=h^{\dagger}\left(k</em>{0}\right)\left|\Psi_{0}\right\rangle$, but the ITENSOR give me the errors<br>
I = (dim=2|id=932|"l=39,Link") <br>
1: 2 QN()<br>
Q = QN({"Nf",1,-1},{"Sz",1})<br>
From line 683, file index.cc<br>
Index does not contain given QN block.</p>
<p>the minimal code is:<br>
auto [energy, psi] = dmrg(H, psi0, sweeps);<br>
auto AmpoTemp = AutoMPO(sites);// Hubbard Model<br>
for (auto b : range1(int(N)))<br>
{<br>
AmpoTemp += Coefficent, "Cup", b;<br>
}<br>
auto Htemp=toMPO(AmpoTemp);<br>
auto NewPsi=applyMPO(Htemp,psi,{"Method=","DensityMatrix","MaxDim=",1000,"Cutoff=",1E-8});// |y>=h|x><br>
NewPsi.noPrime().normalize();</p>
<p>If I change the Cup to Nup, it works. I want to know why and how to fix it. Many thanks!</p>
http://itensor.org/support/2459/about-the-excited-state-electron-wave-packet-using-the-tompoMon, 31 Aug 2020 01:30:59 +0000Hubbard model in magnetic field
http://itensor.org/support/2456/hubbard-model-in-magnetic-field
<p>Hello,</p>
<p>I was trying to simulate 1D Hubbard model ground state in presence of a magnetic field. When I vary the strength of the magnetic field, the ground state energy was changing, but the 1-site reduced density matrix does not change, which should not be the case.</p>
<p>I am writing the code below. Any suggestion will be appreciated.</p>
<pre><code>auto t1 = 1;
auto U1 = 0;
auto sites = Electron(N);
auto ampo = AutoMPO(sites);
for(double mu=-4; mu<=4; mu=mu+0.5)
{
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);
auto state = InitState(sites);
int p = Npart;
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);
Print(totalQN(psi0);
auto [energy,psi] = dmrg(H,psi0,sweeps,{"Quiet",quiet});
mat rho_1 = RDM_site(psi, N/2, 4);
cout << rho_1 << endl;
}
</code></pre>
<p>where RDM_site is the function for calculating the 1-site reduced density matrix.</p>
http://itensor.org/support/2456/hubbard-model-in-magnetic-fieldSun, 30 Aug 2020 14:06:22 +0000dmrg function not accepting MPO obtained by using nmultMPO
http://itensor.org/support/2453/dmrg-function-not-accepting-mpo-obtained-by-using-nmultmpo
<p>Hi, <br>
I am using itensor v3 to compute ground state of (H-E)^2=H^2-2EH+E^2, where H is Fermi Hubbard Hamiltonian as defined in <a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/autompo&vers=cppv3">http://itensor.org/docs.cgi?page=classes/autompo&vers=cppv3</a> except I am calculating it in 2D square lattice and E is some constant. In order to construct H^2 I used nmultMPO function flowing way:<br>
auto H = toMPO(ampo);<br>
auto Hn = toMPO(ampo);<br>
auto HH = MPO{};<br>
nmultMPO(prime(H),Hn,HH,{"MaxDim",1000,"Cutoff",1E-14});<br>
so constructed HH (i.e. H^2) works fine with operation like inner(psi,HH,psi) but calling it upon dmrg function returns following message:<br>
dim(inds(phi.front())) = 16<br>
A.size() = 64<br>
From line 137, file /data/pn1_1/psharma/ITensor-v3/itensor/iterativesolvers.h</p>
<p>davidson: size of initial vector should match linear matrix size</p>
<p>davidson: size of initial vector should match linear matrix size<br>
Aborted (core dumped)<br>
while dmrg function works perfectly fine with H and same initial MPS (used for HH).<br>
Is there a way to fix this issue or do there exist any other simple way to find ground state of my problem? </p>
http://itensor.org/support/2453/dmrg-function-not-accepting-mpo-obtained-by-using-nmultmpoFri, 28 Aug 2020 02:00:50 +0000Commutators of MPO's
http://itensor.org/support/2446/commutators-of-mpos
<p>Hello!</p>
<p>I want to compute the following matrix elements: </p>
<p><img src="https://latex.codecogs.com/gif.latex?%3C%7B%5CPhi_0%7D%7C%5B%5Chat%20H,%20a%5E%5Cdagger_qa_p%5D%7C%7B%5CPhi_0%7D%3E" alt="enter image description here"></p>
<p>The Hamiltonian (H) is already stored as an MPO and Phi_0 is also stored as an MPS. Below is the code I am trying right now:</p>
<pre><code> for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
auto ampo = AutoMPO(sites);
ampo += "Cdagup", i, "Cup", j;
//ampo += "Cdagdn", i, "Cdn", j;
MPO op = toMPO(ampo);
auto C = nmultMPO(H[point],op,{"MaxDim",500,"Cutoff",1E-8}); cout << "os edo kala\n";
auto D = nmultMPO(op, H[point], {"MaxDim",500,"Cutoff",1E-8}); cout << "os edo kala\n";
gsl_matrix_set(G, i,j,-inner(states.at(ind),C,states.at(ind))+inner(states.at(ind),D,states.at(ind)));
}
}
</code></pre>
<p>I am getting the following error: Unassigned site in SiteStore</p>
<p>Any idea about why? Is it because I only have two indices in the C,D MPO's?</p>
<p>What I am trying to do is to basically implement orbital optimization for the Hubbard Hamiltonian. I do not know if there is another way to do that in iTensor.</p>
http://itensor.org/support/2446/commutators-of-mposWed, 26 Aug 2020 15:03:54 +0000removeqns(ITensor) in Julia
http://itensor.org/support/2440/removeqns-itensor-in-julia
<p>Hi,</p>
<p>I would like to remove the quantum numbers of ITensors (or MPS) in Julia, so that I can do contractions between MPS with QNs and operators which do NOT have the corresponding quantum symmetry.</p>
<p>I find a similar problem has been solved,</p>
<p><a rel="nofollow" href="http://itensor.org/support/2320/convert-a-quantum-number-mps-to-a-no-quantum-number-mps">http://itensor.org/support/2320/convert-a-quantum-number-mps-to-a-no-quantum-number-mps</a></p>
<p>But that function (i.e., <code>removeqns(psi)</code>) with the same name in Julia can only be applied to indices, not ITensors nor MPS.</p>
<p>Best,<br>
Junsen</p>
http://itensor.org/support/2440/removeqns-itensor-in-juliaTue, 25 Aug 2020 12:34:27 +0000Error regarding cmake samples
http://itensor.org/support/2439/error-regarding-cmake-samples
<p>Hi,</p>
<p>I am rather ignorant in cmake. I followed the instructions from the ITensor website and tried to compile the library first, and got this message:</p>
<p>Configure: Writing current dir to this_dir.mk</p>
<p>Building ITensor library</p>
<p>make[1]: Entering directory '/home/tianqic/ITensor/itensor'<br>
Building static library /home/tianqic/ITensor/lib/libitensor-g.a<br>
make[1]: Leaving directory '/home/tianqic/ITensor/itensor'</p>
<p>Presumably I believe ITensor has been successfully compiled? Then I got to samples folder and tried to make them but I got this:</p>
<p>g++ -m64 -std=c++17 -fconcepts -fPIC -c -I. -I'/home/tianqic/ITensor' -I/opt/intel/mkl/include -I/usr/lib64/include -DITENSOR<em>USE</em>HDF5 -O2 -DNDEBUG -Wall -Wno-unknown-pragmas -o dmrg.o dmrg.cc<br>
g++ -m64 -std=c++17 -fconcepts -fPIC -I. -I'/home/tianqic/ITensor' -I/opt/intel/mkl/include -I/usr/lib64/include -DITENSOR<em>USE</em>HDF5 -O2 -DNDEBUG -Wall -Wno-unknown-pragmas dmrg.o -o dmrg -L'/home/tianqic/ITensor/lib' -litensor -L/opt/intel/compilers<em>and</em>libraries<em>2020.0.166/linux/compiler/lib/intel64 -lmkl</em>intel<em>lp64 -lmkl</em>intel<em>thread -lmkl</em>rt -lmkl<em>core -liomp5 -lpthread -L/usr/lib64/lib -lhdf5 -lhdf5</em>hl<br>
/usr/bin/ld: cannot find -lmkl<em>intel</em>lp64<br>
/usr/bin/ld: cannot find -lmkl<em>intel</em>thread<br>
/usr/bin/ld: cannot find -lmkl<em>rt<br>
/usr/bin/ld: cannot find -lmkl</em>core<br>
collect2: error: ld returned 1 exit status<br>
make: *** [Makefile:29: dmrg] Error 1</p>
<p>Could anyone help me with this issue? Kind of clueless now. Thank you!</p>
<p>Best,<br>
Tianqi</p>
http://itensor.org/support/2439/error-regarding-cmake-samplesTue, 25 Aug 2020 10:50:08 +0000How to calculate Sz=1 sector magnetization?
http://itensor.org/support/2434/how-to-calculate-sz-1-sector-magnetization
<p>Dear ITensor team, <br>
Thanks for you reply. I want to follow spin-1 Heisenberg chain(see S.R.White PhysRevB.48.10345 Fig.7(b)) by using ITensor, but I just want to calculate Sz=1 sector physical quantity(such as magnetization). I don't know where I can modified. I have two naive idea to do so:<br>
1) Just keep initial state Sz=1 and they not change under evolving process.<br>
2) auto sites = SpinOne(N,{"ConserveQNs=1",true});?(I don't know it is work?)</p>
<p>Please help me! For convenience, this is my naive code for reference:</p>
<p>int main()<br>
{<br>
ofstream outfile;<br>
outfile.open("sz.dat",ios::app);</p>
<p>//Define a site set object "sites" which lets us<br>
//easily obtain Site indices defining our Hilbert space<br>
//and S=1 single-site operators</p>
<p>int N = 60; //number of sites<br>
auto sites = SpinOne(N,{"ConserveQNs=",true});</p>
<p>//Make initial MPS psi to be in the Neel state<br>
auto state = InitState(sites);<br>
auto ampo = AutoMPO(sites);<br>
for(auto j : range1(N))<br>
{<br>
state.set(j,j%2==1?"Up":"Dn");<br>
}<br>
auto psi = MPS(state);</p>
<p>for(int b = 1; b < N; ++b)<br>
{<br>
ampo += 0.5,"S+",b,"S-",b+1;<br>
ampo += 0.5,"S-",b,"S+",b+1;<br>
ampo += "Sz",b,"Sz",b+1;<br>
}</p>
<p>auto H = MPO(ampo);</p>
<p>auto sweeps = Sweeps(30);<br>
sweeps.maxm() = 100,200,800,800,1000;<br>
sweeps.cutoff() = 1E-10;<br>
sweeps.niter() = 2;<br>
sweeps.noise() = 1E-7,1E-8,1E-9;<br>
println(sweeps);</p>
<p>//<br>
// Begin the DMRG calculation<br>
//<br>
auto energy = dmrg(psi,H,sweeps,"Quiet");<br>
println(energy);<br>
auto psi0=psi;</p>
<p>for(int i = 1; i <= N; ++i)<br>
{<br>
auto Sz=op(sites,"Sz",i);<br>
auto newpsi = Sz*psi(i);<br>
newpsi.noPrime();<br>
psi.set(i,newpsi);</p>
<p>outfile <<i<<" "<<real(innerC(psi0,psi))<< endl;<br>
}</p>
<p>outfile.close();<br>
return 0;<br>
}</p>
http://itensor.org/support/2434/how-to-calculate-sz-1-sector-magnetizationSun, 23 Aug 2020 15:36:00 +0000Extended hubbard model ground state energy not converging for negative V
http://itensor.org/support/2432/extended-hubbard-ground-state-energy-converging-negative
<p>Dear Sir / Ma'am,</p>
<p>I was calculating the ground state enrgy for extended hubbard model using the code provided in sample folder. I used the range for U1 to be -8 to 8, and the range for V1 (nearest neighbour spin-spin interaction) to be in the range -6 to 6. in the above range, for some region of negative V1, the energy was not converging. It will be very helpful if someone can tell me what is going wrong here.</p>
<p>Some other points about the parameters I used:</p>
<ol>
<li><p>I used a lattice site of 10, with half-filling</p></li>
<li><p>I used periodic boundary condition</p></li>
<li><p>The sweeps were following:</p></li>
</ol>
<p>nsweeps = 60<br>
sweeps<br>
{<br>
maxdim mindim cutoff niter noise<br>
50 10 1E-12 2 1E-7<br>
100 20 1E-12 2 1E-8<br>
200 20 1E-12 2 1E-10<br>
400 20 1E-12 2 0<br>
800 20 1E-12 2 1E-11<br>
800 20 1E-12 2 0<br>
}</p>
<p>Best,<br>
Sreetama</p>
http://itensor.org/support/2432/extended-hubbard-ground-state-energy-converging-negativeFri, 21 Aug 2020 12:16:07 +0000Forcing S=0 and total number of electrons in the Fermi-Hubbard model (Julia)
http://itensor.org/support/2431/forcing-total-number-electrons-the-fermi-hubbard-model-julia
<p>I'm trying to adapt the code here ( <a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/autompo&vers=cppv3">http://itensor.org/docs.cgi?page=classes/autompo&vers=cppv3</a> )from C++ to Julia, specifically for the 1D Hubbard model. I'm a little confused on how I can enforce the number of electrons, number of sites, and number of spin-up and spin-down electrons.</p>
<p>Here is the code:</p>
<pre><code>N = 2 # number of sites
t = 1.0 # hopping term
u = 0.0 # potential term (onsite)
sites = siteinds("Electron", N)
ampo = AutoMPO()
for i=1:N
ampo += u ,"Nupdn", i
end
for i=1:N-1
ampo += -t, "Cdagup", i, "Cup", i+1
ampo += -t, "Cdagup", i+1, "Cup", i
ampo += -t, "Cdagdn", i, "Cdn", i+1
ampo += -t, "Cdagdn", i+1, "Cdn", i
end
H = MPO(ampo, sites)
</code></pre>
<p>N = 2 above enforces that we have a two site Hubbard model. I'm assuming that I've also enforced two electrons here in the line:</p>
<pre><code>sites = siteinds("Electron", N)
</code></pre>
<p>since I'm creating N=2 electrons (though I'm not sure if this is entirely true).</p>
<p>How might I enforce total S=0 (half of the electrons spin up, the other half spin down)? And how do I control how many electrons I have?</p>
<p>Apologies for the basic question!</p>
http://itensor.org/support/2431/forcing-total-number-electrons-the-fermi-hubbard-model-juliaSat, 15 Aug 2020 23:33:13 +0000Selecting specific rows, columns, i.e. fancy indexing in ITensor
http://itensor.org/support/2430/selecting-specific-rows-columns-fancy-indexing-in-itensor
<p>Hi folks,</p>
<p>I think I just missed it in the docs, but I do not see an easy way to do "fancy" indexing in ITensor. Lets us consider the following example </p>
<pre><code>i = Index(10,"i")
j = Index(20,"j")
k = Index(30,"k")
A = randomITensor(i,j,k)
U,Σ,V = svd(A,(i,j));
u = commonind(U,Σ)
# Now I would like to select all rows where Σ is larger than 15
cn = (Σ.store .> 15)
dim_cn = sum(cn)
c = Index(dim_cn,"c")
selector = zeros(dim_cn,dim(u))
selector[:,cn].= I(dim_cn)
selector = ITensor(selector,c,u)
U_new = selector * U
</code></pre>
<p>You see what is my goal: I would like to select specific rows of U. With standard Julia syntax I could just use</p>
<pre><code>U_new = U[:,Σ.> 15]
</code></pre>
<p>Thanks a lot.</p>
<p>Best,</p>
<p>v.</p>
http://itensor.org/support/2430/selecting-specific-rows-columns-fancy-indexing-in-itensorThu, 13 Aug 2020 09:14:31 +0000Entanglement entropy (Julia)
http://itensor.org/support/2423/entanglement-entropy-julia
<p>Hello, <br>
how we can calculate the entanglement entropy of an half chain with Julia?<br>
I am trying to adapt the following lines of code which are given for C++</p>
<p>Thanks a lot! <br>
Jacopo</p>
<p>auto b = 10;</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*log(p);<br>
}</p>
http://itensor.org/support/2423/entanglement-entropy-juliaWed, 05 Aug 2020 15:32:47 +0000Jordan wigner fermi string in self-writing AutoMPO
http://itensor.org/support/2422/jordan-wigner-fermi-string-in-self-writing-autompo
<p>I'm working on a 3-flavor fermion model on DMRG and coming up with the correlation of fermion operator.<br>
I don't know the rule of Jordan Wigner string "F" in this situation. Please give me some info about how AutoMPO deal with self-writing Fermions</p>
http://itensor.org/support/2422/jordan-wigner-fermi-string-in-self-writing-autompoWed, 05 Aug 2020 10:06:32 +0000SVD swapping index arrow in TEBD algorithm with conserved quantum numbers
http://itensor.org/support/2421/swapping-index-arrow-algorithm-conserved-quantum-numbers
<p>Hello,<br>
I am implementing the TEBD algorithm in Vidal's gauge (G. Vidal, PRL 98 2007) in presence of conserved quantum numbers and I get some error regarding the indices’ arrows. <br>
I report here a minimal example code that reproduces the issue:</p>
<pre><code>auto sites = SpinHalf(N,{"ConserveQNs=",true});
auto init = InitState(sites);
for(auto n : range1(N))
{
init.set(n, n%2 == 1 ? "Up" : "Dn");
}
auto psi = MPS(init);
std::vector<ITensor> lambda(N-1);
for(int i=1; i<= N-1; i++)
{
auto u= commonIndex(psi(i),psi(i+1));
lambda.at(i-1) = ITensor(dag(u), prime(u));
lambda.at(i-1).set(dag(u)(1), prime(u)(1), 1.);
}
for(int b= 1; b<N; b++){
ITensor A = psi(b);
ITensor B = psi(b+1);
Print(lambda.at(b-1));
A = noPrime(lambda.at(b-1)*A);
auto AA = A*B;
auto u= commonInds(A,AA);
auto [U,S,V] = svd(AA,u,{"Truncation=", false});
lambda.at(b-1) = S;
psi.ref(b) = U;
psi.ref(b+1) = V;
}
</code></pre>
<p>Here, I initialize the system in a product state and define the lambda matrices in the second loop. After this procedure, the indices' arrows of the lambdas have the correct direction in and out. <br>
Then, to avoid priming/unpriming indices in the lambdas, I perform the svd in the third loop, that should just change the indices from (i,i') to (i,j). Nevertheless, I observe that after contraction with the state at a local site psi(i) and SVD the direction of one of the arrows changes from in to out, thus making the contraction with the following site impossible. Furthermore, here the lambda acquires a fictitious bond dimension d=2 and its norm becomes larger by a factor sqrt(2). Please notice that the code does not show the actual TEBD, but just the minimal working patch that reproduces the issue.<br>
Even though it might be possible to fix this issue, at least for what concerns the wrong arrows, by manually change the direction of the troublesome index, I feel like there must be something I am missing and an easier solution.<br>
As this seems to involve the svd routine, I hope you could give some insightful answer to this issue.</p>
<p>Pietro</p>
http://itensor.org/support/2421/swapping-index-arrow-algorithm-conserved-quantum-numbersTue, 04 Aug 2020 10:27:27 +0000Purpose of various actions and parameters in replacebond! function?
http://itensor.org/support/2418/purpose-various-actions-parameters-replacebond-function
<p>I am curious about the purpose of various actions and parameters within the replacebond! function in src/mps/mps.jl. Some of these things don't have obvious use in the code, or I tried to look into the ITensors.jl code for them but didn't get much clarity. Since I am trying to make modified versions of this function for various purposes, I thought I should make sure I understand all of the parts.</p>
<p>(1) What is the purpose of spec, and of the Spectrum object type more generally? I see that spec comes from the factorization "L,R,spec = factorize(...)", and I see that it is returned at the end of the replacebond! function, but what is it supposed to accomplish? In particular, when the dmrg function calls replacebond!, it doesn't use spec for anything, as far as I can tell.</p>
<p>(2) I see that the normalize parameter is set to false by default. Under what circumstances would one likely wish to set it to true, and in such situations, what is it meant to accomplish? I see the lines of the form "normalize && (M[b] ./= norm(M[b]))" near the end of the method, but it's not clear to me when we should be using this and why by default we choose not to.</p>
<p>(3) What is the purpose of setleftlim! and setrightlim!, and more broadly, what is the purpose of leftlim and rightlim at all? I see lines of the form "leftlim(M) == b-1 && setleftlim!(M, leftlim(M)+1)" near the end of the method, but again, it's not clear to me why we are doing this. I notice that we increase leftlim(M) and rightlim(M) by 1 when ortho == "left" and decrease both by 1 when ortho == "right", so that part makes sense (i.e. sweeping to the left versus sweeping to the right). But what is this trying to achieve? And in general, what values are leftlim(M) and rightlim(M) supposed to be in a given situation?</p>
http://itensor.org/support/2418/purpose-various-actions-parameters-replacebond-functionTue, 28 Jul 2020 17:45:13 +0000Julia script for calculating energy gaps
http://itensor.org/support/2411/julia-script-for-calculating-energy-gaps
<p>Hi there,</p>
<p>Is there any existing Julia script for calculating exited MPS states using DMRG? I could only find the C++ version <a rel="nofollow" href="https://www.itensor.org/docs.cgi?page=formulas/excited_dmrg&vers=cppv3">here</a>.</p>
http://itensor.org/support/2411/julia-script-for-calculating-energy-gapsTue, 28 Jul 2020 10:29:23 +0000A Question for the Input Tensor
http://itensor.org/support/2410/a-question-for-the-input-tensor
<p>Hi</p>
<p>Do you happen to have a script/code to generate the input tensors for different scenarios? </p>
<p>We’re thinking of saving the tensors from ITensor to a file (in the format widely adopted in HPC sparse tensor community), which can be used to test other packages for your applications as well. </p>
<p>Thanks!<br>
Jiawen</p>
http://itensor.org/support/2410/a-question-for-the-input-tensorTue, 28 Jul 2020 03:25:05 +0000How do you separate product of two ITensor objects if the two tensors do not have any common indices? (Julia)
http://itensor.org/support/2403/separate-product-itensor-objects-tensors-common-indices-julia
<p>As an example, suppose the first and last sites of an MPS M are combined into an ITensor as phi = M[1] * M[N]. Then you perform some optimization that changes phi, for instance eigsolve using some other tensor as the "matrix" and phi as the "vector." Now I want to put the updated value of phi back into M[1] and M[N], but this requires me to somehow split the ITensor so that the two resulting ITensor objects have the same index structure as M[1] and M[N], respectively. How do I do this?</p>
<p>In regular DMRG, this is done using the factorize method, but I'm pretty sure this only works when the two things you want to separate have an index in common. For instance, if you do phi = M[1] * M[2], then since M[1] and M[2] share a common index, then the appropriate factorization will "sever" the appropriate bond between the two tensors, thus giving you one tensor with the same index structure as M[1] and one tensor with the same index structure as M[2].</p>
<p>However, when I tried this, it doesn't work. In particular, the code seems to introduce a new index to bind the two tensors together. To show an example using code, I did phi = M[1] * M[2] * M[3] * M[6] * M[7] * M[8] on an 8-site MPS M. Then, after doing some changes to phi using eigsolve, I wanted to separate it into M[1] * M[2] * M[3] and M[6] * M[7] * M[8] (each of which can then be separated using further factorize commands). I tried to do so using the following command:</p>
<pre><code>index_list = Index[]
for j=1:3
append!(index_list, inds(M[j]))
end
index_set = IndexSet(index_list)
L,R,spec = factorize(phi, index_set; which_decomp = which_decomp,
tags = tags(linkind(M,3)),
kwargs...)
</code></pre>
<p>But the result I got was the following:</p>
<pre><code>left side of phi:
IndexSet{5} (dim=2|id=16|"S=1/2,Site,n=1") (dim=2|id=978|"S=1/2,Site,n=2")
(dim=2|id=311|"S=1/2,Site,n=3") (dim=1|id=305|"Link,l=3") (dim=8|id=372|"Link,l=3")
right side of phi:
IndexSet{5} (dim=8|id=372|"Link,l=3") (dim=1|id=608|"Link,l=5")
(dim=2|id=514|"S=1/2,Site,n=6") (dim=2|id=558|"S=1/2,Site,n=7")
(dim=2|id=515|"S=1/2,Site,n=8")
</code></pre>
<p>Notice the new index (dim=8|id=372|"Link,l=3") used to connect the two tensors. I don't want to do this--I just want to separate the two tensors so that they have the same index structure as before. How do I do this? It's possible that factorization isn't the right term to describe this.</p>
http://itensor.org/support/2403/separate-product-itensor-objects-tensors-common-indices-juliaSat, 25 Jul 2020 06:57:12 +0000Using IQTensor for general states
http://itensor.org/support/2395/using-iqtensor-for-general-states
<p>Hi,</p>
<p>I have a question about IQTensor following that of <a rel="nofollow" href="http://itensor.org/support/1126/superposed-states-with-iqtensor.">http://itensor.org/support/1126/superposed-states-with-iqtensor.</a> Say I need to calculate O|psi> where O preserves some symmetry G but |psi> does not. That being said, |psi> can (as always) be decomposed into G eigenvectors such that each has a block structure.</p>
<p>My understanding is that the quantum number is taken care by the "boundary tensor". (correct me if I'm wrong.) That's to say, all tensors apart from the boundray one has divergence 0, while the divergence of the boundary one agrees with the quantum number. So a block-structured of |psi> is possible by a proper definition of the boundary one (i.e. a sum of tensors w/ different divergences) and it would still be efficient if I make use of the symmetry throughout. Is that correct?</p>
<p>Best,<br>
Chengshu</p>
http://itensor.org/support/2395/using-iqtensor-for-general-statesFri, 24 Jul 2020 18:42:19 +0000Swapping indices of an MPS for Hubbard
http://itensor.org/support/2379/swapping-indices-of-an-mps-for-hubbard
<p>Hello,</p>
<p>I have written a code that creates MPS's as a product of valence bonds for Hubbard. The code works fine for the cases where the valence bonds have adjacent sites., ie. for 6 sites: 1-2 3-4 5-6, 1-2 5-6 3-4, etc. My guess is that I am doing something wrong when I swap the indices and there must be a difference for Hubbard and Heisenberg, because for Heisenberg the same swapping part of the code works. Below is the code I have written:</p>
<pre><code> ITensor wf, S,V,U;
for (int i=swaps_.size()-1; i>=0; i--){
// swaps_ has all the swaps that are necessary so that I get the pattern that I want.
// swaps_ is calculated somewhere else, but I do not think it matters for the code below.
// Below is some code that gets the indices, again, not super important I think.
ar1 = swaps_[i].first;
ar2 = swaps_[i].second;
s1.clear(); s1.push_back(siteIndex(psi,ar1));
s2.clear(); s2.push_back(siteIndex(psi,ar2));
auto is1 = IndexSet(s1);
auto is2 = IndexSet(s2);
// And below comes the swapping part that works for Heisenberg.
psi.position(ar1);
wf = psi.A(ar1)*psi.A(ar2);
wf.swapInds(is1,is2);
wf.noPrime();
U = psi.A(ar1);
svd(wf,U,S,V,{"Cutoff=",1E-8});
psi.setA(ar1,U);
psi.setA(ar2,S*V);
}
</code></pre>
<p>Does anyone have any input maybe? Am I missing a sign for the fermionic wavefunction somehow that disturbs the final result? Could the error be somewhere else? The Hubbard that I am using preserves all quantum numbers.</p>
<p>Thank you,<br>
Thanos</p>
http://itensor.org/support/2379/swapping-indices-of-an-mps-for-hubbardWed, 22 Jul 2020 16:49:16 +0000Why is a ProjMPO callable but an ITensor not? (Julia)
http://itensor.org/support/2376/why-is-a-projmpo-callable-but-an-itensor-not-julia
<p>I am working on certain modifications to ITensors.jl for my own applications, and one thing I want to play with is how to do an optimization step with sites from both ends of the chain (e.g. optimizing sites N and 1 while everything else stays fixed).</p>
<p>To this end, the ProjMPO structure seemed too rigid, so I contracted the other tensors into an ITensor object in the most standard way, as follows:</p>
<pre><code>M = copy(H[1])
for j=2:N-1
M *= H[j] * psi[j] * dag(prime(psi[j]))
end
M *= H[N]
</code></pre>
<p>So far, so good. However, when I then tried to call eigsolve afterward, I got the following error: "ERROR: LoadError: MethodError: objects of type ITensor{8} are not callable".</p>
<p>I looked into the source code to better understand what was going on, but I didn't really get anywhere. To this end, I want to ask the following: what in the code makes a ProjMPS "callable" but an ITensor not, and why was this choice made?</p>
http://itensor.org/support/2376/why-is-a-projmpo-callable-but-an-itensor-not-juliaWed, 22 Jul 2020 09:28:20 +0000When ITensors in dev mode, modifications to existing functions are recognized but new functions are not
http://itensor.org/support/2375/itensors-modifications-existing-functions-recognized-functions
<p>I have a question regarding ITensors.jl in development mode. I have ITensors in the .julia/dev folder, since I am trying to made modifications to the ITensors.jl code itself for my applications.</p>
<p>I have noticed that, if I modify an existing method in a file in ITensors (for instance, adding a print statement to one of the dmrg functions in src/mps/dmrg.jl), I can see that change reflected immediately in any code I run that calls that function. However, if I create a new method in one of the existing files, then this change fails. Just as an example, I did this with a very simple addition to src/mps/dmrg.jl:</p>
<pre><code>function test_function()
println("You made it!")
return 0
end
</code></pre>
<p>I then made another file with just two lines of code:</p>
<pre><code>using ITensors
my_var = test_function()
</code></pre>
<p>And here is the output I got when running this file:</p>
<pre><code>ERROR: LoadError: UndefVarError: test_function not defined
Stacktrace:
[1] top-level scope at d:\Sujay Google Drive\Julia
Files\J1_J2_model_custom_periodic_dmrg.jl:32
[2] include(::String) at .\client.jl:439
[3] startdebug(::Base.PipeEndpoint, ::VSCodeDebugger.var"#3#4"{Tuple{String,String}})
at c:\Users\user\.vscode\extensions\julialang.language-julia-
0.17.7\scripts\packages\DebugAdapter\src\packagedef.jl:89
[4] startdebugger() at c:\Users\user\.vscode\extensions\julialang.language-julia-
0.17.7\scripts\packages\VSCodeDebugger\src\VSCodeDebugger.jl:38
[5] top-level scope at c:\Users\user\.vscode\extensions\julialang.language-julia-
0.17.7\scripts\debugger\run_debugger.jl:7
[6] include(::Module, ::String) at .\Base.jl:377
[7] exec_options(::Base.JLOptions) at .\client.jl:288
[8] _start() at .\client.jl:484
in expression starting at d:\Sujay Google Drive\Julia
Files\J1_J2_model_custom_periodic_dmrg.jl:32
</code></pre>
<p>Why is this? Is there something different about creating a new function, as opposed to modifying an existing one, that leads to the former change not being incorporated into some other piece of code that uses that function? I can post </p>
http://itensor.org/support/2375/itensors-modifications-existing-functions-recognized-functionsWed, 22 Jul 2020 08:58:23 +0000