Skip to content

Commit af80b85

Browse files
committed
revise the DRAG
1 parent ede9d52 commit af80b85

8 files changed

Lines changed: 178 additions & 141 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

QuSim/.DS_Store

6 KB
Binary file not shown.

QuSim/DataPlot/plot_lib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ def plot_pulse_sequence(pulse_sequence, simulation_option):
2020
q_index_list.append(pulse["q_index"])
2121
# waveform_y = [drive_pulse(t, None) for t in t_list]
2222
waveform_y = drive_pulse
23+
2324
# Rescale the pulses by factor 1/1.2
24-
for i in range(len(t_list)):
25-
if waveform_y[i] != None and pulse_amp != 0:
26-
waveform_y[i] /= np.abs(pulse_amp)
25+
# for i in range(len(t_list)):
26+
# if waveform_y[i] != None and pulse_amp != 0:
27+
# waveform_y[i] /= np.abs(pulse_amp)
28+
2729
channel_name = "{}{}".format(pulse["type"], pulse["q_index"])
2830
if channel_name in channel_dic:
2931
channel_dic[channel_name].append(waveform_y)

QuSim/PulseGen/pulse_waveform.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, pulse):
3030

3131
def get_pulse(self, simulation_option):
3232
tlist = np.linspace(0, simulation_option["simulation_time"], simulation_option["simulation_step"])
33+
delta_t = tlist[1] - tlist[0]
3334
pulse_shape = pulse_shape_dic[self.pulse_shape]
3435
drive_pulse = pulse_shape(tlist, self.pulse)
3536
if drive_pulse is None:
@@ -41,7 +42,7 @@ def get_pulse(self, simulation_option):
4142
# Multiple DRAG, define a new function
4243
drag_scale_list, drag_delta_list, num_drag = self.DRAG_pulse_pend_list()
4344
for i in range(num_drag):
44-
drive_pulse += self.DRAG(drive_pulse, drag_scale_list[i], drag_delta_list[i])
45+
drive_pulse += self.DRAG(drive_pulse, drag_scale_list[i], drag_delta_list[i], delta_t)
4546

4647
# Pulse detuning correction on
4748
# After all DRAG
@@ -59,18 +60,13 @@ def get_pulse(self, simulation_option):
5960
else: ValueError("Invalid pulse type: pulse_index = " + self.pulse_index + ', pulse_shape = ' + self.pulse_shape)
6061

6162
return np.real(drive_pulse)
62-
63-
# def carrier(self, tlist , freq , ph=0 , imb=0 ):
64-
# A = np.cos( np.pi/4 + imb) * np.sqrt(2) ;
65-
# B = np.sin( np.pi/4 + imb) * np.sqrt(2) ;
66-
# return A * np.cos( 2*np.pi*freq*tlist + ph) + 1j*B*np.sin( 2*np.pi*freq* tlist + ph) ;
6763

6864
def carrier(self, tlist, freq, phase = 0):
69-
return np.exp(1j * (2 * np.pi * freq * tlist + phase))
65+
return np.exp(-1j * (2 * np.pi * freq * tlist + phase))
7066

71-
def DRAG(self, drive_pulse, drag_scale, drag_delta):
72-
if np.abs(drag_delta) < 1e-6: raise ValueError('DRAG delta value is too small = {}'.format(drag_delta))
73-
return 1j*tools.grad(drive_pulse) * drag_scale/(drag_delta * 2 * np.pi)
67+
def DRAG(self, drive_pulse, drag_scale, drag_delta, delta_t):
68+
# if np.abs(drag_delta) > 1: raise ValueError('DRAG delta value is too small = {}'.format(drag_delta))
69+
return -1j*tools.grad(drive_pulse)/delta_t * drag_scale/(drag_delta * 2 * np.pi)
7470

7571
def DRAG_pulse_pend_list(self):
7672
try:

Tutorial/arb_qubit_tutorial/arb_qubit_demo.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@
11431143
"name": "python",
11441144
"nbconvert_exporter": "python",
11451145
"pygments_lexer": "ipython3",
1146-
"version": "3.10.2"
1146+
"version": "3.10.11"
11471147
},
11481148
"orig_nbformat": 4
11491149
},

Tutorial/transmon_tutorial/DRAG.ipynb

Lines changed: 140 additions & 104 deletions
Large diffs are not rendered by default.

