Skip to content

Conversation

@ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Dec 2, 2024

Checklist

Thank you for contributing to QuantumToolbox.jl! Please make sure you have finished the following tasks before opening the PR.

  • Please read Contributing to QuantumToolbox.jl.
  • Any code changes were done in a way that does not break public API.
  • Appropriate tests were added and tested locally by running: make test.
  • Any code changes should be julia formatted by running: make format.
  • All documents (in docs/ folder) related to code changes were updated and able to build locally by running: make docs.
  • (If necessary) the CHANGELOG.md should be updated (regarding to the code changes) and built by running: make changelog.

Request for a review after you have completed all the tasks. If you have not finished them all, you can also open a Draft Pull Request to let the others know this on-going work.

Description

The current implementation of spectrum does not align with QuTiP (see the documentation here). The spectrum should only return the value of spectrum corresponding to the user specified ω_list. Also, the peudo-inverse method is missing.

Furthermore, in QuTiP, the spectra obtained from fft of the correlation function is done by a function called spectrum_correlation_fft instead of spectrum.

Finally, we can support nothing input state for correlation functions, that will automatically solve the steadystate first.

TODO list:

  • separate the source code of spectrum and correlation functions into independent files
  • adjust the parameter order of spectrum and correlation functions to align with QuTiP (also add the deprecated methods to deprecated.jl)
  • add time list checks for correlation functions
  • adjust the return correlation Matrix dimension order to align with QuTiP
  • remove the return of ω_list in spectrum function
  • support nothing::Nothing input state for correlation functions [only when Hamiltonian is constant (Qobj)]
  • allow time-dependent Hamiltonian (QobjEvo) as an input for correlation functions.
  • remove spectrum solver FFTCorrelation (move it to deprecated.jl)
  • introduce a new function called spectrum_correlation_fft(tlist, corr) to replace the functionality of FFTCorrelation
  • introduce PseudoInverse <: SpectrumSolver for spectrum
  • introduce correlation_3op_1t
  • write the document page: Two-time correlation functions

@ytdHuang
Copy link
Member Author

ytdHuang commented Dec 2, 2024

I have already done the function spectrum_correlation_fft:

function spectrum_correlation_fft(tlist::AbstractVector, corr::AbstractVector; inverse::Bool=false)
    N = length(tlist)
    dt_list = diff(tlist)
    dt = dt_list[1]
    
    all((dt), dt_list) || ArgumentError("tlist must be equally spaced for FFT.")

    F = inverse ? N * ifft(corr) : fft(corr)
    Flist = fftshift(F)
    
    flist = fftshift(fftfreq(N, 1 / dt))

    return 2 * π * flist, 2 * dt * real(Flist)
end

This gives the same result in QuTiP

@albertomercurio
Copy link
Member

Great

@albertomercurio
Copy link
Member

I would also change the order of the arguments, since I think it is a bit different from QuTiP.

@ytdHuang ytdHuang marked this pull request as ready for review December 3, 2024 06:34
@ytdHuang ytdHuang changed the title Make spectrum align with QuTiP Make spectrum and correlation align with QuTiP Dec 3, 2024
@ytdHuang
Copy link
Member Author

ytdHuang commented Dec 3, 2024

I would also change the order of the arguments, since I think it is a bit different from QuTiP.

I also did it in this PR~

@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.28%. Comparing base (9a9a80d) to head (508d4d1).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/spectrum.jl 93.22% 4 Missing ⚠️
src/correlations.jl 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
+ Coverage   93.19%   93.28%   +0.09%     
==========================================
  Files          36       38       +2     
  Lines        2602     2637      +35     
==========================================
+ Hits         2425     2460      +35     
  Misses        177      177              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ytdHuang ytdHuang removed the request for review from albertomercurio December 4, 2024 06:42
@albertomercurio albertomercurio merged commit cfe7943 into qutip:main Dec 4, 2024
15 of 16 checks passed
@ytdHuang ytdHuang deleted the dev/spectrum branch December 4, 2024 10:09
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

Successfully merging this pull request may close these issues.

2 participants