8000 add documentation for vector element processing · python-control/python-control@0fab739 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fab739

Browse files
committed
add documentation for vector element processing
1 parent b10e3e2 commit 0fab739

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

doc/iosys.rst

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,86 @@ Additional features
191191
===================
192192

193193
The I/O systems module has a number of other features that can be used to
194-
simplify the creation of interconnected input/output systems.
194+
simplify the creation and use of interconnected input/output systems.
195+
196+
Vector elements processing
197+
--------------------------
198+
199+
Several I/O system commands perform processing of vector elements
200+
(such as initial states or input vectors) and broadcast these to the
201+
proper shape.
202+
203+
For static elements, such as the initial state in a simulation or the
204+
nominal state and input for a linearization), the following processing
205+
is done:
206+
207+
* Scalars are automatically converted to a vector of the appropriate
208+
size consisting of the scalar value. This is commonly used when
209+
specifying the origin ('0') or a step input ('1').
210+
211+
* Lists of values are concatenated into a single vector. This is
212+
often used when you have an interconnected system and you need to
213+
specify the initial condition or input value for each subsystem
214+
(e.g., [X1eq, X2eq, ...]).
215+
216+
* Vector elements are zero padded to the required length. If you
217+
specify only a portion of the values for states or inputs, the
218+
remaining values are taken as zero. (If the final element in the
219+
given vector is non-zero, a warning is issues.)
220+
221+
Similar processing is done for input time series, used for the
222+
:func:`~control.input_output_response` and
223+
:func:`~control.forced_response` commands, with the following
224+
additional feature:
225+
226+
* Time series elements are broadcast to match the number of time points
227+
specified. If a list of time series and static elements are given (as a
228+
list), static elements are broadcast to the proper number of time points,
229+
and the overall list of elements concatenated to provide the full input
230+
vector.
231+
232+
As an example, suppose we have an interconnected system consisting of three
233+
subsystems, a controlled process, an estimator, and a (static) controller::
234+
235+
proc = ct.nlsys(...,
236+
states=2, inputs=['u1', 'u2', 'd'], outputs='y')
237+
estim = ct.nlsys(...,
238+
states=2, inputs='y', outputs=['xhat[0]', 'xhat[1]')
239+
ctrl = ct.nlsys(...,
240+
states=0, inputs=['r', 'xhat[0]', 'xhat[1]'], outputs=['u1', 'u2'])
241+
242+
clsys = ct.interconnect(
243+
[proc, estim, ctrl], inputs=['r', 'd'], outputs=['y', 'u1', 'u2'])
244+
245+
To linearize the system around the origin, we can utilize the scalar
246+
processing feature of vector elements::
247+
248+
P = proc.linearize(0, 0)
249+
250+
In this command, the states and the inputs are broadcast to the size of the
251+
state and input vectors, respectively.
252+
253+
If we want to linearize the closed loop system around a process state
254+
``x0`` (with two elemenst) and an estimator state ``0`` (for both states),
255+
we can use the list processing feature::
256+
257+
H = clsys.liniearize([x0, 0], 0)
258+
259+
Note that this also utilizes the zero-padding functionality, since the
260+
second argument in the list ``[x0, 0]`` is a scalar and so the vector
261+
``[x0, 0]`` only has three elements instead of the required four.
262+
263+
To run an input/output simulation with a sinsoidal signal for the first
264+
input, a constant for the second input, and no external disturbance, we can
265+
use the list processing feature combined with time series broadcasting::
266+
267+
timepts = np.linspace(0, 10)
268+
u1 = np.sin(timepts)
269+
u2 = 1
270+
resp = ct.input_output_response(clsys, timepts, [u1, u2, 0])
271+
272+
In this command, the second and third arguments will be broadcast to match
273+
the number of time points.
195274

196275
Summing junction
197276
----------------

0 commit comments

Comments
 (0)
0