Skip to content

Add quantum fisher information for a driven-dissipative Kerr parametric oscillator using auto-diff #47

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

Merged
merged 2 commits into from
Jul 18, 2025

Conversation

ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Jun 16, 2025

Checklist

Thank you for contributing to Tutorials for Quantum Toolbox in Julia! Please make sure you have finished the following tasks before opening the PR.

  • Please read Contributing to Quantum Toolbox in Julia.
  • The (last update) date were modified for new or updated tutorials.
  • For new tutorials, a Version Information section was added at the end and displays the output of versioninfo().
  • All tutorials were able to render locally by running: make render.

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

This is a PR to preview the new tutorial contributed by @oameye

@ytdHuang ytdHuang changed the title Add Quantum Fisher Information for a driven-dissipative Kerr Parametric Oscillator using Auto-diff Add quantum fisher information for a driven-dissipative Kerr parametric oscillator using auto-diff Jun 16, 2025
Copy link

github-actions bot commented Jun 16, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://qutip.github.io/qutip-julia-tutorials/pr-preview/pr-47/

Built to branch gh-pages at 2025-07-15 17:17 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

using SciMLSensitivity # Allows for ODE sensitivity analysis
using FiniteDiff # Finite difference methods
using LinearAlgebra # Linear algebra operations
using CairoMakie # Plotting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add

CairoMakie.activate!(type = "svg")

The KPO system is governed by the Hamiltonian:
$$H = -p_1 a^\dagger a + K (a^\dagger)^2 a^2 - G (a^\dagger a^\dagger + a a)$$

where:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should leave an empty line after where:, otherwise the list is not properly shown.

Comment on lines 31 to 67
```{julia}
function final_state(p)
G, K, γ = 0.002, 0.001, 0.01

N = 20 # cutoff of the Hilbert space dimension
a = destroy(N) # annihilation operator

coef(p,t) = - p[1]
H = QobjEvo(a' * a , coef) + K * a' * a' * a * a - G * (a' * a' + a * a)
c_ops = [sqrt(γ)*a]
ψ0 = fock(N, 0) # initial state

tlist = range(0, 2000, 100)

sol = mesolve(H, ψ0, tlist, c_ops; params = p, progress_bar = Val(false), saveat = [tlist[end]])
return sol.states[end].data
end
```

```{julia}
function final_state(p, t)
G, K, γ = 0.002, 0.001, 0.01

N = 20 # cutoff of the Hilbert space dimension
a = destroy(N) # annihilation operator

coef(p,t) = - p[1]
H = QobjEvo(a' * a , coef) + K * a' * a' * a * a - G * (a' * a' + a * a)
c_ops = [sqrt(γ)*a]
ψ0 = fock(N, 0) # initial state

tlist = range(0, 2000, 100)

sol = mesolve(H, ψ0, tlist, c_ops; params = p, progress_bar = Val(false), saveat = [t])
return sol.states[end].data
end
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we define everything in one function?

Suggested change
```{julia}
function final_state(p)
G, K, γ = 0.002, 0.001, 0.01
N = 20 # cutoff of the Hilbert space dimension
a = destroy(N) # annihilation operator
coef(p,t) = - p[1]
H = QobjEvo(a' * a , coef) + K * a' * a' * a * a - G * (a' * a' + a * a)
c_ops = [sqrt(γ)*a]
ψ0 = fock(N, 0) # initial state
tlist = range(0, 2000, 100)
sol = mesolve(H, ψ0, tlist, c_ops; params = p, progress_bar = Val(false), saveat = [tlist[end]])
return sol.states[end].data
end
```
```{julia}
function final_state(p, t)
G, K, γ = 0.002, 0.001, 0.01
N = 20 # cutoff of the Hilbert space dimension
a = destroy(N) # annihilation operator
coef(p,t) = - p[1]
H = QobjEvo(a' * a , coef) + K * a' * a' * a * a - G * (a' * a' + a * a)
c_ops = [sqrt(γ)*a]
ψ0 = fock(N, 0) # initial state
tlist = range(0, 2000, 100)
sol = mesolve(H, ψ0, tlist, c_ops; params = p, progress_bar = Val(false), saveat = [t])
return sol.states[end].data
end
```
function final_state(p, t=nothing)
G, K, γ = 0.002, 0.001, 0.01
N = 20 # cutoff of the Hilbert space dimension
a = destroy(N) # annihilation operator
coef(p,t) = - p[1]
H = QobjEvo(a' * a , coef) + K * a' * a' * a * a - G * (a' * a' + a * a)
c_ops = [sqrt(γ)*a]
ψ0 = fock(N, 0) # initial state
tlist = isnothing(t) ? [0, 2000] : [0, t]
sol = mesolve(H, ψ0, tlist, c_ops; params = p, progress_bar = Val(false))
return sol.states[end].data
end

Plot the time evolution of the Quantum Fisher Information:

```{julia}
fig = Figure(size=(900, 350))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the size here? We should have set a default size in Quarto already.

@albertomercurio
Copy link
Member

Hi @ytdHuang and @oameye. The tutorial is nice. I would make some improvements though. I just made some comments.

@oameye
Copy link
Contributor

oameye commented Jul 3, 2025

I don't have the permissions to push to this branch/PR nor to resolve the comments on github. See #46

Here is the notebook with implemented suggestions:
Quantum_Fisher_Information_with_automatic_differentiation.qmd.tar.gz

@oameye
Copy link
Contributor

oameye commented Jul 13, 2025

Friendly bump

@ytdHuang
Copy link
Member Author

@oameye

Can you locally make a new branch based on tutor/QFI, apply the changes, and make a new PR merging to tutor/QFI?

@oameye
Copy link
Contributor

oameye commented Jul 14, 2025

done

@ytdHuang ytdHuang requested a review from albertomercurio July 15, 2025 16:55
Copy link
Member

@albertomercurio albertomercurio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm approving.

I'm also working to make it working with true automatic differentiation using Enzyme.jl. I will let you know.

@albertomercurio albertomercurio merged commit 45e181b into main Jul 18, 2025
2 checks passed
@oameye
Copy link
Contributor

oameye commented Jul 18, 2025

ooeoe. That would be super cool!

@ytdHuang ytdHuang deleted the tutor/QFI branch July 18, 2025 21:23
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.

3 participants