Esempio n. 1
0
    def plot_phase_plane_closed_loop( self , x_axis = 0 , y_axis = 1 ):
        """ 
        Plot Phase Plane vector field of the system
        ------------------------------------------------
        
        blue arrows for the open-loop behavior
        red arrows  for the closed-loop behavior
        
        """

        pp = phaseanalysis.PhasePlot( self.plant , x_axis , y_axis )
        
        pp.compute_grid()
        pp.plot_init()
        
        # Closed-loop Behavior
        pp.color = 'b'
        pp.compute_vector_field()
        pp.plot_vector_field()
        
        # Open-Loop Behavior
        pp.f     = self.fzbar    # assume default internal states
        pp.ubar  = self.ubar
        pp.color = 'r'
        pp.compute_vector_field()
        pp.plot_vector_field()
        
        pp.plot_finish()
        
        return pp
Esempio n. 2
0
    def phase_plane_trajectory_closed_loop(self, traj, x_axis, y_axis):
        """ """
        pp = phaseanalysis.PhasePlot(self.sys, x_axis, y_axis)

        pp.compute_grid()
        pp.plot_init()

        # Closed-loop Behavior
        pp.color = 'r'
        pp.compute_vector_field()
        pp.plot_vector_field()

        # Open-Loop Behavior
        pp.f = self.sys.f
        pp.ubar = self.sys.ubar
        pp.color = 'b'
        pp.compute_vector_field()
        pp.plot_vector_field()

        pp.plot_finish()

        # Plot trajectory
        plt.plot(traj.x[:, x_axis], traj.x[:, y_axis], 'b-')  # path
        plt.plot([traj.x[0, x_axis]], [traj.x[0, y_axis]], 'o')  # start
        plt.plot([traj.x[-1, x_axis]], [traj.x[-1, y_axis]], 's')  # end

        plt.draw()

        plt.tight_layout()

        plt.draw()
        plt.show()
Esempio n. 3
0
 def phase_plane_trajectory_closed_loop(self , x_axis , y_axis ):
     """ """
     self.pp = phaseanalysis.PhasePlot( self.cds , x_axis , y_axis )
     
     self.pp.compute_grid()
     self.pp.plot_init()
     
     # Closed-loop Behavior
     self.pp.color = 'r'
     self.pp.compute_vector_field()
     self.pp.plot_vector_field()
     
     # Open-Loop Behavior
     self.pp.f     = self.sys.f
     self.pp.ubar  = self.sys.ubar
     self.pp.color = 'b'
     self.pp.compute_vector_field()
     self.pp.plot_vector_field()
     
     self.pp.plot_finish()
     
     # Plot trajectory
     plt.plot(self.x_sol[:,x_axis], self.x_sol[:,y_axis], 'b-') # path
     plt.plot([self.x_sol[0,x_axis]], [self.x_sol[0,y_axis]], 'o') # start
     plt.plot([self.x_sol[-1,x_axis]], [self.x_sol[-1,y_axis]], 's') # end
     
     plt.tight_layout()
Esempio n. 4
0
    def plot_phase_plane_closed_loop(self, x_axis=0, y_axis=1):
        """ 
        Plot Phase Plane vector field of the system
        ------------------------------------------------
        
        x_axis : index of state on x axis
        y_axis : index of state on y axis
        
        """

        self.pp = phaseanalysis.PhasePlot(self, x_axis, y_axis)

        self.pp.compute_grid()
        self.pp.plot_init()

        # Closed-loop Behavior
        self.pp.color = 'r'
        self.pp.compute_vector_field()
        self.pp.plot_vector_field()

        # Open-Loop Behavior
        self.pp.f = self.sys.f
        self.pp.ubar = self.sys.ubar
        self.pp.color = 'b'
        self.pp.compute_vector_field()
        self.pp.plot_vector_field()

        self.pp.plot_finish()
Esempio n. 5
0
 def phase_plane_trajectory(self , x_axis , y_axis ):
     """ """
     self.pp = phaseanalysis.PhasePlot( self.cds , x_axis , y_axis )
     self.pp.plot()
            
     plt.plot(self.x_sol[:,x_axis], self.x_sol[:,y_axis], 'b-') # path
     plt.plot([self.x_sol[0,x_axis]], [self.x_sol[0,y_axis]], 'o') # start
     plt.plot([self.x_sol[-1,x_axis]], [self.x_sol[-1,y_axis]], 's') # end
     
     self.pp.phasefig.tight_layout()
Esempio n. 6
0
    def plot_phase_plane(self , x_axis = 0 , y_axis = 1 ):
        """ 
        Plot Phase Plane vector field of the system
        ------------------------------------------------
        x_axis : index of state on x axis
        y_axis : index of state on y axis
        
        """

        self.pp = phaseanalysis.PhasePlot( self , x_axis , y_axis )
        
        self.pp.plot()
Esempio n. 7
0
    def phase_plane_trajectory(self, traj, x_axis=0, y_axis=1):
        """ """
        pp = phaseanalysis.PhasePlot(self.sys, x_axis, y_axis)
        pp.plot()

        plt.plot(traj.x[:, x_axis], traj.x[:, y_axis], 'b-')  # path
        plt.plot([traj.x[0, x_axis]], [traj.x[0, y_axis]], 'o')  # start
        plt.plot([traj.x[-1, x_axis]], [traj.x[-1, y_axis]], 's')  # end

        plt.draw()

        pp.phasefig.tight_layout()

        plt.draw()
        plt.show()