ONV 1.0.1__tar.gz → 1.0.4__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ONV
3
- Version: 1.0.1
3
+ Version: 1.0.4
4
4
  Summary: Package for general NV based simulations
5
5
  Author: Oliver Whaites
6
6
  Author-email: o.whaites@btinternet.com
@@ -11,5 +11,11 @@ Classifier: Programming Language :: Python :: 2
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Operating System :: MacOS :: MacOS X
13
13
  Classifier: Operating System :: Microsoft :: Windows
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: keywords
19
+ Dynamic: summary
14
20
 
15
- A basic package of functions which are commonly used in the simuitons of NV centers fro quantum computing and NMR sensing
21
+ A basic package of functions which are commonly used in the simuitons of NV centers from quantum computing and NMR
@@ -1,4 +1,4 @@
1
- setup_ONV.py
1
+ setup.py
2
2
  ONV.egg-info/PKG-INFO
3
3
  ONV.egg-info/SOURCES.txt
4
4
  ONV.egg-info/dependency_links.txt
@@ -6,6 +6,8 @@ ONV.egg-info/top_level.txt
6
6
  cce/CCE.py
7
7
  cce/PCE.py
8
8
  cce/__init__.py
9
+ nmr/__init__.py
10
+ nmr/nmr.py
9
11
  nv/__init__.py
10
12
  nv/nv.py
11
13
  p1/__init__.py
@@ -1,4 +1,5 @@
1
1
  cce
2
+ nmr
2
3
  nv
3
4
  p1
4
5
  tools
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ONV
3
- Version: 1.0.1
3
+ Version: 1.0.4
4
4
  Summary: Package for general NV based simulations
5
5
  Author: Oliver Whaites
6
6
  Author-email: o.whaites@btinternet.com
@@ -11,5 +11,11 @@ Classifier: Programming Language :: Python :: 2
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Operating System :: MacOS :: MacOS X
13
13
  Classifier: Operating System :: Microsoft :: Windows
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: keywords
19
+ Dynamic: summary
14
20
 
