Exemple #1
0
    def test_set_logical_states_none(self):
        c0 = Cavity("c0", levels=6)
        c1 = Cavity("c1", levels=10)
        c0.set_logical_states(None, None)
        c1.set_logical_states(None, None)

        self.assertEqual(c0.logical_zero(), c0.basis(0))
        self.assertEqual(c0.logical_one(), c0.basis(1))

        self.assertEqual(c1.logical_zero(), c1.basis(0))
        self.assertEqual(c1.logical_one(), c1.basis(1))
Exemple #2
0
    def test_paulis_custom_logical_states(self):
        c0 = Cavity("c0", levels=6)
        c1 = Cavity("c1", levels=10)

        c0.set_logical_states(c0.basis(0), c0.basis(1))
        c1.set_logical_states(c1.basis(2), c1.basis(3))

        c0_0 = c0.logical_zero(full_space=False)
        c0_1 = c0.logical_one(full_space=False)
        c1_0 = c1.logical_zero(full_space=False)
        c1_1 = c1.logical_one(full_space=False)
        c0_I = c0.I
        c1_I = c1.I

        single_mode_paulis = {
            "X0": c0_0 * c0_1.dag() + c0_1 * c0_0.dag(),
            "X1": c1_0 * c1_1.dag() + c1_1 * c1_0.dag(),
            "Y0": -1j * (c0_0 * c0_1.dag() - c0_1 * c0_0.dag()),
            "Y1": -1j * (c1_0 * c1_1.dag() - c1_1 * c1_0.dag()),
            "Z0": c0_0 * c0_0.dag() - c0_1 * c0_1.dag(),
            "Z1": c1_0 * c1_0.dag() - c1_1 * c1_1.dag(),
        }

        c0.space = c1.space = [c1, c0]
        self.assertEqual(c0.sigmax(full_space=False), single_mode_paulis["X0"])
        self.assertEqual(c0.sigmay(full_space=False), single_mode_paulis["Y0"])
        self.assertEqual(c0.sigmaz(full_space=False), single_mode_paulis["Z0"])

        self.assertEqual(c1.sigmax(full_space=False), single_mode_paulis["X1"])
        self.assertEqual(c1.sigmay(full_space=False), single_mode_paulis["Y1"])
        self.assertEqual(c1.sigmaz(full_space=False), single_mode_paulis["Z1"])

        self.assertEqual(c0.sigmax(full_space=True),
                         qutip.tensor(c1_I, single_mode_paulis["X0"]))
        self.assertEqual(c0.sigmay(full_space=True),
                         qutip.tensor(c1_I, single_mode_paulis["Y0"]))
        self.assertEqual(c0.sigmaz(full_space=True),
                         qutip.tensor(c1_I, single_mode_paulis["Z0"]))

        self.assertEqual(c1.sigmax(full_space=True),
                         qutip.tensor(single_mode_paulis["X1"], c0_I))
        self.assertEqual(c1.sigmay(full_space=True),
                         qutip.tensor(single_mode_paulis["Y1"], c0_I))
        self.assertEqual(c1.sigmaz(full_space=True),
                         qutip.tensor(single_mode_paulis["Z1"], c0_I))
Exemple #3
0
    def test_paulis_fock(self):
        q0 = Cavity("q0", levels=6)
        q1 = Cavity("q1", levels=10)

        q0_0 = q0.basis(0, full_space=False)
        q0_1 = q0.basis(1, full_space=False)
        q1_0 = q1.basis(0, full_space=False)
        q1_1 = q1.basis(1, full_space=False)
        q0_I = q0.I
        q1_I = q1.I

        single_mode_paulis = {
            "X0": q0_0 * q0_1.dag() + q0_1 * q0_0.dag(),
            "X1": q1_0 * q1_1.dag() + q1_1 * q1_0.dag(),
            "Y0": -1j * (q0_0 * q0_1.dag() - q0_1 * q0_0.dag()),
            "Y1": -1j * (q1_0 * q1_1.dag() - q1_1 * q1_0.dag()),
            "Z0": q0_0 * q0_0.dag() - q0_1 * q0_1.dag(),
            "Z1": q1_0 * q1_0.dag() - q1_1 * q1_1.dag(),
        }

        q0.space = q1.space = [q1, q0]
        self.assertEqual(q0.sigmax(full_space=False), single_mode_paulis["X0"])
        self.assertEqual(q0.sigmay(full_space=False), single_mode_paulis["Y0"])
        self.assertEqual(q0.sigmaz(full_space=False), single_mode_paulis["Z0"])

        self.assertEqual(q1.sigmax(full_space=False), single_mode_paulis["X1"])
        self.assertEqual(q1.sigmay(full_space=False), single_mode_paulis["Y1"])
        self.assertEqual(q1.sigmaz(full_space=False), single_mode_paulis["Z1"])

        self.assertEqual(q0.sigmax(full_space=True),
                         qutip.tensor(q1_I, single_mode_paulis["X0"]))
        self.assertEqual(q0.sigmay(full_space=True),
                         qutip.tensor(q1_I, single_mode_paulis["Y0"]))
        self.assertEqual(q0.sigmaz(full_space=True),
                         qutip.tensor(q1_I, single_mode_paulis["Z0"]))

        self.assertEqual(q1.sigmax(full_space=True),
                         qutip.tensor(single_mode_paulis["X1"], q0_I))
        self.assertEqual(q1.sigmay(full_space=True),
                         qutip.tensor(single_mode_paulis["Y1"], q0_I))
        self.assertEqual(q1.sigmaz(full_space=True),
                         qutip.tensor(single_mode_paulis["Z1"], q0_I))
Exemple #4
0
    def test_invalid_logical_state(self):
        c0 = Cavity("c0", levels=6)
        c1 = Cavity("c1", levels=10)

        c0.set_logical_states(c0.basis(0), c0.basis(1))
        c1.set_logical_states(c1.basis(2), c1.basis(3))

        c0.space = c1.space = [c1, c0]

        with self.assertRaises(ValueError):
            c0.set_logical_states(c0.basis(0), c0.basis(1))

        with self.assertRaises(ValueError):
            c1.set_logical_states(c1.basis(2), c1.basis(3))