-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.py
168 lines (133 loc) · 4.63 KB
/
defs.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# P. M. Harrington, F. Moseley
import numpy as np
import qutip
import helpers_qutip
def get_parameters(num_sites=1, num_fock=2):
p = helpers_qutip.Parameters(num_sites=num_sites,
num_fock=num_fock,
times=np.linspace(0, 10, 501),
time_dep=True,
ntraj=50,
nsubsteps=41,
random_seed=10)
p.chi = 1*p.unit
p.kappa = 2*p.unit
p.Delta_1 = 0.
p.epsilon_1 = 0.35*p.unit
p.gamma = 0.01*p.unit
p.solver = 'mesolve'
return p
def get_collapse_operators(p, ops):
c_ops = []
for k in range(p.num_sites):
c_ops.append(np.sqrt(p.kappa)*ops.a[k])
c_ops.append(np.sqrt(p.gamma)*ops.Sm[k])
return c_ops
def get_initial_state(p, state_qb):
'''
Define the initial state of the system.
'''
if state_qb=='+x':
psi_q = (qutip.basis(2,0) + qutip.basis(2,1))/np.sqrt(2)
elif state_qb=='-x':
psi_q = (qutip.basis(2,0) - qutip.basis(2,1))/np.sqrt(2)
elif state_qb=='+y':
psi_q = (qutip.basis(2,0) + 1j*qutip.basis(2,1))/np.sqrt(2)
elif state_qb=='-y':
psi_q = (qutip.basis(2,0) - 1j*qutip.basis(2,1))/np.sqrt(2)
elif state_qb=='+z':
psi_q = qutip.basis(2,0)
elif state_qb=='-z':
psi_q = qutip.basis(2,1)
# the zt states represent \tilde{z}, which are a slight pertubations
# to z eigenstates that's used to get around the fixed point at
# z = +1, -1. only works with density matricies
elif state_qb=='+z_tilde':
ket_gnd = qutip.basis(2, 0)
ket_exc = qutip.basis(2, 1)
psi_c = qutip.basis(p.num_fock, 0)
# ground state
op_ = []
for site_num in range(p.num_sites):
op_.append(qutip.tensor(psi_c, ket_gnd))
state_gnd = qutip.ket2dm(qutip.tensor(op_))
# excited state
op_ = []
for site_num in range(p.num_sites):
op_.append(qutip.tensor(psi_c, ket_exc))
state_exc = qutip.ket2dm(qutip.tensor(op_))
delta = 0.0001
return (1-delta)*state_gnd + delta*state_exc
elif state_qb=='-z_tilde':
ket_gnd = qutip.basis(2, 0)
ket_exc = qutip.basis(2, 1)
psi_c = qutip.basis(p.num_fock, 0)
# ground state
op_ = []
for site_num in range(p.num_sites):
op_.append(qutip.tensor(psi_c, ket_gnd))
state_gnd = qutip.ket2dm(qutip.tensor(op_))
# excited state
op_ = []
for site_num in range(p.num_sites):
op_.append(qutip.tensor(psi_c, ket_exc))
state_exc = qutip.ket2dm(qutip.tensor(op_))
delta = 0.0001
return (1-delta)*state_exc + delta*state_gnd
elif state_qb=='arb':
theta = np.pi/8
c0 = np.cos(theta)
c1 = np.sin(theta)
psi_q = c0*qutip.basis(2,0) + c1*qutip.basis(2,1)
else:
raise RuntimeError('Qubit state not defined.')
psi_c = qutip.basis(p.num_fock, 0)
#psi_c = coherent(p.num_fock, 2)
# vacuum state
op_ = []
for site_num in range(p.num_sites):
op_.append(qutip.tensor(psi_c, psi_q))
ket = qutip.tensor(op_)
if (p.solver=='sesolve'): # the stochastic (monte carlo) solver acts on kets not density matricies
return ket
elif (p.solver=='mesolve'): # the SME solver operates on density matricies so return that instead
return qutip.ket2dm(ket)
def get_hamiltonian(p, ops):
'''
Define the Hamiltonian.
'''
# define returns
hamiltonian = []
# operators
iden = ops.iden
Sz = ops.Sz
a = ops.a
# Hamiltonian
# # resonator
# h_a = 0
# for k in range(p.num_sites):
# h_a += p.omega_a*a[k].dag()*a[k]
# # qubit
# h_q = 0
# for k in range(p.num_sites):
# h_q += p.omega_q*(iden[k] - Sz[k])/2
# local resonator-qubit interaction
h_disp = 0
for k in range(p.num_sites):
h_disp += -p.chi*a[k].dag()*a[k]*Sz[k]
# # resonator-resonator interaction
# h_J = 0
# for k in range(p.num_sites-1):
# h_J += J*(a[k]*a[k+1].dag() + a[k].dag()*a[k+1])
# # drive qubit
# h_drive_q_Delta = 0
# h_drive_q_Omega = 0
# for k in range(p.num_sites):
# h_drive_q_Delta += Delta_q*(iden[k] - Sz[k])/2
# h_drive_q_Omega += (Omega/2)*Sx[k]
h_drive_Delta_1 = 0
h_drive_epsilon_1 = 0
for k in range(p.num_sites):
h_drive_Delta_1 += p.Delta_1*a[k].dag()*a[k]
h_drive_epsilon_1 += p.epsilon_1*a[k] + np.conj(p.epsilon_1)*a[k].dag()
return h_disp + h_drive_Delta_1 + h_drive_epsilon_1