forked from qutip/qutip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_11.py
74 lines (67 loc) · 1.87 KB
/
test_11.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
from qutip import *
from numpy import *
from time import time
def test_11(runs=1):
"""
mcsolve evolution of 4-spin chain
"""
test_name='MC 4-spin [16]'
N = 4# number of spins
# uniform parameters
h = 1.0 * 2 * pi * ones(N)
Jz = 0.1 * 2 * pi * ones(N)
Jx = 0.1 * 2 * pi * ones(N)
Jy = 0.1 * 2 * pi * ones(N)
# dephasing rate
gamma = 0.01 * ones(N)
# intial state, first spin in state |1>, the rest in state |0>
psi_list = []
psi_list.append(basis(2,1))
for n in range(N-1):
psi_list.append(basis(2,0))
psi0 = tensor(psi_list)
tlist = linspace(0, 10, 200)
# Hamiltonian
si = qeye(2)
sx = sigmax()
sy = sigmay()
sz = sigmaz()
sx_list = []
sy_list = []
sz_list = []
for n in range(N):
op_list = []
for m in range(N):
op_list.append(si)
op_list[n] = sx
sx_list.append(tensor(op_list))
op_list[n] = sy
sy_list.append(tensor(op_list))
op_list[n] = sz
sz_list.append(tensor(op_list))
# construct the hamiltonian
H = 0
# energy splitting terms
for n in range(N):
H += - 0.5 * h[n] * sz_list[n]
# interaction terms
for n in range(N-1):
H += - 0.5 * Jx[n] * sx_list[n] * sx_list[n+1]
H += - 0.5 * Jy[n] * sy_list[n] * sy_list[n+1]
H += - 0.5 * Jz[n] * sz_list[n] * sz_list[n+1]
# collapse operators
c_op_list = []
# spin dephasing
for n in range(N):
c_op_list.append(sqrt(gamma[n]) * sz_list[n])
# evolve and calculate expectation values
opts=Odeoptions(gui=False)
tot_elapsed = 0
for n in range(runs):
tic=time()
mcsolve(H, psi0, tlist, c_op_list, sz_list,options=opts)
toc=time()
tot_elapsed += toc - tic
return [test_name], [tot_elapsed / runs]
if __name__=='__main__':
test_11()