66
77import numpy as np
88import matplotlib .pyplot as mpl
9- from control .phaseplot import PhasePlot
9+ from control .phaseplot import phase_plot
1010from numpy import pi
1111
1212# Clear out any figures that are present
@@ -26,7 +26,7 @@ def invpend_ode(x, t, m=1., l=1., b=0.2, g=1):
2626mpl .title ('Inverted pendlum' )
2727
2828# Outer trajectories
29- PhasePlot (invpend_ode ,
29+ phase_plot (invpend_ode ,
3030 X0 = [ [- 2 * pi , 1.6 ], [- 2 * pi , 0.5 ], [- 1.8 , 2.1 ],
3131 [- 1 , 2.1 ], [4.2 , 2.1 ], [5 , 2.1 ],
3232 [2 * pi , - 1.6 ], [2 * pi , - 0.5 ], [1.8 , - 2.1 ],
@@ -36,7 +36,7 @@ def invpend_ode(x, t, m=1., l=1., b=0.2, g=1):
3636
3737# Separatrices
3838mpl .hold (True );
39- PhasePlot (invpend_ode , X0 = [[- 2.3056 , 2.1 ], [2.3056 , - 2.1 ]], T = 6 , lingrid = 0 )
39+ phase_plot (invpend_ode , X0 = [[- 2.3056 , 2.1 ], [2.3056 , - 2.1 ]], T = 6 , lingrid = 0 )
4040mpl .show ();
4141
4242#
@@ -48,15 +48,15 @@ def oscillator_ode(x, t, m=1., b=1, k=1):
4848
4949# Generate a vector plot for the damped oscillator
5050mpl .figure (); mpl .clf ();
51- PhasePlot (oscillator_ode , [- 1 , 1 , 10 ], [- 1 , 1 , 10 ], 0.15 );
51+ phase_plot (oscillator_ode , [- 1 , 1 , 10 ], [- 1 , 1 , 10 ], 0.15 );
5252mpl .hold (True ); mpl .plot ([0 ], [0 ], '.' );
5353# a=gca; set(a,'FontSize',20); set(a,'DataAspectRatio',[1,1,1]);
5454mpl .xlabel ('x1' ); mpl .ylabel ('x2' );
5555
5656# Generate a phase plot for the damped oscillator
5757mpl .figure (); mpl .clf ();
5858mpl .axis ([- 1 , 1 , - 1 , 1 ]); # set(gca, 'DataAspectRatio', [1, 1, 1]);
59- PhasePlot (oscillator_ode ,
59+ phase_plot (oscillator_ode ,
6060 X0 = [
6161 [- 1 , 1 ], [- 0.3 , 1 ], [0 , 1 ], [0.25 , 1 ], [0.5 , 1 ], [0.75 , 1 ], [1 , 1 ],
6262 [1 , - 1 ], [0.3 , - 1 ], [0 , - 1 ], [- 0.25 , - 1 ], [- 0.5 , - 1 ], [- 0.75 , - 1 ], [- 1 , - 1 ]
@@ -81,7 +81,7 @@ def saddle_ode(x, t):
8181m = 1 ; b = 1 ; k = 1 ; # default values
8282mpl .figure (); mpl .clf ();
8383mpl .axis ([- 1 , 1 , - 1 , 1 ]); # set(gca, 'DataAspectRatio', [1 1 1]);
84- PhasePlot (oscillator_ode ,
84+ phase_plot (oscillator_ode ,
8585 X0 = [
8686 [- 1 ,1 ], [- 0.3 ,1 ], [0 ,1 ], [0.25 ,1 ], [0.5 ,1 ], [0.7 ,1 ], [1 ,1 ], [1.3 ,1 ],
8787 [1 ,- 1 ], [0.3 ,- 1 ], [0 ,- 1 ], [- 0.25 ,- 1 ], [- 0.5 ,- 1 ], [- 0.7 ,- 1 ], [- 1 ,- 1 ],
@@ -95,7 +95,7 @@ def saddle_ode(x, t):
9595# Saddle
9696mpl .figure (); mpl .clf ();
9797mpl .axis ([- 1 , 1 , - 1 , 1 ]); # set(gca, 'DataAspectRatio', [1 1 1]);
98- PhasePlot (saddle_ode , scale = 2 , timepts = [0.2 , 0.5 , 0.8 ], X0 =
98+ phase_plot (saddle_ode , scale = 2 , timepts = [0.2 , 0.5 , 0.8 ], X0 =
9999 [ [- 1 , - 1 ], [1 , 1 ],
100100 [- 1 , - 0.95 ], [- 1 , - 0.9 ], [- 1 , - 0.8 ], [- 1 , - 0.6 ], [- 1 , - 0.4 ], [- 1 , - 0.2 ],
101101 [- 0.95 , - 1 ], [- 0.9 , - 1 ], [- 0.8 , - 1 ], [- 0.6 , - 1 ], [- 0.4 , - 1 ], [- 0.2 , - 1 ],
@@ -111,7 +111,7 @@ def saddle_ode(x, t):
111111m = 1 ; b = 0 ; k = 1 ; # zero damping
112112mpl .figure (); mpl .clf ();
113113mpl .axis ([- 1 , 1 , - 1 , 1 ]); # set(gca, 'DataAspectRatio', [1 1 1]);
114- PhasePlot (oscillator_ode , timepts =
114+ phase_plot (oscillator_ode , timepts =
115115 [pi / 6 , pi / 3 , pi / 2 , 2 * pi / 3 , 5 * pi / 6 , pi , 7 * pi / 6 , 4 * pi / 3 , 9 * pi / 6 , 5 * pi / 3 , 11 * pi / 6 , 2 * pi ],
116116 X0 = [ [0.2 ,0 ], [0.4 ,0 ], [0.6 ,0 ], [0.8 ,0 ], [1 ,0 ], [1.2 ,0 ], [1.4 ,0 ] ],
117117 T = np .linspace (0 , 20 , 200 ), parms = (m , b , k ));
0 commit comments