ONV 0.0.1__tar.gz

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.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: ONV
3
+ Version: 0.0.1
4
+ Summary: Package for general NV based simulations
5
+ Author: Oliver Whaites
6
+ Author-email: o.whaites@btinternet.com
7
+ Keywords: NV
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 2
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+
15
+ A basic package of functions which are commonly used in the simuitons of NV centers fro quantum computing and NMR sensing
@@ -0,0 +1,13 @@
1
+ setup_ONV.py
2
+ ONV.egg-info/PKG-INFO
3
+ ONV.egg-info/SOURCES.txt
4
+ ONV.egg-info/dependency_links.txt
5
+ ONV.egg-info/top_level.txt
6
+ cce/CCE.py
7
+ cce/PCE.py
8
+ cce/__init__.py
9
+ nv/__init__.py
10
+ nv/nv.py
11
+ nv/p1.py
12
+ tools/__init__.py
13
+ tools/plot_tools.py
@@ -0,0 +1,3 @@
1
+ cce
2
+ nv
3
+ tools
onv-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.1
2
+ Name: ONV
3
+ Version: 0.0.1
4
+ Summary: Package for general NV based simulations
5
+ Author: Oliver Whaites
6
+ Author-email: o.whaites@btinternet.com
7
+ Keywords: NV
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 2
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+
15
+ A basic package of functions which are commonly used in the simuitons of NV centers fro quantum computing and NMR sensing
onv-0.0.1/cce/CCE.py ADDED
@@ -0,0 +1,305 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Created on Fri Sep 2 15:32:37 2022
5
+
6
+ @author: ollywhaites
7
+ """
8
+
9
+ """
10
+ import modules
11
+ """
12
+ from sys import path
13
+
14
+ path.append('/Users/ollywhaites/Documents/Documents/PhD/Python/Libraries')
15
+
16
+ import NV_Library as nv
17
+ import pandas as pd
18
+ import numpy as np
19
+ import math
20
+
21
+ from tqdm import tqdm
22
+
23
+ from os import path
24
+
25
+ """
26
+ define functions
27
+ """
28
+
29
+ def CCE0(spins,couplings,ts,params = nv.params(),pbar = True,NV_state = 'Xp',measure = 'x',NV_sub = '-'):
30
+
31
+ """
32
+ A program which finds PCE for a bath of spins and coupled to the NV.
33
+
34
+ Parameters
35
+ ----------
36
+ spins: list of a spin numbers which exist in bath and couplings data frame
37
+ couplings: dataframe of couplings Ax, Az for each spin in bath
38
+ params: dict of parameters needed for the simulations. default
39
+ = nv.params() which is constructed in NV_Library library
40
+ pbar: bool determines whether progressbar is needed. defualt =
41
+ True
42
+
43
+
44
+ Returns:
45
+ --------
46
+ done_df: dataframe of spins which have been constructed
47
+ """
48
+
49
+ Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Extend_coherence/CCE/{}/data/'.format(params['protocol'])
50
+
51
+
52
+ params['N_nuc'] = 0
53
+ operators, params = nv.generate_operators([], [], params, NV_state = NV_state,NV_sub=NV_sub)
54
+
55
+ operators = nv.generate_full_H0(operators,
56
+ couplings.loc[[]],
57
+ params = params,
58
+ CC_coupling = False)
59
+
60
+ L0 = [];
61
+ for t in ts:
62
+
63
+ params['tau'] = t
64
+ params['t_ev'] = t
65
+
66
+ Ltemp, rho = nv.pulse_NV(operators,params, inst = False,measure = measure)
67
+ L0.append(Ltemp.real)
68
+
69
+ sub_sys = []
70
+ CCE0 = pd.DataFrame(L0,columns = ['coherence'],index = ts)
71
+ sub_sys.sort()
72
+
73
+ filename_CCE = 'CCE0.csv'
74
+ CCE0.to_csv(Dir + filename_CCE)
75
+
76
+
77
+
78
+ def CCE1(spins,couplings,ts,params = nv.params(),pbar = True,NV_state = 'Xp',measure = 'x',NV_sub = '-',cluster = 'test'):
79
+
80
+ """
81
+ A program which finds PCE for a bath of spins and coupled to the NV.
82
+
83
+ Parameters
84
+ ----------
85
+ spins: list of a spin numbers which exist in bath and couplings data frame
86
+ couplings: dataframe of couplings Ax, Az for each spin in bath
87
+ params: dict of parameters needed for the simulations. default
88
+ = nv.params() which is constructed in NV_Library library
89
+ pbar: bool determines whether progressbar is needed. defualt =
90
+ True
91
+
92
+
93
+ Returns:
94
+ --------
95
+ done_df: dataframe of spins which have been constructed
96
+ """
97
+
98
+ params['N_nuc'] = 1
99
+ operators, params = nv.generate_operators([0], [0], params, NV_state = NV_state,NV_sub = NV_sub)
100
+
101
+
102
+ Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Extend_coherence/CCE/{}/{}_data/1_spin/'.format(params['protocol'],cluster)
103
+
104
+
105
+ # PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
106
+
107
+ filename = 'done.csv'
108
+
109
+
110
+ if path.exists(Dir + filename):
111
+ done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
112
+
113
+ else: done = []
114
+ done = []
115
+
116
+
117
+ if pbar == True:
118
+
119
+ for s in tqdm(spins,desc = 'CCE1',position = 0):
120
+
121
+
122
+ lst = [s];
123
+ if lst not in done:
124
+
125
+
126
+ operators = nv.generate_full_H0(operators,
127
+ couplings.loc[[s]],
128
+ params = params,
129
+ CC_coupling = False)
130
+ L1 = [];
131
+ for t in ts:
132
+
133
+ params['tau'] = t
134
+ params['t_ev'] = t
135
+
136
+ Ltemp, rho = nv.pulse_NV(operators,params,measure=measure)
137
+ L1.append(Ltemp.real)
138
+
139
+
140
+
141
+ # PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
142
+ sub_sys = [s]
143
+ CCE1 = pd.DataFrame(L1,columns = ['coherence'],index = ts)
144
+ sub_sys.sort()
145
+
146
+ filename_CCE = 'C{}.csv'.format(sub_sys[0])
147
+ CCE1.to_csv(Dir + filename_CCE)
148
+
149
+ done.append(lst);
150
+
151
+ else:
152
+
153
+ for s in spins:
154
+
155
+ lst = [s];
156
+
157
+
158
+ if lst not in done:
159
+ operators = nv.generate_full_H0(operators,
160
+ couplings.loc[[s]],
161
+ params = params,
162
+ CC_coupling = False)
163
+
164
+
165
+
166
+ L1 = [];
167
+ for t in ts:
168
+
169
+ params['tau'] = t
170
+ params['t_ev'] = t
171
+
172
+ Ltemp, rho = nv.pulse_NV(operators,params,measure = measure)
173
+ L1.append(Ltemp)
174
+
175
+
176
+
177
+ # PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
178
+ sub_sys = [s]
179
+ CCE1 = pd.DataFrame(L1,columns = ['coherence'],index = ts)
180
+ sub_sys.sort()
181
+
182
+ filename_CCE = 'C{}.csv'.format(sub_sys[0])
183
+ CCE1.to_csv(Dir + filename_CCE)
184
+
185
+ done.append(lst);
186
+
187
+ done_df = pd.DataFrame(done)
188
+ done_df.to_csv(Dir + filename)
189
+
190
+ return done_df
191
+
192
+
193
+ def CCE2(spins,couplings,ts,params = nv.params(),pbar = True, NV_state = 'Xp',measure = 'x',NV_sub = '-',cluster = 'test',CC_coupling = True):
194
+
195
+ """
196
+ A program which finds PCE for a bath of spins and coupled to the NV.
197
+
198
+ Parameters
199
+ ----------
200
+ spins: list of a spin numbers which exist in bath and couplings data frame
201
+ couplings: dataframe of couplings Ax, Az for each spin in bath
202
+ params: dict of parameters needed for the simulations. default
203
+ = nv.params() which is constructed in NV_Library library
204
+ pbar: bool determines whether progressbar is needed. defualt =
205
+ True
206
+
207
+
208
+ Returns:
209
+ --------
210
+ done_df: dataframe of spins which have been constructed
211
+ """
212
+
213
+ params['N_nuc'] = 2
214
+ operators, params = nv.generate_operators([0,0], [0,0], params, NV_state = NV_state,NV_sub = NV_sub)
215
+
216
+
217
+ Dir = '/Users/ollywhaites/Documents/Documents/PhD/Python/Extend_coherence/CCE/{}/{}_data/2_spin/'.format(params['protocol'],cluster)
218
+
219
+
220
+ # PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
221
+
222
+ filename = 'done.csv'
223
+
224
+
225
+ if path.exists(Dir + filename):
226
+ done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
227
+
228
+ else: done = []
229
+ done = []
230
+
231
+
232
+ if pbar == True:
233
+
234
+ for s in tqdm(spins,desc = 'CCE2',position = 0):
235
+ for m in spins:
236
+
237
+ lst = [s,m];
238
+ lst.sort()
239
+ if (lst not in done) & (m != s) & (couplings['C{}'.format(m)].loc[s] >= 0.5):
240
+
241
+
242
+ operators = nv.generate_full_H0(operators,
243
+ couplings.loc[[s,m]],
244
+ params = params,
245
+ CC_coupling = CC_coupling)
246
+ L2 = [];
247
+ for t in ts:
248
+
249
+ params['tau'] = t
250
+ params['t_ev'] = t
251
+
252
+ Ltemp, rho = nv.pulse_NV(operators,params,measure = measure)
253
+ L2.append(Ltemp.real)
254
+
255
+
256
+
257
+ # PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
258
+ sub_sys = [s,m]
259
+ CCE2 = pd.DataFrame(L2,columns = ['coherence'],index = ts)
260
+ sub_sys.sort()
261
+
262
+ filename_CCE = 'C{}_C{}.csv'.format(sub_sys[0],sub_sys[1])
263
+ CCE2.to_csv(Dir + filename_CCE)
264
+
265
+ done.append(lst);
266
+
267
+ else:
268
+
269
+ for s in spins:
270
+ for m in spins:
271
+
272
+ lst = [s,m];
273
+ lst.sort()
274
+ if (lst not in done) & (m != s) & (couplings['C{}'.format(m)].loc[s] >= 0.5):
275
+
276
+
277
+ operators = nv.generate_full_H0(operators,
278
+ couplings.loc[[s,m]],
279
+ params = params,
280
+ CC_coupling = CC_coupling)
281
+ L2 = [];
282
+ for t in ts:
283
+
284
+ params['tau'] = t
285
+ params['t_ev'] = t
286
+
287
+ Ltemp, rho = nv.pulse_NV(operators,params,measure = measure)
288
+ L2.append(Ltemp.real)
289
+
290
+
291
+
292
+ # PCE4['P4_%d_%d_%d'%(s,p,q)] = np.array(P4)
293
+ sub_sys = [s,m]
294
+ CCE2 = pd.DataFrame(L2,columns = ['coherence'],index = ts)
295
+ sub_sys.sort()
296
+
297
+ filename_CCE = 'C{}_C{}.csv'.format(sub_sys[0],sub_sys[1])
298
+ CCE2.to_csv(Dir + filename_CCE)
299
+
300
+ done.append(lst);
301
+
302
+ done_df = pd.DataFrame(done)
303
+ done_df.to_csv(Dir + filename)
304
+
305
+ return done_df