Skip to content

Commit c148465

Browse files
authored
Merge pull request #34 from qojulia/Matias
should_upstream.jl removed since it has been upstreamed in QuantumOpticsBase.jl
2 parents 2e4d63c + c480f52 commit c148465

34 files changed

+2297
-396
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Manifest.toml
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using QuantumOptics
2+
using WaveguideQED
3+
using LinearAlgebra
4+
using PyPlot
5+
pygui(false)
6+
pygui(true)
7+
include("singlecavity_simulations.jl")
8+
#Parameter structure imported from singlecavity_simulations (bit overkill for now, but can prove usefull)
9+
param = parameters()
10+
11+
#Set detuning:
12+
param.δ = 0
13+
#Set non linearity:
14+
param.x3 = 0
15+
16+
param.times = 0:0.1:10
17+
18+
dt = param.times[2] - param.times[1]
19+
20+
#Create operators for two photons interacting with cavity
21+
bc = FockBasis(1)
22+
bw = WaveguideBasis(1,param.times)
23+
a = destroy(bc)
24+
ad = create(bc);
25+
n = ad*a identityoperator(bw)
26+
#$w†a and a†w efficient implementation$
27+
wda = emission(bc,bw)
28+
adw = absorption(bc,bw)
29+
H = param.δ*n + im*sqrt(param.γ/dt)*(adw-wda) + param.x3/4*(n*n+n)
30+
31+
32+
#Define input onephoton state shape
33+
ξfun(t,σ,t0) = complex(sqrt(2/σ)* (log(2)/pi)^(1/4)*exp(-2*log(2)*(t-t0)^2/σ^2))
34+
ξvec = ξfun.(param.times,param.σ,param.t0)
35+
36+
ψ_cw = onephoton(bw,ξvec)
37+
psi = fockstate(bc,0) ψ_cw
38+
39+
#Solve
40+
@btime ψ = waveguide_evolution(param.times, psi, H)
41+
42+
#REFERENCE SOLUTION
43+
sol1 = solve_differentialeq(param,ξfun)
44+
ref_sol = ξfun.(sol1.t,param.σ,param.t0)-sqrt(param.γ)*sol1
45+
46+
#Plot single photon waveguide state
47+
ψ_single = OnePhotonView(ψ)/sqrt(dt)
48+
49+
fig,ax = subplots(1,1,figsize=(9,4.5))
50+
ax.plot(param.times,abs.(ξvec).^2,"g-",label="Input pulse")
51+
ax.plot(param.times,abs.(ψ_single).^2,"ro",label="δ = 0",fillstyle="none")
52+
ax.plot(sol1.t,abs.(ref_sol).^2,"r-")
53+
ax.set_xlabel("time [1/γ]")
54+
ax.set_ylabel(L"$\xi_{out}^{(1)}$")
55+
ax.legend()
56+
plt.tight_layout()
57+
58+
using DifferentialEquations
59+
using LinearAlgebra
60+
using PyPlot
61+
function dpsi!(dpsi,psi,p,t)
62+
y,d,nsteps,dt = p
63+
timeindex = round(Int,t/dt,RoundDown) + 1
64+
dpsi .= 0
65+
dpsi[2+nsteps] = -sqrt(y/dt)*psi[1+timeindex]
66+
dpsi[1+timeindex] = sqrt(y/dt)*psi[2+nsteps]
67+
end
68+
69+
#Define parameters
70+
y,d,dt = 1,0,0.1
71+
times = 0:dt:10
72+
N = length(times)
73+
p = (y,d,N,dt)
74+
75+
#Define input gaussian state with width s = 1 and arrivial time t0=5
76+
xi(t,s,t0) = complex(sqrt(2/s)* (log(2)/pi)^(1/4)*exp(-2*log(2)*(t-t0)^2/s^2))
77+
psi = zeros(ComplexF64,2*(N+1))
78+
psi[2:N+1] .= sqrt(dt)*xi.(times,1,5)
79+
prob = ODEProblem(dpsi!, psi, (times[1], times[end]+dt), p)
80+
sol = solve(prob, OrdinaryDiffEq.DP5();reltol = 1.0e-8,abstol = 1.0e-10);
81+
psi_out = sol[end][2:N+1]
82+
83+
#Plot the output
84+
fig,ax = subplots(1,1,figsize=(9,4.5))
85+
ax.plot(times,abs.(psi_out).^2,"r-",label="Input pulse")

Examples/qo_singlephoton.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include("singlecavity_simulations.jl")
99
param = parameters()
1010

1111
#Set detuning:
12-
param.δ = 0
12+
param.δ = 2
1313
#Set non linearity:
1414
param.x3 = 0
1515

@@ -53,4 +53,5 @@ ax.plot(sol1.t,abs.(ref_sol).^2,"r-")
5353
ax.set_xlabel("time [1/γ]")
5454
ax.set_ylabel(L"$\xi_{out}^{(1)}$")
5555
ax.legend()
56-
plt.tight_layout()
56+
plt.tight_layout()
57+

Examples/qo_twophoton.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ psi = fockstate(bc,0) ⊗ ψ_cw
4141

4242
ψ_double = TwoPhotonView(ψ)
4343

44+
4445
fig,ax = subplots(1,1,figsize=(4.5,4.5))
4546
xgrid = repeat(param.times',length(param.times),1)
4647
ygrid = repeat(param.times,1,length(param.times))

0 commit comments

Comments
 (0)