yingjerkao / uni10

Official Repo for Uni10
28 stars 9 forks source link

bug in combineBond #22

Open rezah opened 7 years ago

rezah commented 7 years ago

when using parity symmetry Symmetric.py.tar.gz

(Z_{2}), it seems combineBond function could not properly track all indices. Please follow my example, attached file (python file).

Please note, I've only used parity symmetry (not U(1)), so permutation does not change anything.

I really need it, so if you could fix it quickly, it becomes great.

I'm looking forward to hearing from you.

rezah commented 7 years ago

Another example is attached. when you have z2_symmetry it should not change anything if you do permutation and or combination of indices Symmetric.py.tar.gz . I'm not sure if it is the case for other symmetry and or even in the case that you don't have any symmetry.

yingjerkao commented 7 years ago

It might be a feature, not a bug. I will look into it. For symmetric cases, it is recommended to use Network for contraction, not to use contract directly.

rezah commented 7 years ago

I'm almost sure there is something wrong. To me, using any sequence of permutation and combining indices should not change results. But, unfortunately, it's the case as I've shown in the sample files. Please let me know if you still think it's a feature.

Thank you for your recommendation. May I know what is different? Using network is better for complicated tensor network contractions. For contraction two or three tensors I always use operation * directly. Do I have to use, for such simple cases, Network object?

yingjerkao commented 7 years ago

There is some issues that we discover about combineBond. We are working on a temporary fix, but the long term fix might require some rewriting of the bond class. If you do not combine bond and just permute such that bond labels match so that you can do multiplication, then everything should be ok.

Yun-Hsuan commented 7 years ago

Hi, thanks for your report. We found that the error occurred when the quantum numbers in the combined bond is not ordered. For instance, if combining a bond with quantum numbers <+-> into a bond with <++>, we will get a bundle bond with quantum numbers <+-+-> and the arrangement of elements will mismatch to the original one. On the other hand, if combining bond <++> into a bond <+->, the quantum numbers in the bundle bond will be <++--> and the result will be correct.

Now, I roughly fixed this bug in the commit 9d7cc26. This way, however, is very expensive. I recommend that you can just set the corresponded labels to the bonds and use UniTensor::contract() or network to contract tensors directly, and had better not use UniTensor::combineBond() if necessary.

YenHsinWu commented 7 years ago

Hi, I have a question to the update. The 951 line in UniTensorComplex.cpp and the 895 line UniTensorReal.cpp are different. Which one is the correct version.

Yun-Hsuan commented 7 years ago

Sorry for my mistake. The Real one is correct. Please checkout to the newest commit d1911c2.