Exemplo n.º 1
0
def plot_flip_error():
        """
        Plot the flip-error measures R1 and R2 as a function of the
        cycle time T (loop duration).
        """
        ##
        # plot ratios b_1/a_1(T)
        ##
        params = getParamList(a1 = 0.0, a2 = 0.0, b1 = 0.8, b2 = 0.8,
                          c1 = 0.2, c2 = 0.2, p = 0.0)
        params = getParamList(a2 = -0.3, b1 = 0.45, b2 = 0.9,
                              c1 = 0.1, c2 = 0.1, p = 0.0)
        Tmax = 20
        TN = 50
        Trange = np.linspace(0.01, Tmax, TN)
        R1 = np.zeros((TN,), complex)
        R2 = np.zeros((TN,), complex)
        
        for n, T in enumerate(Trange):
            print "T = ", T
            
            ##
            # flip-error R1
            ##
            h = Base(T=T, loop_type=1, init_state='a',
                       init_cond=params, loop_direction='-')
            _, psi_a, psi_b = h.solve_ODE()
            R1[n] = psi_b[-1]/psi_a[-1]
            
            ##
            # flip-error R2
            ##
            h = Base(T=T, loop_type=1, init_state='b',
                       init_cond=params, loop_direction='-')
            _, psi_a, psi_b = h.solve_ODE()
            R2[n] = psi_a[-1]/psi_b[-1]
            
        xlim(0, Tmax)
        ylim(1e-2, 1e3)
        semilogy(Trange, abs(R1), "ro-")
        semilogy(Trange, abs(R2), "go-")
        semilogy(Trange, abs(R1*R2), "ko-")
        show()