@@ -98,15 +98,47 @@ def testAuto(self):
98
98
f2 = _convertToFRD (np .matrix ([[1 , 0 ], [0.1 , - 1 ]]), omega )
99
99
f2 = _convertToFRD ([[1 , 0 ], [0.1 , - 1 ]], omega )
100
100
101
- def testBode (self ):
101
+ def testNyquist (self ):
102
102
h1 = TransferFunction ([1 ], [1 , 2 , 2 ])
103
103
omega = np .logspace (- 1 , 2 , 40 )
104
104
f1 = FRD (h1 , omega )
105
105
control .freqplot .nyquist (f1 , np .logspace (- 1 , 2 , 100 ))
106
+ plt .savefig ('/dev/null' , format = 'svg' )
106
107
plt .figure (2 )
107
108
control .freqplot .nyquist (f1 , f1 .omega )
108
- plt .show ( )
109
+ plt .savefig ( '/dev/null' , format = 'svg' )
109
110
111
+ def testMIMO (self ):
112
+ sys = StateSpace ([[- 0.5 , 0.0 ], [0.0 , - 1.0 ]],
113
+ [[1.0 , 0.0 ], [0.0 , 1.0 ]],
114
+ [[1.0 , 0.0 ], [0.0 , 1.0 ]],
115
+ [[0.0 , 0.0 ], [0.0 , 0.0 ]])
116
+ omega = np .logspace (- 1 , 2 , 10 )
117
+ f1 = FRD (sys , omega )
118
+ np .testing .assert_array_almost_equal (
119
+ sys .freqresp ([0.1 , 1.0 , 10 ])[0 ],
120
+ f1 .freqresp ([0.1 , 1.0 , 10 ])[0 ])
121
+ np .testing .assert_array_almost_equal (
122
+ sys .freqresp ([0.1 , 1.0 , 10 ])[1 ],
123
+ f1 .freqresp ([0.1 , 1.0 , 10 ])[1 ])
124
+
125
+ def testMIMOfb (self ):
126
+ sys = StateSpace ([[- 0.5 , 0.0 ], [0.0 , - 1.0 ]],
127
+ [[1.0 , 0.0 ], [0.0 , 1.0 ]],
128
+ [[1.0 , 0.0 ], [0.0 , 1.0 ]],
129
+ [[0.0 , 0.0 ], [0.0 , 0.0 ]])
130
+ omega = np .logspace (- 1 , 2 , 10 )
131
+ f1 = FRD (sys , omega ).feedback ([[0.1 , 0.3 ],[0.0 , 1.0 ]])
132
+ f2 = FRD (sys .feedback ([[0.1 , 0.3 ],[0.0 , 1.0 ]]), omega )
133
+ print f1 - f2
134
+ print f1
135
+ print f2
136
+ #np.testing.assert_array_almost_equal(
137
+ # sys.feedback([[0.1, 0.3],[0.0, 1.0]]).freqresp([0.1, 1.0, 10])[0],
138
+ # f1.feedback([[0.1, 0.3],[0.0, 1.0]]).freqresp([0.1, 1.0, 10])[0])
139
+ #np.testing.assert_array_almost_equal(
140
+ # sys.feedback([[0.1, 0.3],[0.0, 1.0]]).freqresp([0.1, 1.0, 10])[1],
141
+ # f1.feedback([[0.1, 0.3],[0.0, 1.0]]).freqresp([0.1, 1.0, 10])[1])
110
142
if __name__ == "__main__" :
111
143
unittest .main ()
112
144
sys .exit (0 )
0 commit comments