ITensor Support Q&A - Recent questions and answers
http://itensor.org/support/qa
Powered by Question2AnswerAnswered: Periodic MPO
http://itensor.org/support/2953/periodic-mpo?show=2955#a2955
<p>You can consider a ladder with only two rungs as a chain with periodic boundary conditons.</p>
http://itensor.org/support/2953/periodic-mpo?show=2955#a2955Tue, 13 Apr 2021 11:01:29 +0000Answered: How to use ITensor to simulate doped spinful Hubbard chain ?
http://itensor.org/support/2950/how-to-use-itensor-to-simulate-doped-spinful-hubbard-chain?show=2952#a2952
<p>Hi,<br>
Here are some comments I hope are helpful:</p>
<p>(1) your Hamiltonian is not Hermitian. This is likely the main reason you are getting inconsistent results. The terms you are missing are these:<br>
ampo += -t, "Cdagup",j+1,"Cup",j;<br>
ampo += -t, "Cdagdn",j+1,"Cdn",j;</p>
<p>(2) you may also be getting different results each time because you are not doing enough sweeps. For a doped electron systems, sometimes 10 sweeps is just not enough. Please keep increasing the number of sweeps until you see the energy become stable to quite a few digits, say 4 digits of accuracy at least.</p>
<p>(3) to check if the filling is correct, you can compute the total quantum number of your MPS as totalQN(psi) and print that out. From it you will see how many electrons the MPS has (the "Nf" quantum number value) and work out whether you are correctly at the filling you want.</p>
<p>(4) for a small enough system, you can do reliable DMRG of a periodic Hamiltonian just by adding Hamiltonian terms which connect the first and last sites. So like:<br>
ampo += "Cdagup",1,"Cup",N;<br>
ampo += "Cdagup",N,"Cup",1;<br>
ampo += "Cdagdn",1,"Cdn",N;<br>
ampo += "Cdagdn",N,"Cdn",1;</p>
<p>But you do need to do a lot of sweeps to converge on periodic Hamiltonians.</p>
<p>You could consider iDMRG, but our iDMRG code is not officially supported and not too well documented, so you have to know how to carefully use it. It would not be too hard for an entropy calculation, though, so we could discuss that if it's really necessary for your project.</p>
<p>Miles</p>
http://itensor.org/support/2950/how-to-use-itensor-to-simulate-doped-spinful-hubbard-chain?show=2952#a2952Mon, 12 Apr 2021 02:35:46 +0000Answered: Playing with MPS/ ITensors Indexing
http://itensor.org/support/2925/playing-with-mps-itensors-indexing?show=2945#a2945
<p>Hi Arnab,<br>
Thanks for the question. I'll give some brief answers and we can discuss more in comments below.</p>
<p>(1) "I can get the local 2-D tensors (at each) by doing setting the site-index to 1 or 2." This is not correct unless the MPS is a product (unentangled) state. I think what you are trying to do is to obtain the probability of finding some site j to be in the up state versus the down state. So you are looking for these two numbers, call them p<em>up and p</em>dn. These numbers are the diagonal elements of the reduced density matrix for site j. This reduced density matrix can be found by (a) first calling orthogonalize!(T,j) to make site j the orthogonality center of your MPS then (b) by creating the density matrix rho<em>j = T[j] * prime(dag(T[j]),"Site"). This density matrix will be a 2x2 matrix and its diagonal entries will be p</em>up and p_dn. Please check that they add to 1.0.</p>
<p>(2) to obtain the probabilities of up and down states in a different basis, such as the x basis, you can perform a change of basis by acting with a unitary operator on site j. First, make sure your MPS is orthogonalized to site j as in (1a) above. Then obtain the j'th MPS tensor: Aj = T[j]. Now act with the Hadamard gate which will change the basis to the X basis: Ajx = noprime(op("H",sites,j)*Aj). Finally, make the density matrix in the X basis: rhox_j = Ajx * prime(dag(Ajx),"Site"). The diagonal entries of rhox_j will be the probabilities for up and down in the X basis.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/2925/playing-with-mps-itensors-indexing?show=2945#a2945Wed, 07 Apr 2021 14:22:15 +0000Answered: Change the size of the Index (the dimension of the vector space that the Index defines) but don't change the id
http://itensor.org/support/2919/change-size-index-dimension-vector-space-index-defines-change?show=2937#a2937
<p>(See discussion above.)</p>
http://itensor.org/support/2919/change-size-index-dimension-vector-space-index-defines-change?show=2937#a2937Wed, 31 Mar 2021 13:53:06 +0000Answered: Discrepancy in correlation functions calculated from ED and DMRG for free fermions
http://itensor.org/support/2935/discrepancy-correlation-functions-calculated-free-fermions?show=2936#a2936
<p>Hi, so I see in your code that you are not including any Jordan-Wigner “F” string operators in your MPS correlation function calculations. This is necessary when computing pairs of operators such as C^dagger and C which have an odd fermion parity. (As a side comment, we are nearly done with a new feature that will remove this requirement, using a technique that makes tensor indices anticommutative, but it’s technical and still in the debugging phase.)</p>
<p>For some resources on how to do this and why, here is a sample code for the C++ version showing how to compute fermion correlators properly for the case of spinless fermions:<br>
<a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=formulas/spinless_correlator_mps">http://itensor.org/docs.cgi?vers=cppv3&page=formulas/spinless_correlator_mps</a></p>
<p>For a discussion about Jordan-Wigner string and mappings to bosonic operators (all ITensors are bosonic in that sense), see this tutorial page: <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/fermions">http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/fermions</a></p>
<p>Finally, the approach you are taking of making prod_aux where you combine many MPS tensors together looks like it will have an exponential cost, if I am understanding your code correctly there. This page has an explanation of the approach that is efficient for calculating MPS correlators: <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/correlations">http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/correlations</a> </p>
<p>We can discuss some more if you have questions -</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/2935/discrepancy-correlation-functions-calculated-free-fermions?show=2936#a2936Wed, 31 Mar 2021 13:52:35 +0000Calculating fidelity with iMPS
http://itensor.org/support/2931/calculating-fidelity-with-imps
<p>Edit: I have made some progress with this but I'm on holiday at the moment. I will add something in the next couple of weeks.</p>
<p>Dear Miles/Matt/ITensor,</p>
<p>I've been using your iDMRG example code (idmrg.h etc) and I've adapted it to some models I'm interested in. My goal is to use the fidelity and fidelity per site (and their susceptibilities) to examine the phase diagram. For a finite system, the fidelity is simply the overlap of the ground states at two different values of some parameter of the Hamiltonian. I'm able to calculate the "overlap" of two iMPS's with some code adapted from your examples - this required some modifications to make the site indices match if they were created from different SiteSet instances. I believe this is appropriate for the fidelity but I'm not sure, and it offers no way to calculate the fidelity per site. I've added this code below.</p>
<p>In McCulloch's, "Infinite size density matrix renormalization group, revisited" (section D. Fidelity), he suggests a method using the eigenvalues of a transfer matrix Eq. (39). I'm having difficulty understanding this section, in particular what 'E' denotes in Eq. (39). I've gone through the references but I haven't been able to decipher it. However, McCulloch seems to imply the procedure is fairly simple.</p>
<p>So, I was wondering if you have any suggestions on how to calculate the fidelity (per site) from iMPS's.</p>
<p>Cheers,<br>
Alex Henry</p>
<pre><code>Complex ioverlap(MPS &psi1, MPS &psi2, bool same) {
if (same) {
// if psi1 and psi2 already have the same site indices
auto O = dag(psi1(1)) * psi2(1);
for (auto n : range1(2, length(psi2)))
O = O * dag(psi1(n)) * psi2(n);
auto ovrlap = real(eltC(O));
return ovrlap;
}
auto O = dag(psi1(1)) * psi2(1);
auto l1 = findIndex(dag(psi1(1)), "Site");
auto l2 = findIndex(psi2(1), "Site");
O = O * delta(l1, l2);
for (auto n : range1(2, length(psi2))) {
auto a = dag(psi1(n));
auto b = psi2(n);
l1 = findIndex(a, "Site");
l2 = findIndex(b, "Site");
auto link = delta(l1, l2);
a = a * link;
O = O * a * b;
}
auto overlap = real(eltC(O));
return overlap;
}
</code></pre>
http://itensor.org/support/2931/calculating-fidelity-with-impsThu, 25 Mar 2021 03:13:30 +0000Is it normal that the Julia version gives different results on AMD cores from those on intel cores?
http://itensor.org/support/2929/normal-version-gives-different-results-cores-those-intel-cores
<p>Hi,</p>
<p>I noticed that ITensors.jl gives different results on AMD cores from those on intel cores. In some calculations, this small discrepancy may results in very different results in the large volume limit, that is, the RG flow goes to the wrong fixed point.</p>
<p>Sorry I didn't prepare the sample code for this question. I wonder if this is normal or not before doing that. Thanks.</p>
<p>Jin</p>
http://itensor.org/support/2929/normal-version-gives-different-results-cores-those-intel-coresTue, 23 Mar 2021 02:07:54 +0000Answered: Turning a randomITensor into a periodic MPS description
http://itensor.org/support/2882/turning-a-randomitensor-into-a-periodic-mps-description?show=2928#a2928
<p>(See answer above)</p>
http://itensor.org/support/2882/turning-a-randomitensor-into-a-periodic-mps-description?show=2928#a2928Mon, 22 Mar 2021 19:33:47 +0000Answered: Flip in the indices order of Hermitian conjugate of a two qubit quantum state.
http://itensor.org/support/2884/flip-indices-order-hermitian-conjugate-qubit-quantum-state?show=2927#a2927
<p>(See discussion above)</p>
http://itensor.org/support/2884/flip-indices-order-hermitian-conjugate-qubit-quantum-state?show=2927#a2927Mon, 22 Mar 2021 17:26:46 +0000Specific Questions about Constructing MPOs by hand in iDMRG
http://itensor.org/support/2926/specific-questions-about-constructing-mpos-by-hand-in-idmrg
<p>Hi Miles,</p>
<p>I have been recently trying doing some iDMRG simulations (C++v3). It is super nice of you to give sample codes in <a rel="nofollow" href="https://github.com/ITensor/iDMRG.">https://github.com/ITensor/iDMRG.</a> And for others who might be interested, here is a great brief introduction to the algorithm - <a rel="nofollow" href="http://itensor.org/docs.cgi?page=tutorials/iDMRG&vers=cppv2.">http://itensor.org/docs.cgi?page=tutorials/iDMRG&vers=cppv2.</a></p>
<p>But since I don't find any documentations about the implementation of the codes, it is a bit hard for me to modify based on that. And I think you might be I have some naive technical questions regarding how to construct a general Hamiltonian (to be specific, biquadratic Heisenberg model for my purpose).</p>
<p>$$H=\sum_{}\alpha s_i\cdot s_j+\beta(s_i\cdot s_j)^2$$</p>
<p>In the <a rel="nofollow" href="https://github.com/ITensor/iDMRG/blob/master/sample/Heisenberg.h">Heisenberg.h</a>, </p>
<p>Question 1<br>
How is the size for each QN block being decided? (3, 1, 1) in the following code.</p>
<pre><code> auto ts = format("Link,l=%d",l);
links.at(l) = Index(QN({"Sz", 0}),3,
QN({"Sz",-2}),1,
QN({"Sz",+2}),1,
Out,
ts);
</code></pre>
<p>Question 2</p>
<p>I guess the following codes are the ones that deal with the construction of Heisenberg MPO. But could you explain how these columns and rows correspond to the MPO of the Heisenberg MPO? And in general, how do you specify the row and column indices?</p>
<pre><code> W = ITensor(dag(sites_(n)),prime(sites_(n)),row,col);
W += sites_.op("Id",n) * setElt(row(1)) * setElt(col(1)); //ending state
W += sites_.op("Id",n) * setElt(row(2)) * setElt(col(2)); //starting state
W += sites_.op("Sz",n) * setElt(row(3)) * setElt(col(1));
W += sites_.op("Sz",n) * setElt(row(2)) * setElt(col(3)) * Jz_;
W += sites_.op("Sm",n) * setElt(row(4)) * setElt(col(1));
W += sites_.op("Sp",n) * setElt(row(2)) * setElt(col(4)) * J_/2;
W += sites_.op("Sp",n) * setElt(row(5)) * setElt(col(1));
W += sites_.op("Sm",n) * setElt(row(2)) * setElt(col(5)) * J_/2;
</code></pre>
<p>Thank you very much!</p>
<p>Best,<br>
Yi</p>
http://itensor.org/support/2926/specific-questions-about-constructing-mpos-by-hand-in-idmrgMon, 22 Mar 2021 17:04:29 +0000Answered: MPS for MixedSiteSet with different QN conservation on subsystems
http://itensor.org/support/2917/for-mixedsiteset-with-different-conservation-subsystems?show=2923#a2923
<p>For anyone interested, I solved the issue by now by adding "empty" quantum numbers in the file ITensor/itensor/mps/sites/boson.h<br>
Replacing one line <br>
s = Index(1+maxOcc,tags);<br>
with <br>
s = Index(QN(),1+maxOcc,tags); <br>
did the trick.</p>
http://itensor.org/support/2917/for-mixedsiteset-with-different-conservation-subsystems?show=2923#a2923Mon, 22 Mar 2021 09:24:08 +0000Answered: Valence bond - fast implementation (2)
http://itensor.org/support/2911/valence-bond-fast-implementation-2?show=2915#a2915
<p>(See discussion in above comments)</p>
http://itensor.org/support/2911/valence-bond-fast-implementation-2?show=2915#a2915Mon, 15 Mar 2021 18:37:04 +0000Error: Index::write: Index is default initialized
http://itensor.org/support/2902/error-index-write-index-is-default-initialized
<p>Hi,</p>
<p>I am not able to save a state using the WriteToFile function.<br>
The code returns the following error:<br>
<strong>Index::write: Index is default initialized</strong></p>
<p>It's not clear to me why it's happening. <br>
I have a bosonic system of size N with a certain cut-off to the Fock space.<br>
The state is the following:<br>
$$<br>
|\psi\rangle = |0 0 ...\rangle \otimes |\psi<em>0\rangle \otimes |00..0\rangle<br>
$$<br>
where @@|\psi</em>0\rangle@@ is a certain state. Since I am able to compute local quantites and perform a TEBD real time evolution I don't see any issue with the state itself (e.g. mismatch with indices). <br>
Could you help me?</p>
<p>Thank you in advance.<br>
Riccardo</p>
http://itensor.org/support/2902/error-index-write-index-is-default-initializedMon, 08 Mar 2021 17:28:28 +0000Answered: [Julia] Defining custom MPOs using op vs. op!
http://itensor.org/support/2897/julia-defining-custom-mpos-using-op-vs-op?show=2899#a2899
<p>Hi, so there may be a few things going on here causing the errors you are seeing.</p>
<p>First of all, we recommend overloading the functions called either <code>op!</code> or <code>op</code> which take an OpName"String" type argument. In your first code example, you are instead overloading a version of <code>op</code> which takes an AbstractString argument which is an older style we do not encourage users to adopt. So please use the newer style as you did with your later examples.</p>
<p>Also, I just looked at the Electron site code and I do not see it using the older-style <code>op</code> which takes an AbstractString anymore. You can see the latest code here:<br>
<a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/blob/master/src/physics/site_types/electron.jl">https://github.com/ITensor/ITensors.jl/blob/master/src/physics/site_types/electron.jl</a></p>
<p>So perhaps you are looking at an older version of the Electron site code?</p>
<p>Finally, there is an up-to-date example of making a custom site type and custom operators with QNs here: <a rel="nofollow" href="http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_qns">http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_qns</a></p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/2897/julia-defining-custom-mpos-using-op-vs-op?show=2899#a2899Sun, 07 Mar 2021 19:49:08 +0000Answered: Converting ITensors to matrices in Julia
http://itensor.org/support/2885/converting-itensors-to-matrices-in-julia?show=2887#a2887
<p>The short answer is that you can use the <code>Array</code> or <code>Matrix</code> function:</p>
<pre><code>i = Index(2, "i")
T = randomITensor(i', dag(i))
A = Array(A, i', i)
# Same thing, for an order-2 ITensor
M = Matrix(A, i', i)
</code></pre>
<p>where the indices are used to specify the memory ordering of the Array/Matrix. You can also use the lower case function <code>A = array(A)</code> which uses the current index ordering of the ITensor for the memory ordering of the Array, and makes the Array a view of the ITensor when possible. However, generally I would recommend working with ITensors when possible since it can help minimize mistakes with connecting the wrong indices together.</p>
<p>I'll also point out that we are planning on adding more functions to help with these conversions: <a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/issues/374">https://github.com/ITensor/ITensors.jl/issues/374</a></p>
http://itensor.org/support/2885/converting-itensors-to-matrices-in-julia?show=2887#a2887Mon, 01 Mar 2021 14:31:46 +0000Extract/Project IQTensor on a QN subspace
http://itensor.org/support/2879/extract-project-iqtensor-on-a-qn-subspace
<p>Hi all,</p>
<p>I am fairly new to ITensor and C++. <br>
Thus if you have any advice that can be easier implemented in Julia I could take it into account, too.</p>
<p>First let me describe the system I am dealing with:<br>
I consider a Bosonic chain of N sites: Boson(N,{"ConserveQNs=",true,"MaxOcc",1})). <br>
I would like to construct the reduced density matrix of the system and project it on a given subspace.<br>
In formulas, given the reduced density matrix @@\rho_A=Tr(|\psi><\psi|)@@<br>
I would like <br>
$$<br>
\rho_A(q)=\frac{P_q \rho_A P_q}{Tr(\rho_A P_q)}<br>
$$<br>
Where @@P_q@@ is the projector on the subspace with a given number of particles<br>
$$<br>
\sum_{i=1}^{l}n_i=q.<br>
$$<br>
Here @@n_i@@ is the number of Bosons at site i and l is the length of the subsystem.</p>
<p>The question is the following: is there a way to do obtain @@\rho_A(q)@@, using IQTensor, without computing explicitly the reduced density matrix and the projector, since it is very inefficient?</p>
<p>I saw in the source code of qutil.h the function getBlock, but I'm not used to C++ and I could not deduce its functionalities.</p>
<p>Thank you for your time.</p>
<p>Best,<br>
Vittorio</p>
http://itensor.org/support/2879/extract-project-iqtensor-on-a-qn-subspaceTue, 23 Feb 2021 15:45:31 +0000TDVP with time dependent term
http://itensor.org/support/2878/tdvp-with-time-dependent-term
<p>Hi all,<br>
I was trying to use the one center TDVP algorithm to study a system with a time-dependent term that is not part of the Hamiltonian. The overall system evolution is described by <br>
$$\dot y = H y + f(t)$$<br>
where y is the state, H the Hamiltonian, and f(t) is a time dependent vector. How should I modify the original TDVP code to treat this case?</p>
<p>Thanks,<br>
Raffaele</p>
http://itensor.org/support/2878/tdvp-with-time-dependent-termSun, 21 Feb 2021 09:12:32 +0000Answered: Applying local MPOs in Julia
http://itensor.org/support/2869/applying-local-mpos-in-julia?show=2870#a2870
<p>It looks like both approaches work fine. However, in the first approach, you are modifying <code>psi</code>, and you are using the modified version of <code>psi</code> in the second approach. To avoid this, you need to make a copy of the state before modifying it, for example:</p>
<pre><code>using ITensors
N = 6
bond_dim=24
sites = siteinds("S=1/2",N)
psi0 = randomMPS(sites, bond_dim);
psi1 = randomMPS(sites, bond_dim);
j = 3
psi = copy(psi0)
s = siteind(psi,j)
newpsi= 2*op(s,"Sx") * psi[j]
noprime!(newpsi)
psi[j]= newpsi
println("First value is ", inner(psi1, psi))
sample = AutoMPO()
sample += 2,"Sx", j;
Operator= MPO(sample,sites);
println("Second value is ", inner(psi1, Operator, psi0))
</code></pre>
<p>which outputs for me:</p>
<pre><code>First value is -0.14996338790894725
Second value is -0.14996338790894728
</code></pre>
<p>In the original post, in the second approach you are effectively applying the operator <code>2 Sz</code> twice to the original MPS <code>psi</code>.</p>
<p>As I'm sure you know, it is best to use the first approach since it doesn't scale with the number of sites, whereas the second approach uses an MPO that scales with the number of sites.</p>
<p>-Matt</p>
http://itensor.org/support/2869/applying-local-mpos-in-julia?show=2870#a2870Mon, 15 Feb 2021 15:19:50 +0000Answered: Making Initial Product States in 2D
http://itensor.org/support/2848/making-initial-product-states-in-2d?show=2849#a2849
<p>Hi Yi,<br>
So if I understand the code correctly, the problem (not the error but the conceptual problem) is coming from the lines:</p>
<pre><code>psi0.ref(n + m) = ITensor(s1);
psi0.ref(n + m + Ny) = ITensor(s2);
</code></pre>
<p>It seems you are planning to split the two-site singlet tensor "wf" into two pieces and then assign these two pieces, which share a common bond index, to two MPS tensors which are not neighbors of each other, in the sense of the 1D MPS ordering.</p>
<p>In short, the resulting setting of psi0 will not be a valid MPS. The tensors will not have an MPS structure.</p>
<p>I hope that's clear, but a good way to see it is to draw the tensor diagram for your MPS psi0 (putting the tensors along a 1D line, since the DMRG code doesn't know anything about 2D) and then you will see that the common bond between sitees n+m and n+m+Ny is a "long bond" that is connecting across many 1D sites, which is not the form an MPS has by definition.</p>
<p>Ok please let me know if that helps & we can discuss more.</p>
<p>Finally, we had previously discussed an idea of moving the dimers around using swap operators. The reason for the swaps is precisely because the dimers cannot be initially created in the way above: they would have to be placed along the MPS path initially then moved with nearest-neighbor moves. </p>
<p>Also what did you think about the idea of just using a Hamiltonian whose ground state is exactly the desired dimer state? That idea would be the simplest one to try first, assuming it works.</p>
<p>Miles</p>
http://itensor.org/support/2848/making-initial-product-states-in-2d?show=2849#a2849Wed, 10 Feb 2021 14:39:14 +0000Is there a method that gives the quantum number flux of a particular element in an ITensor
http://itensor.org/support/2844/there-method-gives-quantum-number-particular-element-itensor
<p>From this answer</p>
<p><a rel="nofollow" href="http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo">http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo</a></p>
<p>I realized that one can use the "flux" function to get the quantum number flux of an ITensor. However I wonder if there is a method to get the quantum number flux <em>for a particular element</em> in an ITensor?</p>
http://itensor.org/support/2844/there-method-gives-quantum-number-particular-element-itensorSun, 07 Feb 2021 16:11:38 +0000A partial fix of arnoldi
http://itensor.org/support/2843/a-partial-fix-of-arnoldi
<p>Hi Matthew,</p>
<p>The <a rel="nofollow" href="https://github.com/ITensor/ITensor/issues/360">issue#360</a> in <code>arnoldi</code> function is because of an extra multiplication of <code>A</code> in <a rel="nofollow" href="https://github.com/ITensor/ITensor/blob/fb83fde4a07f2122cf56f9a79f8e8ec01c7cad18/itensor/iterativesolvers.h#L809">the deflation</a>.</p>
<p>The current (incorrect) <code>arnoldi</code> calculates instead the first eigenvalues of <code>A</code> and <code>A-A^2</code>. That's why in <a rel="nofollow" href="https://github.com/ITensor/ITensor/issues/360">issue#360</a> the two eigenvectors are identical and the eigenvalues <br>
<code>lambda0 = (0.598975,0)
lambda1 = (0.240204,0)</code><br>
satisfy <code>lambda1 = lambda0 - lambda0^2</code>.</p>
<p>A minor pull request has been submitted <a rel="nofollow" href="https://github.com/ITensor/ITensor/pull/382">here</a>.</p>
<p>However, even after this fix the <code>arnoldi</code> function can only deal with Hermitian operator. Because the current deflation process cannot project to the correct subspace if the previously calculated eigenvectors are not orthogonal.</p>
<p>Ce</p>
http://itensor.org/support/2843/a-partial-fix-of-arnoldiSun, 07 Feb 2021 03:13:35 +0000initialize an ITensor from allocated memory
http://itensor.org/support/2842/initialize-an-itensor-from-allocated-memory
<p>Hi, </p>
<p>Is there any way to create an ITensor "in place" from some already allocated memory?</p>
<p>For example</p>
<pre><code>const int nx = 10;
const int ny = 10;
double* arr = new double[nx * ny] ;
Index i(nx);
Index j(ny);
ITensor A(i, j); //the storage is not yet initialized.
</code></pre>
<p>Currently I only know how to copy this allocated memory to the data vector of A as following</p>
<pre><code>vector_no_init<double>& dvec = (*((ITWrap<Dense<double>>*) & (*A.store()))).d.store;
dvec.assign(arr, arr + nx*ny);
</code></pre>
<p>What I'd like to do is to "steal" the allocated memory from <code>arr</code> and use that as the internal data vector of <code>A</code>. Although <code>memcpy</code> is in general very fast, sometimes we still want to avoid this overhead in case it is a huge <code>for</code> loop.</p>
<p>There's <a rel="nofollow" href="https://stackoverflow.com/questions/21917529/is-it-possible-to-initialize-stdvector-over-already-allocated-memory">some instruction</a> on how to steal the memory by overloading the allocator. But the data vector's allocator has already been overloaded as in the definition of <a rel="nofollow" href="https://github.com/ITensor/ITensor/blob/fb83fde4a07f2122cf56f9a79f8e8ec01c7cad18/itensor/util/vector_no_init.h#L24">vector no init</a>. </p>
<p>Do you have any idea how to combine the two overloaded versions of allocator, s.t. it can work as described above?</p>
<p>Ce</p>
http://itensor.org/support/2842/initialize-an-itensor-from-allocated-memorySun, 07 Feb 2021 02:51:04 +0000Answered: Canonical MPS representation given an initial state in Julia
http://itensor.org/support/2820/canonical-mps-representation-given-an-initial-state-julia?show=2836#a2836
<p>Is this what you are looking for?</p>
<pre><code>using ITensors
N = 4
s = siteinds("S=1/2", N)
A = randomITensor(s...)
psi = MPS(A, s; cutoff = 1e-10)
@show maxlinkdim(psi)
@show isapprox(A, prod(psi))
</code></pre>
<p>Notice that <code>prod</code> is a general Julia function for multiplying a collection together, so in the case of an MPS it contracts all of the tensors together into a single ITensor to reproduce the (approximation) of the original state. You can also set a maximum dimension with the keyword argument <code>maxdim</code>.</p>
<p>-Matt</p>
http://itensor.org/support/2820/canonical-mps-representation-given-an-initial-state-julia?show=2836#a2836Fri, 05 Feb 2021 18:10:00 +0000Answered: Matrix element of (tensor products of) Pauli operators in Julia
http://itensor.org/support/2824/matrix-element-tensor-products-of-pauli-operators-in-julia?show=2825#a2825
<p>Hi Arnab, yes this is a task that MPS (and ITensor) is perfectly suited for.</p>
<p>The simplest way to do this is to:<br>
1. choose a target string i1, i2, i3, that you want to compute (i.e. fix the i’s)<br>
2. apply the X^i_n operators to the MPS psi. Since these are single-site operators they can be applied very quickly and efficiently (even in parallel if you want to go there) by just multiplying each MPS by X on its physical index. In ITensor, you obtain the X operator for that site, use the * operator to contract it with the MPS, then call <code>noprime</code> to set the site’s prime level back to 0. Of course for sites where you act with the identity, you can just skip over such sites.<br>
3. finally take the resulting MPS, calling it Xpsi, say, then call <code>inner(phi,Xpsi)</code> to obtain the overlap of the modified psi with phi. </p>
<p>Then you can repeat this for other i-strings. </p>
<p>Finally, if you are planning to obtain a large number, or all amplitudes this way, there should be a way to organize them where say you reuse substrings, i.e. overlap by hand the modified psi tensors with phi tensors and then attach the next ones in both combinations and so on. It would take a bit of thought to see how advantage there would be in doing this (because ultimately you’d still have to make exponentially many such “substring partial overlap” tensors anyway). </p>
<p>Let me know if any of those steps aren’t clear. </p>
<p>Oh also we have a new framework precisely for making it easier to apply various operators to MPS, but it’s not totally well documented yet. Here is a sample code file showing it off:</p>
<p><a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/blob/master/examples/gate_evolution/quantum_simulator.jl">https://github.com/ITensor/ITensors.jl/blob/master/examples/gate_evolution/quantum_simulator.jl</a></p>
<p>But it’s overkill just for your case of single-site operators which you can definitely do with the usual ITensor interface.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/2824/matrix-element-tensor-products-of-pauli-operators-in-julia?show=2825#a2825Thu, 04 Feb 2021 23:06:49 +0000[Julia] Largest truncation error in DMRG output
http://itensor.org/support/2818/julia-largest-truncation-error-in-dmrg-output
<p>Hi,</p>
<p>I've been using the julia version of ITensor lately, and I noticed that calling DMRG by default does not print any information regarding the maximum truncation error for each sweep, unlike the C++ version. I've searched the documentation but could not find anything related to the truncation error. Is there some way to turn this feature on? Or is it just not implemented yet?</p>
<p>Best,</p>
<p>Rafael</p>
http://itensor.org/support/2818/julia-largest-truncation-error-in-dmrg-outputTue, 02 Feb 2021 23:59:38 +0000Answered: [Julia] QN Block Sparse ITensor gives wrong results for multiplying the delta tensor
http://itensor.org/support/2814/block-sparse-itensor-wrong-results-multiplying-delta-tensor?show=2816#a2816
<p>This was indeed a bug in the low level contraction code for contracting block sparse tensors. I've fixed it here: <a rel="nofollow" href="https://github.com/ITensor/NDTensors.jl/pull/64">https://github.com/ITensor/NDTensors.jl/pull/64</a> . The fix will be available in the next ITensors release (v0.1.38), it should be available later today.</p>
http://itensor.org/support/2814/block-sparse-itensor-wrong-results-multiplying-delta-tensor?show=2816#a2816Tue, 02 Feb 2021 17:54:56 +0000Answered: Computational cost of ITensor permute method
http://itensor.org/support/2810/computational-cost-of-itensor-permute-method?show=2811#a2811
<p>Hi Chia-Min,<br>
Good question. It really does permute all of the data, so the cost is proportional to the number of tensor elements.</p>
<p>The concept of permuting can be a little bit confusing in the case of ITensors, where the index order should not matter to the user. The way to think about it is that the permute function is a "lower-level" operation which is really permuting the way an ITensor is stored in memory. The usefulness of it is in case a different layout would make a later operation more efficient, or if you want to use a more traditional notation to access tensor elements such as T(1,2,3). </p>
<p>Otherwise, for normal types of operations involving ITensors such as adding them or contracting them with other ITensors, there is never any need to call the permute function.</p>
<p>Hope that helps! </p>
<p>Miles</p>
http://itensor.org/support/2810/computational-cost-of-itensor-permute-method?show=2811#a2811Thu, 21 Jan 2021 21:23:19 +0000Answered: M1 processor compatibility
http://itensor.org/support/2796/m1-processor-compatibility?show=2807#a2807
<p>Hi Jun,<br>
Thanks for the interesting question. So I just tried the C++ version of ITensor on a Macbook Air with the M1 processor, and it was a smooth experience. I just cloned ITensor from Github, and then used the options.mk.sample file provided as the template for options.mk. The only change I needed to make was to use clang as the C++ compiler, rather than g++. Otherwise I got an error about the -fconcepts flag not being recognized. I did not try to install MKL and build ITensor against that; it would be an interesting thing to try and important to compare the speed to Apple's default "vecLib" framework (default BLAS provided by MacOS).</p>
<p>The performance was very good. The speed I got running the exthubbard sample code was comparable to a workstation at our office that has a 24-core, 3.4 GHz Xeon chip, whereas from what I have read, the M1 has 8 3.2 GHz cores. It was more than two times faster than my Intel Macbook Pro which has a 2.9 GHz chip!</p>
<p>I also installed Julia and the Julia version of ITensor, ITensors.jl, without any issue. That surprised me because I had read that Julia was not yet working for the M1, so perhaps it is using the Rosetta compatibility layer? Also I was able to install the MKL Julia package which we have found significantly speeds up ITensors.jl on Intel chips. It would be interesting to compare Julia with and without MKL on the M1 chip.</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/2796/m1-processor-compatibility?show=2807#a2807Mon, 18 Jan 2021 02:19:07 +0000Answered: Are 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?show=2801#a2801
<p>Yes, if you call <code>flux(psi)</code> where psi is an MPS or <code>flux(H)</code> where H is an MPO it will tell you the total flux of that MPS or MPO.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/2799/are-there-methods-for-returning-value-for-mps-or-flux-for-mpo?show=2801#a2801Fri, 15 Jan 2021 18:53:33 +0000Answered: [julia] DMRGObserver not working
http://itensor.org/support/2779/julia-dmrgobserver-not-working?show=2793#a2793
<p>Hi Sherry, so that documentation was a little bit hard to understand, because it makes it appear as if those arguments are named arguments. They are (or were - see below) not named arguments but just default arguments. However, that constructor turned out to have another bug, so would not have worked anyway even if called correctly.</p>
<p>I used that situation as an opportunity to improve the interface, and now it should work as you'd expect, i.e. </p>
<p>DMRGObserver(; energy_tol = 1E-4, minsweeps = 2)</p>
<p>say. Note that this is true right now only for the master branch of ITensors.jl and isn't in the latest numbered version yet. But we will tag a new version soon and the change will be included in 0.1.35.</p>
<p>Miles</p>
http://itensor.org/support/2779/julia-dmrgobserver-not-working?show=2793#a2793Wed, 13 Jan 2021 21:46:26 +0000Answered: [julia] Initial state for DMRG
http://itensor.org/support/2780/julia-initial-state-for-dmrg?show=2791#a2791
<p>Please see the discussion above. The key take-away of the discussion is that the same array of site indices used to originally make an MPS must be used to make a compatible MPO or other MPS. This array of site indices can be conveniently obtained from an existing MPS <code>psi</code> by calling:</p>
<pre><code>sites = siteinds(psi)
</code></pre>
http://itensor.org/support/2780/julia-initial-state-for-dmrg?show=2791#a2791Wed, 13 Jan 2021 05:40:17 +0000Answered: convergence problem for small lattice
http://itensor.org/support/2766/convergence-problem-for-small-lattice?show=2775#a2775
<p>(Please see discussion above.)</p>
http://itensor.org/support/2766/convergence-problem-for-small-lattice?show=2775#a2775Sat, 09 Jan 2021 22:35:28 +0000Answered: leftlim and rightlim initialization present in randomizeMPS! but not productMPS
http://itensor.org/support/2771/rightlim-initialization-present-randomizemps-productmps?show=2772#a2772
<p>Hi Sujay,<br>
Happy to discuss more, but most of your question can probably be answered by addressing the true purpose of leftlim and rightlim. They do not represent the boundaries of the region currently optimized (though in an optimization context they might correspond to these regions). What they actually represent are the orthogonality properties of the MPS, or at least as much that we can guarantee in the code in an automated way. (What I mean by that last part is that the MPS might be orthogonal over an even larger region than indicated by leftlim and rightlim but at a minimum it is guaranteed to be orthogonal up to leftlim and rightlim.)</p>
<p>You probably already know what I mean by parts of the MPS being orthogonal, but to be clear the meaning of leftlim is that the MPS tensors 1:leftlim are all left-orthogonal (square to an identity when contracted over both their left index and site index) and the MPS tensors rightlim:N are all right-orthogonal. Again other MPS tensors might be right or left orthogonal besides the ones in (1:leftlim) and (rightlim:N) but we only guarantee the ones in those ranges in terms of our algorithms.</p>
<p>The specific case of the productMPS function is one where we could, and probably should, strengthen this guarantee. I gather that right now leftlim and rightlim just remain at their most conservative settings of leftlim=0 and rightlim=N+1 i.e. not guaranteeing any orthogonality. Whereas productMPS is a special case where <em>all</em> of the MPS tensors are simulaneously both left and right orthogonal. So we could instead say set leftlim=0 and rightlim=2 for productMPS or some other setting.</p>
<p>The randomMPS function doesn't specifically "shift" leftlim and rightlim: rather it sets them because it constructs the MPS out of a quantum circuit that ensures the property that all MPS tensors from 2:N are right-orthogonal. The MPS tensor at site 1 is the "orthogonality center" of this MPS gauge (so called right-orthogonal gauge). </p>
<p>What does shift the leftlim and rightlim values are functions like <code>replacebond!</code> as you mention, which is used internally by DMRG and other algorithms (or you can use it directly). In a sense, this is its main purpose i.e. to update an MPS locally while correctly shifting leftlim and rightlim, as well as selecting among various algorithms for you based on truncation and accuracy settings. Doing this correctly "by hand" could be error prone so we introduced this function to help.</p>
<p>Finally, what is the real purpose of even having leftlim and rightlim? It is for two reasons: correctness and efficiency. There is a correctness aspect where truncating an MPS locally without including the orthogonality center can lead to an uncontrolled / unknown error. Another reason is efficiency: having a known leftlim and rightlim means that for many purposes the left- and right-orthogonal tensors can be omitted from certain algorithmic steps which cuts down on computation by quite a lot without sacrificing correctness or accuracy.</p>
<p>Hope that helps - this is giving me some ideas of things we should put into the docs -</p>
<p>Miles</p>
http://itensor.org/support/2771/rightlim-initialization-present-randomizemps-productmps?show=2772#a2772Sat, 09 Jan 2021 18:08:23 +0000Answered: Non-contracting product in ITensor Julia
http://itensor.org/support/2762/non-contracting-product-in-itensor-julia?show=2763#a2763
<p>Hi Amartya, <br>
We haven’t defined that one in the Julia version. One reason is that it became hard to define it for QN conserving tensors in the C++ version. Another is just that we weren’t sure if anyone was using it. </p>
<p>Could I ask what your use case for it is?</p>
<p>Miles </p>
http://itensor.org/support/2762/non-contracting-product-in-itensor-julia?show=2763#a2763Thu, 24 Dec 2020 15:52:50 +0000Answered: convert an ITensor to fewer quantum number
http://itensor.org/support/2732/convert-an-itensor-to-fewer-quantum-number?show=2759#a2759
<p>Hi Chia-Min,<br>
The short answer is, no, we don't have this capability right now. It is something that could be theoretically added, but it would be hard for us to prioritize this right now. </p>
<p>If the purpose of this is to contract two tensors with different QNs, though, then one way you could do this is to just convert them both to dense, non-QN tensors and then contract them that way. (You may likely have to do some index replacement on one of them to get the id's to match before hand.)</p>
<p>Another way to go is just to use fewer QNs in the first place, so like the minimum amount shared by the two tensors. If you wanted to give a little more context, I might be able to help you more.</p>
<p>Miles</p>
http://itensor.org/support/2732/convert-an-itensor-to-fewer-quantum-number?show=2759#a2759Mon, 21 Dec 2020 01:27:47 +0000Answered: Questions about "Observer" Feature in ITensors.jl
http://itensor.org/support/2751/questions-about-observer-feature-in-itensors-jl?show=2757#a2757
<p>Hi, so we now have much more complete documentation about the DMRG observer system for the Julia version of ITensor (ITensors.jl). </p>
<p>Please see the 'dev' branch of the documentation here:</p>
<p><a rel="nofollow" href="https://itensor.github.io/ITensors.jl/dev/Observer.html">https://itensor.github.io/ITensors.jl/dev/Observer.html</a></p>
<p>(It will appear in the stable version after the next release.)</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/2751/questions-about-observer-feature-in-itensors-jl?show=2757#a2757Sun, 20 Dec 2020 21:30:05 +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 +0000Answered: Replace siteIndex of MPO
http://itensor.org/support/2724/replace-siteindex-of-mpo?show=2746#a2746
<p>(Please see discussion above.)</p>
http://itensor.org/support/2724/replace-siteindex-of-mpo?show=2746#a2746Tue, 15 Dec 2020 16:09:30 +0000Answered: Spinless Fermionic Correlator Across a 1-d Lattice
http://itensor.org/support/2722/spinless-fermionic-correlator-across-a-1-d-lattice?show=2742#a2742
<p>(Please see the discussion above.)</p>
http://itensor.org/support/2722/spinless-fermionic-correlator-across-a-1-d-lattice?show=2742#a2742Mon, 14 Dec 2020 21:05:46 +0000Answered: Error after updating ITensors.jl
http://itensor.org/support/2726/error-after-updating-itensors-jl?show=2727#a2727
<p>Hi Jin,</p>
<p>This works as expected for me with the latest version of ITensors.jl:</p>
<pre><code>pkg> st ITensors
Status [...]
[9136182c] ITensors v0.1.30
julia> using ITensors
julia> s = Index([QN(("N",i,3))=>1 for i = 0:(2)];dir = ITensors.Arrow(1))
(dim=3|id=859) <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> l = setdir(addtags(s,"left"),ITensors.Arrow(-1))
(dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> r = addtags(s,"right")
(dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> A = emptyITensor(l,r)
ITensor ord=2
(dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
(dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
NDTensors.Empty{Float64,NDTensors.BlockSparse{Float64,Array{Float64,1},2}}
julia> A[l(1),r(1)] = 1.0
1.0
julia> @show A;
A = ITensor ord=2
Dim 1: (dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
Dim 2: (dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
NDTensors.BlockSparse{Float64,Array{Float64,1},2}
3×3
Block: Block{2}((0x0000000000000001, 0x0000000000000001), 0xa03b74afc6984a6a)
[1:1, 1:1]
1.0
</code></pre>
<p>We've been making quite a few changes to indexing and block sparse operations in recent versions, so possibly something broke in one of the versions before v0.1.30.</p>
<p>Also note that the Index direction is out by default, and you can make a new Index with the arrow direction reversed with <code>dag</code>:</p>
<pre><code>julia> s = Index([QN("N",i,3)=>1 for i = 0:2])
(dim=3|id=917) <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> l = dag(addtags(s,"left"))
(dim=3|id=917|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
</code></pre>
<p>-Matt</p>
http://itensor.org/support/2726/error-after-updating-itensors-jl?show=2727#a2727Fri, 11 Dec 2020 14:30:27 +0000Answered: set ITensor elements Array-wise
http://itensor.org/support/2713/set-itensor-elements-array-wise?show=2714#a2714
<p>Hi,</p>
<p>Good question. Unfortunately we don't have very good support right now for slicing ITensors like that. However, in this case you can make use of the NDTensors.jl library, which is a "basic tensor" library that is used by ITensors for basic tensor operations. Here is an example for how to use it:</p>
<pre><code>using ITensors
using ITensors.NDTensors
i = Index(2)
j = Index(2)
k = Index(2)
l = Index(2)
A = randomITensor(i, j, k, l)
tensor(A)[1, 2, :, :] = [0 0; 0 0]
</code></pre>
<p>Note that when you index into a Tensor object (which is what you get when you call <code>tensor(A)</code>), it will use the current Index ordering of <code>A</code>, so you will have to be careful about the ordering of the indices. You can print the current Index ordering with <code>@show inds(A)</code>.</p>
<p>The ITensor functionality you suggest would be pretty easy to implement, I'm working on it now and I'll add a comment here when it is implemented.</p>
<p>-Matt</p>
http://itensor.org/support/2713/set-itensor-elements-array-wise?show=2714#a2714Wed, 02 Dec 2020 14:29:31 +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 +0000Answered: Unknown issue concerning diagITensor with adding MPSs?
http://itensor.org/support/2686/unknown-issue-concerning-diagitensor-with-adding-mpss?show=2702#a2702
<p>I've implemented a new algorithm for adding MPS/MPO which now works with QNs here: <a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/pull/528">https://github.com/ITensor/ITensors.jl/pull/528</a></p>
<p>We will release a new version of ITensors.jl that includes this improvement tomorrow. Hopefully this fixes the problem you are seeing. Please try it out after it is released and update us here or with an issue on Github if you keep seeing problems after updating your ITensors.jl version.</p>
http://itensor.org/support/2686/unknown-issue-concerning-diagitensor-with-adding-mpss?show=2702#a2702Thu, 19 Nov 2020 22:50:53 +0000Answered: What 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?show=2701#a2701
<p>Over all, the point of the space function is to define the Hilbert space of a physical site. If no QNs are being used, it is just an integer (so the size of the Hilbert space), while if QNs are being used the space is split up into different blocks for different quantum numbers.</p>
<p>What you are looking at there are just generic fallbacks for when the space function is not defined for a specific SiteType, and isn't relevant for user code. Most of the time only the first one is relevant, and that is what a user would overload for their own SiteType. You might imagine that it should return an error instead of nothing, however we don't want it to error because internally we sometimes check if space is defined for a certain tag, and move on if it isn't (so we don't always want an error). You can think of it returning <code>nothing</code> as a way to avoid doing exception handling with <code>try ... catch</code>. </p>
<p>The second definition can be used in the case when a site location is relevant for the space function, for example if you were conserving momentum where the momentum quantum number depends on the site (see <a rel="nofollow" href="https://github.com/ITensor/ITensors.jl/blob/master/examples/src/electronk.jl#L7-L71">https://github.com/ITensor/ITensors.jl/blob/master/examples/src/electronk.jl#L7-L71</a> as an example). This usually isn't the case, however. Possibly that interface could change if we come up with a better design for that feature.</p>
<p>I would focus on these two pages by Miles:</p>
<p><a rel="nofollow" href="http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_basic">http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_basic</a></p>
<p><a rel="nofollow" href="http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_qns">http://itensor.org/docs.cgi?vers=julia&page=formulas/sitetype_qns</a></p>
<p>which explain the user interface for this system.</p>
http://itensor.org/support/2699/what-is-the-point-of-the-space-method-used-in-siteind?show=2701#a2701Tue, 17 Nov 2020 21:52:23 +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 +0000Answered: Can 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?show=2696#a2696
<p>Yes, I believe that MKL does work on AMD processors. However, by default it may not be as fast on AMD processors. My understanding is that you can set the following environment variable (in Linux):</p>
<pre><code>export MKL_DEBUG_CPU_TYPE=5
</code></pre>
<p>and then MKL should run as fast on AMD as it does on Intel processors, but this is an undocumented option in MKL and may not be guaranteed to work for different versions of MKL (and I have not personally tried it). Here are some more discussions about it:</p>
<p><a rel="nofollow" href="https://sites.google.com/a/uci.edu/mingru-yang/programming/mkl-has-bad-performance-on-an-amd-cpu">https://sites.google.com/a/uci.edu/mingru-yang/programming/mkl-has-bad-performance-on-an-amd-cpu</a></p>
<p><a rel="nofollow" href="https://www.reddit.com/r/matlab/comments/dxn38s/howto_force_matlab_to_use_a_fast_codepath_on_amd">https://www.reddit.com/r/matlab/comments/dxn38s/howto_force_matlab_to_use_a_fast_codepath_on_amd</a></p>
<p><a rel="nofollow" href="https://github.com/flame/blis/issues/312">https://github.com/flame/blis/issues/312</a></p>
http://itensor.org/support/2695/can-use-intel-mkl-libraries-systems-with-new-amd-processors?show=2696#a2696Fri, 13 Nov 2020 20:12:20 +0000Answered: runtime performance of Julia vs c++ DMRG
http://itensor.org/support/2119/runtime-performance-of-julia-vs-c-dmrg?show=2689#a2689
<p>Hi Matthew,<br>
We now have publicly available benchmarks of both the C++ and Julia version of ITensor, including DMRG benchmarks but also algorithms like TRG (<a rel="nofollow" href="http://tensornetwork.org/trg/)">http://tensornetwork.org/trg/)</a> and corner-transfer renormalization group (CTMRG). Here is the link:<br>
<a rel="nofollow" href="https://github.com/ITensor/ITensorsBenchmarks.jl">https://github.com/ITensor/ITensorsBenchmarks.jl</a></p>
<p>If you specifically look at the plots subfolder you can see some comparison graphs:<br>
<a rel="nofollow" href="https://github.com/ITensor/ITensorsBenchmarks.jl/tree/main/benchmarks/julia_vs_c%2B%2B/plots">https://github.com/ITensor/ITensorsBenchmarks.jl/tree/main/benchmarks/julia_vs_c%2B%2B/plots</a></p>
<p>The summary of what we've observed is that the Julia version is always very competitive with the C++ version, and typically even exceeds the C++ version's performance. We aren't totally sure why this is, but could include lots of effort by ITensor lead developer Matt Fishman to optimize the Julia version, and our use of high-quality Julia libraries for which we don't have an analogue in C++. Plus in some sense the Julia version got a head start by being based on years of effort designing and optimizing the C++ version.</p>
<p>We plan to put these benchmark results into the published version of the ITensor Paper (<a rel="nofollow" href="https://arxiv.org/abs/2007.14822)">https://arxiv.org/abs/2007.14822)</a> and give a more thorough discussion of them there.</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/2119/runtime-performance-of-julia-vs-c-dmrg?show=2689#a2689Wed, 11 Nov 2020 17:23:06 +0000Answered: iDMRG for spinful fermions
http://itensor.org/support/2683/idmrg-for-spinful-fermions?show=2684#a2684
<p>I'll give a quick answer and I'm sure Miles can expand on it. You would have to make the MPO manually as explained here: <a rel="nofollow" href="http://itensor.org/docs.cgi?page=tutorials/MPO">http://itensor.org/docs.cgi?page=tutorials/MPO</a></p>
<p>There is an open issue about making this more automated with AutoMPO but we haven't incorporated it yet: <a rel="nofollow" href="https://github.com/ITensor/ITensor/pull/161">https://github.com/ITensor/ITensor/pull/161</a></p>
<p>However, I would definitely suggest trying out finite DMRG and using finite-size scaling first. It will be a lot easier to set up, and there isn't much of a disadvantage.</p>
<p>To answer the question about impurities, the standard iDMRG algorithm is not designed for impurities. I think the way to do it would be to first solve the problem with iDMRG without the impurity, then solve the impurity problem on a "finite" system using the solution from iDMRG to set the boundary conditions.</p>
http://itensor.org/support/2683/idmrg-for-spinful-fermions?show=2684#a2684Mon, 09 Nov 2020 13:43:24 +0000Answered: Misunderstanding about C/A operators in electron model
http://itensor.org/support/2626/misunderstanding-about-c-a-operators-in-electron-model?show=2679#a2679
<p>Hi Cameron,<br>
This issue ought to be fixed now in ITensor version v3.1.6. You should just be able to do a "git pull" and then do a "make clean" followed by "make" to rebuild ITensor and obtain this fix.</p>
<p>Please let me know if the issue persists though!</p>
<p>Miles</p>
http://itensor.org/support/2626/misunderstanding-about-c-a-operators-in-electron-model?show=2679#a2679Fri, 06 Nov 2020 04:59:39 +0000Answered: Calculate absolute value of magnetization
http://itensor.org/support/2657/calculate-absolute-value-of-magnetization?show=2678#a2678
<p>For an official answer, I'm going to say that I think your best bet without having to do heavy algorithm development (or unless I'm missing something simple) is to use sampling to address this problem. </p>
<p>In the Julia version of ITensor we have a function called <code>sample</code> (and a more guaranteed-efficient version called <code>sample!</code>) which will sample a configuration "c" from an MPS with probability |psi(c)|^2. One nice thing about MPS is that this sampling algorithm is 'perfect', meaning it does not rely on a Markov chain or have any autocorrelation time or effects.</p>
<p>For the C++ version, you can look in itensor/tutorial/finiteT folder for the METTS code there to see a version of the same sampling algorithm in C++. Or you could adapt the Julia code to C++.</p>
<p>For each sample, you can straightforwardly compute your observable and I think you know that the |psi(c)|^2 factor would be implicit in the algorithm itself so you can just compute a straight average.</p>
<p>Again there may be other ideas but this one has the virtue of being pretty straightforward to implement.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/2657/calculate-absolute-value-of-magnetization?show=2678#a2678Thu, 05 Nov 2020 22:27:05 +0000