コード例 #1
0
    def test_singular_equilibrium(self):
        N, L, Delta, theta, gamma = self.positive_toggle()
        pos_cfs = CyclicFeedbackSystem(N, L, Delta, theta, gamma)
        x = pos_cfs.singular_equilibrium()
        assert (np.allclose(x(.1), np.array([[1.5], [1.5]])))

        N, L, Delta, theta, gamma = self.neg_edge_toggle()
        pos_cfs = CyclicFeedbackSystem(N, L, Delta, theta, gamma)
        U1 = Delta[0, 1] + L[0, 1]
        U2 = Delta[1, 0] + L[1, 0]
        theta1 = theta[0, 1]
        theta2 = theta[1, 0]
        Delta1 = Delta[0, 1]
        Delta2 = Delta[1, 0]

        s = sympy.symbols('r')
        eps_func = sympy.Matrix([[0, 1], [1, 0]]) * s
        s_val = .1
        eps1 = s_val
        eps2 = s_val
        m1 = Delta1 / (2 * eps1)
        m2 = Delta2 / (2 * eps2)
        #solution for gamma1 = gamma2 = 1
        x1 = (U1 + (theta1 - eps1 - U2) * m1 -
              (theta2 - eps2) * m1 * m2) / (1 - m1 * m2)
        x2 = (U2 + (theta2 - eps2 - U1) * m2 -
              (theta1 - eps1) * m1 * m2) / (1 - m1 * m2)
        expected = np.array([[x1], [x2]])
        x = pos_cfs.singular_equilibrium(eps_func)
        assert (np.allclose(x(s_val), expected))
コード例 #2
0
 def test_pos_bifurcations(self):
     N, L, Delta, theta, gamma = self.neg_edge_toggle()
     cfs = CyclicFeedbackSystem(N, L, Delta, theta, gamma)
     s = sympy.symbols('s')
     eps_func = sympy.Matrix([[0, 1], [1, 0]]) * s
     x_eq = cfs.singular_equilibrium(eps_func, lambdify=False)
     zero_crossings = cfs.j_border_crossings(0, x_eq, eps_func)
     assert (len(zero_crossings) == 1)
     for crossing in zero_crossings:
         assert (np.allclose(crossing[0], .3162, rtol=1e-4))
         assert (np.allclose(cfs(crossing[1],
                                 np.array([[0, .3162], [.3162, 0]])),
                             np.zeros([2, 1]),
                             atol=1e-4))
     crossings, eps_func_out = cfs.border_crossings(eps_func)
     assert (eps_func_out == eps_func)
     assert (crossings[0][0][0] == zero_crossings[0][0])
     assert (len(crossings[1]) == 1)
     for crossing in crossings[1]:
         assert (np.allclose(crossing[0], .67202))
         assert (np.allclose(cfs(crossing[1],
                                 np.array([[0, .67202], [.67202, 0]])),
                             np.zeros([2, 1]),
                             atol=1e-4))
     #get_bifurcations
     bifurcations = cfs.get_bifurcations(eps_func)[0]
     assert (not cfs.in_singular_domain(
         x_eq.subs(s, .37202), np.array([[0, .37202], [.37202, 0]]), 1))
     assert (len(bifurcations[0]) == 1)
     for s_val in bifurcations[0]:
         assert (np.allclose(s_val[0], .3162, rtol=1e-4))
     #make sure border_crossings runs on three nodes
     cfs = CyclicFeedbackSystem(*self.three_node_network())
     crossings, eps_func = cfs.border_crossings()
     assert (True)