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

[ITensors] [QN] Improve siteinds QN conservation interface #522

Open
mtfishman opened this issue Nov 11, 2020 · 2 comments
Open

[ITensors] [QN] Improve siteinds QN conservation interface #522

mtfishman opened this issue Nov 11, 2020 · 2 comments
Assignees
Labels
api Issues related to the interface breaking This would require a breaking change enhancement New feature or request physics qns QN related issue
Milestone

Comments

@mtfishman
Copy link
Member

Right now, for more complicated site types, there is a bit of an explosion of keyword arguments for choosing what QNs get conserved. Here is a proposal for an improved interface:

siteinds("Electron", conserve_qns = ("Sz", "Nf", "NfParity"))

instead of the current:

siteinds("Electron", conserve_sz = true, conserve_nf = true, conserve_nfparity = true)

Setting conserve_qns = true would select a preset choice that we consider to be the most common combination.

Additionally, if someone wants custom names for the QNs, we could have a syntax like the following:

siteinds("Electron", conserve_qns = ("Sz" => "SzA", "Nf" => "NfA", "NfParity" => "NfPA))

which is useful if there are lattices with mixed site types.

Finally, it would be nice to think about a system for providing custom QNs to an existing site type. An example is adding momentum conservation to the Electron site type. This could be done with a QNType, analogous to the SiteType, where a user overloads a function like:

qn(::SiteType"Electron", ::QNType"Sz") = [("Sz", 0) => 1, ("Sz",+1) => 1, ("Sz",-1) => 1, ("Sz", 0) => 1]

This system could also make the implementation of the space function easier, where the specified conserved QNs are looped over and appended to the space (instead of the current system with many if-statements). We would need nice functions for this which are fast and deal with the case of mismatched blocks.

@mtfishman mtfishman added enhancement New feature or request breaking This would require a breaking change qns QN related issue api Issues related to the interface physics labels Nov 11, 2020
@mtfishman mtfishman added this to the v0.2 milestone Nov 11, 2020
@mtfishman mtfishman self-assigned this Nov 11, 2020
@emstoudenmire emstoudenmire changed the title Improve siteinds QN conervation interface Improve siteinds QN conservation interface Nov 11, 2020
@emstoudenmire
Copy link
Collaborator

I definitely support this improvement. The "intersection of booleans" approach I've done so far is starting to really show its limitations I agree. One symptom is that users have been confused about how to obtain certain QN combinations, and rightly so.

My main comment (which I think you touched on at the end) is that internally we could use some helper functions to process these tuples of QN names so that the implementation is clean enough and uniform across the different built-in site types.

The idea of providing qn overloads is creative and really interesting. I think it's tentatively a good idea, but let's prototype it at some point and see how the resulting code looks. My one concern there is that the code flow of functions like op or space could become too convoluted, where a user reading it for the first or second time could just get lost in the complexity or find it too opaque (since the code is calling out to so many other functions whose purpose might not be obvious unless explained really well). The constrasting approach would be to say something like "if you need something like the "Electron" site type but with very different QNs, please copy the electron.jl file and change the name to something else and then customize the space function". So that's the other approach I see as the competitor initially.

@mtfishman
Copy link
Member Author

Definitely agreed that the qn overload adds extra complexity to the design and we should consider if it is worth it (and like you say, for now users can just copy the definition and extend it themselves).

@emstoudenmire emstoudenmire mentioned this issue Apr 28, 2021
7 tasks
@mtfishman mtfishman modified the milestones: v0.2, v0.3 May 14, 2021
@mtfishman mtfishman changed the title Improve siteinds QN conservation interface [ITensors] [QN] Improve siteinds QN conservation interface Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the interface breaking This would require a breaking change enhancement New feature or request physics qns QN related issue
Projects
None yet
Development

No branches or pull requests

2 participants