Skip to content

Commit 51ba2db

Browse files
committed
Added a bit more documentation for the monitoring operator, and added runtests.jl to run all the tests
1 parent 64794fd commit 51ba2db

10 files changed

+86
-20
lines changed

docs/src/monitoring_metrology.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BackAction.expheff_derivative(Heff_par::Function, tau::Float64, theta::Vector{Fl
1717
```
1818

1919
```@docs
20-
BackAction.jumpoperators_derivatives(Ls_par, theta, dtheta)
20+
BackAction.jumpoperators_derivatives(Ls_par, theta::Vector{Float64}, dtheta::Vector{Float64})
2121
```
2222

2323
```@docs

src/monitoring.jl

+42-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
getheff_parametrized(H_par::Function, Ls_par)
55
```
66
7-
TODO: write this documentation
7+
From the function `H_par`, which is assumed to be the parametrization of the hamiltonian, and
8+
an array of functions `Ls` which are assumed to parametrize the jump operators, return a function
9+
that's the parametrization of the effective Hamiltonian.
10+
11+
!!! note "About the Arguments"
12+
The calculation of monitoring operator assumes that the arguments of `H_par` and the functions in
13+
`Ls` are the same and in the same order.
14+
815
"""
916
function getheff_parametrized(H_par::Function, Ls_par)::Function
1017
# here theta is expected to be a vector
@@ -22,7 +29,21 @@ end
2229
expheff_derivative(Heff_par::Function, tau::Float64, theta::Vector{Float64}, dtheta::Vector{Float64})
2330
```
2431
25-
TODO: write this documentation
32+
Calculate the derivative ``\\partial_{i}e^{-i\\tau H_e(\\theta)}``, where ``i`` is the ``i-th`` component
33+
of the vector ``\\theta``.
34+
35+
# Arguments
36+
- `Heff_par::Function`: the parametrization of the effective hamiltonian
37+
- `tau::Float64`: the time in the exponential
38+
- `theta::Vector{Float64}`: vector with the values of the parameters at which the derivative is calculated
39+
- `dtheta::Vector{Float64}`: the displacement vector used to calculate the derivative, if you want the derivative
40+
respect to the ``i-th`` parameter `dtheta` must have zero entries except for `dtheta[i]`.
41+
42+
!!! note "Derivative order "
43+
The derivative is calculate using the five-point stencil rule.
44+
45+
!!! todo "TODO: add an example"
46+
Preferably one in which ``\\partial_i H_e`` commutes with ``H_e``, those are easier.
2647
"""
2748
function expheff_derivative(Heff_par::Function, tau::Float64, theta::Vector{Float64}, dtheta::Vector{Float64})
2849
f1 = exp(-1im*tau*Heff_par((theta + 2*dtheta)...))
@@ -36,12 +57,14 @@ end
3657
"""
3758
3859
```
39-
jumpoperators_derivatives(Ls_par, theta, dtheta)
60+
jumpoperators_derivatives(Ls_par, theta::Vector{Float64}, dtheta::Vector{Float64})
4061
```
4162
42-
TODO: write this documentation
63+
Calculate the derivatives of the list of jump operators, the logic is the same as
64+
for `expheff_derivative`.
65+
4366
"""
44-
function jumpoperators_derivatives(Ls_par, theta, dtheta)
67+
function jumpoperators_derivatives(Ls_par, theta::Vector{Float64}, dtheta::Vector{Float64})
4568
nchannels = size(Ls_par)[1]
4669
nlevels = size(Ls_par[1](theta...))[1]
4770
dLs = zeros(ComplexF64, nlevels, nlevels, nchannels)
@@ -55,6 +78,7 @@ function jumpoperators_derivatives(Ls_par, theta, dtheta)
5578
return dLs
5679
end
5780

81+
5882
"""
5983
6084
```
@@ -64,7 +88,13 @@ writederivative!(dpsi::SubArray{ComplexF64, 1}, L::Matrix{ComplexF64},
6488
psi0::Vector{ComplexF64})
6589
```
6690
67-
TODO: write this documentation
91+
Writes the derivative of ``|\\psi\\rangle = L(\\theta)V(\\theta)|\\psi_0\\rangle ``
92+
at ``\\theta`` in the subarray `dpsi` respect to the ``i-th`` component of ``theta``,
93+
following the same logic as `expheff_derivative`. The derivatives of ``V`` and ``L`` at
94+
must be provided via `dL` and `dV`.
95+
96+
!!! note "Initial State dependency"
97+
This is intended to be used when ``|\\psi_0\\rangle`` doesn't have dependeny on ``\\theta``.
6898
"""
6999
function writederivative!(dpsi::SubArray{ComplexF64, 1},
70100
L::Matrix{ComplexF64},
@@ -85,7 +115,12 @@ writederivative!(dpsi::SubArray{ComplexF64, 1},
85115
dpsi0::SubArray{ComplexF64, 1})
86116
```
87117
88-
TODO: write this documentation
118+
Writes the derivative of ``|\\psi\\rangle = L(\\theta)V(\\theta)|\\psi_0\\rangle ``
119+
at ``\\theta`` in the subarray `dpsi` respect to the ``i-th`` component of ``theta``,
120+
following the same logic as `expheff_derivative`. The derivatives of ``V`` and ``L`` at
121+
must be provided via `dL` and `dV`, and also that of ``|\\psi0\\rangle`` as `dpsi0`.
122+
123+
89124
"""
90125
function writederivative!(dpsi::SubArray{ComplexF64, 1},
91126
L::Matrix{ComplexF64},

test/Project.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[deps]
2-
BackAction = "32f8aca8-888b-4d2f-bb84-700bec69f41d"
32
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
43
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
54
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
5+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
66
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
7+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
78
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
89
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
9-
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
10+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
11+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using BackAction
2+
using Test
3+
4+
@testset "Radiative Damping" begin
5+
include("test_radiative_damping.jl")
6+
end
7+
8+
@testset "states_atjumps" begin
9+
include("test_states_atjumps.jl")
10+
end
11+
12+
@testset "states_att" begin
13+
include("test_states_att.jl")
14+
end
15+
16+
17+
@testset "Resonance Fluorescene" begin
18+
include("test_drive_qubit.jl")
19+
end
20+
21+
@testset "Driven Qubit" begin
22+
include("test_drive_qubit.jl")
23+
end
24+
25+
@testset "Monitoring Operator" begin
26+
include("test_monitoring.jl")
27+
end
28+

test/test_drive_qubit.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This visual test is intended to test the evolution of mixed states
22
# # Import all the necessary libraries
3-
libraries = ["BackAction", "LinearAlgebra", "Statistics", "Plots", "LaTeXStrings", "OrdinaryDiffEq", "Test"]
3+
libraries = ["LinearAlgebra", "Statistics", "Plots", "LaTeXStrings", "OrdinaryDiffEq", "Test"]
44

55
function ensure_imports(packages::Vector{String})
66
for pkg in packages

test/test_monitoring.jl

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This test evaluates if the trace of the monitoring operator is working
22
using Test
3-
using BackAction
3+
# using BackAction
44
using LinearAlgebra
55
using LaTeXStrings
66
using ProgressMeter
@@ -153,7 +153,8 @@ fi_t_gammelmark = [0.115, 0.221, 0.338, 0.425, 0.507, 0.557, 0.573, 0.566, 0.532
153153
end
154154
end
155155

156-
scatter(delta_gammelmark, fi_t_gammelmark, label="Gammelmark-Molmer") # dashlengths=dashlengths)
157-
plot!(delta_gammelmark, fi_t_gammelmark, label=false, linestyle=:dash, xlabel=L"\Delta", ylabel=L"I_{\Delta\Delta}/T")
158-
scatter!(delta_gammelmark, my_fi_t , label="Produced")
159-
plot!(delta_gammelmark, my_fi_t, label=false, linestyle=:dash)
156+
# Activate plots in case you want to see them
157+
# scatter(delta_gammelmark, fi_t_gammelmark, label="Gammelmark-Molmer") # dashlengths=dashlengths)
158+
# plot!(delta_gammelmark, fi_t_gammelmark, label=false, linestyle=:dash, xlabel=L"\Delta", ylabel=L"I_{\Delta\Delta}/T")
159+
# scatter!(delta_gammelmark, my_fi_t , label="Produced")
160+
# plot!(delta_gammelmark, my_fi_t, label=false, linestyle=:dash)

test/test_radiative_damping.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Distributions, HypothesisTests
22
using Test
3-
using BackAction
3+
# using BackAction
44
using Statistics
55
using LinearAlgebra
66
using Plots

test/test_resonance_fluorescene.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HypothesisTests, Distributions
2-
using BackAction, LinearAlgebra, Statistics, Random, QuadGK, Test, Plots,
2+
using LinearAlgebra, Statistics, Random, QuadGK, Test, Plots,
33
OrdinaryDiffEq
44
########## Setup
55
sys = BackAction.rf_sys

test/test_states_atjumps.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BackAction, LinearAlgebra, Test
1+
using LinearAlgebra, Test
22

33
function identifystate(s::Matrix{ComplexF64})
44
excited = [[0, 0] [0, 1.0+0im]]

test/test_states_att.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BackAction, LinearAlgebra, Test
1+
using LinearAlgebra, Test
22
function identifystate(s::Vector{ComplexF64})
33
s1 = [1.0+0im, 0]
44
s2 = [0, 1.0+0im]

0 commit comments

Comments
 (0)