def testOscillatorParams(self):
     m = 1; b = 1; k = 1;			# default values
     phase_plot(self.oscillator_ode, timepts = [0.3, 1, 2, 3], X0 =
               [[-1,1], [-0.3,1], [0,1], [0.25,1], [0.5,1], [0.7,1],
                [1,1], [1.3,1], [1,-1], [0.3,-1], [0,-1], [-0.25,-1],
                [-0.5,-1], [-0.7,-1], [-1,-1], [-1.3,-1]],
               T = np.linspace(0, 10, 100), parms = (m, b, k));
 def testInvPendLogtime(self):
     phase_plot(self.invpend_ode,
                X0=[[-2 * pi, 1.6], [-2 * pi, 0.5], [-1.8, 2.1], [-1, 2.1],
                    [4.2, 2.1], [5, 2.1], [2 * pi, -1.6], [2 * pi, -0.5],
                    [1.8, -2.1], [1, -2.1], [-4.2, -2.1], [-5, -2.1]],
                T=np.linspace(0, 40, 200),
                logtime=(3, 0.7),
                verbose=False)
 def testInvPendLogtime(self):
     phase_plot(self.invpend_ode, X0 =
               [ [-2*pi, 1.6], [-2*pi, 0.5], [-1.8, 2.1],
                 [-1, 2.1], [4.2, 2.1], [5, 2.1],
                 [2*pi, -1.6], [2*pi, -0.5], [1.8, -2.1],
                 [1, -2.1], [-4.2, -2.1], [-5, -2.1] ],
               T = np.linspace(0, 40, 200),
               logtime=(3, 0.7),
               verbose=False)
 def testOscillatorParams(self):
     # default values
     m = 1
     b = 1
     k = 1
     phase_plot(self.oscillator_ode,
                timepts=[0.3, 1, 2, 3],
                X0=[[-1, 1], [-0.3, 1],
                    [0, 1], [0.25, 1], [0.5, 1], [0.7, 1], [1, 1], [1.3, 1],
                    [1, -1], [0.3, -1], [0, -1], [-0.25, -1], [-0.5, -1],
                    [-0.7, -1], [-1, -1], [-1.3, -1]],
                T=np.linspace(0, 10, 100),
                parms=(m, b, k))
    def testNoArrows(self):
        # Test case from aramakrl that was generating a type error
        # System does not have arrows
        # cf. issue #96,
        # https://github.com/python-control/python-control/issues/96
        def d1(x1x2, t):
            x1, x2 = x1x2
            return np.array([x2, x2 - 2 * x1])

        x1x2_0 = np.array([[-1., 1.], [-1., -1.], [1., 1.], [1., -1.],
                           [-1., 0.], [1., 0.], [0., -1.], [0., 1.], [0., 0.]])

        mpl.figure(1)
        phase_plot(d1, X0=x1x2_0, T=100)
    def testNoArrows(self):
        # Test case from aramakrl that was generating a type error
        # System does not have arrows
        # cf. issue #96,
        # https://github.com/python-control/python-control/issues/96
        def d1(x1x2,t):
            x1,x2 = x1x2
            return np.array([x2, x2 - 2*x1])

        x1x2_0 = np.array([[-1.,1.], [-1.,-1.], [1.,1.], [1.,-1.],
                           [-1.,0.],[1.,0.],[0.,-1.],[0.,1.],[0.,0.]])

        mpl.figure(1)
        phase_plot(d1,X0=x1x2_0,T=100)
plt.plot([tim1[-1], tim1[-1] + 1], [sol1[-1, 0], sol2[0, 1]], 'ko:',
         [tim1[-1], tim1[-1] + 1], [sol1[-1, 1], sol2[0, 0]], 'ko:')
# set(pl, 'LineWidth', AM_data_linewidth, 'MarkerSize', AM_data_markersize)
plt.plot(tim2, sol2[:, 0], 'b-', tim2, sol2[:, 1], 'g--')
# set(pl, 'LineWidth', AM_data_linewidth)
plt.axis([0, 25, 0, 5])