15
- A basic package of functions which are commonly used in the simuitons of NV centers fro quantum computing and NMR sensing
21
+ A basic package of functions which are commonly used in the simuitons of NV centers from quantum computing and NMR
@@ -99,7 +99,7 @@ def CCE1(spins,couplings,ts,params = nv.params(),pbar = True,NV_state = 'Xp',mea
99
99
  operators, params = nv.generate_operators([0], [0],params = params, NV_state = NV_state,NV_sub = NV_sub)
100
100
 
101
101
 
102
- Dir += '{}_data/1_spin/'.format(cluster)
102
+ Dir = '{}_data/1_spin/'.format(cluster)
103
103
 
104
104
 
105
105
  # PCE4 = pd.DataFrame(columns = ['P3'], index = taus*1e6)
@@ -108,7 +108,7 @@ def CCE1(spins,couplings,ts,params = nv.params(),pbar = True,NV_state = 'Xp',mea
108
108
 
109
109
 
110
110
  if path.exists(Dir + filename):
111
- done = pd.read_csv(Dir + filename,index_col = 0).values.tolist()
111
+ done = pd.read_csv(Dir + filename,index_col = 0)['0'].values.tolist()
112
112
 
113
113
  else: done = []
114
114
  done = []
@@ -0,0 +1 @@
1
+ from .nmr import nv_bubble
onv-1.0.4/nmr/nmr.py ADDED
@@ -0,0 +1,320 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Created on Mon Jul 15 15:07:41 2024
5
+
6
+ @author: ollywhaites
7
+ """
8
+ from sys import path
9
+ path.append('/Users/ollywhaites/Documents/Documents/PhD/Python/Libraries/')
10
+
11
+ import numpy as np
12
+ import NV_Library as nv
13
+ import qutip
14
+
15
+ import matplotlib.pyplot as plt
16
+
17
+
18
+
19
+ options = qutip.solver.Options()
20
+ options.store_states = True
21
+
22
+ """
23
+
24
+ """
25
+
26
+
27
+
28
+ class nv_bubble:
29
+
30
+
31
+
32
+ def __init__(self,seed,d = 7e-9,rho = 670,b = 7.7e-9,species = 'H',params = nv.params(),alpha = np.radians(45)):
33
+
34
+ np.random.seed(seed)
35
+
36
+ N = int(4*rho*(b*1e9)**3)
37
+ #N = 1
38
+
39
+ X = b*(-1 + 2*np.random.random(N))
40
+ Y = b*(-1 + 2*np.random.random(N))
41
+ Z = d + b*np.random.random(N)
42
+
43
+
44
+ A = [nv.hyperfine(nv.y_rotation(np.array([x,y,z]),alpha),params = params,species = species) for x,y,z in zip(X,Y,Z)]
45
+
46
+ phi = 2*np.pi*np.random.random(N)
47
+ theta = np.arccos(2*np.random.random(N) - 1)
48
+ #theta = 2*np.random.random(N)
49
+
50
+ self.positions = np.array([Z,Y,Z]).T
51
+ self.coupings = A
52
+ self.states = np.array([theta,phi]).T
53
+ self.spins = N
54
+
55
+ self.depth = d
56
+ self.ppm = rho
57
+ self.species = species
58
+ self.bubble_radius = b
59
+ self.params = params
60
+ self.nv_angle = alpha
61
+
62
+ np.random.seed(None)
63
+
64
+ def find_classical(self):
65
+
66
+ params = self.params
67
+ species = self.species
68
+
69
+ x = self.positions.T[0]
70
+ y = self.positions.T[1]
71
+ z = self.positions.T[2]
72
+
73
+ theta = self.states.T[0]
74
+
75
+ r = np.sqrt(x**2 + y**2 + z**2)
76
+
77
+ a0 = 3*params['mu_red']*params['gamma_%s'%species]*params['h']*np.cos(theta)*(3*z*z - r**2)/(4*np.pi*r**5)
78
+ a = abs(3*params['mu_red']*params['gamma_%s'%species]*params['h']*np.sin(theta)*np.sqrt((z*x)**2 + (z*y)**2)/(4*np.pi*r**5))
79
+ phi1 = np.arctan2(y,x)
80
+
81
+ self.class_field = np.array([a0,a,phi1]).T
82
+ self.find_mag()
83
+
84
+
85
+ def find_mag(self):
86
+
87
+ class_field = self.class_field
88
+ a0 = class_field.T[0]
89
+ a = class_field.T[1]
90
+ phi = class_field.T[2]
91
+
92
+ mag_theta = np.arctan(a.sum()/a0.sum())
93
+ B = np.sqrt(a.sum()**2 + a0.sum()**2)
94
+
95
+ self.mag_theta = mag_theta
96
+ self.B = B
97
+ self.mag_phi = phi.sum()
98
+
99
+
100
+
101
+ def plot_xy(self,b,d,params,species,fig,ax):
102
+
103
+
104
+ X = np.linspace(-b,b,100)
105
+ Y = np.linspace(-b,b,100)
106
+ Z = d
107
+
108
+ x,y = np.meshgrid(X,Y)
109
+ AXY = []
110
+ for x1,y1 in zip(x,y):
111
+ AXYtemp = []
112
+ for x2,y2 in zip(x1,y1):
113
+
114
+ xn,yn,zn = nv.y_rotation(np.array([x2,y2,Z]), self.nv_angle,passive = True)
115
+
116
+ #xn,yn,zn = np.meshgrid(Xn,Yn,Zn)
117
+ r = np.sqrt(xn**2 + yn**2 + zn**2)
118
+
119
+
120
+ aXY = abs(3*params['mu_red']*params['gamma_%s'%species]*params['h']/(4*np.pi*r**5)*np.sqrt((zn*xn)**2 + (zn*yn)**2))
121
+ AXYtemp.append(aXY)
122
+
123
+ AXY.append(AXYtemp)
124
+
125
+ ax.contourf(x*1e9,y*1e9,np.array(AXY))
126
+
127
+ ax.set_ylabel('y (nm)',fontsize = 12)
128
+ ax.set_xlabel('x (nm)',fontsize = 12)
129
+
130
+ def plot_xz(self,b,d,params,species,fig,ax):
131
+
132
+ X = np.linspace(-b,b,100)
133
+ Y = 0
134
+ Z = np.linspace(d,d + b,100)
135
+
136
+ x,z = np.meshgrid(X,Z)
137
+ AXZ = []
138
+ for x1,z1 in zip(x,z):
139
+ AXZtemp = []
140
+ for x2,z2 in zip(x1,z1):
141
+
142
+ xn,yn,zn = nv.y_rotation(np.array([x2,Y,z2]), self.nv_angle,passive = True)
143
+
144
+ #xn,yn,zn = np.meshgrid(Xn,Yn,Zn)
145
+ r = np.sqrt(xn**2 + yn**2 + zn**2)
146
+
147
+
148
+ aXZ = abs(3*params['mu_red']*params['gamma_%s'%species]*params['h']/(4*np.pi*r**5)*np.sqrt((zn*xn)**2 + (zn*yn)**2))
149
+ AXZtemp.append(aXZ)
150
+
151
+ AXZ.append(AXZtemp)
152
+
153
+ ax.contourf(x*1e9,z*1e9,np.array(AXZ))
154
+
155
+ B = self.B
156
+ theta = self.mag_theta
157
+
158
+ vec = [np.sin(theta),0,np.cos(theta)]
159
+ vecNew = nv.y_rotation(np.array(vec), -self.nv_angle,passive = True)
160
+
161
+ #ax.plot([b/2,b*vecNew[0]/4],[d + b/2,d + b/2 + b*vecNew[2]/4],color = 'k')
162
+ ax.arrow(0, d*1e9 + b*1e9/2, vecNew[0]*(B/(self.spins*1e-10))*(b*1e9/4),vecNew[2]*(B/(self.spins*1e-10))*(b*1e9/4),
163
+ head_width=b*1e9/70,
164
+ length_includes_head=True,
165
+ head_length=b*1e9/70,
166
+ color = 'w',
167
+ lw = 3)
168
+
169
+ ax.text(0, d*1e9 + b*1e9/2,r'$\mathbf{M}$',fontsize = 12,color = 'w',va = 'top')
170
+
171
+ ax.set_ylabel('z (nm)',fontsize = 12)
172
+ ax.set_xlabel('x (nm)',fontsize = 12)
173
+
174
+ def plot_bubble(self):
175
+
176
+ b = self.bubble_radius
177
+ d = self.depth
178
+
179
+ params = self.params
180
+ species = self.species
181
+
182
+ fig,axes = plt.subplots(1,2,figsize = [9,4],dpi = 200)
183
+
184
+ self.plot_xy(b,d,params,species,fig,axes[0])
185
+ self.plot_xz(b,d,params,species,fig,axes[1])
186
+
187
+
188
+
189
+
190
+
191
+ def generate_bubble(d = 7e-9,rho = 670,b = 7.7e-9,species = 'H',params = nv.params(),ts = np.linspace(0,5e-6,100)):
192
+
193
+
194
+
195
+ N = 4*rho*(b*1e9)**3
196
+
197
+ x = -b + 2*b*np.random.random(int(N))
198
+ y = -b + 2*b*np.random.random(int(N))
199
+ z = d + b*np.random.random(int(N))
200
+
201
+
202
+ r = np.sqrt(x**2 + y**2 + z**2)
203
+
204
+ a = abs(3*params['mu_red']*params['gamma_%s'%species]*params['h']/(4*np.pi*r**5)*np.sqrt((z*x)**2 + (z*y)**2))
205
+ phi1 = np.arctan2(y,x)
206
+
207
+ phi = 2*np.pi*np.random.random(int(N))
208
+ theta = np.arccos(2*np.random.random(int(N)) - 1)
209
+
210
+ omegaL = 2*np.pi*params['B0']*params['gamma_%s'%species]
211
+
212
+ B = 0
213
+ B2 = 0
214
+ for ai,t,p,p1 in zip(a,theta,phi,phi1):
215
+ B += ai*np.sin(t)*np.cos(omegaL*ts + (p - p1))
216
+ B2 += ai*np.sin(t)*np.cos(omegaL*ts - (p + p1))
217
+
218
+ return B, B2
219
+
220
+
221
+
222
+ def generate_mag_bubble(b_rms = 4e-9,species = 'H',params = nv.params(),seed_b = None,seed_theta = None,seed_phi = None):
223
+
224
+ np.random.seed(seed_phi)
225
+ phi = 2*np.pi*np.random.random()
226
+
227
+ np.random.seed(seed_theta)
228
+ theta = np.arccos(2*np.random.random() - 1)
229
+
230
+ np.random.seed(seed_b)
231
+ #b = np.random.normal(0,b_rms)
232
+ b = 500e-9
233
+
234
+
235
+ return b,theta,phi
236
+
237
+
238
+ def hahn(operators,args,H,t_lim = [0,2e-6],s = 200):
239
+
240
+
241
+ t0 = t_lim[0]
242
+ tf = t_lim[1]
243
+
244
+ UY = (-1j*np.pi*operators['Sy']/2).expm()
245
+ UX = (-1j*np.pi*operators['Sx']/2).expm()
246
+
247
+ rho = UY*operators['rho']*UY.dag()
248
+
249
+
250
+ output = qutip.mesolve(H,rho,np.linspace(t0,(t0 + tf)/2,s),e_ops = [operators['Sx']],args = args,options = options)
251
+ rho = output.states[-1]
252
+
253
+ rho = (UY*UY)*rho*(UY*UY).dag()
254
+
255
+ #args['phi'] = phi0 + args['nu']
256
+ output = qutip.mesolve(H,rho,np.linspace((t0 + tf)/2,tf,s),e_ops = [operators['Sx']],args = args,options = options)
257
+ rho = output.states[-1]
258
+
259
+ #args['phi'] = phi0 + 2*args['nu']*tau
260
+
261
+ rho = UX*rho*UX.dag()
262
+
263
+ coh = (rho*operators['Sz']).tr()
264
+
265
+ return coh, rho
266
+
267
+ def hahn_test(operators,args,H0,M,tau,s = 100):
268
+
269
+
270
+ dt = tau/s
271
+
272
+ UY = (-1j*np.pi*operators['Sy']/2).expm()
273
+ UX = (-1j*np.pi*operators['Sx']/2).expm()
274
+
275
+ rho = UY*operators['rho']*UY.dag()
276
+
277
+ rho,M = evolve(H0,M,rho,dt,s, args)
278
+
279
+ rho = (UY*UY)*rho*(UY*UY).dag()
280
+
281
+ #args['phi'] = phi0 + args['nu']
282
+ rho,M = evolve(H0,M,rho,dt,s, args)
283
+
284
+ #args['phi'] = phi0 + 2*args['nu']*tau
285
+
286
+ rho = UX*rho*UX.dag()
287
+
288
+
289
+ return rho, M
290
+
291
+
292
+ def class_field(M,args):
293
+
294
+ return M[0]
295
+
296
+
297
+
298
+ def evolve(H0,M,rho,dt,N, args):
299
+
300
+ #evolve state
301
+ for n in range(N):
302
+
303
+ U0 = (-1j*class_field(M,args)*H0*dt).expm()
304
+
305
+ rho = U0*rho*U0.dag()
306
+
307
+ M = nv.xy_rotation(M,args['Omega']*dt,args['phase'])
308
+ M = nv.z_rotation(M,args['nu']*dt)
309
+
310
+
311
+ return rho, M
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
@@ -70,6 +70,7 @@ def params():
70
70
  params['Omega'] = np.pi/params['Tp']
71
71
  params['tau'] = 0#the wait time of the pulse protocol
72
72
  params['t_ev'] = 0
73
+ params['tau_offset'] = 0
73
74
  params['delta'] = 0#any pulse error introduced
74
75
  params['protocol'] = 'CPMG'
75
76
  params['pulse_profile'] = 'inst'
@@ -180,6 +181,7 @@ def xy_rotation(vec,theta,phase):
180
181
  [uz*ux*(1 - c) - uy*s,uz*uy*(1 - c) + ux*s,c + uz**2*(1 - c)]])
181
182
 
182
183
  return R.dot(vec)
184
+
183
185
 
184
186
  # a function which changes the basis of the lattice coordinates to one in line with NV-axis
185
187
  def change_basis(vec):
@@ -238,12 +240,13 @@ def hyperfine(r,params = params(),species = 'C'):
238
240
 
239
241
 
240
242
  #returns the density matrix for a qubit up state
241
- def rhoU():
243
+ def rhoU(params = params(), species = 'C'):
244
+
242
245
 
243
246
  return qutip.Qobj([[1,0],[0,0]]);
244
247
 
245
248
  #returns the density matrix for a qubit down state
246
- def rhoD():
249
+ def rhoD(params = params(), species = 'C'):
247
250
 
248
251
  return qutip.Qobj([[0,0],[0,1]]);
249
252
 
@@ -263,6 +266,8 @@ def rhoT(params = params(), species = 'C'):
263
266
  s = species_spin[species]
264
267
 
265
268
  r =(-(params['h']*params[f'gamma_{species}']*params['B0']*Iz(s))/(2*np.pi*params['k_B']*params['Temp'])).expm();
269
+
270
+ r = qutip.identity(s)
266
271
 
267
272
  return r/r.tr()
268
273
  #returns the density matrix for a qubit in a thermal state
@@ -500,7 +505,8 @@ def generate_operators(Az, Ax,species = None, params = params(), NV_state = 'up'
500
505
 
501
506
  NV_dict = {'-':qubit_Szm(),
502
507
  '+':qubit_Szp(),
503
- '+-':qubit_Szm() + qubit_Szp()}
508
+ '+-':qubit_Szm() + qubit_Szp(),
509
+ '1/2':(1/2)*qutip.Qobj([[1,0],[0,-1]])}
504
510
 
505
511
  dict_operators = {}
506
512
  #compute the number of nuclei in the system
@@ -574,7 +580,8 @@ def generate_operators(Az, Ax,species = None, params = params(), NV_state = 'up'
574
580
 
575
581
  dict_operators['H0'] = H0;
576
582
 
577
-
583
+ dict_operators['UX'] = (-1j*dict_operators['Sx']*np.pi).expm()
584
+ dict_operators['UY'] = (-1j*dict_operators['Sy']*np.pi).expm()
578
585
 
579
586
  return dict_operators,params
580
587
 
@@ -618,13 +625,14 @@ def add_N14(operators,params,couplings,TN = 3):
618
625
 
619
626
  params['N_nuc'] += 1
620
627
 
621
- r0 = qutip.Qobj([[1,0,0],[0,1,0],[0,0,1]])
628
+ r0 = qutip.Qobj([[1,0,0],[0,0,0],[0,0,0]])
622
629
  #r0 = (-state_3_Sz()/TN).expm()
630
+ #r0 = rhoT(params = params, species = '14N')
623
631
 
624
632
 
625
633
  operators['rho0'] = qutip.tensor(operators['rho0'],r0/r0.tr())
626
634
 
627
- Az = -2*np.pi*2.164689e6
635
+ Az = -2*np.pi*2.162e6
628
636
  Ax = -2*np.pi*2.632e6
629
637
 
630
638
  omega = np.sqrt((params['B0']*2*np.pi*params['gamma_N'] + Az/2)**2 + (Ax/2)**2)
@@ -634,7 +642,7 @@ def add_N14(operators,params,couplings,TN = 3):
634
642
  # 'Az': Az,
635
643
  # 'omega': omega},ignore_index = True)
636
644
 
637
- couplings = pd.concat([couplings, pd.DataFrame([{'Species': 'N',
645
+ couplings = pd.concat([couplings, pd.DataFrame([{'Species': '14N',
638
646
  'Ax': Ax,
639
647
  'Az': Az,
640
648
  'omega': omega}],index = [0])],ignore_index = True)
@@ -687,7 +695,7 @@ def generate_H0(operators,couplings,params):
687
695
 
688
696
  operators['H0'] = H0;
689
697
 
690
-
698
+
691
699
 
692
700
  return operators
693
701
 
@@ -785,8 +793,11 @@ def inst_pulse(operators,params,rot = np.pi):
785
793
  Omega = (abs(rot + delta))/Tp
786
794
 
787
795
 
788
- UX = (-1j*(np.sign(rot)*Omega*operators['Sx'])*Tp).expm();
789
- UY = (-1j*(np.sign(rot)*Omega*operators['Sy'])*Tp).expm();
796
+ #UX = (-1j*(np.sign(rot)*Omega*operators['Sx'])*Tp).expm();
797
+ #UY = (-1j*(np.sign(rot)*Omega*operators['Sy'])*Tp).expm();
798
+
799
+ UX = operators['UX']
800
+ UY = operators['UY']
790
801
 
791
802
  return UX, UY
792
803
 
@@ -1073,7 +1084,7 @@ def CPMG(operators, params,measure):
1073
1084
  tau = params['tau'];
1074
1085
  profile = params['pulse_profile']
1075
1086
 
1076
- params['t_ev'] = tau/2
1087
+ params['t_ev'] = tau
1077
1088
 
1078
1089
  if params['decoherence'] == False:
1079
1090
 
@@ -1100,6 +1111,75 @@ def CPMG(operators, params,measure):
1100
1111
 
1101
1112
  else: raise Exception('Invalid value for params["decoherence"]. Must be bool not {params["decoherence"]}.')
1102
1113
 
1114
+
1115
+ # a function which takes a free evolution operator and pulse operators and returns a packet of CPMG. Note that UX must be a pi/2 pulse
1116
+ def Hahn(operators, params,measure):
1117
+
1118
+ """
1119
+ a function which constructs the pulse packet for a Hahn sequence using free evolution
1120
+ and pi/2 pulses. pulse errors, delta, may be included as Tp = (np.pi + delta)/2.
1121
+ Hahn sequence here is U0*UX*U0
1122
+
1123
+ Parameters
1124
+ ----------
1125
+
1126
+ operators: a dict of operators for the system which can be retrieved using the
1127
+ generate operators function
1128
+ params: dict of system parameters which define the protocol. Can be found
1129
+ using the params() function
1130
+ inst: bool to determine whether pulses are instantaneous. Default is False
1131
+
1132
+
1133
+ returns
1134
+ -------
1135
+
1136
+ U: Qobj for the CPMG pulse packet
1137
+ """
1138
+
1139
+ tau = params['tau'];
1140
+ dtau = params['tau_offset']
1141
+ profile = params['pulse_profile']
1142
+
1143
+ params['t_ev'] = tau
1144
+
1145
+ if params['decoherence'] == False:
1146
+
1147
+ if dtau == 0:
1148
+ U0 = (-1j*operators['H0']*params['t_ev']).expm();
1149
+
1150
+
1151
+ UX, UY = pulse_profiles[profile](operators,params,rot = np.pi)
1152
+
1153
+
1154
+ U = (U0*UX*U0)**params['Np']
1155
+
1156
+ rho = U*operators['rho0']*U.dag();
1157
+
1158
+ coh = (operators['S%s'%measure]*rho).tr().real
1159
+
1160
+ else:
1161
+ U01 = (-1j*operators['H0']*(params['t_ev'] + dtau)).expm();
1162
+ U02 = (-1j*operators['H0']*(params['t_ev'] - dtau)).expm();
1163
+
1164
+
1165
+ UX, UY = pulse_profiles[profile](operators,params,rot = np.pi)
1166
+
1167
+
1168
+ U = (U02*UX*U01)**params['Np']
1169
+
1170
+ rho = U*operators['rho0']*U.dag();
1171
+
1172
+ coh = (operators['S%s'%measure]*rho).tr().real
1173
+
1174
+
1175
+ return coh,rho, U
1176
+
1177
+ elif params['decoherence'] == False:
1178
+ raise Exception('Decoherence has not been initialised with this pulse protocol.')
1179
+
1180
+
1181
+
1182
+ else: raise Exception('Invalid value for params["decoherence"]. Must be bool not {params["decoherence"]}.')
1103
1183
 
1104
1184
 
1105
1185
  # a function which takes a free evolution operator and pulse operators and returns a packet of CPMG. Note that UX must be a pi/2 pulse
@@ -1130,7 +1210,7 @@ def spin_locking(operators, params,measure):
1130
1210
  tau = params['tau'];
1131
1211
 
1132
1212
 
1133
- params['t_ev'] = tau/2
1213
+ params['t_ev'] = tau
1134
1214
 
1135
1215
 
1136
1216
  if params['decoherence'] == False:
@@ -1467,7 +1547,8 @@ def pulse_NV(operators,params,measure = 'x'):
1467
1547
  'Free':Free,
1468
1548
  'spin_locking':spin_locking,
1469
1549
  'Ramsey': Ramsey,
1470
- 'PMC': PMC};
1550
+ 'PMC': PMC,
1551
+ 'Hahn':Hahn};
1471
1552
 
1472
1553
 
1473
1554
 
@@ -1888,7 +1969,7 @@ def plot_D_pol_N(P_df,fig_size = [7,4],fig = None, ax = None, plot_avg = True,ti
1888
1969
  FLOQUET
1889
1970
  """
1890
1971
 
1891
- def floquet_spectrum(operators,params,taus, bound = 1,tan2 = False,inst = True):
1972
+ def floquet_spectrum(operators,params,species,taus, bound = 1,tan2 = False):
1892
1973
 
1893
1974
  """
1894
1975
  A function which takes the free Hamiltonian of a system and a partiuclar pulse
@@ -1914,34 +1995,40 @@ def floquet_spectrum(operators,params,taus, bound = 1,tan2 = False,inst = True):
1914
1995
  N_nuc = params['N_nuc'];
1915
1996
  protocol = params['protocol']
1916
1997
 
1998
+ if species == None:
1999
+ species = []
2000
+ for i in range(params['N_nuc']):
2001
+ species.append('C')
2002
+ print(species)
2003
+ species.insert(0, 'NV')
1917
2004
 
1918
2005
  ''' find the unperturbed starting floquet states '''
1919
2006
  params['tau'] = 1e-9;
1920
2007
 
1921
- U_ini = protocols_dict[protocol](operators,params,inst);
2008
+ _,_,U_ini = protocols_dict[protocol](operators,params,measure = 'z');
1922
2009
  lbda, vecOld = U_ini.eigenstates(sort = 'low');
1923
2010
 
1924
-
2011
+ space_size = np.array([species_spin[s] for s in species])
1925
2012
 
1926
2013
 
1927
2014
  ''' initialise arrays '''
1928
2015
  E = []
1929
2016
  Vec = []
1930
2017
  wind = [];
1931
- for i in range(2**(N_nuc + 1)):
2018
+ for i in range(space_size.prod()):
1932
2019
 
1933
2020
  E.append([]);
1934
2021
  Vec.append([])
1935
2022
  wind.append(0);
1936
2023
 
1937
2024
  ''' run through tau array and find all floquet phases and states '''
1938
- for j in pb.progressbar(range(len(taus))):
2025
+ for j in tqdm(range(len(taus))):
1939
2026
 
1940
2027
  states = []
1941
2028
  params['tau'] = taus[j]
1942
2029
 
1943
2030
 
1944
- U = protocols_dict[protocol](operators,params,inst);
2031
+ _,_,U = protocols_dict[protocol](operators,params,measure = 'z');
1945
2032
 
1946
2033
  lbda,vectemp = U.eigenstates(sort = 'low');
1947
2034
 
@@ -1997,7 +2084,7 @@ def floquet_spectrum(operators,params,taus, bound = 1,tan2 = False,inst = True):
1997
2084
  vecNew[states[n]] = vectemp[n]
1998
2085
  vecOld = vecNew;
1999
2086
 
2000
- return E,Vec
2087
+ return E,Vec
2001
2088
 
2002
2089
 
2003
2090
 
@@ -80,25 +80,32 @@ def construct_H0(operators,params,spins,bath,Tin):
80
80
  if Tin == True:
81
81
  AN = find_axisCoup(Adiag,axis = bath.loc[i]['JT_axis'].iloc[1])[2]
82
82
 
83
- Hi += (params['D']*operators['Iz'][2*k + 0] + 2*np.pi*params['gamma_e']*params['B0']*operators['Iz'][2*k + 0] + 2*np.pi*params['gamma_N']*params['B0']*operators['Iz'][2*k + 1]
84
- + (AN[2]*operators['Iz'][2*k + 1] + AN[0]*operators['Ix'][2*k + 1] + AN[1]*operators['Iy'][2*k + 1])*operators['Iz'][2*k + 0]
83
+ Hi += (params['D']*operators['Iz'][2*k + 0] + 0*2*np.pi*params['gamma_N']*params['B0']*operators['Iz'][2*k + 1]
84
+ + 0*(AN[2]*operators['Iz'][2*k + 1] + AN[0]*operators['Ix'][2*k + 1] + AN[1]*operators['Iy'][2*k + 1])*operators['Iz'][2*k + 0]
85
85
  #+ tensor_prod(operators,2*k + 1,2*k + 1,PN)
86
86
  + 2*np.pi*1e3*(bath.loc[i]['Az'].iloc[1]*operators['Iz'][2*k + 0])*operators['Sz']
87
87
  + params['Omega_RF']*(np.sin(params['RF_phase'])*operators['Ix'][2*k + 0] + np.cos(params['RF_phase'])*operators['Iy'][2*k + 0])
88
- + params['Omega_N']*(np.sin(params['N_phase'])*operators['Ix'][2*k + 1] + np.cos(params['N_phase'])*operators['Iy'][2*k + 1]))
89
-
88
+ #+ params['Omega_N']*(np.sin(params['N_phase'])*operators['Ix'][2*k + 1] + np.cos(params['N_phase'])*operators['Iy'][2*k + 1]))
89
+ )
90
90
  elif Tin == False:
91
- AN = find_axisCoup(Adiag,axis = bath.loc[i]['JT_axis'].iloc[1])
91
+ #AN = find_axisCoup(Adiag,axis = bath.loc[i]['JT_axis'].iloc[1])
92
+ AN = find_axisCoup(Adiag,axis = bath.loc[i]['JT_axis'].iloc[1])[2]
92
93
 
93
94
  Hi += (2*np.pi*params['gamma_e']*params['B0']*operators['Iz'][2*k + 0] + 2*np.pi*params['gamma_N']*params['B0']*operators['Iz'][2*k + 1]
94
- + tensor_prod(operators,2*k + 0,2*k + 1,AN)
95
- #+ (AN[2]*operators['Iz'][2*k + 1] + AN[0]*operators['Ix'][2*k + 1] + AN[1]*operators['Iy'][2*k + 1])*operators['Iz'][2*k + 0]
96
- + tensor_prod(operators,2*k + 1,2*k + 1,PN)
95
+ + (AN[2]*operators['Iz'][2*k + 1] + AN[0]*operators['Ix'][2*k + 1] + AN[1]*operators['Iy'][2*k + 1])*operators['Iz'][2*k + 0]
96
+ #+ tensor_prod(operators,2*k + 1,2*k + 1,PN)
97
97
  + 2*np.pi*1e3*(bath.loc[i]['Az'].iloc[1]*operators['Iz'][2*k + 0])*operators['Sz']
98
- #+ 2*np.pi*1e3*(bath.loc[i]['Az'].iloc[1]*operators['Iz'][2*k + 0] + bath.loc[i]['Ax'].iloc[1]*operators['Ix'][2*k + 0] + bath.loc[i]['Ay'].iloc[1]*operators['Iy'][2*k + 0])*operators['Sz']
99
- #+ 2*params['Omega']*(np.sin(params['omega_RF']*params['t'] - params['RF_phase'])*operators['Ix'][2*k + 0]))
100
98
  )
101
99
 
100
+ # Hi += (2*np.pi*params['gamma_e']*params['B0']*operators['Iz'][2*k + 0] + 2*np.pi*params['gamma_N']*params['B0']*operators['Iz'][2*k + 1]
101
+ # + tensor_prod(operators,2*k + 0,2*k + 1,AN)
102
+ # #+ (AN[2]*operators['Iz'][2*k + 1] + AN[0]*operators['Ix'][2*k + 1] + AN[1]*operators['Iy'][2*k + 1])*operators['Iz'][2*k + 0]
103
+ # + tensor_prod(operators,2*k + 1,2*k + 1,PN)
104
+ # + 2*np.pi*1e3*(bath.loc[i]['Az'].iloc[1]*operators['Iz'][2*k + 0])*operators['Sz']
105
+ # #+ 2*np.pi*1e3*(bath.loc[i]['Az'].iloc[1]*operators['Iz'][2*k + 0] + bath.loc[i]['Ax'].iloc[1]*operators['Ix'][2*k + 0] + bath.loc[i]['Ay'].iloc[1]*operators['Iy'][2*k + 0])*operators['Sz']
106
+ # #+ 2*params['Omega']*(np.sin(params['omega_RF']*params['t'] - params['RF_phase'])*operators['Ix'][2*k + 0]))
107
+ # )
108
+
102
109
 
103
110
  for j in spins[k + 1:]:
104
111
 
@@ -108,6 +115,8 @@ def construct_H0(operators,params,spins,bath,Tin):
108
115
 
109
116
 
110
117
  Cij = 2*np.pi*nv.cc_coupling(r1,r2,params = params,species = 'e')
118
+ #Cij = 2*np.pi*2e6
119
+
111
120
 
112
121
  Hij += Cij*(operators['Iz'][2*k + 0]*operators['Iz'][2*k + 2] - (1/2)*(operators['Ix'][2*k + 0]*operators['Ix'][2*k + 2] + operators['Iy'][2*k + 0]*operators['Iy'][2*k + 2]))
113
122
 
@@ -162,47 +171,47 @@ def LG4(operators,params,bath,spins,Tin):
162
171
  def LG(operators,params,bath,spins,Tin):
163
172
 
164
173
  operators,params = construct_H0(operators,params,spins,bath,Tin)
165
- rho,coh, U = nv.pulse_NV(operators,params,measure = 'x',)
174
+ coh,rho, U = nv.pulse_NV(operators,params,measure = 'x',)
166
175
 
167
- return U
176
+ return U,rho,coh
168
177
 
169
178
  def LG_pulse(operators,params,bath,spins,Tin):
170
179
 
171
- D = params['D']
172
180
  OmRF = params['Omega_RF']
173
- OmN = params['Omega_N']
174
- Om = params['Omega']
175
- alpha = params['RF_phase']
181
+ protocol = params['protocol']
176
182
  t_ev = params['t_ev']
183
+ shift = params['Tp_RF'] if protocol == 'Hahn' else 0
177
184
 
178
185
 
179
- params['D'] = 0
180
- params['Omega_RF'] = OmRF
181
- params['Omega_N'] = 0
182
- params['RF_phase'] = alpha
183
-
186
+
187
+ params['Omega_RF'] = 0
188
+ params['t_ev'] = t_ev + shift/2
184
189
 
190
+ params['tau_offset'] = shift/2
191
+
185
192
  operators,params = construct_H0(operators,params,spins,bath,Tin)
186
- _,_, U0 = nv.pulse_NV(operators,params,measure = 'x',)
193
+ _,_, U01 = nv.pulse_NV(operators,params,measure = 'x',)
187
194
 
195
+ params['tau_offset'] = -shift/2
196
+
197
+ operators,params = construct_H0(operators,params,spins,bath,Tin)
198
+ _,_, U02 = nv.pulse_NV(operators,params,measure = 'x',)
188
199
 
189
- params['D'] = 0
190
- params['Omega_RF'] = 0
191
- params['Omega_N'] = OmN
192
- params['Omega'] = 0
193
- params['RF_phase'] = alpha + np.pi/2
194
200
 
201
+
202
+ params['Omega_RF'] = OmRF
203
+ params['protocol'] = 'Free'
195
204
  params['t_ev'] = params['Tp_RF']
196
- params['t_ev'] = np.pi/params['Omega_N'] if params['Omega_N'] != 0 else 0
205
+
197
206
 
198
207
  operators,params = construct_H0(operators,params,spins,bath,Tin)
199
208
  _,_, UX = nv.pulse_NV(operators,params,measure = 'x',)
200
209
 
201
- params['Omega'] = Om
202
- params['RF_phase'] = alpha
210
+ params['protocol'] = protocol
203
211
  params['t_ev'] = t_ev
212
+ params['tau_offset'] = 0
204
213
 
205
- return U0*UX*U0
214
+ return U02*UX*U01
206
215
 
207
216
  RF_protocols = {'LG': LG,
208
217
  'LG4': LG4,
@@ -210,6 +219,6 @@ RF_protocols = {'LG': LG,
210
219
 
211
220
  def find_U(operators,params,bath,spins,Tin):
212
221
 
213
- U = RF_protocols[params['RF_protocol']](operators,params,bath,spins,Tin)
222
+ U, rho, coh = RF_protocols[params['RF_protocol']](operators,params,bath,spins,Tin)
214
223
 
215
- return U
224
+ return U, rho, 2*coh
@@ -1,8 +1,8 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.4'
4
4
  DESCRIPTION = 'Package for general NV based simulations'
5
- LONG_DESCRIPTION = 'A basic package of functions which are commonly used in the simuitons of NV centers fro quantum computing and NMR sensing'
5
+ LONG_DESCRIPTION = 'A basic package of functions which are commonly used in the simuitons of NV centers from quantum computing and NMR'
6
6
 
7
7
  setup(
8
8
  name = 'ONV',
@@ -12,6 +12,7 @@ setup(
12
12
  description = DESCRIPTION,
13
13
  long_description = LONG_DESCRIPTION,
14
14
  packages = find_packages(),
15
+ py_modules=['nv','cce','p1','nmr','tools'],
15
16
  install_requires = [],
16
17
 
17
18
  keywords = ['NV'],
@@ -0,0 +1 @@
1
+ from .plot_tools import add_arrow, add_text, colorline, make_segments
@@ -1 +0,0 @@
1
- from plot_tools import add_arrow, add_text, colorline, make_segments
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes