def testDRAG(self): ''' Try a unitary inversion pulse on a three level SCQuibt and see if we get something close to DRAG ''' #Setup a three level qubit and a 100MHz delta Q1 = SCQubit(3, 4.987456e9, -150e6, name='Q1') systemParams = SystemParams() systemParams.add_sub_system(Q1) systemParams.add_control_ham(inphase = Hamiltonian(0.5*(Q1.loweringOp + Q1.raisingOp)), quadrature = Hamiltonian(0.5*(-1j*Q1.loweringOp + 1j*Q1.raisingOp))) systemParams.add_control_ham(inphase = Hamiltonian(0.5*(Q1.loweringOp + Q1.raisingOp)), quadrature = Hamiltonian(0.5*(-1j*Q1.loweringOp + 1j*Q1.raisingOp))) systemParams.create_full_Ham() systemParams.measurement = Q1.levelProjector(1) #Setup the pulse parameters for the optimization numPoints = 30 pulseTime = 15e-9 pulseParams = PulseParams() pulseParams.timeSteps = (pulseTime/numPoints)*np.ones(numPoints) pulseParams.rhoStart = Q1.levelProjector(0) pulseParams.rhoGoal = Q1.levelProjector(1) pulseParams.Ugoal = Q1.pauliX pulseParams.add_control_line(freq=-Q1.omega, bandwidth=300e6, maxAmp=200e6) pulseParams.add_control_line(freq=-Q1.omega, phase=-np.pi/2, bandwidth=300e6, maxAmp=200e6) pulseParams.H_int = Hamiltonian((Q1.omega)*np.diag(np.arange(Q1.dim))) pulseParams.optimType = 'unitary' pulseParams.derivType = 'finiteDiff' #Start with a Gaussian tmpGauss = np.exp(-np.linspace(-2,2,numPoints)**2) tmpScale = 0.5/(np.sum(pulseParams.timeSteps*tmpGauss)) pulseParams.startControlAmps = np.vstack((tmpScale*tmpGauss, np.zeros(numPoints))) #Call the optimization optimize_pulse(pulseParams, systemParams) if plotResults: plt.plot(np.cumsum(pulseParams.timeSteps)*1e9,pulseParams.controlAmps.T/1e6); plt.ylabel('Pulse Amplitude (MHz)') plt.xlabel('Time (ns)') plt.legend(('X Quadrature', 'Y Quadrature')) plt.title('DRAG Pulse from Optimal Control') plt.show() #Now test the optimized pulse and make sure it does give us the desired unitary result = simulate_sequence(pulseParams, systemParams, pulseParams.rhoStart, simType='unitary') assert np.abs(np.trace(np.dot(result[1].conj().T, pulseParams.Ugoal)))**2/np.abs(np.trace(np.dot(pulseParams.Ugoal.conj().T, pulseParams.Ugoal)))**2 > 0.99
def testDRAG(self): ''' Try a unitary inversion pulse on a three level SCQuibt and see if we get something close to DRAG ''' #Setup a three level qubit and a 100MHz delta Q1 = SCQubit(3, 4.987456e9, -150e6, name='Q1') systemParams = SystemParams() systemParams.add_sub_system(Q1) systemParams.add_control_ham( inphase=Hamiltonian(0.5 * (Q1.loweringOp + Q1.raisingOp)), quadrature=Hamiltonian(0.5 * (-1j * Q1.loweringOp + 1j * Q1.raisingOp))) systemParams.add_control_ham( inphase=Hamiltonian(0.5 * (Q1.loweringOp + Q1.raisingOp)), quadrature=Hamiltonian(0.5 * (-1j * Q1.loweringOp + 1j * Q1.raisingOp))) systemParams.create_full_Ham() systemParams.measurement = Q1.levelProjector(1) #Setup the pulse parameters for the optimization numPoints = 30 pulseTime = 15e-9 pulseParams = PulseParams() pulseParams.timeSteps = (pulseTime / numPoints) * np.ones(numPoints) pulseParams.rhoStart = Q1.levelProjector(0) pulseParams.rhoGoal = Q1.levelProjector(1) pulseParams.Ugoal = Q1.pauliX pulseParams.add_control_line(freq=-Q1.omega, bandwidth=300e6, maxAmp=200e6) pulseParams.add_control_line(freq=-Q1.omega, phase=-np.pi / 2, bandwidth=300e6, maxAmp=200e6) pulseParams.H_int = Hamiltonian( (Q1.omega) * np.diag(np.arange(Q1.dim))) pulseParams.optimType = 'unitary' pulseParams.derivType = 'finiteDiff' #Start with a Gaussian tmpGauss = np.exp(-np.linspace(-2, 2, numPoints)**2) tmpScale = 0.5 / (np.sum(pulseParams.timeSteps * tmpGauss)) pulseParams.startControlAmps = np.vstack( (tmpScale * tmpGauss, np.zeros(numPoints))) #Call the optimization optimize_pulse(pulseParams, systemParams) if plotResults: plt.plot( np.cumsum(pulseParams.timeSteps) * 1e9, pulseParams.controlAmps.T / 1e6) plt.ylabel('Pulse Amplitude (MHz)') plt.xlabel('Time (ns)') plt.legend(('X Quadrature', 'Y Quadrature')) plt.title('DRAG Pulse from Optimal Control') plt.show() #Now test the optimized pulse and make sure it does give us the desired unitary result = simulate_sequence(pulseParams, systemParams, pulseParams.rhoStart, simType='unitary') assert np.abs(np.trace(np.dot( result[1].conj().T, pulseParams.Ugoal)))**2 / np.abs( np.trace(np.dot(pulseParams.Ugoal.conj().T, pulseParams.Ugoal)))**2 > 0.99
#Rotate Q2's desired unitary by the frame rotation UFrameShift = expm(-1j * 2 * pi * np.sum(pulseParams.timeSteps) * systemParams.expand_operator('Q2', Q2.omega * Q2.numberOp)) pulseParams.Ugoal = np.dot(UFrameShift, pulseParams.Ugoal) #State to state goals pulseParams.rhoStart = np.zeros((9, 9), dtype=np.complex128) pulseParams.rhoStart[0, 0] = 1 pulseParams.rhoGoal = np.zeros((9, 9), dtype=np.complex128) pulseParams.rhoGoal[3, 3] = 1 #Call the optimization pulseParams.fTol = 1e-4 pulseParams.maxfun = 50 pulseParams.derivType = 'finiteDiff' pulseParams.startControlAmps = 0.01e9 / 2 / pi * np.ones((2, 144)) optimize_pulse(pulseParams, systemParams) plt.figure() plt.plot(np.cumsum(pulseParams.timeSteps), pulseParams.controlAmps.T) plt.show() #Decimate the pulse down to the AWG sampling rate #pulseParams.controlAmps = decimate(pulseParams.controlAmps, 10, n=5, axis=1) ''' Look at the fidelity of some more traditional pulses ''' #First a simple Gaussian #xPts = np.linspace(-2.5,2.5,1000)