Skip to content

Commit 48cf4f4

Browse files
committed
fix bug in predprey controller (was generating wrong steady state
1 parent 258e28e commit 48cf4f4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
421 Bytes
Loading

doc/iosys.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ constructed using :func:`nlsys` with no update function:
236236
.. testcode:: predprey
237237

238238
def output(t, x, u, params):
239-
return -K @ (u[1:] - xeq) + kf * (u[0] - ueq)
239+
Ld, x, ye = u[0], u[1:], xeq[1]
240+
return ueq - K @ (x - xeq) + kf * (Ld - ye)
240241

241242
controller = ct.nlsys(
242243
None, output,
@@ -259,16 +260,19 @@ To connect the controller to the predatory-prey model, we use the
259260
],
260261
inplist=['control.Ld'], inputs='Ld',
261262
outlist=['predprey.Hares', 'predprey.Lynxes', 'control.y[0]'],
262-
outputs=['Hares', 'Lynxes', 'u0'], name='closed'
263+
outputs=['Hares', 'Lynxes', 'u0'], name='closed loop'
263264
)
264265

265266
Finally, we simulate the closed loop system:
266267

267268
.. testcode:: predprey
268269

269270
# Simulate the system
270-
resp = ct.input_output_response(closed, timepts, 30, [15, 20])
271-
resp.plot(plot_inputs=False, overlay_signals=True, legend_loc='upper left')
271+
Ld = 30
272+
resp = ct.input_output_response(closed, timepts, U=Ld, X0=[15, 20])
273+
cplt = resp.plot(
274+
plot_inputs=False, overlay_signals=True, legend_loc='upper left')
275+
cplt.axes[0, 0].axhline(Ld, linestyle='--', color='black')
272276

273277
.. testcode:: predprey
274278
:hide:

0 commit comments

Comments
 (0)