Tutorial/transmon_tutorial/Pulse_parameter_optimize.ipynb

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,11 @@
258258
],
259259
"source": [
260260
"p0_max, p1_max, p2_max = [], [], []\n",
261-
"ss = simulation_option[\"simulation_step\"]-1\n",
262261
"\n",
263262
"for k, DRAG_detuning in enumerate(freq_scan):\n",
264-
" p2_max.append(np.max(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[ss-1:ss])) \n",
265-
" p1_max.append(np.max(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[ss-1:ss])) \n",
266-
" p0_max.append(np.max(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[ss-1:ss])) \n",
263+
" p2_max.append(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[-1])\n",
264+
" p1_max.append(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[-1])\n",
265+
" p0_max.append(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[-1])\n",
267266
"plt.plot(freq_scan, p2_max, label=r'$\\rho_{22}$')\n",
268267
"plt.plot(freq_scan, p1_max, label=r'$\\rho_{11}$')\n",
269268
"plt.plot(freq_scan, p0_max, label=r'$\\rho_{00}$')\n",
@@ -325,12 +324,11 @@
325324
],
326325
"source": [
327326
"p0_max, p1_max, p2_max = [], [], []\n",
328-
"ss = simulation_option[\"simulation_step\"]-1\n",
329327
"\n",
330328
"for k, DRAG_detuning in enumerate(plateau_scan):\n",
331-
" p2_max.append(np.max(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[ss-1:ss])) \n",
332-
" p1_max.append(np.max(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[ss-1:ss])) \n",
333-
" p0_max.append(np.max(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[ss-1:ss])) \n",
329+
" p2_max.append(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[-1])\n",
330+
" p1_max.append(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[-1])\n",
331+
" p0_max.append(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[-1])\n",
334332
"plt.plot(plateau_scan, p2_max, label=r'$\\rho_{22}$')\n",
335333
"plt.plot(plateau_scan, p1_max, label=r'$\\rho_{11}$')\n",
336334
"plt.plot(plateau_scan, p0_max, label=r'$\\rho_{00}$')\n",
@@ -391,12 +389,11 @@
391389
],
392390
"source": [
393391
"p0_max, p1_max, p2_max = [], [], []\n",
394-
"ss = simulation_option[\"simulation_step\"]-1\n",
395392
"\n",
396393
"for k, DRAG_detuning in enumerate(width_scan):\n",
397-
" p2_max.append(np.max(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[ss-1:ss])) \n",
398-
" p1_max.append(np.max(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[ss-1:ss])) \n",
399-
" p0_max.append(np.max(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[ss-1:ss])) \n",
394+
" p2_max.append(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[-1])\n",
395+
" p1_max.append(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[-1])\n",
396+
" p0_max.append(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[-1])\n",
400397
"plt.plot(width_scan, p2_max, label=r'$\\rho_{22}$')\n",
401398
"plt.plot(width_scan, p1_max, label=r'$\\rho_{11}$')\n",
402399
"plt.plot(width_scan, p0_max, label=r'$\\rho_{00}$')\n",
@@ -455,12 +452,11 @@
455452
],
456453
"source": [
457454
"p0_max, p1_max, p2_max = [], [], []\n",
458-
"ss = simulation_option[\"simulation_step\"]-1\n",
459455
"\n",
460456
"for k, DRAG_detuning in enumerate(amp_scan):\n",
461-
" p2_max.append(np.max(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[ss-1:ss])) \n",
462-
" p1_max.append(np.max(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[ss-1:ss])) \n",
463-
" p0_max.append(np.max(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[ss-1:ss])) \n",
457+
" p2_max.append(qs.expect(result_collection[k][0].states, state_2 * qs.dag(state_2))[-1])\n",
458+
" p1_max.append(qs.expect(result_collection[k][0].states, state_1 * qs.dag(state_1))[-1])\n",
459+
" p0_max.append(qs.expect(result_collection[k][0].states, state_0 * qs.dag(state_0))[-1])\n",
464460
"plt.plot(amp_scan, p2_max, label=r'$\\rho_{22}$')\n",
465461
"plt.plot(amp_scan, p1_max, label=r'$\\rho_{11}$')\n",
466462
"plt.plot(amp_scan, p0_max, label=r'$\\rho_{00}$')\n",
@@ -496,7 +492,7 @@
496492
"name": "python",
497493
"nbconvert_exporter": "python",
498494
"pygments_lexer": "ipython3",
499-
"version": "3.10.2"
495+
"version": "3.10.11"
500496
}
501497
},
502498
"nbformat": 4,

Tutorial/transmon_tutorial/Test_waveform.ipynb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"%autoreload 2 \n",
3434
"\n",
3535
"import QuSim.PulseGen.edges as edges\n",
36+
"import QuSim.PulseGen.pulse_waveforml as pw\n",
3637
"\n",
3738
"def carrier(tlist , freq , ph=0 , imb=0 ):\n",
3839
" A = np.cos( np.pi/4 + imb) * np.sqrt(2) ; \n",
@@ -69,12 +70,18 @@
6970
}
7071
],
7172
"source": [
72-
"tlist = np.linspace(0,200,50000)\n",
73+
"tlist = np.linspace(0,40,50000)\n",
7374
"t_delay = 0\n",
74-
"t_width = 90\n",
75-
"t_plateau = 30\n",
76-
"c = carrier(tlist, 3, 0)\n",
77-
"YY = edges.cosine_edge(tlist, t_delay, t_width, t_plateau)\n",
75+
"t_width = 20\n",
76+
"t_plateau = 0\n",
77+
"simulation_option = {\n",
78+
" \"simulation_time\": 40, # ns\n",
79+
" \"simulation_step\": 10000\n",
80+
"}\n",
81+
"pw\n",
82+
"\n",
83+
"# c = carrier(tlist, 3, 0)\n",
84+
"# YY = edges.cosine_edge(tlist, t_delay, t_width, t_plateau)\n",
7885
"# YY *= c\n",
7986
"# YY *= 0.05\n",
8087
"plt.plot(tlist, np.real(YY))"
@@ -221,7 +228,7 @@
221228
"name": "python",
222229
"nbconvert_exporter": "python",
223230
"pygments_lexer": "ipython3",
224-
"version": "3.10.2"
231+
"version": "3.10.11"
225232
}
226233
},
227234
"nbformat": 4,

0 commit comments

Comments
 (0)