def amp_EFRabi(self, rabi_freq): rabi = EFRabi(self.qubit) rabi.set_experiment_options(amplitudes=np.linspace(-1, 1, self.times), frequency_shift=rabi_freq) rabi_data = rabi.run(self.backend) rabi_data.block_for_results() print(rabi_data.block_for_results("rabi_state")) rabi_amp = rabi_data.analysis_results("rabi_rate_12").value.value return rabi_amp, rabi_data.figure(0)
def test_ef_rabi_end_to_end(self): """Test the EFRabi experiment end to end.""" test_tol = 0.01 backend = RabiBackend() # Note that the backend is not sophisticated enough to simulate an e-f # transition so we run the test with a tiny frequency shift, still driving the e-g transition. rabi = EFRabi(self.qubit, self.sched) rabi.set_experiment_options(amplitudes=np.linspace(-0.95, 0.95, 21)) expdata = rabi.run(backend) result = expdata.analysis_results(1) self.assertEqual(result.quality, "good") self.assertTrue(abs(result.value.value - backend.rabi_rate) < test_tol)
def test_ef_rabi_circuit(self): """Test the EFRabi experiment end to end.""" anharm = -330e6 rabi12 = EFRabi(2) rabi12.set_experiment_options(amplitudes=[0.5], frequency_shift=anharm) circ = rabi12.circuits(RabiBackend())[0] with pulse.build() as expected: pulse.shift_frequency(anharm, pulse.DriveChannel(2)) pulse.play(pulse.Gaussian(160, 0.5, 40), pulse.DriveChannel(2)) pulse.shift_frequency(-anharm, pulse.DriveChannel(2)) self.assertEqual(circ.calibrations["Rabi"][((2, ), (0.5, ))], expected) self.assertEqual(circ.data[0][0].name, "x") self.assertEqual(circ.data[1][0].name, "Rabi")
def test_roundtrip_serializable(self): """Test round trip JSON serialization""" exp = EFRabi(0, self.sched) self.assertRoundTripSerializable(exp, self.json_equiv)
def test_experiment_config(self): """Test converting to and from config works""" exp = EFRabi(0, self.sched) loaded_exp = EFRabi.from_config(exp.config()) self.assertNotEqual(exp, loaded_exp) self.assertTrue(self.json_equiv(exp, loaded_exp))