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

Can't see occupations for composite many-body basis #383

Closed
Umut-Can-Physics opened this issue Feb 23, 2024 · 3 comments
Closed

Can't see occupations for composite many-body basis #383

Umut-Can-Physics opened this issue Feb 23, 2024 · 3 comments

Comments

@Umut-Can-Physics
Copy link

Example code is following:

b = NLevelBasis(3)
s = bosonstates(b, [0,1,2])
mb = ManyBodyBasis(b,s)
A = destroy(mb,1) ⊗ identityoperator(mb) # composite operator
A.basis_l # print: [ManyBody(onebodybasis=NLevel(N=3), states:10) ⊗ ManyBody(onebodybasis=NLevel(N=3), states:10)]
mb.occupations # one species basis # I can reach it
MB = tensor(mb,mb)
# But there is no occupations tag for MB object
MB.bases # (ManyBody(onebodybasis=NLevel(N=3), states:10), ManyBody(onebodybasis=NLevel(N=3), states:10))
MB.shape # 2-element Vector{Int64}: 10 10

So, ı want to see our occupations or Fock basis for composite mixture. I'm wondering how QoJulia construct basis for my A operator?

@Krastanov
Copy link
Collaborator

Hi, @Umut-Can-Physics ! Sorry for the long wait, the notification about this post got lost. Do not hesitate to bump posts in situations like this (e.g. by making a reminder comment; emoji reactions do not generate notifications so we probably would not see those).

As a rule of thumb, if you are accessing a field of a struct in julia, you are probably working with internal implementation details, not with a stable public API. Such implementation details can change without warning (they are not part of the public API which has stability guarantees). More specifically, you should avoid relying on mb.occupations and instead use s which you have already defined (partially because most bases do not even have .occupations defined for them).

To try to answer your questions though: I am not immediately sure what you want MB.occupations to be -- could you give an expected result or a definition?

One possible answer would be:

julia> s = bosonstates(3,[0,1,2]);
julia> [[a;b] for a in s for b in s]

Or if you just want to get all the basis states:

julia> [basisstate(MB, i) for i in 1:length(MB)]

@Umut-Can-Physics
Copy link
Author

I solved that problem. Let say I wanna construct two body space via tensor product that compatible with operators where located at QoJulia freamwork such as create(MB, 1) or destroy(MB,1)

To do that run the following code
OneComponentBasis = bosonstates(3,[0,1,2]); [[ copy(β),copy(α) ] for α in OneComponentBasis for β in OneComponentBasis]
And it return a set of basis as type of element Vector{Vector{Vector{Int64}}}
... [[1, 1, 0] ⊗ [0, 0, 0]] ...

@Krastanov
Copy link
Collaborator

Thanks for posting the resolution! I will close the issue for now, but feel free to reopen it (or to open a new one) if there is something else to figure out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants