Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

t_eval is not respected for system with 0 states #742

Closed
Labels
@hyumo

Description

@hyumo

It seems thatt_eval is ignored when simulating a system withnstates=0.

The bug seems to be located at:

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:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp