@@ -1233,6 +1233,39 @@ def test_refgain_pattern(ninputs, Kf):
12331233 np .testing .assert_almost_equal (clsys .D [:sys .nstates , :], manual .D )
12341234
12351235
1236+ def test_refgain_pattern_integral_action ():
1237+ sys = ct .ss (
1238+ [[0.0 , 1.0 ], [- 2.0 , - 3.0 ]],
1239+ [[0.0 , 1.0 ], [1.0 , 0.0 ]],
1240+ np .eye (2 ),
1241+ np .zeros ((2 , 2 )),
1242+ )
1243+ Kp = np .array ([[1.0 , 2.0 ], [3.0 , 4.0 ]])
1244+ Ki = np .array ([[5.0 ], [6.0 ]])
1245+ K = np .hstack ([Kp , Ki ])
1246+ Kf = np .diag ([7.0 , 8.0 ])
1247+ C_int = np .array ([[1.0 , 0.0 ]])
1248+
1249+ ctrl , clsys = ct .create_statefbk_iosystem (
1250+ sys , K , Kf , integral_action = C_int , feedfwd_pattern = 'refgain' )
1251+
1252+ np .testing .assert_array_equal (ctrl .A , np .zeros ((1 , 1 )))
1253+ np .testing .assert_array_equal (ctrl .B , np .hstack ([- np .eye (1 , 2 ), C_int ]))
1254+ np .testing .assert_array_equal (ctrl .C , - Ki )
1255+ np .testing .assert_array_equal (ctrl .D , np .hstack ([Kf , - Kp ]))
1256+
1257+ np .testing .assert_array_equal (
1258+ clsys .A , np .block ([[sys .A - sys .B @ Kp , - sys .B @ Ki ],
1259+ [C_int , np .zeros ((1 , 1 ))]]))
1260+ np .testing .assert_array_equal (
1261+ clsys .B , np .vstack ([sys .B @ Kf , - np .eye (1 , sys .ninputs )]))
1262+ np .testing .assert_array_equal (
1263+ clsys .C , np .block ([[np .eye (sys .nstates ), np .zeros ((sys .nstates , 1 ))],
1264+ [- Kp , - Ki ]]))
1265+ np .testing .assert_array_equal (
1266+ clsys .D , np .vstack ([np .zeros ((sys .nstates , sys .ninputs )), Kf ]))
1267+
1268+
12361269def test_create_statefbk_errors ():
12371270 sys = ct .rss (2 , 2 , 1 , strictly_proper = True )
12381271 sys .C = np .eye (2 )
0 commit comments