ITensor Support Q&A - Recent questions
http://itensor.org/support/questions
Powered by Question2AnswerComputational 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 +0000defining composite on-site operators in AutoMPO (Julia)
http://itensor.org/support/2662/defining-composite-on-site-operators-in-autompo-julia
<p>I was wondering if you could help me with the following problem I ran into when using the Julia version of ITensor. When I define a composite on-site operator in the autoMPO of a Hamiltonian such as writing $C^\dagger<em>{up} C</em>{up}$ instead of $N_{up}$ when using "Electron" site types, I get unphysical results for the energy and ground state properties.</p>
<p>I have included a minimal code (based on your example of the Hubbard model) showing the problem I am having. It would be great if you could let me know how I can avoid this problem. In particular how can I avoid this problem in four Fermi terms where two fermi operators belong to one site.</p>
<p>Thank you.</p>
<p>============================================================</p>
<pre><code>using ITensors
N = 5
Npart = 3
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
## The following two choices for including an on-site potential result in two different results for the energy and ground state properties. In particular the second choice seems defective.
## Choice 1:
ampo += 1000.,"Nup",1
ampo += 1000.,"Ndn",1
## Choice 2:
# ampo += 1000.,"Cdagup",1,"Cup",1
# ampo += 1000.,"Cdagdn",1,"Cdn",1
H = MPO(ampo,sites);
</code></pre>
http://itensor.org/support/2662/defining-composite-on-site-operators-in-autompo-juliaTue, 03 Nov 2020 02:59:30 +0000Calculate absolute value of magnetization
http://itensor.org/support/2657/calculate-absolute-value-of-magnetization
<p>On the itensor homepage, there is an example given to calculate the on-site magnetization.</p>
<pre><code>for(int j = 1; j <= N; ++j)
{
//Make site j the MPS "orthogonality center"
psi.position(j);
//Measure magnetization
Real Szj = elt(psi(j)
* op(sites,"Sz",j)
* dag(prime(psi(j),"Site")));
println("Sz_",j," = ",Szj);
}
</code></pre>
<p>I'm interested in calculating the absolute value of the on-site magnetization. Just to be clear about what I mean, given a pure state @@\ket{\psi}@@ of dimension @@ d=2^N @@ and hilbert space H comprising of all possible spin configurations, I want to do the following.</p>
<pre><code>absM = 0
for idx = 1:2^N
SumSz = 0
for spin_idx = 1:N
SumSz += H[idx][spin_idx] # spin value
end
absM += abs(SumSz)*|psi(idx)|^2
end
</code></pre>
<p>How do I do this in itensor given an MPS from a DMRG calculation?</p>
<p>As a side note, there is a related thread on measuring the magnetization-squared (which I will also need) <a rel="nofollow" href="https://itensor.org/support/1719/efficient-calculation-of-magnetization-susceptibility?show=1719#q1719">here</a>. But, this is all that I could find that it somewhat related to my question. </p>
<p>Thanks again for the help, and hope you guys are staying safe!</p>
http://itensor.org/support/2657/calculate-absolute-value-of-magnetizationFri, 30 Oct 2020 21:37:15 +0000Error in the energy
http://itensor.org/support/2643/error-in-the-energy
<p>I'm just wondering if it's possible to extract the error in the energy one gets from running a DMRG calculation. Obviously, there isn't a statistical error bar like there would be in a Monte Carlo simulation. But, is it known how truncation errors in the eigenvalues of the reduced density matrix translate to errors in the energy?</p>
http://itensor.org/support/2643/error-in-the-energyWed, 28 Oct 2020 18:56:26 +0000Construction of Matrix product density operator
http://itensor.org/support/2641/construction-of-matrix-product-density-operator
<p>Hi Miles</p>
<pre><code> I was wondering how can we construct the matrix product density operator in ITensor since there is not any explicit way of doing that. I need to construct MPDO for the pure state as thermal state. Thanks in advance.
</code></pre>
http://itensor.org/support/2641/construction-of-matrix-product-density-operatorWed, 28 Oct 2020 11:35:37 +0000Getting "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 +0000