tempoCollaboration / OQuPy

A Python package to efficiently simulate non-Markovian open quantum systems with process tensors.
https://oqupy.readthedocs.io
Apache License 2.0
71 stars 24 forks source link

Code and tutorial for multi-time correlations #122

Closed rmadw closed 1 month ago

rmadw commented 3 months ago

Hi Piper and Gerald,

As discussed in issue #105, here is a pull request for the multi-time correlations code, the modifications to the original two-time correlations code and the tutorial. I have implemented all the feedback given by Piper (thank you again!).

Going through the contribution checklist, I think all the relevant boxes are ticked now:

Thank you and let me know if there's anything else I can improve on.

Best,

Roos

piperfw commented 3 months ago

Hi @rmadw! Great work on this. I've fixed two small things:

  1. The docstring of compute_correlations (two-time) said it returned three items, but it now only returns two (this broke bath_dynamics.py line 133, but no other code was effected).
  2. In the case of out of time order arguments, the progress bar wasn't being updated (try e.g. times_3 = 10*dt in the tutorial with the code before my edit)

Another thing I changed is to rename compute_nt_correlations to compute_correlations_nt, simply so it appears directly after compute_correlations in the documentation. If you have any reason this isn't a good idea, we can easily undo this (it's just my last commit there). I believe I've updated every instance of the function name in the code.

One thing I would want to be sure on is that the NaN's being returned when one has times out of order are correct. I suspect you've already checked this, in which case - nothing to do!

Finally, and this probably isn't something to be changed, it seems a little odd to me that we have to add +dt in times_1 = (0.0, dt*20+dt) to include the endpoint. Maybe there is a more intuitive way, but likely this is fine.

Given the above I am happy. Once Gerald has had time to check over things himself I'll complete the merge.

P.S. modules.rst is updated 'automatically' based on the docstrings in the code. So yes nothing more to do there either :)

rmadw commented 3 months ago

Hi @piperfw,

Thanks for the additional comments!

I didn't realise it was the compute_correlations code that was breaking bath_dynamics when I ran the test, sorry about that and thanks for fixing!

And all the other points sound good, I'm happy with renaming there. I've checked that all the NaN's are in the right places in the outputs, so I think that's all good.

I agree it's a bit annoying that you have to add a dt to the time inputs though, I think this might have do to do with how the parse_times function deals with the time inputs. I'll have a look at that later today to check if there's a good fix for that.

gefux commented 2 months ago

Hi @rmadw & @piperfw,

I apologise: I didn't realise that you've been waiting for my OK. I had a look through. It's great! I only have a few minor comments:

I'll double check the NaNs on Monday, and get back to you.

piperfw commented 2 months ago

Hi Gerald, Thanks for looking over this. @rmadw would you be able to implement the suggested naming and description changes? Similarly with the tutorial rendering - I think it would be worth double checking the converted .rst version as well, because issues can arise there too.

Regarding the preprint reference, this was temporarily removed due to a change in state of preparation of the paper. @rmadw would you be happy for it to be included now, or prefer to delay until a later point? Again this version of the documentation won't be 'live' on readthedocs for some months probably.

rmadw commented 2 months ago

Hi Gerald,

Thanks a lot for the feedback! I'm currently implementing the changes you suggested.

As @piperfw mentioned, my preprint is still in draft stage and will hopefully be submitted soon, but I'm not completely confident what the timeline for that is. I'd prefer to delay adding the preprint reference for now if that's OK.

Let me know if there's anything else I can do! - Roos

gefux commented 2 months ago

Hi @rmadw and @piperfw:

I had now a closer look into the examples and the 'NaN's. The two time correlation 'NaN's don't seem to be quite correct. I have created a simple example and added the expected result (from previous implementation) as a comment at the end of the file:

Also:

rmadw commented 2 months ago

Hi @gefux

Thank you for the additional feedback.

piperfw commented 1 month ago

Hi @rmadw Thanks for working on the changes. Regarding the ordering, can you explain why it is an issue to have symmetric behaviour here? Naively I would expect time ordering to mean t_A < t_B [other way around in your comment?] and anti-ordered to mean t_A > t_B, but wouldn't be surprised if both cases included equality. In other words, I would argue to keep the equal times (or not) in both cases.

Beyond that, if you would like to confirm you've addressed all of Gerald's feedback I can make the PR.

rmadw commented 1 month ago

Hi @piperfw,

I think I do agree with you there; the original two-time correlations code did implement the ordering as t_A <= t_B and t_A > t_B (sorry, I indeed switched the arguments by accident in my comment), which is why I raised it as an issue in my previous comment.

For my 2D spectroscopy related purposes, it would be useful to have the 'ordered' inequality set as t_A <= t_B, so I'd be happy keep the equal times in both inequalities if everyone is happy with that. In that case I'll remove the few lines I added to the code to remove the equal times.

Besides that, I can confirm that I've implemented all of Gerald's feedback!

piperfw commented 1 month ago

Thanks for confirming @rmadw and I think, please go ahead and remove those lines.

rmadw commented 1 month ago

No problem @piperfw, lines have been removed!

piperfw commented 1 month ago

That's complete, congratulations @rmadw !

Regarding your preprint, I think ultimately we should have a reference in the documentation here (and OQuPaper). I would suggest we either i. cite a work by you and BWL/JMJK 'in preparation' or ii. cite the oqupaper (once it is submitted). I would vote i.

A tentative date for dev0.5 to go live is 24th of this month, so one way or the other perhaps you could give us an update on the status of the preprint by then?