-
Notifications
You must be signed in to change notification settings - Fork 2
/
coupling_calc.py
70 lines (51 loc) · 2.02 KB
/
coupling_calc.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
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
nl_list = [(1, 5), (1, 7), (1, 9)]
nl_list = np.array(nl_list)
fname = ''
for i in range(len(nl_list)):
fname = fname + str(nl_list[i,0]) + '_' + str(nl_list[i,1])
if(i!=len(nl_list)-1): fname = fname + '-'
Z = np.loadtxt('Z_%s.dat'%fname)
Z_diag = np.loadtxt('Z_diag_%s.dat'%fname)
OM = np.loadtxt('../OM.dat')
Z = np.real(Z)
Z_diag = np.real(Z_diag)
n_modes = len(nl_list)
# for i in range(n_modes):
# diag_no = 2*np.sum(nl_list[0,1]) + 1 + np.abs(nl_list[i][1]-nl_list[0][1])
# inst_diag = np.diag(Z,diag_no)
# plt.plot(inst_diag)
# print(diag_no,inst_diag)
for i in range(n_modes):
for j in range(i+1,n_modes):
cumul_l = np.sum(nl_list[i:j,1])
m_skip = np.abs(nl_list[j,1]-nl_list[j-1,1])
diag_no = 2*cumul_l + j-i + m_skip
cross_coupling = np.trim_zeros(np.diag(Z,diag_no))
if(len(cross_coupling) == 0): continue
coupling_strength = np.zeros(len(cross_coupling))
i_inds, j_inds = np.where(np.abs(Z - cross_coupling[0])<1e-6)
local_i = i_inds[0]
local_j = j_inds[0]
for k in range(len(cross_coupling)):
coupling_strength[k] = cross_coupling[k] \
/np.abs(Z[local_i,local_i] - Z[local_j,local_j])
local_i += 1
local_j += 1
plt.plot(coupling_strength * OM *1e6,'.')
#for the negative diagonal
diag_no *= -1
cross_coupling = np.trim_zeros(np.diag(Z,diag_no))
if(len(cross_coupling) == 0): continue
coupling_strength = np.zeros(len(cross_coupling))
i_inds, j_inds = np.where(np.abs(Z - cross_coupling[0])<1e-6)
local_i = i_inds[0]
local_j = j_inds[0]
for k in range(len(cross_coupling)):
coupling_strength[k] = cross_coupling[k] \
/np.abs(Z[local_i,local_i] - Z[local_j,local_j])
local_i += 1
local_j += 1
plt.plot(coupling_strength * OM *1e6,'--')