Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniTensor with only incoming or outgoing bonds #497

Open
manuschneider opened this issue Nov 7, 2024 · 0 comments
Open

UniTensor with only incoming or outgoing bonds #497

manuschneider opened this issue Nov 7, 2024 · 0 comments
Labels
suggestion Suggestion for current codebase

Comments

@manuschneider
Copy link
Collaborator

Currently, Cytnx does not allow for BlockUniTensors with only incoming or outgoing legs:

bond = cytnx.Bond(cytnx.BD_IN, [cytnx.Qs(1)>>1],[cytnx.Symmetry.U1()])
uT = cytnx.UniTensor([bond,bond])

gives the error

[ERROR][BlockUniTensor] must have at least one ket-bond and one bra-bond.

On the other hand, a DenseUniTensor with only incoming/outgoing legs can be created. Also linear algebra functions like Qr lead to such BlockUniTensors:

bond = cytnx.Bond(cytnx.BD_IN, [cytnx.Qs(0)>>1,cytnx.Qs(1)>>1],[cytnx.Symmetry.U1()])
uT = cytnx.UniTensor([bond.redirect(),bond])
[Q,R]=cytnx.linalg.Qr(uT)
Q.print_diagram()

-----------------------
tensor Name : 
tensor Rank : 2
contiguous  : True
valid blocks : 2
is diag   : False
on device   : cytnx device: CPU
      row           col 
         -----------    
         |         |    
   0 *<--| 2     2 |-->  _aux_
         |         |    
         -----------

Shall we drop the restriction that a tensor needs to have at least one incoming and one outgoing leg? It would also allow the user more flexibility.

I already did this in the branch fermions since it was easier to remove the unnecessary restriction for BlockUniTensor rather than implementing it for BlockFermionicUniTensor. Everything works fine, but might need more testing of specific cases.

When tensors have only incoming or outgoing bonds, then the rule "incoming quantum number = outgoing quantum number" cannot be applied anymore. Instead, a neutral element needs to be defined, such that "incoming + reverse_rule(outgoing) = neutral element", which also works for no incoming or no outgoing bonds.
Currently, 0 is assumed to be the neutral element for all symmetries. But we could also have a neutral element defined for each symmetry explicitly (as other libraries do).

@manuschneider manuschneider added the suggestion Suggestion for current codebase label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggestion for current codebase
Projects
None yet
Development

No branches or pull requests

1 participant