implemented a possibility of mixing measurement operators and callback functions in e_ops list#1655
Conversation
…r performing measurements
|
@marekyggdrasil Thanks Marek. This was already implemented for QuTiP 5 in #1462. I think there is still some value in having this implemented for 4.7 though. I'm going to leave the review for @Ericgig -- the changes look good and fairly straightforward to me, but it would also be good to be sure that they fit in with the plans for version 5. |
|
Thank you @hodgestar ! I will also fix the PEP8 problem. |
Ericgig
left a comment
There was a problem hiding this comment.
Hi @marekyggdrasil, thank you for your contribution.
This approach look good.
Ericgig
left a comment
There was a problem hiding this comment.
I rewrote the doc in a more verbose way and removed mention of QobjEvo in sesolve and mesolve's e_ops where they are not supported.
Co-authored-by: Eric Giguère <eric.giguere@calculquebec.ca>
|
@Ericgig any tips how to locally run |
|
No, we use default setting for |
|
@marekyggdrasil could you fix the |
|
@Ericgig sure I will be happy to fix the linting errors, I seem to have missed your previous message about codeclimate, sorry about that. |
|
I think I found what you want: |
|
Merged! |
|
It's my pleasure, @Ericgig ! |
Description
I propose to make it possible to have callable functions inside of the
e_opslist, not only operators. This becomes useful if we want to measure energy or if we want to have time-dependent measurements just like time-dependent Hamiltonian.Changes are pretty straightforwards, mostly making sure types match. Important design choice is, if measurement is not an operator but a function, the data type is complex by default (to handle the general case).
Feedback and suggestions for changes are welcome. I will be happy to contribute more!
Related issues or PRs
Suggested in #1238
Changelog
mesolveandsesolveobjects to handle callable function inside of thee_opslist.solverto create empty measured data if list ofe_opscontains a callable function.test_compatibility_with_solverby adding an additional measurement which is not an operator but a lambda expression.