def testRabiInteractionFrame(self): ''' Test Rabi oscillations after moving into an interaction frame that is different to the pulsing frame and with an irrational timestep for good measure. ''' #Setup the system self.systemParams.subSystems[0] = SCQubit(2,5e9, 'Q1') self.systemParams.create_full_Ham() #Setup the pulseSequences pulseSeqs = [] for pulseLength in self.pulseLengths: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-5.0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq*np.array([[1]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([pulseLength]) tmpPulseSeq.maxTimeStep = pi/2*1e-10 tmpPulseSeq.H_int = Hamiltonian(np.array([[0,0], [0, 5.005e9]], dtype = np.complex128)) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] expectedResults = np.cos(2*pi*self.rabiFreq*self.pulseLengths) if plotResults: plt.figure() plt.plot(self.pulseLengths,results) plt.plot(self.pulseLengths, expectedResults, color='r', linestyle='--', linewidth=2) plt.title('10MHz Rabi Oscillations in Interaction Frame') plt.xlabel('Pulse Length') plt.ylabel(r'$\sigma_z$') plt.legend(('Simulated Results', '10MHz Cosine')) plt.show() np.testing.assert_allclose(results, expectedResults , atol = 1e-4)
def testTwoPhoton(self): ''' Test spectroscopy and the two photon transition from the ground to the second excited state. ''' freqSweep = 1e9 * np.linspace(4.9, 5.1, 1000) rabiFreq = 1e6 #Setup the pulseSequences as a series of 10us low-power pulses pulseSeqs = [] for freq in freqSweep: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=freq, phase=0) tmpPulseSeq.controlAmps = np.array([[rabiFreq]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([10e-6]) tmpPulseSeq.maxTimeStep = np.Inf tmpPulseSeq.H_int = Hamiltonian( np.diag(freq * np.arange(3, dtype=np.complex128))) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='lindblad')[0] if plotResults: plt.figure() plt.plot(freqSweep / 1e9, results) plt.xlabel('Frequency') plt.ylabel(r'$\sigma_z$') plt.title('Qutrit Spectroscopy') plt.show()
def testTwoPhoton(self): ''' Test spectroscopy and the two photon transition from the ground to the second excited state. ''' freqSweep = 1e9*np.linspace(4.9, 5.1, 1000) rabiFreq = 1e6 #Setup the pulseSequences as a series of 10us low-power pulses pulseSeqs = [] for freq in freqSweep: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=freq, phase=0) tmpPulseSeq.controlAmps = np.array([[rabiFreq]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([10e-6]) tmpPulseSeq.maxTimeStep = np.Inf tmpPulseSeq.H_int = Hamiltonian(np.diag(freq*np.arange(3, dtype=np.complex128))) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='lindblad')[0] if plotResults: plt.figure() plt.plot(freqSweep/1e9,results) plt.xlabel('Frequency') plt.ylabel(r'$\sigma_z$') plt.title('Qutrit Spectroscopy') plt.show()
def testRabiRotatingFrame(self): ''' Test Rabi oscillations in the rotating frame, i.e. with zero drift Hamiltonian drive frequency of zero. ''' #Setup the pulseSequences pulseSeqs = [] for pulseLength in self.pulseLengths: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq*np.array([[1]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([pulseLength]) tmpPulseSeq.maxTimeStep = pulseLength tmpPulseSeq.H_int = None pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] expectedResults = np.cos(2*pi*self.rabiFreq*self.pulseLengths) if plotResults: plt.figure() plt.plot(self.pulseLengths,results) plt.plot(self.pulseLengths, expectedResults, color='r', linestyle='--', linewidth=2) plt.title('10MHz Rabi Oscillations in Rotating Frame') plt.xlabel('Pulse Length') plt.ylabel(r'$\sigma_z$') plt.legend(('Simulated Results', '10MHz Cosine')) plt.show() np.testing.assert_allclose(results, expectedResults , atol = 1e-4)
def testT1Recovery(self): ''' Test a simple T1 recovery without any pulses. Start in the first excited state and watch recovery down to ground state. ''' self.systemParams.dissipators = [Dissipator(self.qubit.T1Dissipator)] #Just setup a series of delays delays = np.linspace(0,5e-6,40) pulseSeqs = [] for tmpDelay in delays: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line() tmpPulseSeq.controlAmps = np.array([[0]]) tmpPulseSeq.timeSteps = np.array([tmpDelay]) tmpPulseSeq.maxTimeStep = tmpDelay tmpPulseSeq.H_int = None pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, np.array([[0,0],[0,1]], dtype=np.complex128), simType='lindblad')[0] expectedResults = 1-2*np.exp(-delays/self.qubit.T1) if plotResults: plt.figure() plt.plot(1e6*delays,results) plt.plot(1e6*delays, expectedResults, color='r', linestyle='--', linewidth=2) plt.xlabel(r'Recovery Time ($\mu$s)') plt.ylabel(r'Expectation Value of $\sigma_z$') plt.title(r'$T_1$ Recovery to the Ground State') plt.legend(('Simulated Results', 'Exponential T1 Recovery')) plt.show() np.testing.assert_allclose(results, expectedResults, atol=1e-4)
def sim_setup_cython(Hnat, controlHams, controlFields, controlFreqs): systemParams = SystemParams() systemParams.Hnat = Hamiltonian(Hnat) pulseSeq = PulseSequence() pulseSeq.controlAmps = controlFields for ct in range(len(controlHams)): systemParams.add_control_ham(inphase=Hamiltonian(controlHams[ct])) pulseSeq.add_control_line(freq = controlFreqs[ct], phase=0, controlType='sinusoidal') for ct in range(np.int(np.log2(Hnat.shape[0]))): systemParams.add_sub_system(SCQubit(2,0e9, name='Q1', T1=1e-6)) pulseSeq.timeSteps = 0.01*np.ones(controlFields.shape[1]) pulseSeq.maxTimeStep = 1e6 return systemParams, pulseSeq
def testZZGate(self): '''Test whether the ZZ interaction performs as expected''' #Take the bare Hamiltonian as the interaction Hamiltonian H_int = Hamiltonian(self.systemParams.Hnat.matrix) #First add a 2MHz ZZ interaction and add it to the system self.systemParams.add_interaction('Q1', 'Q2', 'ZZ', 2e6) self.systemParams.create_full_Ham() #Setup the pulseSequences delays = np.linspace(0, 4e-6, 100) pulseSeqs = [] for delay in delays: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-5.0e9, phase=0) tmpPulseSeq.add_control_line(freq=-6.0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq * np.array( [[1, 0], [0, 0]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([25e-9, delay]) tmpPulseSeq.maxTimeStep = np.Inf tmpPulseSeq.H_int = H_int pulseSeqs.append(tmpPulseSeq) self.systemParams.measurement = np.kron(self.Q1.pauliX, self.Q2.pauliZ) resultsXZ = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] self.systemParams.measurement = np.kron(self.Q1.pauliY, self.Q2.pauliZ) resultsYZ = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] if plotResults: plt.figure() plt.plot(delays * 1e6, resultsXZ) plt.plot(delays * 1e6, resultsYZ, 'g') plt.legend(('XZ', 'YZ')) plt.xlabel('Coupling Time') plt.ylabel('Operator Expectation Value') plt.title('ZZ Coupling Evolution After a X90 on Q1') plt.show()
def testRabiInteractionFrame(self): ''' Test Rabi oscillations after moving into an interaction frame that is different to the pulsing frame and with an irrational timestep for good measure. ''' #Setup the system self.systemParams.subSystems[0] = SCQubit(2, 5e9, 'Q1') self.systemParams.create_full_Ham() #Setup the pulseSequences pulseSeqs = [] for pulseLength in self.pulseLengths: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-5.0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq * np.array( [[1]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([pulseLength]) tmpPulseSeq.maxTimeStep = pi / 2 * 1e-10 tmpPulseSeq.H_int = Hamiltonian( np.array([[0, 0], [0, 5.005e9]], dtype=np.complex128)) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] expectedResults = np.cos(2 * pi * self.rabiFreq * self.pulseLengths) if plotResults: plt.figure() plt.plot(self.pulseLengths, results) plt.plot(self.pulseLengths, expectedResults, color='r', linestyle='--', linewidth=2) plt.title('10MHz Rabi Oscillations in Interaction Frame') plt.xlabel('Pulse Length') plt.ylabel(r'$\sigma_z$') plt.legend(('Simulated Results', '10MHz Cosine')) plt.show() np.testing.assert_allclose(results, expectedResults, atol=1e-4)
def testT1Recovery(self): ''' Test a simple T1 recovery without any pulses. Start in the first excited state and watch recovery down to ground state. ''' self.systemParams.dissipators = [Dissipator(self.qubit.T1Dissipator)] #Just setup a series of delays delays = np.linspace(0, 5e-6, 40) pulseSeqs = [] for tmpDelay in delays: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line() tmpPulseSeq.controlAmps = np.array([[0]]) tmpPulseSeq.timeSteps = np.array([tmpDelay]) tmpPulseSeq.maxTimeStep = tmpDelay tmpPulseSeq.H_int = None pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, np.array([[0, 0], [0, 1]], dtype=np.complex128), simType='lindblad')[0] expectedResults = 1 - 2 * np.exp(-delays / self.qubit.T1) if plotResults: plt.figure() plt.plot(1e6 * delays, results) plt.plot(1e6 * delays, expectedResults, color='r', linestyle='--', linewidth=2) plt.xlabel(r'Recovery Time ($\mu$s)') plt.ylabel(r'Expectation Value of $\sigma_z$') plt.title(r'$T_1$ Recovery to the Ground State') plt.legend(('Simulated Results', 'Exponential T1 Recovery')) plt.show() np.testing.assert_allclose(results, expectedResults, atol=1e-4)
def testRabiRotatingFrame(self): ''' Test Rabi oscillations in the rotating frame, i.e. with zero drift Hamiltonian drive frequency of zero. ''' #Setup the pulseSequences pulseSeqs = [] for pulseLength in self.pulseLengths: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq * np.array( [[1]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([pulseLength]) tmpPulseSeq.maxTimeStep = pulseLength tmpPulseSeq.H_int = None pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] expectedResults = np.cos(2 * pi * self.rabiFreq * self.pulseLengths) if plotResults: plt.figure() plt.plot(self.pulseLengths, results) plt.plot(self.pulseLengths, expectedResults, color='r', linestyle='--', linewidth=2) plt.title('10MHz Rabi Oscillations in Rotating Frame') plt.xlabel('Pulse Length') plt.ylabel(r'$\sigma_z$') plt.legend(('Simulated Results', '10MHz Cosine')) plt.show() np.testing.assert_allclose(results, expectedResults, atol=1e-4)
def testZZGate(self): '''Test whether the ZZ interaction performs as expected''' #Take the bare Hamiltonian as the interaction Hamiltonian H_int = Hamiltonian(self.systemParams.Hnat.matrix) #First add a 2MHz ZZ interaction and add it to the system self.systemParams.add_interaction('Q1', 'Q2', 'ZZ', 2e6) self.systemParams.create_full_Ham() #Setup the pulseSequences delays = np.linspace(0,4e-6,100) pulseSeqs = [] for delay in delays: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-5.0e9, phase=0) tmpPulseSeq.add_control_line(freq=-6.0e9, phase=0) tmpPulseSeq.controlAmps = self.rabiFreq*np.array([[1, 0], [0,0]], dtype=np.float64) tmpPulseSeq.timeSteps = np.array([25e-9, delay]) tmpPulseSeq.maxTimeStep = np.Inf tmpPulseSeq.H_int = H_int pulseSeqs.append(tmpPulseSeq) self.systemParams.measurement = np.kron(self.Q1.pauliX, self.Q2.pauliZ) resultsXZ = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] self.systemParams.measurement = np.kron(self.Q1.pauliY, self.Q2.pauliZ) resultsYZ = simulate_sequence_stack(pulseSeqs, self.systemParams, self.rhoIn, simType='unitary')[0] if plotResults: plt.figure() plt.plot(delays*1e6, resultsXZ) plt.plot(delays*1e6, resultsYZ, 'g') plt.legend(('XZ','YZ')) plt.xlabel('Coupling Time') plt.ylabel('Operator Expectation Value') plt.title('ZZ Coupling Evolution After a X90 on Q1') plt.show()
CRGaussOnBlock[4] = halfGauss[-1::-1] CRGaussOffBlock = np.zeros((2*numChannels,numPoints)); CRGaussOffBlock[4] = halfGauss CRBlock = np.array([0,0,0,0,1,0]).reshape(2*numChannels,1) CRBlock *= CRAmp; baseSeq = PulseSequence() baseSeq.add_control_line(freq=-drive1Freq, phase=0) baseSeq.add_control_line(freq=-drive1Freq, phase=-pi/2) baseSeq.add_control_line(freq=-drive2Freq, phase=0) baseSeq.add_control_line(freq=-drive2Freq, phase=-pi/2) baseSeq.add_control_line(freq=-drive1Freq, phase=0) baseSeq.add_control_line(freq=-drive1Freq, phase=-pi/2) baseSeq.maxTimeStep = timeStep/4 baseSeq.H_int = Hamiltonian(systemParams.expand_operator('Q1', drive1Freq*Q1.numberOp) + systemParams.expand_operator('Q2', drive2Freq*Q2.numberOp)) ''' #Look at the all XY set of experiments pulseSeqs = [] #Nothing tmpPulseSeq = deepcopy(baseSeq) tmpPulseSeq.controlAmps = np.zeros((4,1)) tmpPulseSeq.timeSteps = timeStep*np.ones(tmpPulseSeq.controlAmps.shape[1]) pulseSeqs.append(tmpPulseSeq)
#Setup the pulseSequences to calibrate the optimal control pulse pulseSeqs = [] nutFreqs = np.linspace(0, 100e6, 50) for nutFreq in nutFreqs: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-drive1Freq, initialPhase=0) tmpPulseSeq.add_control_line(freq=-drive1Freq, initialPhase=-pi / 2) tmpPulseSeq.add_control_line(freq=-drive2Freq, initialPhase=0) tmpPulseSeq.add_control_line(freq=-drive2Freq, initialPhase=-pi / 2) # tmpPulseSeq.controlAmps = np.hstack((Q2PiBlock, nutFreq*jayPulseBlock, Q2PiBlock)) tmpPulseSeq.controlAmps = nutFreq * jayPulseBlock tmpPulseSeq.timeSteps = timeStep * np.ones( tmpPulseSeq.controlAmps.shape[1]) tmpPulseSeq.maxTimeStep = timeStep / 4 tmpPulseSeq.H_int = Hamiltonian( systemParams.expand_operator('Q1', drive1Freq * Q1.numberOp) + systemParams.expand_operator('Q2', drive2Freq * Q2.numberOp)) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, systemParams, rhoIn, simType='unitary') #Calibrates to 9.51MHz as expected Q1Cal = 0.5 / (np.sum(gaussPulse) * timeStep) bufferPts = 2 Q1PiPulse = np.zeros((systemParams.numControlHams, numPoints)) Q1PiPulse[0] = Q1Cal * gaussPulse
#Setup the pulseSequences to calibrate the optimal control pulse pulseSeqs = [] nutFreqs = np.linspace(0,100e6,50) for nutFreq in nutFreqs: tmpPulseSeq = PulseSequence() tmpPulseSeq.add_control_line(freq=-drive1Freq, initialPhase=0) tmpPulseSeq.add_control_line(freq=-drive1Freq, initialPhase=-pi/2) tmpPulseSeq.add_control_line(freq=-drive2Freq, initialPhase=0) tmpPulseSeq.add_control_line(freq=-drive2Freq, initialPhase=-pi/2) # tmpPulseSeq.controlAmps = np.hstack((Q2PiBlock, nutFreq*jayPulseBlock, Q2PiBlock)) tmpPulseSeq.controlAmps = nutFreq*jayPulseBlock tmpPulseSeq.timeSteps = timeStep*np.ones(tmpPulseSeq.controlAmps.shape[1]) tmpPulseSeq.maxTimeStep = timeStep/4 tmpPulseSeq.H_int = Hamiltonian(systemParams.expand_operator('Q1', drive1Freq*Q1.numberOp) + systemParams.expand_operator('Q2', drive2Freq*Q2.numberOp)) pulseSeqs.append(tmpPulseSeq) results = simulate_sequence_stack(pulseSeqs, systemParams, rhoIn, simType='unitary') #Calibrates to 9.51MHz as expected Q1Cal = 0.5/(np.sum(gaussPulse)*timeStep) bufferPts = 2 Q1PiPulse = np.zeros((systemParams.numControlHams,numPoints)) Q1PiPulse[0] = Q1Cal*gaussPulse Q1PiBlock = np.hstack((np.zeros((systemParams.numControlHams,bufferPts)), Q1PiPulse, np.zeros((systemParams.numControlHams,bufferPts)))) Q1Pi2Block = np.hstack((np.zeros((systemParams.numControlHams,bufferPts)), 0.5*Q1PiPulse, np.zeros((systemParams.numControlHams,bufferPts)))) Q1TimePts = timeStep*np.ones(Q1PiBlock.shape[1])