8
def probcorr(E,kappa,gamma,g,wc,w0,wl,N):
10
# [corrES,covES] = probcorr(E,kappa,gamma,g,wc,w0,wl,N)
11
# returns the two-time correlation and covariance of the intracavity
12
# field as exponential series for the problem of a coherently driven
13
# cavity with a two-level atom
15
# E = amplitude of driving field, kappa = mirror coupling,
16
# gamma = spontaneous emission rate, g = atom-field coupling,
17
# wc = cavity frequency, w0 = atomic frequency, wl = driving field frequency,
18
# N = size of Hilbert space for intracavity field (zero to N-1 photons)
24
# Define cavity field and atomic operators
25
a = tensor(destroy(N),idatom)
26
sm = tensor(ida,sigmam())
29
H = (w0-wl)*sm.dag()*sm + (wc-wl)*a.dag()*a + 1j*g*(a.dag()*sm - sm.dag()*a) + E*(a.dag()+a)
35
# Calculate the Liouvillian
38
L = -1.0j * (spre(H) - spost(H))
39
for m in range(0, n_op):
40
cdc = c_op_list[m].dag() * c_op_list[m]
41
L += spre(c_op_list[m])*spost(c_op_list[m].dag())-0.5*spre(cdc)-0.5*spost(cdc)
43
# Find steady state density matrix and field
46
# Initial condition for regression theorem
47
arhoad = a * rhoss * a.dag();
48
#psi = tensor(basis(N,0),basis(2,0))
49
#arhoad = psi * trans(psi)
51
#print "rhoss =", rhoss
53
# Solve differential equation with this initial condition
54
solES = ode2es(L, arhoad);
56
# Find trace(a' * a * solution)
57
corrES = scalar_expect((a.dag() * a), solES);
73
start_time=time.time()
74
corrES = probcorr(E,kappa,gamma,g,wc,w0,wl,N);
75
print 'time elapsed (probcorr) = ' +str(time.time()-start_time)
77
tlist = linspace(0,10.0,200);
79
start_time=time.time()
80
corr = esval(corrES,tlist);
81
print 'time elapsed (esval) = ' +str(time.time()-start_time)
84
plot(tlist,real(corr))
86
ylabel('Correlation and covariance')