-
Notifications
You must be signed in to change notification settings - Fork 109
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
potentialoperator()
could use better documentation
#351
Comments
You have a couple of options for this, and there are a few reasons it might be good this is not automated. First, you can always manually write a Taylor expansion of the cosine. That is not a terrible idea, in particular because it preserves some sparsity in the operator representation, even if it is only approximate. Second, you can try to extract the underlying matrix and perform the cosine call yourself. In general, it is implemented in Julia by eigenvector decomposition. After all
The error happens because a Hermitian sparse matrix is used to represent the underlying data. Eigendecomposition of sparse matrices generally does not preserve sparsity so many of these functions are not implemented at all (reasons explained below). So the developers are left with two options now:
Now, back to this particular issue. If you are fine with losing sparsity, you can do this:
Some of this should indeed be implemented as part of QuantumOptics. While the conversion to dense matrix should certainly be explicit, some helpers for the rest of the operation would be nice. I am sure the devs here would be very grateful if you submit a pull request with it -- probably a whole new set of operator function methods. Also, this object is actually still quite sparse. It would be wonderful to implement special methods for operator functions that preserve sparsity, but doing that the correct way is a lot of work. The linked issue above provides a list of many implementations of the "proper" methods to do it, but someone needs to do the work to bridge them to QuantumOptics.jl. If you are interested in starting this work, you will find a lot of support here.
I believe you did not meant it that way, but comments like this are not taken very well in the open source community. The folks that have developed QuantumOptics have mostly done it in their free time and such demanding tone from the users of free software can be very discouraging. |
And for special cases like this, where sparsity (surprisingly) remains preserved, you can use this very roundabout way to make a sparse cos operator
|
Thank you @Krastanov, I also think it should not be automated. @rafaelcoldatoms you can use the function
Note that you also need to define |
It seems it is actually already implemented :D |
Hey, thanks for the help!
I'm truly sorry if I came out a inconsiderate. I am grateful for the community and the devs that keep up such wonderful projects. It was a keyboard slip-up, nothing more. Now, regarding your comments:
It here still a need for a pull request? It does look like the suggestion by @ChristophHotter works as intended, and I wouldn't want to burden the devs with unnecessary work. Thanks again! |
No worries, I have occasionally misphrased things in a similar manner and just wanted to warn fellow community members about this common source of misunderstanding. If the |
The I looked in the documentation, and found a single use of So I'll change the name of the issue, as you suggested. Maybe later, when I'll have time to learn how to properly do a PR (never tried one before) I'll try to fix it myself if. |
potentialoperator
could use better documentation
potentialoperator
could use better documentationpotentialoperator()
could use better documentation
While working to reproduce the results from Fitzek (2020), I tried to implement a cosine- shaped potential in the following way (this is a minimal-working example):
This return an error:
It looks like there's no cosine method for operators. If this is truly a missing feature and not a bug, I think it should be fixed ASAP.
The text was updated successfully, but these errors were encountered: