ITensor Support Q&A - Recent questions and answers
http://itensor.org/support/qa
Powered by Question2AnswerAnswered: Using ITensor as external library in cmake project: undefined reference to `itensor::typeNameOf...
http://itensor.org/support/575/itensor-external-project-undefined-reference-typenameof?show=577#a577
<p><strong>UPDATE</strong> ;)</p>
<p>it seems the error was somewhere hidden in the CMake file (not too surprising as I am still new to this framework).... THIS new <a rel="nofollow" href="https://drive.google.com/file/d/0BzL-NWO3QoFVRXFxelF5bzVNNDA/view?usp=sharing">CMake</a> file seems to work with the code and I can also run the tutorials (after copying them into my project)</p>
<p>:)</p>
http://itensor.org/support/575/itensor-external-project-undefined-reference-typenameof?show=577#a577Fri, 23 Jun 2017 09:00:47 +0000Ground state energy increase after 10th sweep
http://itensor.org/support/576/ground-state-energy-increase-after-10th-sweep
<p>I'm calculating the spin 1 bilinear biquadratic model at the critical point $\theta=-PI/4$. For N=32, I did 13 sweeps. The ground state energy after each sweep is:<br>
Sweep 01: -88.497967398468<br>
Sweep 02: -88.909137146883<br>
Sweep 03: -88.917526981673<br>
Sweep 04: -88.917544395609<br>
Sweep 05: -88.917545655638<br>
Sweep 06: -88.917545847203<br>
Sweep 07: -88.917545866916<br>
Sweep 08: -88.917545867250<br>
Sweep 09: -88.917545867323<br>
Sweep 10: -88.917545867276<br>
Sweep 11: -88.917545867230<br>
Sweep 12: -88.917545867091<br>
Sweep 13: -88.917545867087</p>
<p>We can see from sweep 10, the ground state energy start to increase at order 10^(-10) instead of decreasing. Is it because of the largest truncation error I set is 10^-10? Do I consider this as convergence or wrong result? (The sweep info and code is attached in the end)</p>
<p>Besides this, I have a few questions:<br>
1. How should one set "niter" in each sweep? Large or small number? </p>
<ol>
<li><p>How many sweeps should I do to reach convergence? Should I keep the same "maxm" and do a few sweeps or keep increasing "maxm" to do sweeps (as long as the "maxm" I set is larger than the largest m during sweep)?</p></li>
<li><p>About the mid step information produced by "dmrg", say this example, I get:<br>
Sweep=1, HS=1, Bond=(1,2)<br>
I 0 q 2E+00 E -65.7609306503<br>
I 2 q 4E-14 E -66.9810071517</p></li>
</ol>
<p>What does "I 0" "q 2E+00" "E -65.7609306503" mean? And why are there 2 sets of data?</p>
<ol>
<li>If I want to measure the correlation functions <Sz(j)Sz(N-j+1)>, how can I determine if the correlation function is convergent? Do I compare the correlation function after each sweep? And what's the accuracy of the correlation function compare to the ground state energy?</li>
</ol>
<p>Thank you.</p>
<p>Sweep information:<br>
input<br>
{<br>
N = 32<br>
nsweeps = 13<br>
sw_table<br>
{<br>
maxm minm cutoff niter noise <br>
20 2 1E-8 9 1E-8 <br>
40 2 1E-8 8 1E-9 <br>
80 2 1E-10 7 1E-10<br>
120 2 1E-10 6 1E-10<br>
160 2 1E-10 5 0<br>
200 2 1E-10 4 0<br>
240 2 1E-10 4 0<br>
280 2 1E-10 4 0<br>
320 2 1E-10 5 0<br>
360 2 1E-10 6 0<br>
360 2 1E-10 7 0<br>
360 2 1E-10 8 0<br>
360 2 1E-10 9 0<br>
}<br>
quiet = no<br>
}</p>
<p>Code:</p>
<h2>include "itensor/all.h"</h2>
<h2>include <math.h></h2>
<p>using namespace itensor;<br>
using std::vector;<br>
using std::string;<br>
using std::min;<br>
using std::max;</p>
<h2>define PI 3.14159265358979323846</h2>
<p>int main(int argc, char* argv[])<br>
{<br>
if(argc != 2)<br>
{<br>
//reminds us to give an input file if we forget<br>
printfln("Usage: %s inputfile",argv[0]);<br>
return 0;<br>
}</p>
<pre><code>auto input = InputGroup(argv[1],"input");
auto N = input.getInt("N");
auto nsweeps = input.getInt("nsweeps");
auto sw_table = InputGroup(input,"sw_table");
auto quiet = input.getYesNo("quiet",true);
auto sweeps = Sweeps(nsweeps,sw_table);
println(sweeps);
println(quiet);
double theta = -PI/4;
double cost = cos(theta);
double sint = sin(theta);
auto sites = SpinOne(N);
auto ampo = AutoMPO(sites);
for(int j = 1; j < N; ++j)
{
ampo += cost,"Sz",j,"Sz",j+1;
ampo += cost*0.5,"S+",j,"S-",j+1;
ampo += cost*0.5,"S-",j,"S+",j+1;
ampo += sint,"Sz*Sz",j,"Sz*Sz",j+1;
ampo += sint*0.5,"Sz*S+",j,"Sz*S-",j+1;
ampo += sint*0.5,"Sz*S-",j,"Sz*S+",j+1;
ampo += sint*0.5,"S+*Sz",j,"S-*Sz",j+1;
ampo += sint*0.5,"S-*Sz",j,"S+*Sz",j+1;
ampo += sint*0.25,"S+*S+",j,"S-*S-",j+1;
ampo += sint*0.25,"S-*S-",j,"S+*S+",j+1;
ampo += sint*0.25,"S+*S-",j,"S-*S+",j+1;
ampo += sint*0.25,"S-*S+",j,"S+*S-",j+1;
}
auto H = IQMPO(ampo);
auto state = InitState(sites);
for(int i = 1; i <= N; ++i)
{
if(i%2 == 1)
state.set(i,"Up");
else
state.set(i,"Dn");
}
auto psi = IQMPS(state);
auto energy = dmrg(psi,H,sweeps,{"Quiet",quiet});
//
// Print the final energy reported by DMRG
//
printfln("\nGround State Energy = %.10f",energy);
return 0;
</code></pre>
<p>}</p>
http://itensor.org/support/576/ground-state-energy-increase-after-10th-sweepTue, 20 Jun 2017 19:18:04 +0000Answered: Installation on WIndows Cygwin
http://itensor.org/support/480/installation-on-windows-cygwin?show=570#a570
<p>Would you please upload or copy your mk file here? That will help me a lot. I have problem of mk file, too. </p>
http://itensor.org/support/480/installation-on-windows-cygwin?show=570#a570Sat, 10 Jun 2017 13:34:50 +0000Answered: The installing problem
http://itensor.org/support/565/the-installing-problem?show=567#a567
<p>Would you please upload your mk file or copy your mk file here so that we can read it ?</p>
http://itensor.org/support/565/the-installing-problem?show=567#a567Sat, 10 Jun 2017 13:30:00 +0000Answered: expH for time evolution
http://itensor.org/support/556/exph-for-time-evolution?show=563#a563
<p>Marking this as answered because of the discussion above. Thanks Chengshu!</p>
http://itensor.org/support/556/exph-for-time-evolution?show=563#a563Tue, 06 Jun 2017 16:36:32 +0000Answered: Copying data from local tensor for creating density matrices from wave functions
http://itensor.org/support/553/copying-local-tensor-creating-density-matrices-functions?show=559#a559
<p>Hi Stefan,<br>
One way to do what you are asking is to use a "delta" tensor, which is a diagonal-sparse tensor. Using delta tensor with two indices invokes a special routine that just replaces one index with another.</p>
<p>So if an ITensor A has indices i1,i2,i3, you could do this to replace i2 with a new Index j:</p>
<p>auto j = Index("j",i2.m());<br>
auto B = A;<br>
B *= delta(i2,j);</p>
<p>Now B will have the same data as A but will have indices i1, j, i3 instead. </p>
<p>You can do a similar thing for IQTensors and IQIndices, but make sure in that case to use delta(dag(i2),j), that is you need to flip the arrow of i2 so that the arrow directions are compatible.</p>
<p>Finally, I recently added some functions called "sim" which given an index makes a new index that is distinct, but has the same "physical" properties. This is especially useful for IQIndices. So you can do:</p>
<p>auto j = sim(i);</p>
<p>To make a new IQIndex j that has the same size and QN sectors as an IQIndex j.</p>
<p>Miles</p>
http://itensor.org/support/553/copying-local-tensor-creating-density-matrices-functions?show=559#a559Mon, 05 Jun 2017 17:36:15 +0000Answered: Is it possible to multiply AutoMPO objects before converting to IQMPOs?
http://itensor.org/support/546/possible-multiply-autompo-objects-before-converting-iqmpos?show=547#a547
<p>Hi, so this is a good idea for a feature that we could create with AutoMPO. However it's not a feature that we currently have. I'd like to add it at some point in the future but I can't promise I can get to it very soon.</p>
<p>Here are some things we could do:</p>
<p>(1) You could hack together your own workaround code that computes the product in your code before feeding the operators to AutoMPO. So like if the first MPO is an operator: </p>
<p>$$\sum_{i} h_{i} $$</p>
<p>and the second is </p>
<p>$$\sum_{j} k_{j} $$</p>
<p>then you could make a for loop that feeds operators into AutoMPO of the form </p>
<p>$$\sum_{ij} h_{i} k_{j} $$</p>
<p>It's not yet documented on the website, but AutoMPO now accepts any length string of operators, so it's no longer limited to just 2-site terms.</p>
<p>(2) If you're feeling ambitious, you could start diving into how AutoMPO works and create a function that builds on top of the AutoMPO system to create the product in the way you are asking. Actually this may not be too tough. Basically the AutoMPO just accumulates an array of string and integer pairs, together with a coefficient that also includes keeping track of any fermionic minus signs. So one could create a fancier function that does the double loop over the operators stored in two AutoMPO objects and merges them into the data stored in a single AutoMPO defined as their product (by data stored I mean the intermediate representation stored in the "AutoMPO::terms_" data member before finally converting everything to an actual IQMPO, which is a part you wouldn't have to change as long as the intermediate representation is valid). </p>
<p>But since as I just mentioned it should be somewhat straightforward for someone who understands the system, maybe it's a feature I can add over the next few weeks.</p>
<p>Finally, please let me know if you think there's a bug in nmultMPO as I should fix that. If the IQMPOs you are putting into it are invalid or ill-formed somehow (as you hinted they might be in your question) then it's probably not a bug if nmultMPO fails. But if they are valid IQMPOs and it still failed could you email me a minimal code that reproduces this bug? Thanks -</p>
<p>Miles</p>
http://itensor.org/support/546/possible-multiply-autompo-objects-before-converting-iqmpos?show=547#a547Thu, 25 May 2017 17:15:10 +0000Answered: How do I split one "sites" into several pieces or combine several "sites" to form a bigger "sites"?
http://itensor.org/support/541/split-sites-several-pieces-combine-several-sites-bigger-sites?show=542#a542
<p>Hi Jin,<br>
So the SiteSet class does have a constructor that can accept a vector of IQIndices that could be, say, the sites from two other site sets or a subset of sites from a single site set. So this ought to give you the main ability that you are asking for. </p>
<p>However, when using this constructor one would lose all of the information about local operators that are defined for each site. Is that still something you would need? I.e. to be able to call the .op method for each site after making your new site set?</p>
<p>Miles</p>
http://itensor.org/support/541/split-sites-several-pieces-combine-several-sites-bigger-sites?show=542#a542Mon, 22 May 2017 17:36:44 +0000Answered: Is it possible to export a state (density matrix) in matrix form in a given basis?
http://itensor.org/support/510/possible-export-state-density-matrix-matrix-form-given-basis?show=525#a525
<p>Assuming that you are using IQTensors (IQMPS) for your calculations, I would recommend the following: </p>
<p>(1) convert whichever tensors you want to export to just ITensors. So for an IQMPS convert it to an MPS. Or for an IQTensor (like a reduced density matrix) convert it to an ITensor.</p>
<p>(2) then call the "ordered" function on this ITensor to get a simple, plain tensor with a well-defined memory access pattern and contiguous storage in memory. For more information see the documentation of the ordered function on this page: <a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/itensor">http://itensor.org/docs.cgi?page=classes/itensor</a></p>
<pre><code>auto t = ordered(T,i1,i2,i3); // <- here T is an ITensor
t(1,2,3); // <- how to access an element of the plain tensor t
</code></pre>
<p>(3) either use the .data() and .size() methods of the tensor object returned by the ordered function to write the tensor data to a file (binary stream) or explicitly loop over the indices of the returned tensor object and write them one at a time to a file in the way you wish (ascii or binary)</p>
http://itensor.org/support/510/possible-export-state-density-matrix-matrix-form-given-basis?show=525#a525Thu, 18 May 2017 18:12:24 +0000Answered: About diagHermitian function
http://itensor.org/support/517/about-diaghermitian-function?show=519#a519
<p>Hi Chengshu,<br>
The Sx operator is not compatible with the requirements for IQTensors. (The non-zero blocks of IQTensors have to all have the same "quantum number flux" i.e. change the total quantum number by a fixed amount when acting on a wavefunction in the case of operators.)</p>
<p>So the issues you're seeing above are related to trying to use the Sx operator in an IQTensor context. You just aren't allowed to do it. If it seems to be partially working in the first case, i.e. diagHermitian is letting you plug sx in as the first argument with U,D defined as IQTensors then either you would get an error message if you were running in debug mode or I need to put a new check there that throws an error message.</p>
<p>Miles</p>
http://itensor.org/support/517/about-diaghermitian-function?show=519#a519Thu, 18 May 2017 17:50:51 +0000Answered: Can you use a noise term with fitApplyMPO
http://itensor.org/support/496/can-you-use-a-noise-term-with-fitapplympo?show=504#a504
<p>Hi Lars,<br>
That feature of fitApplyMPO may not be working. However, I recently wrote a slightly different version of fitApplyMPO that does support a noise term and I am pasting it below. Could you look through it and give it a try and let me know if it works for you (perhaps with minor modifications if there's a minor bug somewhere)?</p>
<p>If it works well for you I may replace what's in the library with it:</p>
<pre><code>namespace itensor {
template<typename T>
MPSt<T>
fitApplyOneSite(MPSt<T> const& psi,
MPOt<T> const& W,
Sweeps const& sweeps,
Args args = Args::global())
{
auto quiet = args.getBool("Quiet",true);
auto N = psi.N();
auto res = psi;
auto LR = std::vector<T>(N+2);
LR.at(N) = psi.A(N) * W.A(N) * dag(prime(res.A(N)));
for(auto j = N-1; j > 1; --j)
{
LR.at(j) = LR.at(j+1)*psi.A(j)*W.A(j)*dag(prime(res.A(j)));
}
for(auto sw : range1(sweeps.nsweep()))
{
args.add("Sweep",sw);
args.add("Cutoff",sweeps.cutoff(sw));
args.add("Minm",sweeps.minm(sw));
args.add("Maxm",sweeps.maxm(sw));
auto noise = sweeps.noise(sw);
for(int j = 1, ha = 1; ha <= 2; sweepnext1(j,ha,N))
{
if(not quiet) printfln("sw=%d j=%d ha=%d noise=%.3E",sw,j,ha,noise);
//
// Apply MPO
//
auto WA = psi.A(j);
if(LR.at(j-1)) WA *= LR.at(j-1);
WA *= W.A(j);
if(LR.at(j+1)) WA *= LR.at(j+1);
res.setA(j,noprime(WA));
if(not (ha==2 && j==1))
{
res.Anc(j) /= norm(res.A(j));
//
// Form density matrix
//
auto d = ha==1 ? +1 : -1;
auto li = linkInd(res,ha==1 ? j : j-1);
auto rho = li ? primeExcept(res.A(j),li) : prime(res.A(j));
rho *= dag(res.A(j));
//
// Form noise * density matrix perturbation
//
if(noise > 0.)
{
auto drho = psi.A(j);
if(LR.at(j-d)) drho *= LR.at(j-d);
drho *= W.A(j);
drho = dag(noprime(drho)) * drho;
rho += noise*drho;
}
//
// Diag density matrix
//
T U,D;
auto spec = diagHermitian(rho,U,D,args);
auto ci = commonIndex(U,D);
if(not quiet) printfln("m=%d truncerr=%.5E",ci.m(),spec.truncerr());
if(j+d <= N && j+d >= 1)
{
auto C = dag(U)*res.A(j);
res.setA(j,U);
res.setA(j+d,C*res.A(j+d));
}
LR.at(j) = LR.at(j-d) ? LR.at(j-d)*psi.A(j) : psi.A(j);
LR.at(j) *= W.A(j);
LR.at(j) *= dag(prime(res.A(j)));
}
}
}
return res;
}
} //namespace itensor
</code></pre>
<p>The above code is intended to go into a header file. You can put it into a .cc file too with using namespace itensor; above and just remove the namespace itensor { } part around it.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/496/can-you-use-a-noise-term-with-fitapplympo?show=504#a504Sun, 14 May 2017 00:29:43 +0000Answered: MixedIQTensor with complex coefficients not working ?
http://itensor.org/support/484/mixediqtensor-with-complex-coefficients-not-working?show=503#a503
<p>Hi Samuel,<br>
Sorry about the slow reply - I agree with Jin's response (Jin: feel free to post your comments as a reply instead of just comments if you are confident about them). So I don't think the issue has to do with complex numbers per se but rather the issue of using a non-IQTensor operator in an IQTensor / quantum number conserving context, which causes the code to attempt to compute the divergence of a mixedIQTensor which is not well defined. (Part of the the reason mixedIQTensors exist, in fact.)</p>
<p>A bit more backgroun on why there's such a thing as a mixed IQTensor: earlier on we decided on a design where there is a single SiteSet type for both ITensors and IQTensors for the same type of Hilbert space. (So like SpinHalf, SpinOne, etc. can be used in both an ITensor and IQTensor context.) Thus the return type of the .op method is IQTensor, since IQTensors can always be converted to ITensors. However, there are some operators that are not well-defined IQTensors, such as Sx. So I made a storage type "mixedIQTensor" that can sort of "smuggle" an ITensor in an IQTensor guise.</p>
<p>In the future we may just have two versions of every site set, so like IQSpinHalf as well as SpinHalf. </p>
<p>Another fix might be to make IQTensors less strict about having a well defined divergence as you suggest in the comments. However there's at least one big issue with this: for efficiency when constructing an IQTensor we use the flux, as soon as it can be determined, to work out all of the blocks that can possibly be non-zero and allocate storage for them in one go. That way we only call the allocator once and don't have to resize the memory or have non-contiguous IQTensor memory. Those things could cause big slowdowns. </p>
<p>So in the end the situation as I see it is: (1) one can always work with operators such as S+ and S- that change quantum numbers in a well-defined way for symmetric Hamiltonians; and (2) restricting IQTensors to just these operator types leads to big efficiencies so it's worth it.</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/484/mixediqtensor-with-complex-coefficients-not-working?show=503#a503Sun, 14 May 2017 00:24:48 +0000Answered: Contracting edge indices of MPS in infinite DMRG
http://itensor.org/support/500/contracting-edge-indices-of-mps-in-infinite-dmrg?show=502#a502
<p>Hi Chengshu,<br>
The upper one is exactly right. Thanks for providing a figure as it helps to discuss things. And see the answer I just posted to your other question. </p>
<p>You can see that the upper figure has to be right because the MPS in principle extends much further beyond the sites you show above, but because of the left and right orthogonality property, the tensors outside of the support of "O" cancel leaving identity matrices on the left and right. These become the lines connecting the top (bra) to the bottom (ket).</p>
<p>The lower one wouldn't be correct for a number of reasons. One reason is what I just wrote above about first writing out the full MPS then canceling most of the tensors (it helps to imagine it not as a truly infinite MPS but as a very large finite MPS with open boundaries some unspecified distance away). Another reason it wouldn't be correct is because it would seem to make the states look as if they are periodic states on a system of size N, whereas they are actually wavefunctions on a much larger, or even infinite, system.</p>
<p>Miles</p>
http://itensor.org/support/500/contracting-edge-indices-of-mps-in-infinite-dmrg?show=502#a502Sat, 13 May 2017 21:08:22 +0000Answered: Calculating energy expectation in infinite DMRG
http://itensor.org/support/485/calculating-energy-expectation-in-infinite-dmrg?show=501#a501
<p>Hi Chengshu,<br>
Sorry about the slow reply.</p>
<p>The overlap(psi,H,psi) method is intended for finite, open boundary MPS and finite, open boundary MPOs. </p>
<p>To get the energy from infinite DMRG, one way is to get the energy from the result object:<br>
auto res = idmrg(...);</p>
<p>Print(res.energy);</p>
<p>To actually evaluate the energy from an MPO takes more explanation and it's hard to type it all out here. But basically the kind of MPOs that idmrg expects have left and right boundary vectors stored in H.A(0) and H.A(N+1) (where N = H.N() is the number of sites of the MPO).</p>
<p>The MPS returned from idmrg (meaning the value of psi which is passed by reference after idmrg returns) is in a right-orthogonal gauge, meaning all of it's tensors obey the right orthogonality condition. The tensor psi.A(0) contains the "center matrix" of the MPS, so to construct part of the infinite wavefunction you must multiply psi.A(0)* psi.A(1) to get the orthogonality center tensor on site 1. See the sample/idmrg.cc sample code to see an example of this. Then one can extend the MPS by continuing to multiply by psi.A(2), psi.A(3), ..., psi.(N), psi.A(1), psi.A(2), etc for as many unit cells as needed e.g. to compute correlation functions and or matrix elements of part of the Hamiltonian or an MPO.</p>
<p>Finally, in the result object the idmrg algorithm returns, there are two tensors res.HL and res.HR which are the left and right "Hamiltonian environment" tensors computed as the idmrg algorithm grows the system longer and longer. These are the MPO projected into the semi-infinite "wings" or left and right basis of the infinite MPS. You can use these together with one unit cell of the MPO and MPS to compute the same energy that idmrg reports.</p>
<p>At some point I plan to write a detailed documentation with figures about the idmrg algorithm in ITensor. There is a draft of one written by a couple students but it may have some inaccuracies. It is a fairly complex algorithm to explain, but it follows pretty closely to the algorithm as explained by Schollwock in his review article. I hope what I wrote above gives you the information you need. Also I'd encourage you to read through the idmrg code itself and draw diagrams and/or take notes on how it works for yourself and you can learn a lot this way about its inner workings and the algorithm.</p>
<p>Miles</p>
http://itensor.org/support/485/calculating-energy-expectation-in-infinite-dmrg?show=501#a501Sat, 13 May 2017 21:04:40 +0000Answered: Entanglement entropy for a periodic chain
http://itensor.org/support/494/entanglement-entropy-for-a-periodic-chain?show=497#a497
<p>Hi Jacopovit,</p>
<p>We are always suggested using MPS with open boundary conditions in ITensor. So even if it is a Hamiltonian with PBC, we express the eigenstate with MPS with OBC. Although this would require more memory, it's convenient to compute entanglement entropy for intervals extended to the end by SVD only on a single bond. </p>
<p>The measurement of entanglement entropy of an interval inside a chain is similar in three cases. A similar question is discussed here <a rel="nofollow" href="http://itensor.org/support/229/evaluate-block-entanglement-blocks-that-extend-the-lattice?show=230#a230.">http://itensor.org/support/229/evaluate-block-entanglement-blocks-that-extend-the-lattice?show=230#a230.</a> The main problem is if "l" is very big, it's impossible to do with MPS. But we could calculate the second order Renyi entropy by a sampling method, which is very similar to "perfect sampling" in a paper by Ferris and Vidal.</p>
<p>Jin</p>
http://itensor.org/support/494/entanglement-entropy-for-a-periodic-chain?show=497#a497Wed, 10 May 2017 09:25:13 +0000Answered: Segmentation fault when using combiner
http://itensor.org/support/489/segmentation-fault-when-using-combiner?show=495#a495
<p>Fixed by a pull request: <a rel="nofollow" href="https://github.com/ITensor/ITensor/pull/119">https://github.com/ITensor/ITensor/pull/119</a></p>
<p>Thanks, Lars, for submitting this patch.</p>
http://itensor.org/support/489/segmentation-fault-when-using-combiner?show=495#a495Tue, 09 May 2017 05:13:19 +0000Answered: Starting Initial State as product state of singlets
http://itensor.org/support/490/starting-initial-state-as-product-state-of-singlets?show=493#a493
<p>Hi Dhiman,<br>
Good question as this is an important thing to be able to do sometimes. And of course you can do this, yes, as one can set the elements of an ITensor or IQTensor individually so you can make any MPS this way.</p>
<p>Here is a sample code that makes an MPS which is a product state of singlets. To do the IQMPS version all you should need to do is change MPS to IQMPS and ITensor to IQTensor.</p>
<pre><code>auto psi = MPS(sites);
for(int n = 1; n <= 2*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.Aref(n) = ITensor(s1);
psi.Aref(n+1) = ITensor(s2);
svd(wf,psi.Aref(n),D,psi.Aref(n+1));
psi.Aref(n) *= D;
}
</code></pre>
http://itensor.org/support/490/starting-initial-state-as-product-state-of-singlets?show=493#a493Mon, 08 May 2017 05:08:55 +0000Answered: Installation problem
http://itensor.org/support/468/installation-problem?show=477#a477
<p>Glad you got the installation working! (To those reading please see comments above.)</p>
http://itensor.org/support/468/installation-problem?show=477#a477Wed, 19 Apr 2017 23:30:10 +0000Answered: Conversion of AutoMPO->IQMPO for PBC
http://itensor.org/support/463/conversion-of-autompo-iqmpo-for-pbc?show=473#a473
<p>Hi Samuel,<br>
Thanks for the questions. Let me go through them here:</p>
<p>(1) By the "exact" conversion, what is meant is that every term you put into AutoMPO is translated into the MPO that is returned without any approximation (other than the floating point representation of numbers if you're being picky). The approx/svd case has the advantage that it can handle terms with operators on more than two sites, and it can find a smaller MPO dimension for certain complicated Hamiltonians. But for simple Hamiltonians with couplings of a significant size, both algorithms should give the same results basically. Internally they are very different engines for generating MPOs from AutoMPO data. If you're concerned about one or the other, and both apply to your case I'd recommend testing both on small systems to check. Please let me know any time you think you've found a bug.</p>
<p>(2-3) Right now there's not a way to get a report of the compression in the approx/svd case, but you can control the maximum truncation error by providing a "Cutoff" named arg like this:<br>
auto H = toMPO(ampo,{"Cutoff=",1E-12});<br>
Here I've assumed you want an IQMPO so I made the tensor type IQTensor, but you can make it ITensor too to get an MPO. Above you could experiment with different cutoff values to see how or if it affects your results. It should only matter if some of your Hamiltonian terms have very small coefficients or if you are wanting extremely high-accuracy results.</p>
<p>(4) I can't say why you aren't getting the results you expect for the AKLT Hamiltonian. But if the initial energy is wrong then perhaps the MPO returned from the toMPO function is being constructed incorrectly? Here it would help to have some sample code from you so I could test it. But also you can test the returned MPO yourself by using the "InitState" feature to create various product states and computing overlaps of these with the MPO (using the overlap(psi,H,psi) function to get matrix elements). That's the method I often use to double check the construction of MPOs.</p>
<p>(5) Not sure why the non-symmetric version works but not the symmetric version. My best guess is that either there is a convergence issue with the combination of QN conservation (which can cause DMRG to get stuck more easily) and periodic BC's (which can also cause DMRG to have worse convergence). Or perhaps there is a bug with AutoMPO. We don't use periodic boundary conditions much so it's conceivable.</p>
<p>Miles</p>
http://itensor.org/support/463/conversion-of-autompo-iqmpo-for-pbc?show=473#a473Wed, 19 Apr 2017 03:34:00 +0000Answered: Generalized eigenvalue problem
http://itensor.org/support/467/generalized-eigenvalue-problem?show=472#a472
<p>Hi, <br>
ITensor has a basic matrix/tensor layer that wraps certain LAPACK routines. Currently the main use of this matrix layer is to power the ITensor class and related features (such as IQTensor, MPS, etc.). But this matrix layer is also available to use directly. While ideally we would provide wrappers for every major LAPACK routine, so far we've been conservatively just creating wrappers for ones we use in specific projects or which are needed for the ITensor layer.</p>
<p>You could use one of these wrappers (such as in matrix.cc) to create your own wrapper for a LAPACK routine. Or if you are asking about a specific routine you think should be in ITensor you can let me know which one you are thinking of and I could see about adding it. But it may take some months to fit it in unless you need it urgently for a project.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/467/generalized-eigenvalue-problem?show=472#a472Wed, 19 Apr 2017 03:21:41 +0000Answered: About installing itensor library
http://itensor.org/support/464/about-installing-itensor-library?show=466#a466
<p>Hi, <br>
It might be because you need to specify the BLAS<em>LAPACK</em>INCLUDEFLAGS as well. There should be a flag starting with -I followed by the directory where your header (.h) files are for your LAPACK installation. </p>
<p>For example, <br>
BLAS<em>LAPACK</em>INCLUDEFLAGS=-I/usr/local/opt/lapack/include</p>
<p>Please check the folder to make sure it has header files such as lapacke.h (or some set of relevant headers).</p>
<p>Another thing to check is whether you are setting PLATFORM=lapack correctly. Like, for example, is the PLATFORM variable set again to a different value further down in your options.mk file? The reason I ask is that if PLATFORM=lapack is set correctly then things like LAPACK<em>INT should be set by ITensor itself. So if those aren't getting set then maybe the PLATFORM</em>lapack variable is not being defined.</p>
<p>Finally, please make sure the options.mk file you made is from a recent version of ITensor. If you upgraded from a much older version of ITensor, then you should make a brand new options.mk from scratch from the most recent options.mk.sample file. (If you are just installing ITensor for the first time I assume that's what you did.)</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/464/about-installing-itensor-library?show=466#a466Sun, 16 Apr 2017 02:04:29 +0000Answered: AutoMPO to IQMPO Error with user-defined siteset / four-body interactions
http://itensor.org/support/445/autompo-iqmpo-error-defined-siteset-four-body-interactions?show=457#a457
<p>Hi, thanks for reporting this. I think what's going on here is actually two separate bugs, one within ITensor and one in your code.</p>
<ol>
<li><p>The bug within ITensor, now fixed, is that for efficiency AutoMPO was assuming that operators with the same name also carried the same quantum numbers. But that is not the case for your site set and wouldn't be the case e.g. for a site set with different spin types, like a lattice with both spin half and spin one sites. So now AutoMPO doesn't assume that anymore. Please pull the latest version of ITensor from GitHub and recompile and you'll have this fixed version.</p></li>
<li><p>I believe there's a bug within your code too: you have terms containing things like "S+",i,"S-",i+1 but would not that process fail to conserve A and B total Sz separately? I think maybe you meant for the site to be i and i+2 instead of i and i+1. I could be wrong about this second bug, though, because I didn't do a careful study of it so please just think about it and see if you agree or disagree.</p></li>
</ol>
<p>Please let me know if the new version still doesn't work for you. Thanks for pointing out this serious issue!</p>
<p>Miles</p>
http://itensor.org/support/445/autompo-iqmpo-error-defined-siteset-four-body-interactions?show=457#a457Tue, 11 Apr 2017 20:10:58 +0000Answered: broadcast tensor or index
http://itensor.org/support/454/broadcast-tensor-or-index?show=455#a455
<p>Hi Rui-Zhen,<br>
I am actually working on an implementation of real-space parallel DMRG we hope to release publicly later this year. So that will have code inside it that uses MPI to send ITensors between nodes.</p>
<p>To help you out, I just put a file "parallel.h" into ITensor. So if you pull the latest version from GitHub you should see it in the itensor/util/ folder within the ITensor source code. Please treat the codes in there as somewhat experimental, although we have used them a lot in the past so they should be pretty well tested (we used them for the parallel DMRG paper).</p>
<p>The main object you want to use in parallel.h is the Environment object. You should immediately make this object at the top of your "main" function<br>
Environment env(argc,argv);<br>
(passing it argc and argv to create it). Then it will be destructed at the end of your program and will automatically call MPI_Finalize for you. The environment object "env" has a method env.broadcast(T) which takes any object T (such as an ITensor, IQTensor, SiteSet, MPS, MPO and many other types of objects or even plain data like integers) that can be read from or written to a binary stream.</p>
<p>MailBox is another type of object you can make to send to and receive from specific other nodes. You make a MailBox object and give it the id number of the other node (zero-indexed). then you can use the .send and .receive methods to do blocking sends and receives. I don't think it currently supports non-blocking sends and receives.</p>
<p>Finally, to give you more information about your question, every object in the ITensor Library has a .read and .write method that can read/write that object in binary to a stream (either an istream or an ostream). The codes in parallel.h create a stream (in some cases a stringstream, for example) and use the .read or .write methods of an ITensor (or another type of object) to read/write to this stream. Then the stream is sent to another node using a function provided by the MPI library.</p>
<p>So I hope the above paragraph helps you understand that you don't need to know about the "complex structure" of an ITensor or an IQTensor: you just have to use the .read and .write methods to convert an ITensor to or from a binary stream.</p>
<p>Miles</p>
http://itensor.org/support/454/broadcast-tensor-or-index?show=455#a455Tue, 11 Apr 2017 17:57:35 +0000Answered: Obtaining eigenstates of reduced density matrix
http://itensor.org/support/446/obtaining-eigenstates-of-reduced-density-matrix?show=449#a449
<p>Hi Chengshu,<br>
This is kind of a tricky question to briefly answer on a message board and I'd really need to refer you to an article such as Schollwock's review on DMRG and MPS to give you the full answer. But the basic answer is that if you properly gauge an MPS, then the MPS tensors themselves already give you the eigenstates of the reduced density matrix of a block of sites starting from either the left or right edge of the system, up to the site that is the gauge "center". (You can see why this is hard to explain in writing - it's really something that's easier to draw with diagrams.)</p>
<p>On the other hand if the reduced density matrix you are asking about (you didn't specify) involves tracing out a block of sites that doesn't start from the left or right edge of the system (as defined by the MPS path) then it's highly non-trivial to get the reduced density matrix eigenstates. An example of such a hard case would be a 1d system where the r.d.m. you want is the one obtained by tracing out every even numbered site. In that case you can technically get information about the reduced density matrix by using a sampling procedure but it would be very hard to get the eigenstates of such an r.d.m. </p>
<p>Hope that helps you to understand the issue/question better.</p>
<p>Miles</p>
http://itensor.org/support/446/obtaining-eigenstates-of-reduced-density-matrix?show=449#a449Mon, 10 Apr 2017 04:58:41 +0000Answered: QN degeneracy caused "segmentation fault" for odd number of sites
http://itensor.org/support/406/degeneracy-caused-segmentation-fault-for-odd-number-sites?show=448#a448
<p>Hi Junjie,<br>
Sorry I haven't replied sooner. Based on my understanding of your situation, I think the correct way to proceed is to define some of the Index objects making up your IQIndex definition to have a size greater than 1. So I mean the second thing you suggested.</p>
<p>You said about this second way that "it may have problems when we try to define operators" but I don't see how it would lead to a problem defining operators. Can you tell me what problem you think it would cause when defining operators? </p>
<p>If it helps, recall that when you "index" into an IQIndex, meaning when you write I(n) for some IQIndex "I" and an integer "n", then the associated sector (the things labeled by the Index-QN object pairs) is determined by counting through the sizes of each sector, starting from the beginning. So if all of the sectors (Index objects) are of size 1, as it usually the case for a site IQIndex, then the n'th value corresponds to the n'th sector. But this doesn't have to be the case. If, say, the first sector has size 1 and the second sector has size 2, then I(3) means we are still in the second sector, just the second value within the second sector.<br>
(This concept is briefly explained here in the diagram near the end: <a rel="nofollow" href="http://itensor.org/docs.cgi?page=book/iqindex">http://itensor.org/docs.cgi?page=book/iqindex</a> in the diagram near the end showing the "Index value").</p>
<p>So for defining an operator there should not necessarily be a problem for some of the sectors to have a size > 1. </p>
<p>Miles</p>
http://itensor.org/support/406/degeneracy-caused-segmentation-fault-for-odd-number-sites?show=448#a448Mon, 10 Apr 2017 04:40:18 +0000Answered: Segmentation Fault in Calculation of Excited States?
http://itensor.org/support/441/segmentation-fault-in-calculation-of-excited-states?show=442#a442
<p>Hi Jin,<br>
For an IQMPS to be used it must be fully initialized. The first InitState you made did not specify a state for all of the sites but only the first N/2 of them. So the result is an IQMPS that is not fully defined. </p>
<p>I agree though that this behavior is somewhat confusing and that there should be a clearer error message that happens earlier. I'll see if I can make that happen. </p>
<p>Miles</p>
http://itensor.org/support/441/segmentation-fault-in-calculation-of-excited-states?show=442#a442Fri, 24 Mar 2017 21:31:57 +0000Answered: iDMRG stops at step 3
http://itensor.org/support/419/idmrg-stops-at-step-3?show=431#a431
<p>Hi Sam,<br>
Thanks for pointing out this bug. I just pushed a fix on the ITensor master branch, so idmrg ought to work again now even if you do a git pull to get the very latest github version. Of course please let me know if you run into another issue.</p>
<p>Miles</p>
http://itensor.org/support/419/idmrg-stops-at-step-3?show=431#a431Wed, 22 Mar 2017 06:54:06 +0000Answered: How to restart iDMRG using the state "psi" from previous run?
http://itensor.org/support/410/how-to-restart-idmrg-using-the-state-psi-from-previous-run?show=429#a429
<p>I have solved that.<br>
I think the key point is to add a step to contract "D" from the first idmrg with the initial psi.A(1) in the second idmrg. So I added "D" into the return value of idmrg. Sometimes I want to run another app to measure or continue idmrg starting from a psi stored in the disk. So I also added some codes to write the "res" in idmrg.h into disk. <br>
Besides, I am actually doing adiabatic evolution of a state. So in every idmrg, I have to vary my H by a little, which requires me to reconstruct H every time. This also caused some inconvenience because the indices of the Link on H.A(1) towards HL are random though H's are constructed from the same site. My solution is to identify the indices with an identity matrix.<br>
I am not sure whether it is the best way to tackle the problem, but anyway it works.<br>
Thank you!</p>
<p>Zhiyu</p>
http://itensor.org/support/410/how-to-restart-idmrg-using-the-state-psi-from-previous-run?show=429#a429Tue, 21 Mar 2017 05:11:05 +0000Answered: The idmrg is not working for topological state
http://itensor.org/support/407/the-idmrg-is-not-working-for-topological-state?show=415#a415
<p>Hi, neat that you are tackling this system. It ought to work but I can imagine any number of things that might cause a bug or lack of convergence. Can you provide more details about how you set up the code? Eg currently you can't use AutoMPO to make Hamiltonians for idmrg - did you construct the MPO yourself? </p>
http://itensor.org/support/407/the-idmrg-is-not-working-for-topological-state?show=415#a415Wed, 15 Mar 2017 07:11:53 +0000Answered: Trotter Gates with PBC?
http://itensor.org/support/398/trotter-gates-with-pbc?show=401#a401
<p>Hi Jin,<br>
Someone else may answer who knows more about this than I do, but I don't think there is a nice MPS algorithm that does what you want. There is an older paper by Verstraete and Cirac that discusses optimizing periodic MPS; you could look at that for some ideas. </p>
<p>Also you could do the "poor man's periodic" approach where you actually use an open-boundary MPS (the regular kind used in ITensor) and just apply a two-site gate that acts on sites 1 and N, using a sequence of swap gates to swap site N all the way to site 2 and then back every time. This would be pretty slow of course. But it might work ok.</p>
<p>There is a paper by Zaletel and Pollmann about constructing MPOs that are the exponential of certain local Hamiltonians. Their construction might straightforwardly work for periodic Hamiltonians. Then if you can find an algorithm to apply a periodic MPO to a periodic MPS that is another possible route. (But there may not be such a nice algorithm for that either.)</p>
<p>Finally, please think hard about whether you really need periodic boundary conditions. One of the strengths of MPS techniques is their scalability to very long 1d systems. So often it's better to just study really long open systems than to use PBC to attempt to reduce finite-size effects. And for some quantities and systems, PBC actually gives worse finite-size scaling than OBC!</p>
<p>Miles</p>
http://itensor.org/support/398/trotter-gates-with-pbc?show=401#a401Sun, 12 Mar 2017 23:49:12 +0000Answered: Calculating excited states in infinite DMRG
http://itensor.org/support/399/calculating-excited-states-in-infinite-dmrg?show=400#a400
<p>Hi Chengshu,<br>
Your code looks correct. It's just that the algorithm is not guaranteed to find the first excited state every time. The key thing you need to experiment with is the "Weight" parameter which is the penalty for psi1 and psi0 to have a non-zero overlap. I would start with a weight of 1.0 and experiment with other values if that doesn't work. Also start out on small systems where you know the answer. Finally, make sure the ground state is very well converged before trying to get the first excited state.</p>
<p>Even when you use this algorithm very carefully, it can sometimes miss excited states (it depends on how you initialize the MPS and how you optimize them). So you might get the ground state, first excited state, then the third excited state, and then the second excited state.</p>
<p>There is another approach to getting excited states with DMRG called "multiple targeting". We don't offer a black-box interface for that algorithm in ITensor right now but it would certainly be possible to implement and I think our Davidson code is set up to do it. That's something you could try to code yourself if the above method continues not to work.</p>
<p>Miles</p>
http://itensor.org/support/399/calculating-excited-states-in-infinite-dmrg?show=400#a400Sun, 12 Mar 2017 23:44:03 +0000Answered: possible error of last site MPO in iqdmrg
http://itensor.org/support/393/possible-error-of-last-site-mpo-in-iqdmrg?show=394#a394
<p>Hi Wangwei,<br>
Are you referring to a particular sample code included with ITensor? The iqdmrg.cc code doesn't have a field term in it, so you must add it yourself the correct way, making sure that the loop index "j" runs over all sites and includes the last site.</p>
<p>If you can attach some sample code I can respond with more details.</p>
<p>Miles</p>
http://itensor.org/support/393/possible-error-of-last-site-mpo-in-iqdmrg?show=394#a394Tue, 07 Mar 2017 21:43:17 +0000Answered: dmrg only works for sites with odd number
http://itensor.org/support/391/dmrg-only-works-for-sites-with-odd-number?show=392#a392
<p>Hi Junjie,<br>
It's hard to say what's going wrong without seeing more details of what you are doing.</p>
<p>However, based on the error message and that you are still checking whether your Hamiltonian is correct, the most likely problem is that your current Hamiltonian is either not Hermitian or does not conserve the appropriate symmetries (the ones defined by your QNs). I bet if you check both of these issues then the errors will go away.</p>
<p>Best,<br>
Miles</p>
http://itensor.org/support/391/dmrg-only-works-for-sites-with-odd-number?show=392#a392Mon, 06 Mar 2017 20:42:06 +0000Answered: How to create a new QN
http://itensor.org/support/389/how-to-create-a-new-qn?show=390#a390
<p>Hi Zhiyu,<br>
We just put the "named slot" feature into the QN system for convenience when making very common types of QNs. I think your best bet here is to instead just use the "manual" way of making QNs where you specify the value and mod factor of each slot. So for two separately conserved types of hardcore bosons (without spin) I would just do:</p>
<p>QN({na,1},{nb,1})</p>
<p>where na and nb are integers (0 or 1) indicating how many of each type of boson you have.</p>
<p>Does that work for your problem?</p>
<p>Miles</p>
http://itensor.org/support/389/how-to-create-a-new-qn?show=390#a390Sun, 05 Mar 2017 17:18:07 +0000Answered: Matrix element of hubbard Hamiltonian using hubbard siteset
http://itensor.org/support/387/matrix-element-hubbard-hamiltonian-using-hubbard-siteset?show=388#a388
<p>Hi Junjie,<br>
So just doing it in my head (meaning I could be making a mistake) there's:<br>
1. a minus sign for the process of annihilating the down electron from the UpDn state (with an even number (=0) of electrons to the left of site 1<br>
2. a minus sign from re-creating the down electron on site 2, because there are an odd number of electrons to the left of site 2<br>
3. a minus sign from the -t coefficient of the hopping term where (t=1)</p>
<p>So overall a -1. Hope that helps -</p>
http://itensor.org/support/387/matrix-element-hubbard-hamiltonian-using-hubbard-siteset?show=388#a388Fri, 03 Mar 2017 06:33:50 +0000Answered: Error "Mismatched mod factors" and question about QN intializer list
http://itensor.org/support/373/error-mismatched-factors-and-question-about-intializer-list?show=378#a378
<p>Hi Junjie,<br>
Good question. Your understanding of everything is correct up to a point. However, what you are missing is that in the way our IQTensor system works, the QN objects must be the same globally. So you can't have some QNs where the second "slot" has a mod factor of +1 and other QNs where the second slot has a mod factor of -1. These can be different between two different programs, but within the same program the meaning of the different slot has to be consistent, even across different sites. So the solution is for all of the sites to have <em>both</em> a boson and fermion number in separate slots (in the code I sent you, the first code above you'll see I ignored the Sz quantum number since it is always zero which means it is not being used).</p>
<p>There isn't a shorthand version of the design I described above, by which I mean there's no QN("Nf=",nf,"Nb=",nb) constructor for the QN objects, although I could add one if it becomes a common case. So the best thing to do is to use the constructor where the mod factors are explicitly given as in the code I sent (the first code above).</p>
<p>I hope that answer makes sense to you, if not let's continue to discuss and I can clarify.</p>
<p>Miles</p>
http://itensor.org/support/373/error-mismatched-factors-and-question-about-intializer-list?show=378#a378Thu, 02 Mar 2017 00:08:24 +0000Answered: Reflecting an MPS
http://itensor.org/support/375/reflecting-an-mps?show=376#a376
<p>Hi Oren,<br>
Good question. I think the std::bad_alloc may be because your code is running out of memory. This can happen when the contractions are not doing what you think, and the number of indices grows to be very large. I have been meaning to put in a line that checks if the number of indices grows beyond, say, 10 and then throws an error unless disabled by the user.</p>
<p>So I think what's happening is that the MPS tensors are being swapped ok, but then the actual site indices are not being switched. This could cause mismatches to, say, a Hamiltonian made from the original site set which would have the site indices in the original order. So I'd suggest you add the following step: use "delta" tensors (<a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/diag_itensor)">http://itensor.org/docs.cgi?page=classes/diag_itensor)</a> to change all of the site/physical indices after you swap the order of the tensors. For example, on the first site do:</p>
<p>phi.Aref(1) *= delta(dag(sites(N)),sites(1);</p>
<p>which (efficiently) replaces the Nth site index with the first site index. Here I'm assuming "sites" is the variable holding your site set (SpinHalf, Hubbard, SpinOne, etc. are examples of site sets).</p>
<p>Please let me know if that fixes your issue -</p>
<p>Miles</p>
http://itensor.org/support/375/reflecting-an-mps?show=376#a376Wed, 01 Mar 2017 18:22:56 +0000Answered: Measuring entanglement spectrum in infinite DMRG
http://itensor.org/support/371/measuring-entanglement-spectrum-in-infinite-dmrg?show=372#a372
<p>Hi Chengshu,<br>
So this involves a feature of ITensor that's not well documented yet. It has to do with the return value of the idmrg function. The wavefunction that is returned is in a fully right-orthogonal gauge, with the center tensor (singular values when doing an SVD of an MPS) stored in the tensor psi.A(0). So to properly gauge the MPS you have to multiply psi.A(0) into the first MPS tensor, then use SVDs to move the gauge to other sites (or call the .position method after doing psi.Aref(1) *= psi.A(0)).</p>
<p>The reason the singular values are separated off into psi.A(0) is so that you can chain the returned MPS into a longer wavefunction that repeats infinitely. See for example the sample idmrg code (in the sample/ folder). Toward the end it computes a correlation function to a much longer distance than the size of the MPS returned by idmrg. Note how the code puts psi.A(0) into the tensor that is used to compute the correlator.</p>
<p>Hope that helps -</p>
<p>Miles</p>
http://itensor.org/support/371/measuring-entanglement-spectrum-in-infinite-dmrg?show=372#a372Tue, 28 Feb 2017 01:44:30 +0000Answered: set flag for Jordan-Wigner transformation in 1-D Bose-Fermi mixture SiteSet
http://itensor.org/support/365/flag-jordan-wigner-transformation-bose-fermi-mixture-siteset?show=368#a368
<p>Hi Junjie,<br>
Thanks for working on this some more on your own. The solution you did with the args<em>site is very close to what I was meaning by adding a "flag" to the BoseFermiMix site. The only change I would suggest is that the flag doesn't need to be an Args object. It could just be a simple boolean variable. So when you define Args args</em>site; you could instead just define bool is<em>fermi = true; (always good to put a default). Then in the constructor set is</em>fermi = true; for fermion sites and false for boson sites, and check this boolean in the op function when making the "F" operator.</p>
<p>Now I will try to understand your other issues, but they are hard for me to assess without running the code myself. For example, you say that BoseFermiMix is "not right" compared to BoseHubbard but I'm not sure for example which one is right or what the right answer should be without having some specific numbers.</p>
<p>So I will try running the code myself to see what I find. When DMRG runs really fast and gives a small entanglement, it's usually because either the initial state is too trivial (like a vacuum state, say) or because the Hamiltonian has some sort of flaw, such as the absence of hopping terms that prevent the particles from spreading out over the system.</p>
<p>Miles</p>
http://itensor.org/support/365/flag-jordan-wigner-transformation-bose-fermi-mixture-siteset?show=368#a368Wed, 22 Feb 2017 19:32:43 +0000Answered: iqdmrg related problem
http://itensor.org/support/366/iqdmrg-related-problem?show=367#a367
<p>Hi Wangwei,<br>
These are all reasonable questions based on the small amount of documentation we have on the "IQTensor" system so far. Hopefully in the near future the ITensor book section will be expanded even more to cover all of these questions.</p>
<p>(1) iqdmrg (and the IQTensor / IQMPS / IQMPO system more generally) can handle U(1) symmetries associated with conserving quantum numbers following an integer addition rule as well as quantum numbers following a Z_N addition rule (addition modulo N). So for example you can also conserve just fermion parity instead of fermion number, or more exotic kinds of quantum numbers. The documentation page on the QN class gives a variety of examples: <a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/qn">http://itensor.org/docs.cgi?page=classes/qn</a></p>
<p>(2) The way IQTensors are truncated is that all of their non-zero blocks are SVD'd separately (for more on IQTensor blocks, see <a rel="nofollow" href="http://itensor.org/docs.cgi?page=book/block_sparse).">http://itensor.org/docs.cgi?page=book/block_sparse).</a> All of the resulting singular values are collected, and sorted, and then used to determine a threshold or cutoff for the entire spectrum of the IQTensor. This threshold is then applied to each block to truncate it. Some blocks may get truncated entirely in this process in which case they are removed. The result is really very similar to how truncation is defined for SVD'ing a dense tensor but is much more efficient due to the sparsity.</p>
<p>(3) The way that iqdmrg determines the quantum number (QN) sector to work in is from the initial state (IQMPS wavefunction) that you provide it. The main feature of iqdmrg is that it will not change the global QNs of the IQMPS. So if you give it an IQMPS with a total Sz of zero, nothing the code does can change this, even if you include a magnetic field. If you want to get the ground state in a different QN sector, you must change the initial state you provide. The InitState object is a convenient way to specify an initial state by giving a product-state spin pattern.</p>
<p>Hope that helps. Please post a comment back if you have additional questions.</p>
<p>Miles</p>
http://itensor.org/support/366/iqdmrg-related-problem?show=367#a367Wed, 22 Feb 2017 07:28:12 +0000Answered: In SVD, is there any way to calculate only U and S, not V^T?
http://itensor.org/support/362/in-svd-is-there-any-way-to-calculate-only-u-and-s-not-v-t?show=363#a363
<p>Good question: this is what the denmatDecomp function is for. There is more detailed info about it on this page:<br>
<a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/decomp">http://itensor.org/docs.cgi?page=classes/decomp</a></p>
<p>Basically its interface works the same way as the svd function but you have to provide a "dir" argument (either Fromleft or Fromright) which in SVD language says whether you want U or V (the other tensor will be set equal to either S<em>V or U</em>S where S is the singular value matrix).</p>
<p>Internally, denmatDecomp squares the tensor you are decomposing and then calls a Hermitian diagonalization routine on it to get just U or just V. So it is more efficient than doing a full SVD.</p>
<p>Miles</p>
http://itensor.org/support/362/in-svd-is-there-any-way-to-calculate-only-u-and-s-not-v-t?show=363#a363Tue, 21 Feb 2017 07:32:19 +0000Answered: Problems about 1-D Bose-Fermi mixture when using DMRG
http://itensor.org/support/357/problems-about-1-d-bose-fermi-mixture-when-using-dmrg?show=358#a358
<p>Hi Junjie,<br>
Your code looks good (sorry for not answering already via email - it's been a busy week). I think posting on here is a good idea anyway so people can learn from your code.</p>
<p>There may be a few different bugs causing issues; it's especially tricky to make new fermionic site sets other than the standard ones we provide but I can help you look into that later. </p>
<p>For now I see at least one bug, which is that the way you define the "F" operator gives a minus sign if there is one particle on a site regardless of whether its a bosonic or fermionic site (even though you use f1, it's (correctly) defined identically to b1). So you should put a flag (like a boolean) into your definition of BoseFermiMix that 'remembers' whether that site is fermionic or bosonic, then check this flag when making the "F" operator and put either a -1 or +1 as appropriate.</p>
<p>Try that and let me know if it still doesn't work and we can keep looking at things.</p>
<p>Miles</p>
http://itensor.org/support/357/problems-about-1-d-bose-fermi-mixture-when-using-dmrg?show=358#a358Sun, 19 Feb 2017 04:27:13 +0000Answered: Infinite DMRG without symmetry
http://itensor.org/support/353/infinite-dmrg-without-symmetry?show=354#a354
<p>Hi Chengshu,<br>
First of all, there is an issue with the iDMRG code at the moment on the master branch. I am hoping to fix it very soon. But if you use version 2.0.11 then iDMRG should work perfectly fine.</p>
<p>Now about your specific question, if you are studying a model without any conserved quantities (or not any that you wish to conserve, because technically the transverse-field Ising model has a conserved parity) then the best way to proceed is to not use IQTensors (and IQMPOS and QNs, etc) at all, but rather just used ITensors and the associated MPO and MPS classes.</p>
<p>Would just setting up your calculation using ITensors and the MPO class give you what you are wanting?</p>
<p>Miles</p>
http://itensor.org/support/353/infinite-dmrg-without-symmetry?show=354#a354Tue, 14 Feb 2017 06:07:49 +0000Answered: How to handle with 1-D Bose-Fermi mixture by using DMRG with iTensor
http://itensor.org/support/347/how-to-handle-with-bose-fermi-mixture-using-dmrg-with-itensor?show=352#a352
<p>Thanks for the kind words. The good news is that all you need is a custom site set and then all of the other parts of the code (such as AutoMPO, MPO, DMRG) should just automatically work. I recently made a site set for a student who is doing a two-leg ladder setup like you suggested where each leg has a different type of quantum number. If you email me I can send you the source code for this site set for you to use as an example. </p>
<p>To deal with fermions specifically, things might get a bit tricky with AutoMPO. We'd probably have to talk about how to deal with it best. But I think it could work ok. Basically you'd have to define a fermion string operator called "F" for both fermion and boson sites, and just define it to be a trivial identity operator for the fermion sites. </p>
<p>Ultimately this would be a good type of SiteSet to add to ITensor.</p>
<p>Miles</p>
http://itensor.org/support/347/how-to-handle-with-bose-fermi-mixture-using-dmrg-with-itensor?show=352#a352Fri, 10 Feb 2017 06:02:20 +0000Answered: Higher spin MPS/IQMPS
http://itensor.org/support/349/higher-spin-mps-iqmps?show=351#a351
<p>Hi Samuel,<br>
Yes you'd need to define a new site set based on spinhalf.h and spinone.h. It should be pretty clear, hopefully, to see how to extend them but if not please post your questions here or by email to me. Basically there is a SpinHalfSite object or a SpinOneSite object which defines the QN's (quantum numbers) of each setting of a site index. And there are the operators such as Sz which are customized for each S value. That's all you should have to change.</p>
<p>About including your new file, you could add that line to all_mps.h as you say, or even simpler you could just add that #include line to the top of your project's code (such as the file that contains your main function, or any file that contains code that will need to know about your custom site set).</p>
<p>Miles</p>
http://itensor.org/support/349/higher-spin-mps-iqmps?show=351#a351Fri, 10 Feb 2017 05:58:08 +0000Answered: Fixing random generators
http://itensor.org/support/348/fixing-random-generators?show=350#a350
<p>randomTensor uses the function Global::random() provided with ITensor to generate random numbers. This function optionally takes a "seed" argument, and if you reset this seed it will generate the same sequence of numbers again after the reset. To do this, just call Global::random(seed) where seed is an integer of your choosing. Hope that helps -</p>
http://itensor.org/support/348/fixing-random-generators?show=350#a350Fri, 10 Feb 2017 05:55:20 +0000Answered: Tensor Exponential
http://itensor.org/support/338/tensor-exponential?show=339#a339
<p>Hi, so we have the expHermitian function:<br>
<a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/decomp">http://itensor.org/docs.cgi?page=classes/decomp</a></p>
<p>For non-Hermitian matrices we don't have a function set up to automatically exponentiate tensors for you. </p>
<p>About putting an ITensor into the form of a matrix, we have combiners, which are special tensors (still of type ITensor or IQTensor, so actually a special type of tensor storage) that combine multiple indices into a single index:<br>
<a rel="nofollow" href="http://itensor.org/docs.cgi?page=classes/combiner">http://itensor.org/docs.cgi?page=classes/combiner</a></p>
<p>If those don't cover your use case, please tell me more specifically about your case and I can see if ITensor has the tools you will need.</p>
<p>Miles </p>
http://itensor.org/support/338/tensor-exponential?show=339#a339Mon, 06 Feb 2017 05:13:36 +0000Answered: Need QR decomposition algoritm.
http://itensor.org/support/330/need-qr-decomposition-algoritm?show=332#a332
<p>Yes, I agree we should have this in principle. But overall we've been taking the approach of not adding extra features until someone reports that they have a specific use-case for this. That way we only have features that get used often so that we can stay on top of bugs.</p>
<p>One question is: have you found that the SVD step is an efficiency bottleneck for the algorithm you are performing? In many algorithms the flexibility of the SVD (such as the option to truncate) outweighs the extra cost compared to QR, especially when other parts of the algorithm dominate the run time.</p>
<p>If you do find that QR would speed up your overall code (not just a sub-leading part) I can prioritize adding support for it.</p>
<p>Miles</p>
http://itensor.org/support/330/need-qr-decomposition-algoritm?show=332#a332Wed, 01 Feb 2017 19:44:56 +0000complex numbers
http://itensor.org/support/326/complex-numbers
<p>could you clarify more the following<br>
'complex numbers handled lazily: no efficiency loss if real'</p>
<p>Why should we loose efficiency while using complex numbers? and how much do we loose?</p>
http://itensor.org/support/326/complex-numbersWed, 01 Feb 2017 00:04:30 +0000Does IQtensor support finite abelain groups such as Z_{q} symmetry.
http://itensor.org/support/324/does-iqtensor-support-finite-abelain-groups-such-symmetry
<p>It seems IQtensor only supports U(1) symmetry group, but what about finite groups, like Z_{q}?</p>
<p>Or doest it respect parity symmetry and or a combination of them? like U(1)<em>Z_{q}</em>Z_{2}.</p>
<p>Please let me know of any documentation.</p>
http://itensor.org/support/324/does-iqtensor-support-finite-abelain-groups-such-symmetryMon, 30 Jan 2017 06:19:08 +0000