ONV 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ONV-0.0.1.dist-info/METADATA +15 -0
- ONV-0.0.1.dist-info/RECORD +12 -0
- ONV-0.0.1.dist-info/WHEEL +5 -0
- ONV-0.0.1.dist-info/top_level.txt +3 -0
- cce/CCE.py +305 -0
- cce/PCE.py +632 -0
- cce/__init__.py +3 -0
- nv/__init__.py +10 -0
- nv/nv.py +2091 -0
- nv/p1.py +175 -0
- tools/__init__.py +1 -0
- tools/plot_tools.py +136 -0
cce/PCE.py
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Created on Thu Aug 18 17:59:20 2022
|
|
5
|
+
|
|
6
|
+
@author: ollywhaites
|
|
7
|
+
"""
|
|
8
|
+
import sys
|
|
9
|
+
sys.path.insert(1,'/Users/ollywhaites/Documents/Documents/PhD/Python/Libraries')
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import pandas as pd
|
|
13
|
+
import NV_Library as nv
|
|
14
|
+
from tqdm import tqdm
|
|
15
|
+
|
|
16
|
+
from os import path
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
libraries functions
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def PCE2(spins,centre_spin,couplings,taus,params = nv.params(),pbar = True,avg = False,CC_coupling = False,dataset = ''):
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
A program which finds PCE for a bath of spins and coupled to the NV.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
spins: list of a spin numbers which exist in bath and couplings data frame
|
|
31
|
+
centre_spin: int of PCE spin of interest
|
|
32
|
+
couplings: dataframe of couplings Ax, Az for each spin in bath
|
|
33
|
+
taus: array of taus for tau sweep
|
|
34
|
+
params: dict of parameters needed for the simulations. default
|
|
35
|
+
= nv.params() which is constructed in NV_Library library
|
|
36
|
+
pbar: bool determines whether progressbar is needed. defualt =
|
|
37
|
+
True
|
|
38
|
+
avg: bool for whether a t_wait average is needed
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
--------
|
|
43
|
+
done_df: dataframe of spins which have been constructed
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
params['N_nuc'] = 2
|
|
47
|
+
operators, params = nv.generate_operators([0,0], [0,0], params)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Polarise_bath/PCE/data/%s_data/2_spin/'%dataset
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
|
|
54
|
+
if avg == True:
|
|
55
|
+
filename = 'done_wait.csv'
|
|
56
|
+
else: filename = 'done.csv'
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if path.exists(Dir + filename):
|
|
60
|
+
done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
|
|
61
|
+
else:
|
|
62
|
+
done = []
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if pbar == True:
|
|
68
|
+
|
|
69
|
+
for s in tqdm(spins,desc = 'PCE2, Spin {}: '.format(centre_spin),position = 0):
|
|
70
|
+
|
|
71
|
+
if s != centre_spin:
|
|
72
|
+
|
|
73
|
+
lst = [centre_spin,s];
|
|
74
|
+
lst.sort()
|
|
75
|
+
print(lst)
|
|
76
|
+
lst.append(params['Reps'])
|
|
77
|
+
lst.append(params['Np'])
|
|
78
|
+
if avg == True:
|
|
79
|
+
lst.append(params['num_avg'])
|
|
80
|
+
|
|
81
|
+
lst.append(CC_coupling)
|
|
82
|
+
if lst not in done:
|
|
83
|
+
# operators = nv.generate_H0(operators,
|
|
84
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s]],
|
|
85
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s]],
|
|
86
|
+
# params)
|
|
87
|
+
operators = nv.generate_full_H0(operators,
|
|
88
|
+
couplings = couplings.loc[[centre_spin,s]],
|
|
89
|
+
params = params,
|
|
90
|
+
CC_coupling = CC_coupling)
|
|
91
|
+
|
|
92
|
+
P2 = []
|
|
93
|
+
for t in taus:
|
|
94
|
+
params['tau'] = t;
|
|
95
|
+
|
|
96
|
+
if avg == True:
|
|
97
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
98
|
+
else:
|
|
99
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
100
|
+
|
|
101
|
+
P2.append(np.array(Ptemp).T[-1])
|
|
102
|
+
|
|
103
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
104
|
+
sub_sys = [centre_spin,s]
|
|
105
|
+
PCE2_all = pd.DataFrame(P2,columns = sub_sys,index = taus*1e6)
|
|
106
|
+
sub_sys.sort()
|
|
107
|
+
|
|
108
|
+
filename_PCE = '{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],params['Reps'],params['Np'])
|
|
109
|
+
|
|
110
|
+
if avg == True:
|
|
111
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
112
|
+
if CC_coupling == True:
|
|
113
|
+
filename_PCE = filename_PCE + '_full'
|
|
114
|
+
filename_PCE = filename_PCE + '.csv'
|
|
115
|
+
|
|
116
|
+
PCE2_all.to_csv(Dir + filename_PCE)
|
|
117
|
+
|
|
118
|
+
done.append(lst);
|
|
119
|
+
|
|
120
|
+
else:
|
|
121
|
+
|
|
122
|
+
for s in spins:
|
|
123
|
+
|
|
124
|
+
if s != centre_spin:
|
|
125
|
+
|
|
126
|
+
lst = [centre_spin,s];
|
|
127
|
+
lst.sort()
|
|
128
|
+
print(lst)
|
|
129
|
+
lst.append(params['Reps'])
|
|
130
|
+
lst.append(params['Np'])
|
|
131
|
+
if avg == True:
|
|
132
|
+
lst.append(params['num_avg'])
|
|
133
|
+
|
|
134
|
+
lst.append(CC_coupling)
|
|
135
|
+
if lst not in done:
|
|
136
|
+
# operators = nv.generate_H0(operators,
|
|
137
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s]],
|
|
138
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s]],
|
|
139
|
+
# params)
|
|
140
|
+
operators = nv.generate_full_H0(operators,
|
|
141
|
+
couplings = couplings.loc[[centre_spin,s]],
|
|
142
|
+
params = params,
|
|
143
|
+
CC_coupling = CC_coupling)
|
|
144
|
+
P2 = []
|
|
145
|
+
for t in taus:
|
|
146
|
+
params['tau'] = t;
|
|
147
|
+
if avg == True:
|
|
148
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
149
|
+
else:
|
|
150
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
151
|
+
P2.append(np.array(Ptemp).T[-1])
|
|
152
|
+
|
|
153
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
154
|
+
sub_sys = [centre_spin,s]
|
|
155
|
+
PCE2_all = pd.DataFrame(P2,columns = sub_sys,index = taus*1e6)
|
|
156
|
+
sub_sys.sort()
|
|
157
|
+
|
|
158
|
+
filename_PCE = '{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],params['Reps'],params['Np'])
|
|
159
|
+
|
|
160
|
+
if avg == True:
|
|
161
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
162
|
+
if CC_coupling == True:
|
|
163
|
+
filename_PCE = filename_PCE + '_full'
|
|
164
|
+
filename_PCE = filename_PCE + '.csv'
|
|
165
|
+
|
|
166
|
+
PCE2_all.to_csv(Dir + filename_PCE)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
done.append(lst);
|
|
170
|
+
columns = ['s1','s2','Reps','Np']
|
|
171
|
+
if avg == True:
|
|
172
|
+
columns.append('num_avg')
|
|
173
|
+
|
|
174
|
+
columns.append('full')
|
|
175
|
+
|
|
176
|
+
done_df = pd.DataFrame(done,columns = columns)
|
|
177
|
+
done_df.to_csv(Dir + filename)
|
|
178
|
+
|
|
179
|
+
return done_df
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def PCE3(spins,centre_spin,couplings,taus,params = nv.params(),pbar = True,avg = False,CC_coupling = False,dataset = ''):
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
A program which finds PCE for a bath of spins and coupled to the NV.
|
|
188
|
+
|
|
189
|
+
Parameters
|
|
190
|
+
----------
|
|
191
|
+
spins: list of a spin numbers which exist in bath and couplings data frame
|
|
192
|
+
centre_spin: int of PCE spin of interest
|
|
193
|
+
couplings: dataframe of couplings Ax, Az for each spin in bath
|
|
194
|
+
taus: array of taus for tau sweep
|
|
195
|
+
params: dict of parameters needed for the simulations. default
|
|
196
|
+
= nv.params() which is constructed in NV_Library library
|
|
197
|
+
pbar: bool determines whether progressbar is needed. defualt =
|
|
198
|
+
True
|
|
199
|
+
avg: bool for whether a t_wait average is needed
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
--------
|
|
204
|
+
done_df: dataframe of spins which have been constructed
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
params['N_nuc'] = 3
|
|
208
|
+
operators, params = nv.generate_operators([0,0,0], [0,0,0], params)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Polarise_bath/PCE/data/%s_data/3_spin/'%dataset
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
# PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
|
|
215
|
+
if avg == True:
|
|
216
|
+
filename = 'done_wait.csv'
|
|
217
|
+
else: filename = 'done.csv'
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
if path.exists(Dir + filename):
|
|
221
|
+
done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
|
|
222
|
+
|
|
223
|
+
else: done = []
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
if pbar == True:
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
for s in tqdm(spins,desc = 'PCE3, Spin {}: '.format(centre_spin),position = 0):
|
|
231
|
+
if s != centre_spin:
|
|
232
|
+
for p in tqdm(spins,desc = '2nd Spin {}: '.format(s),position = 1):
|
|
233
|
+
lst = [centre_spin,s,p];
|
|
234
|
+
lst.sort()
|
|
235
|
+
lst.append(params['Reps'])
|
|
236
|
+
lst.append(params['Np'])
|
|
237
|
+
if avg == True:
|
|
238
|
+
lst.append(params['num_avg'])
|
|
239
|
+
|
|
240
|
+
lst.append(CC_coupling)
|
|
241
|
+
|
|
242
|
+
if p != centre_spin and p != s and lst not in done:
|
|
243
|
+
# operators = nv.generate_H0(operators,
|
|
244
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p]],
|
|
245
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p]],
|
|
246
|
+
# params)
|
|
247
|
+
operators = nv.generate_full_H0(operators,
|
|
248
|
+
couplings = couplings.loc[[centre_spin,s,p]],
|
|
249
|
+
params = params,
|
|
250
|
+
CC_coupling = CC_coupling)
|
|
251
|
+
P3 = []
|
|
252
|
+
for t in taus:
|
|
253
|
+
params['tau'] = t;
|
|
254
|
+
if avg == True:
|
|
255
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
256
|
+
else:
|
|
257
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
258
|
+
P3.append(np.array(Ptemp).T[-1])
|
|
259
|
+
|
|
260
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
261
|
+
sub_sys = [centre_spin,s,p]
|
|
262
|
+
|
|
263
|
+
PCE3_all = pd.DataFrame(P3,columns = sub_sys,index = taus*1e6)
|
|
264
|
+
sub_sys.sort()
|
|
265
|
+
|
|
266
|
+
filename_PCE = '{}_C{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],params['Reps'],params['Np'])
|
|
267
|
+
|
|
268
|
+
if avg == True:
|
|
269
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
270
|
+
if CC_coupling == True:
|
|
271
|
+
filename_PCE = filename_PCE + '_full'
|
|
272
|
+
filename_PCE = filename_PCE + '.csv'
|
|
273
|
+
PCE3_all.to_csv(Dir + filename_PCE)
|
|
274
|
+
|
|
275
|
+
done.append(lst);
|
|
276
|
+
|
|
277
|
+
else:
|
|
278
|
+
|
|
279
|
+
for s in spins:
|
|
280
|
+
if s != centre_spin:
|
|
281
|
+
for p in spins:
|
|
282
|
+
lst = [centre_spin,s,p];
|
|
283
|
+
lst.sort()
|
|
284
|
+
lst.append(params['Reps'])
|
|
285
|
+
lst.append(params['Np'])
|
|
286
|
+
if avg == True:
|
|
287
|
+
lst.append(params['num_avg'])
|
|
288
|
+
|
|
289
|
+
lst.append(CC_coupling)
|
|
290
|
+
|
|
291
|
+
if p != centre_spin and p != s and lst not in done:
|
|
292
|
+
# operators = nv.generate_H0(operators,
|
|
293
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p]],
|
|
294
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p]],
|
|
295
|
+
# params)
|
|
296
|
+
operators = nv.generate_full_H0(operators,
|
|
297
|
+
couplings = couplings.loc[[centre_spin,s,p]],
|
|
298
|
+
params = params,
|
|
299
|
+
CC_coupling = CC_coupling)
|
|
300
|
+
|
|
301
|
+
P3 = []
|
|
302
|
+
for t in taus:
|
|
303
|
+
params['tau'] = t;
|
|
304
|
+
if avg == True:
|
|
305
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
306
|
+
else:
|
|
307
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
308
|
+
P3.append(np.array(Ptemp).T[-1])
|
|
309
|
+
|
|
310
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
311
|
+
sub_sys = [centre_spin,s,p]
|
|
312
|
+
|
|
313
|
+
PCE3_all = pd.DataFrame(P3,columns = sub_sys,index = taus*1e6)
|
|
314
|
+
sub_sys.sort()
|
|
315
|
+
|
|
316
|
+
filename_PCE = '{}_C{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],params['Reps'],params['Np'])
|
|
317
|
+
|
|
318
|
+
if avg == True:
|
|
319
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
320
|
+
if CC_coupling == True:
|
|
321
|
+
filename_PCE = filename_PCE + '_full'
|
|
322
|
+
filename_PCE = filename_PCE + '.csv'
|
|
323
|
+
PCE3_all.to_csv(Dir + filename_PCE)
|
|
324
|
+
|
|
325
|
+
done.append(lst);
|
|
326
|
+
|
|
327
|
+
columns = ['s1','s2','s3','Reps','Np']
|
|
328
|
+
if avg == True:
|
|
329
|
+
columns.append('num_avg')
|
|
330
|
+
|
|
331
|
+
columns.append('full')
|
|
332
|
+
|
|
333
|
+
done_df = pd.DataFrame(done,columns = columns)
|
|
334
|
+
done_df.to_csv(Dir + filename)
|
|
335
|
+
|
|
336
|
+
return done_df
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def PCE4(spins,centre_spin,couplings,taus,params = nv.params(),pbar = True,avg = False,CC_coupling = False,dataset = ''):
|
|
340
|
+
|
|
341
|
+
"""
|
|
342
|
+
A program which finds PCE 4for a bath of spins and coupled to the NV.
|
|
343
|
+
|
|
344
|
+
Parameters
|
|
345
|
+
----------
|
|
346
|
+
spins: list of a spin numbers which exist in bath and couplings data frame
|
|
347
|
+
centre_spin: int of PCE spin of interest
|
|
348
|
+
couplings: dataframe of couplings Ax, Az for each spin in bath
|
|
349
|
+
taus: array of taus for tau sweep
|
|
350
|
+
params: dict of parameters needed for the simulations. default
|
|
351
|
+
= nv.params() which is constructed in NV_Library library
|
|
352
|
+
pbar: bool determines whether progressbar is needed. defualt =
|
|
353
|
+
True
|
|
354
|
+
avg: bool for whether a t_wait average is needed
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
Returns:
|
|
358
|
+
--------
|
|
359
|
+
done_df: dataframe of spins which have been constructed
|
|
360
|
+
"""
|
|
361
|
+
|
|
362
|
+
params['N_nuc'] = 4
|
|
363
|
+
operators, params = nv.generate_operators([0,0,0,0], [0,0,0,0], params)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Polarise_bath/PCE/data/%s_data/4_spin/'%dataset
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
# PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
|
|
370
|
+
if avg == True:
|
|
371
|
+
filename = 'done_wait.csv'
|
|
372
|
+
else: filename = 'done.csv'
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
if path.exists(Dir + filename):
|
|
376
|
+
done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
|
|
377
|
+
|
|
378
|
+
else: done = []
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
if pbar == True:
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
for s in tqdm(spins,desc = 'PCE4, Spin {}: '.format(centre_spin),position = 0):
|
|
386
|
+
if s != centre_spin:
|
|
387
|
+
for p in tqdm(spins,desc = '2nd Spin {}: '.format(s),position = 1):
|
|
388
|
+
if p != centre_spin and p != s:
|
|
389
|
+
for q in tqdm(spins,desc = '3rd Spin {}: '.format(p),position = 2):
|
|
390
|
+
lst = [centre_spin,s,p,q];
|
|
391
|
+
lst.sort()
|
|
392
|
+
lst.append(params['Reps'])
|
|
393
|
+
lst.append(params['Np'])
|
|
394
|
+
if avg == True:
|
|
395
|
+
lst.append(params['num_avg'])
|
|
396
|
+
|
|
397
|
+
lst.append(CC_coupling)
|
|
398
|
+
if q != centre_spin and q != s and q != p and lst not in done:
|
|
399
|
+
# operators = nv.generate_H0(operators,
|
|
400
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p],couplings['Az'].loc[q]],
|
|
401
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p],couplings['Ax'].loc[q]],
|
|
402
|
+
# params)
|
|
403
|
+
operators = nv.generate_full_H0(operators,
|
|
404
|
+
couplings = couplings.loc[[centre_spin,s,p,q]],
|
|
405
|
+
params = params,
|
|
406
|
+
CC_coupling = CC_coupling)
|
|
407
|
+
|
|
408
|
+
P4 = []
|
|
409
|
+
for t in taus:
|
|
410
|
+
params['tau'] = t;
|
|
411
|
+
if avg == True:
|
|
412
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
413
|
+
else:
|
|
414
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
415
|
+
P4.append(np.array(Ptemp).T[-1])
|
|
416
|
+
|
|
417
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
418
|
+
sub_sys = [centre_spin,s,p,q]
|
|
419
|
+
|
|
420
|
+
PCE4_all = pd.DataFrame(P4,columns = sub_sys,index = taus*1e6)
|
|
421
|
+
sub_sys.sort()
|
|
422
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],params['Reps'],params['Np'])
|
|
423
|
+
|
|
424
|
+
if avg == True:
|
|
425
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
426
|
+
if CC_coupling == True:
|
|
427
|
+
filename_PCE = filename_PCE + '_full'
|
|
428
|
+
filename_PCE = filename_PCE + '.csv'
|
|
429
|
+
PCE4_all.to_csv(Dir + filename_PCE)
|
|
430
|
+
|
|
431
|
+
done.append(lst);
|
|
432
|
+
|
|
433
|
+
else:
|
|
434
|
+
|
|
435
|
+
for s in spins:
|
|
436
|
+
if s != centre_spin:
|
|
437
|
+
for p in tqdm(spins,desc = '2nd Spin {}: '.format(s),position = 1):
|
|
438
|
+
if p != centre_spin and p != s:
|
|
439
|
+
for q in tqdm(spins,desc = '3rd Spin {}: '.format(p),position = 2):
|
|
440
|
+
lst = [centre_spin,s,p,q];
|
|
441
|
+
lst.sort()
|
|
442
|
+
lst.append(params['Reps'])
|
|
443
|
+
lst.append(params['Np'])
|
|
444
|
+
if avg == True:
|
|
445
|
+
lst.append(params['num_avg'])
|
|
446
|
+
|
|
447
|
+
lst.append(CC_coupling)
|
|
448
|
+
if q != centre_spin and q != s and q != p and lst not in done:
|
|
449
|
+
# operators = nv.generate_H0(operators,
|
|
450
|
+
# [couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p],couplings['Az'].loc[q]],
|
|
451
|
+
# [couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p],couplings['Ax'].loc[q]],
|
|
452
|
+
# params)
|
|
453
|
+
operators = nv.generate_full_H0(operators,
|
|
454
|
+
couplings = couplings.loc[[centre_spin,s,p,q]],
|
|
455
|
+
params = params,
|
|
456
|
+
CC_coupling = CC_coupling)
|
|
457
|
+
P4 = []
|
|
458
|
+
for t in taus:
|
|
459
|
+
params['tau'] = t;
|
|
460
|
+
if avg == True:
|
|
461
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
462
|
+
else:
|
|
463
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
464
|
+
P4.append(np.array(Ptemp).T[-1])
|
|
465
|
+
|
|
466
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
467
|
+
sub_sys = [centre_spin,s,p,q]
|
|
468
|
+
|
|
469
|
+
PCE4_all = pd.DataFrame(P4,columns = sub_sys,index = taus*1e6)
|
|
470
|
+
sub_sys.sort()
|
|
471
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_R{}_Np{}'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],params['Reps'],params['Np'])
|
|
472
|
+
|
|
473
|
+
if avg == True:
|
|
474
|
+
filename_PCE = filename_PCE + '_wait{}'.format(params['num_avg'])
|
|
475
|
+
if CC_coupling == True:
|
|
476
|
+
filename_PCE = filename_PCE + '_full'
|
|
477
|
+
filename_PCE = filename_PCE + '.csv'
|
|
478
|
+
PCE4_all.to_csv(Dir + filename_PCE)
|
|
479
|
+
|
|
480
|
+
done.append(lst);
|
|
481
|
+
|
|
482
|
+
columns = ['s1','s2','s3','s4','Reps','Np']
|
|
483
|
+
if avg == True:
|
|
484
|
+
columns.append('num_avg')
|
|
485
|
+
|
|
486
|
+
columns.append('full')
|
|
487
|
+
|
|
488
|
+
done_df = pd.DataFrame(done,columns = columns)
|
|
489
|
+
done_df.to_csv(Dir + filename)
|
|
490
|
+
|
|
491
|
+
return done_df
|
|
492
|
+
|
|
493
|
+
def PCE5(spins,centre_spin,couplings,taus,params = nv.params(),pbar = True,avg = False):
|
|
494
|
+
|
|
495
|
+
"""
|
|
496
|
+
A program which finds PCE 4for a bath of spins and coupled to the NV.
|
|
497
|
+
|
|
498
|
+
Parameters
|
|
499
|
+
----------
|
|
500
|
+
spins: list of a spin numbers which exist in bath and couplings data frame
|
|
501
|
+
centre_spin: int of PCE spin of interest
|
|
502
|
+
couplings: dataframe of couplings Ax, Az for each spin in bath
|
|
503
|
+
taus: array of taus for tau sweep
|
|
504
|
+
params: dict of parameters needed for the simulations. default
|
|
505
|
+
= nv.params() which is constructed in NV_Library library
|
|
506
|
+
pbar: bool determines whether progressbar is needed. defualt =
|
|
507
|
+
True
|
|
508
|
+
avg: bool for whether a t_wait average is needed
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
Returns:
|
|
512
|
+
--------
|
|
513
|
+
done_df: dataframe of spins which have been constructed
|
|
514
|
+
"""
|
|
515
|
+
|
|
516
|
+
params['N_nuc'] = 5
|
|
517
|
+
operators, params = nv.generate_operators([0,0,0,0,0], [0,0,0,0,0], params)
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Polarise_bath/PCE/data/toy_data/5_spin/'
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
# PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
|
|
524
|
+
if avg == True:
|
|
525
|
+
filename = 'done_wait.csv'
|
|
526
|
+
else: filename = 'done.csv'
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
if path.exists(Dir + filename):
|
|
530
|
+
done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
|
|
531
|
+
|
|
532
|
+
else: done = []
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
if pbar == True:
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
for s in tqdm(spins,desc = 'PCE5, Spin {}: '.format(centre_spin),position = 0):
|
|
540
|
+
if s != centre_spin:
|
|
541
|
+
for p in tqdm(spins,desc = '2nd Spin {}: '.format(s),position = 1):
|
|
542
|
+
if p != centre_spin and p != s:
|
|
543
|
+
for q in tqdm(spins,desc = '3nd Spin {}: '.format(p),position = 1):
|
|
544
|
+
if q != centre_spin and q != s and q != p:
|
|
545
|
+
for r in tqdm(spins,desc = '4rd Spin {}: '.format(q),position = 2):
|
|
546
|
+
lst = [centre_spin,s,p,q,r];
|
|
547
|
+
lst.sort()
|
|
548
|
+
lst.append(params['Reps'])
|
|
549
|
+
if avg == True:
|
|
550
|
+
lst.append(params['num_avg'])
|
|
551
|
+
if r != centre_spin and r != s and r != p and r != q and lst not in done:
|
|
552
|
+
operators = nv.generate_H0(operators,
|
|
553
|
+
[couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p],couplings['Az'].loc[q],couplings['Az'].loc[r]],
|
|
554
|
+
[couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p],couplings['Ax'].loc[q],couplings['Ax'].loc[r]],
|
|
555
|
+
params)
|
|
556
|
+
P5 = []
|
|
557
|
+
for t in taus:
|
|
558
|
+
params['tau'] = t;
|
|
559
|
+
if avg == True:
|
|
560
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
561
|
+
else:
|
|
562
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
563
|
+
P5.append(np.array(Ptemp).T[-1])
|
|
564
|
+
|
|
565
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
566
|
+
sub_sys = [centre_spin,s,p,q,r]
|
|
567
|
+
|
|
568
|
+
PCE5_all = pd.DataFrame(P5,columns = sub_sys,index = taus*1e6)
|
|
569
|
+
sub_sys.sort()
|
|
570
|
+
if avg == True:
|
|
571
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_C{}_R{}_Np{}_wait{}.csv'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],sub_sys[4],params['Reps'],params['Np'],params['num_avg'])
|
|
572
|
+
else:
|
|
573
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_C{}_R{}_Np{}.csv'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],sub_sys[4],params['Reps'],params['Np'])
|
|
574
|
+
PCE5_all.to_csv(Dir + filename_PCE)
|
|
575
|
+
|
|
576
|
+
done.append(lst);
|
|
577
|
+
|
|
578
|
+
else:
|
|
579
|
+
|
|
580
|
+
for s in spins:
|
|
581
|
+
if s != centre_spin:
|
|
582
|
+
for p in tqdm(spins,desc = '2nd Spin {}: '.format(s),position = 1):
|
|
583
|
+
if p != centre_spin and p != s:
|
|
584
|
+
for q in tqdm(spins,desc = '3nd Spin {}: '.format(p),position = 1):
|
|
585
|
+
if q != centre_spin and q != s and q != p:
|
|
586
|
+
for r in tqdm(spins,desc = '4rd Spin {}: '.format(q),position = 2):
|
|
587
|
+
lst = [centre_spin,s,p,q,r];
|
|
588
|
+
lst.sort()
|
|
589
|
+
lst.append(params['Reps'])
|
|
590
|
+
if avg == True:
|
|
591
|
+
lst.append(params['num_avg'])
|
|
592
|
+
if r != centre_spin and r != s and r != p and r != q and lst not in done:
|
|
593
|
+
operators = nv.generate_H0(operators,
|
|
594
|
+
[couplings['Az'].loc[centre_spin],couplings['Az'].loc[s],couplings['Az'].loc[p],couplings['Az'].loc[q],couplings['Az'].loc[r]],
|
|
595
|
+
[couplings['Ax'].loc[centre_spin],couplings['Ax'].loc[s],couplings['Ax'].loc[p],couplings['Ax'].loc[q],couplings['Ax'].loc[r]],
|
|
596
|
+
params)
|
|
597
|
+
P5 = []
|
|
598
|
+
for t in taus:
|
|
599
|
+
params['tau'] = t;
|
|
600
|
+
if avg == True:
|
|
601
|
+
rho,Ptemp = nv.D_pol_avg(operators,params,pbar = False)
|
|
602
|
+
else:
|
|
603
|
+
rho,Ptemp = nv.D_pol(operators,params,pbar = False)
|
|
604
|
+
P5.append(np.array(Ptemp).T[-1])
|
|
605
|
+
|
|
606
|
+
# PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
|
|
607
|
+
sub_sys = [centre_spin,s,p,q,r]
|
|
608
|
+
|
|
609
|
+
PCE5_all = pd.DataFrame(P5,columns = sub_sys,index = taus*1e6)
|
|
610
|
+
sub_sys.sort()
|
|
611
|
+
if avg == True:
|
|
612
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_C{}_R{}_Np{}_wait{}.csv'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],sub_sys[4],params['Reps'],params['Np'],params['num_avg'])
|
|
613
|
+
else:
|
|
614
|
+
filename_PCE = '{}_C{}_C{}_C{}_C{}_C{}_R{}_Np{}.csv'.format(params['protocol'],sub_sys[0],sub_sys[1],sub_sys[2],sub_sys[3],sub_sys[4],params['Reps'],params['Np'])
|
|
615
|
+
PCE5_all.to_csv(Dir + filename_PCE)
|
|
616
|
+
|
|
617
|
+
done.append(lst);
|
|
618
|
+
|
|
619
|
+
columns = ['s1','s2','s3','s4','Reps']
|
|
620
|
+
if avg == True:
|
|
621
|
+
columns.append('num_avg')
|
|
622
|
+
|
|
623
|
+
done_df = pd.DataFrame(done,columns = columns)
|
|
624
|
+
done_df.to_csv(Dir + filename)
|
|
625
|
+
|
|
626
|
+
return done_df
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
cce/__init__.py
ADDED
nv/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from nv import params, plot_params, generate_operators, add_N14
|
|
2
|
+
from nv import generate_H0, generate_full_H0
|
|
3
|
+
from nv import pulse_nv, hyperpol, hyperpol_avg
|
|
4
|
+
from nv import plot_D_pol, plot_D_pol_N
|
|
5
|
+
from nv import floquet_spectrum
|
|
6
|
+
from nv import nv_generator
|
|
7
|
+
|
|
8
|
+
from p1 import construct_H0, LG, LG4, find_U
|
|
9
|
+
|
|
10
|
+
|