~jrjohansson/qutip/master

« back to all changes in this revision

Viewing changes to xprobqmc2.py

  • Committer: Paul Nation
  • Date: 2011-04-21 04:46:56 UTC
  • Revision ID: git-v1:dd4c966b490aa468dfbd28cef66694df4bf235c8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from qutip import *
 
2
 
 
3
def probqmc2(E,kappa,gamma,g,wc,w0,wl,N,tlist,ntraj):
 
4
        ida=qeye(N)
 
5
        idatom=qeye(2)
 
6
        a=tensor(destroy(N),idatom)
 
7
        sm=tensor(ida,sigmam())
 
8
        H=(w0-wl)*sm.dag()*sm+(wc-wl)*a.dag()*a+1j*g*(a.dag()*sm-sm.dag()*a)+E*(a.dag()+a)
 
9
 
 
10
        #collapse operators
 
11
        C1=sqrt(2*kappa)*a
 
12
        C2=sqrt(gamma)*sm
 
13
        C1dC1=C1.dag()*C1
 
14
        C2dC2=C2.dag()*C2
 
15
 
 
16
        #intial state
 
17
        psi0=tensor(basis(N,0),basis(2,1))
 
18
 
 
19
        # evolve and calculate expectation values
 
20
        expt_list = mcwf_evolve(tlist, H, psi0, ntraj, [C1, C2], [C1dC1, C2dC2, a])
 
21
 
 
22
        return expt_list[0], expt_list[1], expt_list[2]
 
23
        
 
24
 
 
25
kappa=2
 
26
gamma=0.2
 
27
g=1
 
28
wc=0
 
29
w0=0
 
30
wl=0
 
31
E=0.5
 
32
N=4
 
33
tlist=linspace(0,10,100)
 
34
ntraj=100
 
35
 
 
36
start_time=time.time()
 
37
count1, count2, infield = probqmc2(E,kappa,gamma,g,wc,w0,wl,N,tlist,ntraj)
 
38
print 'time elapsed = ' +str(time.time()-start_time) 
 
39
 
 
40
plot(tlist,real(count1))
 
41
plot(tlist,real(count2))
 
42
xlabel('Time')
 
43
ylabel('Transmitted Intensity and Spontaneous Emission')
 
44
show()
 
45
 
 
46