+1 vote
asked by (1.2k points)
edited by

Hi Miles,

I am using the latest Julia version ITensors.

1.I defined an Index with QN. When I set "dir = In", the Index is not ordered, e.g. qn(s(2)) = QN("N",4,5). When I set "dir = Neither", qn(s(j)) always gives QN("N",0,5). Is this a bug?

s = Index([QN(("N",i,5)) => 1 for i = 0:4];dir = ITensors.Arrow(0))
qn(s(2))

BTW, the direction name "Out", "In" conflict with Out and In in Jupyter Notebook.

2.I wanted to svd an ITensor with QN, but it says "In setindex!, the element you are trying to set is in a block that does not have the same flux as the other blocks of the ITensor. You may be trying to create an ITensor that does not have a well defined quantum number flux."

dim0 = 4
s = Index([QN(("N",i,dim0))=>1 for i = 0:(dim0-1)];dir = ITensors.Arrow(1))
#s = Index(dim0)

l = addtags(s,"left")
r = addtags(s,"right")
u = addtags(s,"up")
d = addtags(s,"down")

A = emptyITensor(l,r,u,d)
for sl = 1:dim0, sd = 1:dim0, sr = 1:dim0, su = 1:dim0
    #if sl+sd == sr+su || abs(sl+sd-sr-su) == dim0
    if val(qn(l(sl))+qn(d(sd))-qn(r(sr))-qn(u(su)),"N") == 0
        A[l(sl),r(sr),u(su),d(sd)] = 1
    end
end
svd(A, (l,d))

Am I doing wrong?

Thanks.

Jin

commented by (1.2k points)
I figured out the second question by reversing the direction of "l" and "d", and using "if sl+sd == sr+su || abs(sl+sd-sr-su) == dim0" instead of "if val(qn(l(sl))+qn(d(sd))-qn(r(sr))-qn(u(su)),"N") == 0". The two conditional statements are the same in C++ ITensor. I think this will be fixed if the first question is resolved.

1 Answer

+1 vote
answered by (70.1k points)

Hi Jin,
Thanks for the question. So I think I see the possible issue: the qn function is defined as the "bare" QN which is the one you see printed when you do @show s say, times the arrow direction of the Index. The direction ITensors.Out corresponds to a multiplication of +1, so no change to the bare QN and you see the one printed. But if the direction is ITensors.In, then it multiples the QN by -1 (effectively) which really means to compute the additive inverse of the QN.

The other thing happening here is that your QN's are defined modulo 5; is that intentional? So since you put a modulus value of 5, the additive inverse of 1 modulo 5 is 4 and so for the case where the direction is ITensors.In you are getting the inverse of the bare QN, hence QN("N",4,5). (The "bare" QN in your case is QN("N",1,5) for subspace number 2.)

I don't think any of this is a bug, but it does raise a potential issue we should think about which is whether we should print the total QN (direction times bare QN, as returned by the qn function) rather than just the bare QN when printing an Index. We will think about it.

Regarding the name space conflict for In and Out, it is unfortunate which is why we don't export those values from ITensors.jl. Are you ok with just writing ITensors.In and ITensors.Out ? In a lot of ITensor code it's not required to work with arrows anyway; usually you obtain an In arrow Index by just taking the conjugate of an Out arrow Index using the function dag.

Miles

commented by (1.2k points)
Hi Miles, thanks for the explanation. Yes, the defined modulo 5 is intentional. I wanted to define a ITensor in "mod(l+d-u-r, 5) = 0" block. I am ok with writing ITensors.In and ITensors.Out.
commented by (70.1k points)
Ok great. Glad this answered your question, though please ask if another aspect is still not clear.

As I mentioned above, Matt and I will be thinking if there’s any improvements we can make in the future to make your situation easier to understand for other users, such as changing the way QN Index objects are printed perhaps.
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.

Categories

...