About diagHermitian function

0 votes
asked May 18 by chengshu (650 points)

Hi Miles,

I'm trying to use the diagHermitian function. As a test I ran the following code:

auto sx = sites.op("Sx",1);
auto sz = sites.op("Sz",1);
IQTensor U,D,U3,D3;

While the result of sz is +/- 0.5, as expected, for sx I get +/+ 0.5. I also use PrintData to obtain the matrix element, see below. Apparently something is wrong here. I think this may have something to do with the QN system I define. What do you think about this? Thanks!


sx =
r=2 div=QN({1,2}) log(scale)=0
IQIndex(S=1/2 1,2,Site|506)
(Up 1,1,Site|592) QN({1,2})
(Dn 1,1,Site|655) QN({0,2})

IQIndex(S=1/2 1,2,Site|506)'
(Up 1,1,Site|592)' QN({1,2})
(Dn 1,1,Site|655)' QN({0,2})

|-- Data -------
QDense Real {2 blocks; data size 2}
(Dn 1,1,Site|655) (Up 1,1,Site|592)'
(2,1) 0.5000000
(Up 1,1,Site|592) (Dn 1,1,Site|655)'
(1,2) 0.5000000


D =
r=2 div=QN({0,2}) log(scale)=0
(d0,1,Link|852)' QN({0,2})
(d1,1,Link|832)' QN({1,2})

(d0,1,Link|852) QN({0,2})
(d1,1,Link|832) QN({1,2})

|-- Data -------
(d0,1,Link|852)'QN({0,2}), (d0,1,Link|852)QN({0,2})
(1,1) 0.5000000
(d1,1,Link|832)'QN({1,2}), (d1,1,Link|832)QN({1,2})
(2,2) 0.5000000


commented May 18 by chengshu (650 points)
Also, if one uses the "Sx" operator in SpinHalf.h, it will throw an error message as "doTask not defined for task Contract and storage types QMixed<Real> QCombiner". Here the symmetry is Z_2 instead of U(1) so it has a well defined QN.

1 Answer

0 votes
answered May 18 by miles (16,560 points)

Hi Chengshu,
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.)

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.


commented May 18 by chengshu (650 points)
Hi Miles,

Thanks for the quick reply. Here I'm using a Z_2 QN system, so I expect that the non-zero blocks of Sx operator do have the same "QN flux". (basically s+ & s- both have QN {1,2}.)

commented May 18 by miles (16,560 points)
I see - interesting. So are you using a custom site set or one of the standard SpinHalf or SpinOne site sets?
commented May 18 by chengshu (650 points)
I'm using a modified SpinHalf with a custom QN system.
commented May 18 by miles (16,560 points)
I see: you're using a custom one. I didn't read your question carefully enough.

I think one aspect of the issues your seeing is that you shouldn't use the Mixed IQTensor feature for Sx for your site set. That's only a workaround for site sets where Sx isn't a proper IQTensor. Since it is a proper IQTensor for your site set you should just make Sx the same way that you make Sz (using similar code but just with different matrix elements of course).
commented May 18 by chengshu (650 points)
Yes I did comment out the mixedIQTensor part.
commented May 18 by miles (16,560 points)
Oh, I was confused then by the comment on your question. But I see now that was in reference to the SpinHalf site set.

Ok so I took a closer look at it appears that the current diagHermitian is limited to the case of only block-diagonal IQTensors (Hermitian IQTensors with total flux zero). So it's naively treating the blocks of Sx separately as 1x1 Hermitian matrices and diagonalizing them individually which is what's causing the funny output you're seeing. If you had run the code in debug mode, you would have seen a different error noting this limitation of diagHermitian (though with a kind of cryptic error message). In the future please do always run your code in debug mode if you are getting errors to see if you get a more helpful error message.

I will think about what can be done to make diagHermitian apply to your case. It might be kind of tricky to do - not sure.
commented May 18 by miles (16,560 points)
Thanks for reporting this. It's very helpful to think about. Hopefully there's a simple resolution but it's not obvious to me right at the moment how to fix it.
commented May 18 by chengshu (650 points)
Thanks for the comments. For now I will use  
which gives the correct result.
commented May 18 by miles (16,560 points)
Ok thanks. That's a good workaround for now in the sense that it ought to give correct results at least. I'll be thinking about if we can generalize diagHermitian for the general Hermitian IQTensor case without making it excessively complicated.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.