plt.xlabel('Time {\itt} [scaled]')
plt.ylabel('Protein concentrations [scaled]')
plt.legend(('z1 (A)', 'z2 (B)'))  # 'Orientation', 'horizontal')
# legend(legh, 'boxoff')

# Phase portrait
plt.figure(2)
plt.clf()  # subplot(221)
plt.axis([0, 5, 0, 5])  # set(gca, 'DataAspectRatio', [1, 1, 1])
phase_plot(genswitch,
           X0=box_grid([0, 5, 6], [0, 5, 6]),
           T=10,
           timepts=[0.2, 0.6, 1.2])

# Add the stable equilibrium points
plt.plot(eqpt[0], eqpt[1], 'k.', eqpt[1], eqpt[0], 'k.', eqpt[2], eqpt[2],
         'k.')  # 'MarkerSize', AM_data_markersize*3)

plt.xlabel('Protein A [scaled]')
plt.ylabel('Protein B [scaled]')  # 'Rotation', 90)

if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
    plt.show()
Example #8
0
mpl.plot(tim1, sol1[:,0], 'b-', tim1, sol1[:,1], 'g--');
# set(pl, 'LineWidth', AM_data_linewidth);
mpl.plot([tim1[-1], tim1[-1]+1], 
         [sol1[-1,0], sol2[0,1]], 'ko:', 
         [tim1[-1], tim1[-1]+1], [sol1[-1,1], sol2[0,0]], 'ko:');
# set(pl, 'LineWidth', AM_data_linewidth, 'MarkerSize', AM_data_markersize);
mpl.plot(tim2, sol2[:,0], 'b-', tim2, sol2[:,1], 'g--');
# set(pl, 'LineWidth', AM_data_linewidth);
mpl.axis([0, 25, 0, 5]);

mpl.xlabel('Time {\itt} [scaled]');
mpl.ylabel('Protein concentrations [scaled]');
mpl.legend(('z1 (A)', 'z2 (B)'))  # 'Orientation', 'horizontal');
# legend(legh, 'boxoff');

# Phase portrait
mpl.figure(2); mpl.clf(); # subplot(221);
mpl.axis([0, 5, 0, 5]);         # set(gca, 'DataAspectRatio', [1, 1, 1]);
phase_plot(genswitch, X0 = box_grid([0, 5, 6], [0, 5, 6]), T = 10, 
          timepts = [0.2, 0.6, 1.2])

# Add the stable equilibrium points
mpl.plot(eqpt[0], eqpt[1], 'k.', eqpt[1], eqpt[0], 'k.', 
  eqpt[2], eqpt[2], 'k.')       # 'MarkerSize', AM_data_markersize*3);

mpl.xlabel('Protein A [scaled]');
mpl.ylabel('Protein B [scaled]');       # 'Rotation', 90);

if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
    mpl.show()
 def testInvPendAuto(self):
     phase_plot(self.invpend_ode,
                lingrid=0,
                X0=[[-2.3056, 2.1], [2.3056, -2.1]],
                T=6,
                verbose=False)
 def testInvPendTimePoints(self):
     phase_plot(self.invpend_ode, (-6, 6, 10), (-6, 6, 10),
                X0=([1, 1], [-1, 1]),
                T=np.linspace(0, 5, 100))
 def testInvPendSims(self):
     phase_plot(self.invpend_ode, (-6, 6, 10), (-6, 6, 10),
                X0=([1, 1], [-1, 1]))
 def testInvPendNoSims(self):
     phase_plot(self.invpend_ode, (-6, 6, 10), (-6, 6, 10))
 def testInvPendAuto(self):
     phase_plot(self.invpend_ode, lingrid = 0, X0=
               [[-2.3056, 2.1], [2.3056, -2.1]], T=6, verbose=False)
 def testInvPendTimePoints(self):
     phase_plot(self.invpend_ode, (-6,6,10), (-6,6,10),
               X0 = ([1,1], [-1,1]), T=np.linspace(0,5,100));
 def testInvPendSims(self):
     phase_plot(self.invpend_ode, (-6,6,10), (-6,6,10),
               X0 = ([1,1], [-1,1]));
 def testInvPendNoSims(self):
     phase_plot(self.invpend_ode, (-6,6,10), (-6,6,10));