ITensor Support Q&A - Recent questions and answers
http://itensor.org/support/qa
Powered by Question2AnswerPractical routes to convergence
http://itensor.org/support/633/practical-routes-to-convergence
<p>I've long struggled with the question, "What is the best possible sequence of input parameters -- energy cutoff, maximum number of singular values, noise, number of sweeps per set of parameters to get the most rapid and precise wavefunction?"</p>
<p>I opted for a compromise, for practical purposes of getting my calculations running, that incorporates a combination of noise at the start of a set of sweeps and doubling in the number of singular values at each set of sweeps.</p>
<p>In other words, I provide up to 7 input files in succession, and each input file has a different maximum number of singular values (M). </p>
<p>So in my most recent set of calculations, I used roughly the following:<br>
Inputfile 1:<br>
M = 50 states kept<br>
Noise = 1E-4 and decreasing to 0 over about 7 sweeps<br>
Energy cutoff = 1E-2</p>
<p>Inputfile 2:<br>
M = 100 states kept<br>
Noise is the same as inputfile 1<br>
Energy cutoff is 1E-4</p>
<p>3:<br>
M = 200<br>
E cutoff is 1E-7</p>
<p>4:<br>
M = 400<br>
Ecutoff is 1E-8</p>
<p>5:<br>
M = 800<br>
Ecutoff is 1E-9</p>
<p>and so on. The higher cutoff files are usually too time-consuming to run so I don't use them often.</p>
<p>I have since realized that this "practical attempt" to get good convergence might be inefficient for the following reason: The decrease in energy from one inputfile to the next is greater than the supposed energy cutoff of the previous inputfile. So I am decreasing the energy cutoffs to better match the true precision afforded by a given M.</p>
<p>Jin recommended letting M follow a simpler sequence such as 20, 20, 40, 40, ...Mprevious + 20 with two sweeps at each M. For me, this seems impractical since I want to reach high precisions (M up to and beyond 800 to get energy precisions above 1E-6 if possible).</p>
<p>Is there any realistic way of optimizing this energy cutoff/states kept/number of sweeps/noise sequence besides an automated (or manual) trial-and-error approach? I am studying a difficult system and need the most efficient and precise wavefunctions I can afford. I have limited computer time that is running out rapidly.</p>
<p>Thanks!</p>
<p>Jon</p>
http://itensor.org/support/633/practical-routes-to-convergenceFri, 18 Aug 2017 01:27:05 +0000Answered: Error: "Default constructed ITensor in product"
http://itensor.org/support/627/error-default-constructed-itensor-in-product?show=628#a628
<p>Hi Jon,<br>
Yes I somtimes get that message when a file is made using a previous version of ITensor. We try to keep backwards compatibility of the file formats but currently the only guarantee is that files read using the same version of ITensor, on the same computer, are guaranteed to work correctly. ("Guaranteed" means what we consider a bug or not.)</p>
<p>So is it possible you wrote the file with a previous version of ITensor? If so that could be the culprit.</p>
<p>If not, can you tell me how you created the file? Like did you make it on a different computer possibly?</p>
<p>Miles</p>
http://itensor.org/support/627/error-default-constructed-itensor-in-product?show=628#a628Tue, 15 Aug 2017 02:32:41 +0000Answered: Installation on Linux Ubuntu
http://itensor.org/support/619/installation-on-linux-ubuntu?show=626#a626
<p>Ok thanks for posting this question. For the answer see the discussion above ^</p>
<p>I'd recommend turning off this particular warning, actually. The reason is it's a "catch 22" warning, meaning that if you do assign the return value to a variable, the warning goes away. But then if you don't use the assigned variable, you get a different warning about "unused variable". So you get a warning either way. That's why I just turn this one off because there can be perfectly good reasons to ignore return values.</p>
<p>Miles</p>
http://itensor.org/support/619/installation-on-linux-ubuntu?show=626#a626Fri, 11 Aug 2017 22:33:13 +0000Answered: How to properly use the MPS and MPO methods for arbitrary MPOs?
http://itensor.org/support/622/how-to-properly-use-the-mps-and-mpo-methods-for-arbitrary-mpos?show=623#a623
<p>Hi Alex,<br>
So exactApplyMPO, and indeed most functions in ITensor, assume open boundary conditions or in some cases also work with "dangling" indices off the left and right for cases involving unit cells of larger or infinite systems. We have very few facilities for dealing with periodic boundary conditions because the technology (in the broader tensor network literature I mean) for working with periodic MPS and MPOs is quite poor. </p>
<p>This is good feedback though, as for me it's so implicit that we're always using open boundaries that I did not think to mention it in the documentation. So I should go through and mention that in the docs.</p>
<p>May I ask why you need periodic boundary conditions? You may need them, but sometimes I find that people are using them in cases where just using open boundaries and going to larger system sizes would work just as well or usually much better.</p>
<p>Miles</p>
http://itensor.org/support/622/how-to-properly-use-the-mps-and-mpo-methods-for-arbitrary-mpos?show=623#a623Thu, 10 Aug 2017 19:02:21 +0000Answered: Conversion MPS into ITensor and Time reversal symmetry
http://itensor.org/support/603/conversion-mps-into-itensor-and-time-reversal-symmetry?show=609#a609
<p>Hi Victor,<br>
Here are my ideas for what you're asking. Let me know if I misunderstood one of your questions.</p>
<ol>
<li><p>If by convert an MPS to ITensor form, you mean obtain a single ITensor which is the entire wavefunction that an MPS represents, then I don't see any other way to do it besides multiplying all of the MPS tensors psi.A(i) together. At least there won't be any other way to do it that will be significantly faster in a generic case than just multiplying the psi.A(i) together. Of course, you might want to multiply the psi.A(i) in a different order depending on the various bond dimensions of the MPS, but in general you will end up with a single tensor with d^N entries that will be expensive to compute and will take up a lot of memory, as you know. <br>
There could be strategies to multiply the psi.A(i) together in groups, such as multiply neighboring A tensors, then multiply the resulting N/2 tensors with their neighbors, then the remaining N/4 tensors with their neighbors etc. and this could even be done in parallel. The idea of this multiplication pattern would be to put off the most costly contractions until the very end where you finally multiply a left-half tensor with N/2 site indices times the right-half tensor with N/2 site indices.</p></li>
<li><p>To check time reversal symmetry, I would think you'd act on each site with the time reversal operator. Then take the overlap of the resulting MPS <code>trpsi</code> with the original MPS <code>psi</code> by doing <code>overlap(trpsi,psi)</code> and see if the overlap is 1 or not.<br>
To check if your code is working correctly, construct an MPS "by hand" which you know a priori to be time reversal invariant (a chain of spin 1/2s in perfect singlet states with their neighbors) and one which is not (a product state of spin 1/2s all pointing up) and apply the above test to both.</p></li>
</ol>
<p>Miles</p>
http://itensor.org/support/603/conversion-mps-into-itensor-and-time-reversal-symmetry?show=609#a609Sun, 06 Aug 2017 22:03:12 +0000Answered: Difficulty adding fermionic IQTensors with sum(psi1,psi2)
http://itensor.org/support/606/difficulty-adding-fermionic-iqtensors-with-sum-psi1-psi2?show=608#a608
<p>Hi Jon,</p>
<p>I get the correct density (222222) with the latest version of ITensor. My code is</p>
<pre><code>#include "itensor/all.h"
using namespace itensor;
int main()
{
auto sites = Hubbard(8);
auto sites1 = sites;
auto sites2 = sites;
IQMPS psi1, psi2;
auto state1 = InitState(sites1);
auto state2 = InitState(sites2);
for(int j = 1; j <= 8; ++j)
{
if(j%2 == 1)
{
state1.set(j, "UpDn");
state2.set(j, "Emp");
}
else
{
state2.set(j, "UpDn");
state1.set(j, "Emp");
}
}
psi1 = IQMPS(state1);
psi2 = IQMPS(state2);
auto psi = sum(psi1,psi2); // I also tried out sum(psi1, psi1) as a check
psi.norm();
Print(psi);
for(int j = 1; j <= 8; ++j)
{
auto Ni = sites1.op("Ntot", j);
auto ket = psi.A(j);
auto bra = dag(prime(ket, Site));
std::cout << (bra*Ni*ket).real() << std::endl;
}
return 0;
}
</code></pre>
<p>The last part gives electron density 2 on every site. Is that what you expect? Thanks.</p>
<p>Jin</p>
http://itensor.org/support/606/difficulty-adding-fermionic-iqtensors-with-sum-psi1-psi2?show=608#a608Sat, 05 Aug 2017 14:10:12 +0000Answered: Installation on WIndows Cygwin
http://itensor.org/support/480/installation-on-windows-cygwin?show=607#a607
<p>I was successfully able to get ITensor working using Cygwin on a laptop running Windows 10.</p>
<p>There are two steps, as follows:<br>
1. Install Cygwin, making sure to put check marks for the options you want. Below I copied a write-up of the installation options I selected when I installed Cygwin:</p>
<hr>
<p>First, download cygwin installation file, setup-x86_64.exe. It doesn't matter where it is saved.</p>
<p>Run the setup file. A large list of add-ons will be provided; you will need to check the following.</p>
<p>First click the box next to Debug, and click on the box under the column Bin? (but not Src?) for the following options:<br>
->Debug<br>
cygwin<em>debuginfo<br>
gcc</em>debuginfo<br>
lapack<em>debuginfo<br>
Then click the box for the heading Devel, and select the following options:<br>
-> Devel<br>
binutils<br>
cygwin</em>devel<br>
gcc<em>core<br>
gcc</em>g++<br>
libargp<br>
libcloog<em>isl4<br>
libltdl7<br>
make<br>
mingw64-i686-binutils<br>
-gcc-core<br>
-g++<br>
-headers<br>
-runtime<br>
-windows-default-manifest<br>
-winpthreads<br>
mingw64-x86</em>64-binutils<br>
-gcc-ada<br>
-gcc-g++<br>
-headers<br>
-runtime<br>
-windwos default manifest<br>
-winpthreads</p>
<p>->editors<br>
nano (if you want the nano editor, otherwise vi is included with gcc-core)</p>
<p>Some of these might be added automatically when you select the main file. For instance, gcc<em>core, gcc</em>g++ might automatically come with cygwin_devel but I forget which ones are automatic.</p>
<p>If these options are not sufficient simply re-install cygwin and add more options. I found some videos on youtube that were helpful.</p>
<p>Cygwin should be installed within the C: drive; it will then have its' own home file, within which you should create a user folder for yourself. In this user folder, install itensor. </p>
<p>In this way, cygwin creates a separate computer within your computer that acts like Linux. When you run the cygwin program, for instance by clicking on the cygwin icon on your desktop if you create a desktop icon, it will open up a unix-like shell that you can run itensor from. This cygwin shell then starts you at a "home" folder that is located within cygwin; from here you can use the shell just like you would in linux with the same navigation commands.</p>
<hr>
<p>SECOND STEP. Add the following sections in your options.mk file (I only copied the relevant parts)</p>
<p>Section [1] ------------------------------</p>
<pre><code>## GCC On Windows cygwin
## Extra flags are workaround for limitations
## of this compiler with Windows binary format
CCCOM=g++ -std=c++11 -Wa,-mbig-obj -O2
</code></pre>
<p>Section [2]------------------------------</p>
<pre><code>##
## Example using a C interface to LAPACK on GNU/LINUX systems
## (Path to lib/ folder may differ on your system)
##
PLATFORM=lapack
##BLAS_LAPACK_LIBFLAGS=-lpthread -L/usr/lib -lblas -llapack
BLAS_LAPACK_LIBFLAGS=-L /usr/lib -lblas -llapack
</code></pre>
<p>Section [3]----------------------------------</p>
<pre><code>## This step is optional, but if you wish to customize the flags
## used to compile optimized and debug code, you can do so here.
## Flags to give the compiler for "release mode"
OPTIMIZATIONS=-O2 -DNDEBUG -Wall
## Flags to give the compiler for "debug mode"
DEBUGFLAGS=-DDEBUG -g -Wall -pedantic -O2
###
### Other Makefile variables defined for convenience.
### Not necessary to modify these for most cases.
###
PREFIX=$(THIS_DIR)
ITENSOR_LIBDIR=$(PREFIX)/lib
ITENSOR_INCLUDEDIR=$(PREFIX)
OPTIMIZATIONS+= -DPLATFORM_$(PLATFORM) -
D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0
DEBUGFLAGS+= -DPLATFORM_$(PLATFORM) -
D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0
ITENSOR_LIBNAMES=itensor
ITENSOR_LIBFLAGS=$(patsubst %,-l%, $(ITENSOR_LIBNAMES))
ITENSOR_LIBFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
ITENSOR_LIBGFLAGS=$(patsubst %,-l%-g, $(ITENSOR_LIBNAMES))
ITENSOR_LIBGFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
ITENSOR_LIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%.a, $(ITENSOR_LIBNAMES))
ITENSOR_GLIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%-g.a, $(ITENSOR_LIBNAMES))
ITENSOR_INCLUDEFLAGS=-I$(ITENSOR_INCLUDEDIR) $(BLAS_LAPACK_INCLUDEFLAGS)
ifndef CCCOM
$(error Makefile variable CCCOM not defined in options.mk; please define it.)
endif
CCFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(OPTIMIZATIONS) -Wno-unused-variable
CCGFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(DEBUGFLAGS)
LIBFLAGS=-L$(ITENSOR_LIBDIR) $(ITENSOR_LIBFLAGS)
LIBGFLAGS=-L$(ITENSOR_LIBDIR) $(ITENSOR_LIBGFLAGS)
</code></pre>
<p>Note that it took Miles a long time to figure out the compiler workarounds in the above file. But since then I have been using it with no problems.</p>
http://itensor.org/support/480/installation-on-windows-cygwin?show=607#a607Thu, 03 Aug 2017 22:56:02 +0000Answered: Difficulties with DMRG on a non-hermitian system
http://itensor.org/support/593/difficulties-with-dmrg-on-a-non-hermitian-system?show=600#a600
<p>Hi, so this is an interesting use case but the dmrg function in ITensor isn't designed to work for non-Hermitian Hamiltonians as you might have guessed. Most of the parts of the dmrg code should generalize to the non-Hermitian case, but the part that probably will not generalize is the Davidson eigensolver at the core of the DMRG algorithm (the part of the algorithm where DMRG does a few steps of an iterative sparse exact diagonalization routine like Davidson or Lanczos).</p>
<p>So for a non-Hermitian case, I would think your best bet would be to replace the Davidson algorithm that ITensor dmrg uses with an algorithm appropriate for non-Hermitian Hamiltonian problems. Probably Arnoldi is the algorithm you want.</p>
<p>Or if you happen to know that Davidson should work for some reason let me know.</p>
<p>The dmrg function provided with ITensor should already fully handle the case where the tensors have complex entries. So I don't think there is any more you can do in that direction.</p>
<p>Hope that helps -</p>
<p>Miles</p>
http://itensor.org/support/593/difficulties-with-dmrg-on-a-non-hermitian-system?show=600#a600Wed, 02 Aug 2017 01:12:28 +0000Answered: What is the order of indexes output by tensor.inds()?
http://itensor.org/support/588/what-is-the-order-of-indexes-output-by-tensor-inds?show=599#a599
<p>It's a good question but I've intentionally tried to make ITensor usable without anything depending on this order on the user level. There is one, maybe two, places on the developer level of the code where I rely on the indices being in a certain order but so far the contract in the design is that the library can internally permute the order of the indices however it wants as long as the tensor data is permuted in the same way.</p>
<p>Can you say more about why you need to keep the indices in a certain order? Maybe there is a different solution to your problem?</p>
<p>Miles</p>
http://itensor.org/support/588/what-is-the-order-of-indexes-output-by-tensor-inds?show=599#a599Wed, 02 Aug 2017 01:08:09 +0000Answered: .set() method of ITensor
http://itensor.org/support/587/set-method-of-itensor?show=598#a598
<p>Hi, I just pushed a new commit that adds this feature to ITensor. Now for both the ITensor and IQTensor class you can do this:</p>
<pre><code>auto T = ITensor(i,j);
auto v = vector<IndexVal>{{i(2),j(3)}};
T.set(v,3.1415);
</code></pre>
<p>Let me know if it doesn't work as expected or if you run into any issues. I'm planning to add a similar feature for the .real and .cplx methods for retrieving values.</p>
http://itensor.org/support/587/set-method-of-itensor?show=598#a598Wed, 02 Aug 2017 01:06:10 +0000Answered: Quick Question: Storing an ITensor to a file
http://itensor.org/support/594/quick-question-storing-an-itensor-to-a-file?show=595#a595
<p>Hi Alex,<br>
Yes there are the following two functions provided in ITensor:</p>
<p>writeToFile(string filename, T const& obj)</p>
<p>readFromFile(string filename)</p>
<p>or </p>
<p>readFromFile(string filename, T & obj)</p>
<p>The writeToFile function is a template function that automatically deduces the type of the second argument (the object you want to write to the file).</p>
<p>The readFromFile functions come in two versions. The first one above requires you to specify the type of the object you expect to be stored in the file, so like:<br>
auto T = readFromFile("mytensor");</p>
<p>The second one is able to deduce the type, so no need for the template stuff, but can be more awkward to use sometimes since it can require more lines of code:<br>
ITensor T;<br>
readFromFile("mytensor",T);</p>
<p>By the way, the ITensor read and write system has the ability to read and write certain common container types, such as std::vector. So you can do things like write an entire std::vector to a file like so:</p>
<p>auto v = vector(5);<br>
for(auto& t : v) t = randomTensor(i,j,k,l); //makes random ITensors<br>
writeToFile("vector_itensors",v);</p>
<p>Miles</p>
http://itensor.org/support/594/quick-question-storing-an-itensor-to-a-file?show=595#a595Tue, 01 Aug 2017 17:37:03 +0000Answered: IQDMRG and good quantum number
http://itensor.org/support/585/iqdmrg-and-good-quantum-number?show=591#a591
<p>Hi Huike,<br>
These are good questions but it will be hard for me to completely answer them here. I am working on the next section of the ITensor Book (<a rel="nofollow" href="http://itensor.org/docs.cgi?page=book)">http://itensor.org/docs.cgi?page=book)</a> which is going to have a section which goes into detail about IQTensors and their structure. There is already some material on IQTensors there which might help you a lot.</p>
<p>About iqdmrg, it is not a separate algorithm from DMRG. If you look at the sample code iqdmrg.cc (in the sample/ folder under the ITensor software) then you'll see at the end it actually calls the same dmrg(...) function that the dmrg.cc code does. It's literally the same algorithm code, just with template parameters that switch the tensor type from ITensor to IQTensor. </p>
<p>So all of the steps are the same as in regular DMRG with dense tensors, except the tensors are block-sparse due to the (Abelian) quantum number conservation. (Recall that the main steps of DMRG are applying a few steps of an iterative solver, such as Davidson or Lanczos, then performing an SVD of the two-site wavefunction tensor to restore the MPS form.)</p>
<p>One important thing about how IQTensor DMRG works is that whatever the initial total quantum number of the initial MPS (actually IQMPS) is, the DMRG algorithm is guaranteed not to change this total quantum number. So it is important to make sure the total quantum numbers of the initial state are well defined. You'll see that in iqdmrg.cc the code uses an InitState helper object to initialize the state to be a product state with a well defined total Sz.</p>
<p>Finally, if you are asking about the details of how IQTensors actually work internally to conserve quantum numbers, it would be too long to explain in full detail here (but the ITensor Book will eventually explain most of this). Basically the indices of an IQTensor, of type IQIndex, are segmented into "sectors" which are labeled by Index and QN object pairs. Once the total "flux" or quantum number of an IQTensor is set (e.g. by setting of the the tensor components non-zero) then only blocks with that total flux are allowed to be non-zero. All other blocks are assumed to be zero and are not even allocated in memory. Operations on IQTensors such as contracting them or computing SVD's of them preserve this block structure and exploit the block structure for extra efficiency.</p>
<p>Best regards,<br>
Miles</p>
http://itensor.org/support/585/iqdmrg-and-good-quantum-number?show=591#a591Tue, 25 Jul 2017 18:30:05 +0000Answered: ITensor/LAPACK SVD
http://itensor.org/support/582/itensor-lapack-svd?show=586#a586
<p>Hi Brendan,<br>
Thanks for the question. This is the case mainly for historical reasons, because we were having some issues with the LAPACK SVD and needed a more reliable SVD as well as a more accurate one. </p>
<p>But it's been on my short list to put in a backend that calls LAPACK for cases where speed is the primary concern. Based on how the tests go, I may make LAPACK the default and allow the current implementation to be turned on with a flag for cases where high accuracy is needed (the current implementation uses a recursive algorithm that corrects errors made in the smallest singular values in earlier passes; it is described in the Appendix of the real-space parallel DMRG paper).</p>
<p>Miles</p>
http://itensor.org/support/582/itensor-lapack-svd?show=586#a586Tue, 18 Jul 2017 07:30:45 +0000Answered: Entanglement Entropy of 2D MPS
http://itensor.org/support/580/entanglement-entropy-of-2d-mps?show=581#a581
<p>Hi Andreas,<br>
There isn't an easy way to extract the entanglement entropy of an arbitrary cluster of a 2D system "snaked" by an MPS, at least not easy in the sense of using an MPS from a single DMRG calculation and just "reading off" the entanglement from it. Instead, you have to do one of two things:</p>
<p>(1) Re-do the DMRG calculation with the 1D ordering of the sites changed so that your MPS first visits every site in your cluster (in a 1D MPS path sense) before visiting the rest of the sites outside of your cluster. Then just compute the entanglement in the usual 1D fashion across the MPS bond separating the cluster from the rest.</p>
<p>(2) Use "swap gates" to re-order the sites of your MPS after computing the ground state, resulting in the same ordering in (1). This will generally increase the MPS bond dimension needed to represent the same state, but it should ultimately result in an MPS with the same bond dimension as the MPS directly optimized for your cluster ordering in (1). This could be much more efficient than (1) if you have many different clusters you wish to compute the entanglement for, because then you wouldn't have to re-do a DMRG calculation for each different cluster ordering.</p>
<p>Hope that helps - please ask if some of that wasn't unclear.</p>
<p>Miles</p>
http://itensor.org/support/580/entanglement-entropy-of-2d-mps?show=581#a581Tue, 27 Jun 2017 09:59:48 +0000Answered: Ground state energy increase after 10th sweep
http://itensor.org/support/576/ground-state-energy-increase-after-10th-sweep?show=579#a579
<p>Interesting question. I can't easily say why the energy rises slightly toward the end of your calculation. My best guess would be that it's a subtle interplay of the convergence of the Davidson algorithm (the solver that ITensor DMRG uses at the core 2-site step) with the truncation errors caused by your parameters (cutoff of 1E-10). Because the truncation at each bond should tend to raise the energy, while the Davidson is always trying to lower it, it's conceivable that the behavior is not always a monotonic decrease in energy but rather some small oscillatory behavior as one reaches the fixed point of the algorithm (for your particular settings I mean).</p>
<p>One of your questions (1) is related to what you observed. Typically one wants to set niter to 2 (the minimum sensible value; niter=1 doesn't do anything for historical reasons). The reason is that for "easy" systems such as spin chains one wants to only do a single Davidson step at each bond (niter=2 is a single Davidson step). This is because each Davidson step at every bond contributes to the overall lowering of the energy, and there is usually not a good reason to fully converge the Davidson at each bond in the presence of an unconverged environment of the rest of the MPS. The Davidson steps are the most expensive part of a normal DMRG calculation so one doesn't want to do more than necessary.</p>
<p>However, there can be good reasons to raise niter larger than 2. One reason could be to overcome a poor initial state in the first few sweeps, later lowering niter to 2. Another reason could be for applying DMRG to a system with multiple, widely separated energy scales. Steve White and myself found in our recent quantum chemistry calculations (<a rel="nofollow" href="https://arxiv.org/abs/1702.03650)">https://arxiv.org/abs/1702.03650)</a> that taking niter = 6 worked better than niter =2 for converging in a smaller number of sweeps. </p>
<p>Finally, in your particular case of wanting a very high-accuracy result, taking niter > 2 could be a key step. When you get toward the end of your calcualtion, the fact that you are limiting niter=2 could mean that the Davidson is not fully converging, so that your errors are dominated by the truncation. This is consistent with your observation that the errors are of the order of your truncation cutoff.</p>
<p>About your question (2), the symbols printed by the Davidson algorithm are I n q x where n is the Davidson iteration number (only 0 and 2 shown usually) and x is the value of the "residual" vector "q" which is a measurement of how well converged the algorithm is. Ideally q should rapidly decrease with the number of iterations. Finally the number after E is the current energy at that step.</p>
<p>Finally, about correlation functions. If your wavefunction is converged well then measurements of it will be converged too. This is one of the main principles behind DMRG and MPS techniques, namely that reducing the error made when truncating the reduced density matrix also reduces the errors in local observables (since these are obtained by tracing with reduced density matrices after all). For a technical discussion of the rate of convergence of energy versus observables in DMRG and MPS, see the comments in this paper by White and Chernyshev: <a rel="nofollow" href="https://arxiv.org/abs/0705.2746">https://arxiv.org/abs/0705.2746</a> at the beginning of page 2.</p>
http://itensor.org/support/576/ground-state-energy-increase-after-10th-sweep?show=579#a579Mon, 26 Jun 2017 20:50:13 +0000Answered: 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 +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 +0000Reflecting an MPS
http://itensor.org/support/375/reflecting-an-mps
<p>Hello,<br>
I'm having trouble trying to reflect an MPS psi around the center of a 1D lattice- <br>
psi(x) ---> psi(-x)<br>
I expected changing the order of the tensors to be enough, i.e. change the tensor at site 1 to be the tensor originally at site N, change site 2 to the tensor at site N-1 etc.<br>
This is the code implementation:</p>
<p>for(int i = 1; i <= N; ++i)<br>
{phi.setA( i, psi.A(N+1-i));}</p>
<p>However, trying to perform a DMRG sweep on the resulting wavefunction phi, I get the error:<br>
terminate called after throwing an instance of 'std::bad_alloc'</p>
<p>Also this error pops up when making calculations on phi using .cplx() :<br>
Wrong number of IndexVals passed to real/cplx (expected 4, got 0)</p>
<p>Swapping just one pair of tensors inside the MPS produced the same error.</p>
<p>Note I'm using IQTensors.<br>
Would appreciate any help.</p>
<p>Thanks,<br>
Oren</p>
http://itensor.org/support/375/reflecting-an-mpsTue, 28 Feb 2017 12:42:07 +0000Error "Mismatched mod factors" and question about QN intializer list
http://itensor.org/support/373/error-mismatched-factors-and-question-about-intializer-list
<p>This is a relevant question of a former one : <a rel="nofollow" href="http://itensor.org/support/357/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</a> and now it is fixed by miles (thanks). But I still have some questions about the definition of IQIndex and QN in this siteset file. I shall describe it in details in the following :<br>
The correct definition of IQIndex (without "Mismatched mod factors" error and dmrg works) given by miles is</p>
<pre><code>BoseFermiSite(int n, Args const& args = Args::global())
{
if(n%2==1) //spinless fermion
{
is_fermi = true;
s = IQIndex(nameint("site=",n),
Index(nameint("Em",n),1,Site),QN({0,-1},{0,1}),
Index(nameint("f1",n),1,Site),QN({1,-1},{0,1}));
}
else //spinless boson
{
is_fermi = false;
s = IQIndex(nameint("site=",n),
Index(nameint("Em",n),1,Site),QN({0,-1},{0,1}),
Index(nameint("b1",n),1,Site),QN({0,-1},{1,1}),
Index(nameint("b2",n),1,Site),QN({0,-1},{2,1}),
Index(nameint("b3",n),1,Site),QN({0,-1},{3,1}));
}
}
</code></pre>
<p>while my original setsite file defines the IQIndex and QN as follows (have "Mismatched mod factors" in debug mode, but dmrg still works)</p>
<pre><code>BoseFermiSite(int n, Args const& args = Args::global())
{
if(n%2==1) //spinless fermion
{
s = IQIndex(nameint("site=",n),
Index(nameint("Em",n),1,Site),QN("Sz=",0,"Nf=",0),
Index(nameint("f1",n),1,Site),QN("Sz=",0,"Nf=",1)
);
}
else //spinless boson
{
is_fermi = false;
s = IQIndex(nameint("site=",n),
Index(nameint("Em",n),1,Site),QN("Sz=",0,"Nb=",0),
Index(nameint("b1",n),1,Site),QN("Sz=",0,"Nb=",1),
Index(nameint("b2",n),1,Site),QN("Sz=",0,"Nb=",2),
Index(nameint("b3",n),1,Site),QN("Sz=",0,"Nb=",3)
);
}
}
</code></pre>
<p>the difference is that I use explicit expression "Sz=", "Nb=","Nf=" to define QN. But it incurs "Mismatched mod factors" error. I once thought that ("Sz=",0,"Nf=",1) is equivalent to initializer list ({0,1},{1,-1}) where -1 indicates fermion flag, and ("Sz=",0,"Nb=",1) is equivalent to ({0,1},{1,1}) for boson. So why the correct initializer list is not as what I once thought ? For example, minus sign of mod factor appears in boson QN object. I think I may misunderstand QN and it seems that some non-trivial modification is needed for Bose-Fermi mixture.<br>
Thanks.</p>
http://itensor.org/support/373/error-mismatched-factors-and-question-about-intializer-listTue, 28 Feb 2017 05:14:12 +0000