Ejemplo n.º 1
0
 def test_bloch(self):
     """test 'bloch'
     """
     qs = QState(qubit_num=3).ry(0, phase=0.25).rz(0, phase=0.25)
     theta, phi = qs.bloch()
     ans = (round(theta, 4) == 0.25 and round(phi, 4) == 0.25)
     self.assertEqual(ans, True)
Ejemplo n.º 2
0
def main():

    hm = Observable("x_0")

    for i in range(21):
        t = i * 0.05
        qs = QState(1)

        # time evolution
        qs.evolve(observable=hm, time=t, iteration=100)

        # quantum stat in bloch spere
        theta, phi = qs.bloch(0)

        print("time = {0:.2f}, theta = {1:.2f}*PI, phi = {2:.2f}*PI".format(
            t, theta, phi))