def test_use_modes(self): qubit = Transmon("qubit", levels=3, kerr=-200e-3) cavity = Cavity("cavity", levels=10, kerr=-10e-6) system = System("system", modes=[qubit, cavity]) with system.use_modes([qubit]): self.assertEqual(system.ground_state(), qubit.fock(0, full_space=False)) with system.use_modes([cavity]): self.assertEqual(system.ground_state(), cavity.fock(0, full_space=False)) with system.use_modes([qubit, cavity]): self.assertEqual( system.ground_state(), qutip.tensor( qubit.fock(0, full_space=False), cavity.fock(0, full_space=False) ), ) system.order_modes = False with system.use_modes([cavity, qubit]): self.assertEqual( system.ground_state(), qutip.tensor( cavity.fock(0, full_space=False), qubit.fock(0, full_space=False) ), )
def test_rabi_two_levels(self): qubit = Transmon("qubit", levels=2) system = System("system", modes=[qubit]) for _ in range(2): _, old_amp, new_amp = tune_rabi(system, qubit.fock(0)) self.assertLess(abs(old_amp - new_amp), 1e-7) init = qubit.fock(0) seq = get_sequence(system) qubit.rotate_x(np.pi) result = seq.run(init) target = qubit.Rx(np.pi) * init fidelity = qutip.fidelity(result.states[-1], target)**2 self.assertLess(abs(1 - fidelity), 1e-10)
def setUpClass(cls): qubit = Transmon("qubit", levels=2) cavity = Cavity("cavity", levels=6) system = System("system", modes=[qubit, cavity]) system.set_cross_kerr(qubit, cavity, -2e-3) with system.use_modes([qubit]): _ = tune_rabi(system, init_state=qubit.fock(0), verify=False) cls.system = system
def test_drag(self): qubit = Transmon("qubit", levels=3, kerr=-200e-3) qubit.gaussian_pulse.sigma = 10 system = System("system", modes=[qubit]) for _ in range(3): _, old_amp, new_amp = tune_rabi(system, qubit.fock(0), plot=False, verify=False) self.assertLess(abs(old_amp - new_amp), 1e-7) _, old_drag, new_drag = tune_drag(system, qubit.fock(0), update=True) self.assertNotAlmostEqual(new_drag, 0) init = qubit.fock(0) seq = get_sequence(system) qubit.rotate_x(np.pi) result = seq.run(init) target = qubit.Rx(np.pi) * init fidelity = qutip.fidelity(result.states[-1], target)**2 self.assertLess(abs(1 - fidelity), 1e-5)