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

work-around with sparse representation of QuadOperator? #896

Open
michaelkaicher opened this issue Oct 17, 2024 · 0 comments
Open

work-around with sparse representation of QuadOperator? #896

michaelkaicher opened this issue Oct 17, 2024 · 0 comments

Comments

@michaelkaicher
Copy link

michaelkaicher commented Oct 17, 2024

Hi all,

I am currently using openfermion.ops.QuadOperator and I wanted to check out some relations I derived which required me to represent the symbolic QuadOperator as an array in the N^M x N^M Hilbertspace, where N is the truncation of the bosonic levels and M is the number of bosonic modes.

I have the following very simple problem: I want to write the QuadOperator
a_quad_operator_on_mode_0 = of.ops.QuadOperator(((0, 'q')), 1)
as a NM x NM array, by first converting it to sparse object and then to an array through
array_example_1 = of.boson_operator_sparse(a_quad_operator_on_mode_0, N, hbar=2).toarray()
The issue is that in this particular instance, if I e.g. choose N=5 and M = 3, i will get array_example_1.shape = (5,5), instead of (125,125).

If instead of a_quad_operator_on_mode_0 I compute a_quad_operator_on_mode_1 = of.ops.QuadOperator(((1, 'q')), 1) then I get a_quad_operator_on_mode_1.shape = (25,25) and similarly a_quad_operator_on_mode_2 = of.ops.QuadOperator(((2, 'q')), 1) then I get a_quad_operator_on_mode_1.shape = (125,125).

One work-around would be to artificially insert the identity [q_j, p_j] = 2i on the modes j which are not k in of.ops.QuadOperator(((k, 'q')), 1)... but this seems like a super inefficient way. Any suggestions? Even just including that identity on the first and last mode (if either one is not k) would be enough already

Thanks!
Michael.

PS: In FermionOperator class it is a bit nicer, since there you can specify the number of modes in your system when using get_sparse_operator.

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

1 participant