From: Ryan K. <kra...@gv...> - 2019-11-26 01:01:00
|
I have a transfer function and I want to simulate its response to initial conditions. Do to this correctly, I think I need to get to OCF so that I understand the initial conditions of the states (if I thought about it, maybe I could use C**-1 to find initial conditions for the states in any form). control.canonical_form seems prefect: from control import TransferFunction as TF diff = TF([1,0],1) wn = 1.1*2*pi z = 0.03 so_p = TF(wn,[1,2*z*wn,wn**2]) p = 2*2*pi pole = TF(p,[1,p]) G = diff*so_p*pole G sys1 = control.tf2ss(G) sys = control.canonical_form(sys1,"observable") When I run that line, I see my desired C=[[1,0,0]] But when I try to run the initial_response method, I get an error: t, y_ol = control.initial_response(sys,t,X0=[100,0,0]) Failure to assume argument is matrix-like in _convertToStateSpace, result setting an array element with a sequence. ---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-13-9f800e97ff4d> in <module>()----> 1 t, y_ol = control.initial_response(sys,t,X0=[100,0,0],input=0,output=0) /usr/local/lib/python3.6/site-packages/control/timeresp.py in initial_response(sys, T, X0, input, output, transpose, return_x) 619 >>> T, yout = initial_response(sys, T, X0) 620 """--> 621 sys = _get_ss_simo(sys, input, output) 622 623 # Create time and input vectors; checking is done in forced_response(...) /usr/local/lib/python3.6/site-packages/control/timeresp.py in _get_ss_simo(sys, input, output) 378 If input is not specified, select first input and issue warning 379 """--> 380 sys_ss = _convertToStateSpace(sys) 381 if sys_ss.issiso(): 382 return sys_ss /usr/local/lib/python3.6/site-packages/control/statesp.py in _convertToStateSpace(sys, **kw) 946 " _convertToStateSpace, result %s" % e) 947 --> 948 raise TypeError("Can't convert given type to StateSpace system.") 949 950 # TODO: add discrete time option TypeError: Can't convert given type to StateSpace system. It sounds like somehow control.initial_response doesn't recognize sys is ss or that it is simo. Am I doing something wrong? How should I proceed? Thanks, Ryan -- Dr. Ryan Krauss Associate Professor Product Design and Manufacturing Engineering Grand Valley State University |