Beispiel #1
0
def vector(evo):
    assert len(evo)
    (time,dop) = evo[0]
    assert dop.shape[0] == dop.shape[1] == 2

    # bloch vector coordinates
    vector = None
    for i in range(0,len(evo)):
        (time,dop) = evo[i]
        assert (dop == numpy.conjugate(numpy.transpose(dop))).all()
        x = hs.dot(pauli.X,dop)
        y = hs.dot(pauli.Y,dop)
        z = hs.dot(pauli.Z,dop)
        entry = numpy.array([x,y,z])
        if vector is None:
            vector = entry
        else:
            vector = numpy.vstack([vector,entry])
            
    return vector
Beispiel #2
0
def hermitian_subspace_generator(generator_func, n):
    """
    return the generator acting on the real Hermitian subspace of n*n complex matrices
	generator_func  function accepting a n*n matrix and returning the
	                time derivative for the given input
	n               system's order
    """
    assert generator_func
    assert n>0

    basis = hermitian_subspace_basis(n)
    _map = numpy.zeros((n*n,n*n))
    row = 0
    col = 0
    for row in range(0, n*n):
        for col in range(0, n*n):
            _map[row][col] = hs.dot(basis[col], generator_func(basis[row]))

    return _map
Beispiel #3
0
def bloch_vector(signal):
    assert len(signal)
    (time,dop) = signal[0]
    assert dop.shape[0] == dop.shape[1] == 2

    import pauli 
    import hs

    x = []
    y = []
    z = []
    for i in range(0,len(signal)):
        (time,dop) = signal[i]
        # coordinates in the basis I, X, Y e Z
        i_tmp = hs.dot(pauli.I,dop)
        x_tmp = hs.dot(pauli.X,dop)
        y_tmp = hs.dot(pauli.Y,dop)
        z_tmp = hs.dot(pauli.Z,dop)
#        print i_tmp, x_tmp, y_tmp, z_tmp
#        assert numpy.imag(x_tmp) == numpy.imag(y_tmp) == numpy.imag(z_tmp) == 0.
#        print 'dop',  dop
#        print 'sum',  (pauli.I*i_tmp + x_tmp*pauli.X+y_tmp*pauli.Y+z_tmp*pauli.Z)/2.
#        assert (pauli.I*i_tmp + x_tmp*pauli.X+y_tmp*pauli.Y+z_tmp*pauli.Z == dop).all()
        x.append(numpy.real(x_tmp))
        y.append(numpy.real(y_tmp))
        z.append(numpy.real(z_tmp))

#    x = numpy.array(x)   
#    y = numpy.array(y)   
#    z = numpy.array(z)   

#    print x
#    print y
#    print z
#   print x.shape
#   print y.shape
#   print z.shape

    from mpl_toolkits.mplot3d import Axes3D
    import pylab

    mpl.rcParams['legend.fontsize'] = 10
    
    fig = pylab.figure()
    ax = Axes3D(fig)

    u = np.linspace(0, 2 * np.pi, 100)
    v = np.linspace(0, np.pi, 100)

    sx = 1 * np.outer(np.cos(u), np.sin(v))
    sy = 1 * np.outer(np.sin(u), np.sin(v))
    sz = 1 * np.outer(np.ones(np.size(u)), np.cos(v))
    ax.plot_surface(sx, sy, sz,  rstride=25, cstride=25, color='b', alpha=0.05)
    
    pylab.hold(True)


    ax.plot(x, y, z, label='parametric curve')
    ax.legend()

    pylab.show()