Exemple #1
0
    def test_integrate(self):

        ssys = SpinSystem(['e'])
        ssys.add_linear_term(0, [1, 0, 0])  # Precession around x
        H = ssys.hamiltonian
        rho0 = DensityOperator.from_vectors()  # Start along z
        avg = H.integrate_decaying(rho0, 1.0, ssys.operator({0: 'z'}))

        self.assertTrue(np.isclose(avg[0], 0.5 / (1.0 + 4 * np.pi**2)))
Exemple #2
0
    def test_evolve(self):

        ssys = SpinSystem(['e'])
        ssys.add_linear_term(0, [1, 0, 0])  # Precession around x
        H = ssys.hamiltonian
        rho0 = DensityOperator.from_vectors()  # Start along z
        t = np.linspace(0, 1, 100)

        evol = H.evolve(rho0, t, ssys.operator({0: 'z'}))

        self.assertTrue(
            np.all(np.isclose(evol[:, 0], 0.5 * np.cos(2 * np.pi * t))))
Exemple #3
0
    def test_addterms(self):

        ssys = SpinSystem(['mu', 'e'])

        t1 = ssys.add_linear_term(0, [1, 0, 1])

        self.assertEqual(t1.label, 'Single')
        self.assertEqual(t1.operator, ssys.operator({0: 'x'}) +
                         ssys.operator({0: 'z'}))

        t2 = ssys.add_bilinear_term(0, 1, np.eye(3))

        self.assertEqual(t2.label, 'Double')
        self.assertEqual(t2.operator, ssys.operator({0: 'x', 1: 'x'}) +
                         ssys.operator({0: 'y', 1: 'y'}) +
                         ssys.operator({0: 'z', 1: 'z'}))

        H = ssys.hamiltonian

        self.assertTrue(np.all(np.isclose(H.matrix,
                                          np.array([[0.75, 0, 0.5, 0.0],
                                                    [0, 0.25, 0.5, 0.5],
                                                    [0.5, 0.5, -0.75, 0],
                                                    [0.0, 0.5, 0, -0.25]]))))

        ssys.add_dissipative_term(ssys.operator({0: 'x'}), 1.0)
        self.assertTrue(ssys.is_dissipative)
Exemple #4
0
    def test_lindbladian(self):

        ssys = SpinSystem(['mu'])
        ssys.add_linear_term(0, [0, 0, 1])

        H = ssys.hamiltonian
        L = ssys.lindbladian
        L0 = -1.0j*SuperOperator.commutator(ssys.operator({0: 'z'}))

        self.assertTrue(np.all(np.isclose(L.matrix, L0.matrix)))

        sx = ssys.operator({0: 'x'})
        d = 2.0
        ssys.add_dissipative_term(sx, d)

        L1 = L0 + d*(SuperOperator.bracket(sx) -
                     0.5*SuperOperator.anticommutator(sx*sx))

        L = ssys.lindbladian
        self.assertTrue(np.all(np.isclose(L.matrix, L1.matrix)))