- Notifications
You must be signed in to change notification settings - Fork441
Closed
Labels
Description
It seems thatt_eval
is ignored when simulating a system withnstates=0
.
The bug seems to be located at:
python-control/control/iosys.py
Lines 1767 to 1777 in3b5f199
ifnstates==0: | |
# No states => map input to output | |
u=U[0]iflen(U.shape)==1elseU[:,0] | |
y=np.zeros((np.shape(sys._out(T[0],X0,u))[0],len(T))) | |
foriinrange(len(T)): | |
u=U[i]iflen(U.shape)==1elseU[:,i] | |
y[:,i]=sys._out(T[i], [],u) | |
returnTimeResponseData( | |
T,y,None,U,issiso=sys.issiso(), | |
output_labels=sys.output_index,input_labels=sys.input_index, | |
transpose=transpose,return_x=return_x,squeeze=squeeze) |
Instead, the following lines are expected to be used, I think:
python-control/control/iosys.py
Lines 1798 to 1825 in3b5f199
defufun(t): | |
# Find the value of the index using linear interpolation | |
# Use clip to allow for extrapolation if t is out of range | |
idx=np.clip(np.searchsorted(T,t,side='left'),1,len(T)-1) | |
dt= (t-T[idx-1])/ (T[idx]-T[idx-1]) | |
returnU[...,idx-1]* (1.-dt)+U[...,idx]*dt | |
# Check to make sure this is not a static function | |
ifnstates==0:# No states => map input to output | |
# Make sure the user gave a time vector for evaluation (or 'T') | |
ift_evalisNone: | |
# User overrode t_eval with None, but didn't give us the times... | |
warn("t_eval set to None, but no dynamics; using T instead") | |
t_eval=T | |
# Allocate space for the inputs and outputs | |
u=np.zeros((ninputs,len(t_eval))) | |
y=np.zeros((noutputs,len(t_eval))) | |
# Compute the input and output at each point in time | |
fori,tinenumerate(t_eval): | |
u[:,i]=ufun(t) | |
y[:,i]=sys._out(t, [],u[:,i]) | |
returnTimeResponseData( | |
t_eval,y,None,u,issiso=sys.issiso(), | |
output_labels=sys.output_index,input_labels=sys.input_index, | |
transpose=transpose,return_x=return_x,squeeze=squeeze) |