-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.py
65 lines (48 loc) · 1.39 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Example file for time-delayed feedback simulation.
This example is a driven two-level atom, the example used in
arXiv:1502.06959.
Example usage:
In python prompt:
>>>> from qutip import *
>>>> from pylab import *
>>>> import example
>>>> times,sol = example.run()
>>>> plot(t,expect(sol,sigmap()*sigmam())
>>>> show()
"""
import numpy as np
import scipy as sp
import qutip as qt
import cascade
gamma = 1.0 # coupling strength to reservoir
phi = 1.*np.pi # phase shift in fb loop
eps = 2.0*np.pi*gamma # eps/2 = Rabi frequency
delta = 0. # detuning
# time delay
tau = np.pi/(eps)
print 'tau =',tau
dim_S = 2
Id = qt.spre(qt.qeye(dim_S))*qt.spost(qt.qeye(dim_S))
# Hamiltonian and jump operators
H_S = delta*qt.sigmap()*qt.sigmam() + eps*(qt.sigmam()+qt.sigmap())
L1 = sp.sqrt(gamma)*qt.sigmam()
L2 = sp.exp(1j*phi)*L1
# initial state
rho0 = qt.ket2dm(qt.basis(2,0))
# times to evaluate rho(t)
tlist=np.arange(0.0001,2*tau,0.01)
def run(rho0=rho0,tau=tau,tlist=tlist):
# run feedback simulation
opts = qt.Options()
opts.nsteps = 1e7
sol = np.array([rho0]*len(tlist))
for i,t in enumerate(tlist):
sol[i] = cascade.rhot(rho0,t,tau,H_S,L1,L2,Id,options=opts)
return tlist,sol
def run_nofb(rho0=rho0,tlist=tlist):
# run simulation without feedback
sol = qt.mesolve(H_S,rho0,tlist,[L1,L2],[])
return sol.times,sol.states
if __name__=='__main__':
run(rho0=rho0)