ITensor / ITensor

A C++ library for efficient tensor network calculations
http://itensor.org
Apache License 2.0
366 stars 161 forks source link

Error with using a IQIndex as a combiner when the indeces in IQIndex has the same QN #102

Closed xichuang closed 8 years ago

xichuang commented 8 years ago

Hello, Miles:

Recently I try to to investigate the properties of the Holstein model (with electron-phonon interaction). Instead of define the electron+phonon sites, I tried to define the fermion sites along with artificial two-state phonon sites legs. Since the electron number is conserved but not for the number of phonon, the phonon sites are defined as, site = IQIndex(nameint("Bsite=", j), Index(nameint("Emp", j), 1, Site), QN(), Index(nameint("Occ", j), 1, Site), QN()); That is , both states are defined with QN(). But errors occur when running dmrg.

It seems that the errors are caused by combiner(site).
To illustrate the error, I wrote the following test program

`

include "itensor/iqtensor.h"

using namespace itensor;

int main() { auto I1 = IQIndex("d",Index("d0",2,Link),QN(),Index("d1",2,Link),QN("Nf=",1)); auto I2 = IQIndex("Fsite=2",Index("Emp2",1,Site),QN(),Index("Occ2",1,Site),QN("Nf=",1));

// Indexes in I3 have the same QN. auto I3 = IQIndex("Bsite=1",Index("Emp1",1,Site),QN(),Index("Occ1",1,Site),QN());

auto AA = IQTensor(I1,I2,I3);
AA.set(I1(1),I2(2),I3(1),0.720404);
AA.set(I1(4),I2(1),I3(2),0.0267623);

auto cmb = combiner(I3);

auto ci = cmb.inds().front();

auto AAc = cmb * AA;

// Error when PrintData(AAc)
PrintData(AAc);

// Error in tensor contraction.
auto rho = AAc * dag(prime(AAc,ci));

return 0;

} `

Then I received two errors. One is from PrintData(AAc) where the outputs are messy codes. The other is "Parameter 14 was incorrect on entry to cblas_dgemm" when contracting the tensors.

I think the error comes from combiner(i3) where the indexes with the same QN are combined to a single one.

Is this a bug? Or any suggestion to defined the electron-phonon sites?

Thank you.

Best, W. Su

emstoudenmire commented 8 years ago

Hi, so this may be sort of a bug with the combiner, in that ideally it would be robust enough to work even if two QN sectors are the same. However, ideally an IQIndex has QN sectors which are all distinct.

Here in your case there is not a good reason to have the boson Emp and Occ sectors treated as distinct, since as you correctly pointed out boson number isn't conserved. It's like you're telling the IQTensor system that certain tensors should be block sparse except all the blocks can be non-zero.

So a possible fix is to continue making the boson site indices still IQIndex type indices, but to just give them one Index sector. This Index would have 2 states, so like:

auto site = IQIndex("B Site", Index("boson",2),QN());

The first state would still mean empty and the second occupied but both would be in the same sector.

This may still cause problems but it's an unusual situation which I wasn't anticipating. Please let me know if this fix works and if not I'd like to get it working!

xichuang commented 8 years ago

Yes, it works. Thank you very much.