Skip to content

Commit 4e06670

Browse files
committed
add documentation on __call__ functions
1 parent 199e0dd commit 4e06670

12 files changed

Lines changed: 56 additions & 13 deletions

File tree

control/flatsys/basis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def __repr__(self):
7171
f'N={self.N}>'
7272

7373
def __call__(self, i, t, var=None):
74-
"""Evaluate the ith basis function at a point in time"""
74+
"""Evaluate the ith basis function at a point in time."""
7575
return self.eval_deriv(i, 0, t, var=var)
7676

7777
def var_ncoefs(self, var):
78-
"""Get the number of coefficients for a variable"""
78+
"""Get the number of coefficients for a variable."""
7979
return self.N if self.nvars is None else self.coef_length[var]
8080

8181
def eval(self, coeffs, tlist, var=None):

control/frdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class constructor, using the :func:`~control.frd` factory function, or
130130
131131
A frequency response data object is callable and returns the value of the
132132
transfer function evaluated at a point in the complex plane (must be on
133-
the imaginary access). See :meth:`~control.FrequencyResponseData.__call__`
133+
the imaginary axis). See :meth:`~control.FrequencyResponseData.__call__`
134134
for a more detailed description.
135135
136136
A state space system is callable and returns the value of the transfer

control/nlsys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __str__(self):
163163

164164
# Return the value of a static nonlinear system
165165
def __call__(sys, u, params=None, squeeze=None):
166-
"""Evaluate a (static) nonlinearity at a given input value
166+
"""Evaluate a (static) nonlinearity at a given input value.
167167
168168
If a nonlinear I/O system has no internal state, then evaluating the
169169
system at an input `u` gives the output `y = F(u)`, determined by the

control/xferfcn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ def den_list(self):
331331
num, den = num_list, den_list
332332

333333
def __call__(self, x, squeeze=None, warn_infinite=True):
334-
335334
"""Evaluate system's transfer function at complex frequencies.
336335
337336
Returns the complex frequency response `sys(x)` where `x` is `s` for

doc/classes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.. _class-ref:
21
.. currentmodule:: control
32

3+
.. _class-ref:
4+
45
**********************
56
Control system classes
67
**********************

doc/descfcn.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ If such an intersection exists, it indicates that there may be a limit
2626
cycle of amplitude :math:`A` with frequency :math:`\omega`.
2727

2828
Describing function analysis is a simple method, but it is approximate
29-
because it assumes that higher harmonics can be neglected.
29+
because it assumes that higher harmonics can be neglected.
30+
3031

3132
Module usage
3233
------------
@@ -90,3 +91,5 @@ Module classes and functions
9091
friction_backlash_nonlinearity
9192
relay_hysteresis_nonlinearity
9293
saturation_nonlinearity
94+
~DescribingFunctionNonlinearity.__call__
95+

doc/examples.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.. _examples:
21
.. currentmodule:: control
32

3+
.. _examples:
4+
45
********
56
Examples
67
********

doc/iosys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. _iosys-module:
2-
31
.. currentmodule:: control
42

3+
.. _iosys-module:
4+
55
**************************
66
Interconnected I/O Systems
77
**************************

doc/linear.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ complicated transfer functions::
114114

115115
sys = 5 * (s + 10)/(s**2 + 2*s + 1)
116116

117+
Transfer functions can be evaluated at a point in the complex plane by
118+
calling the transfer function object::
119+
120+
val = sys(s)
121+
117122
Discrete time transfer functions (described in more detail below) can
118123
be created using `z = ct.tf('z')`.
119124

@@ -227,6 +232,7 @@ response.
227232

228233
.. _discrete_time_systems:
229234

235+
230236
Discrete time systems
231237
=====================
232238

@@ -275,6 +281,7 @@ including functions for converting between state space and frequency
275281
domain, sampling systems in time and frequency domain, and creating
276282
reduced order models.
277283

284+
278285
Conversion between representations
279286
----------------------------------
280287

@@ -382,6 +389,7 @@ purpose, although in that case the output is usually used for plotting
382389
the frequency response, as described in more detail in the
383390
:ref:`frequency_response` section.
384391

392+
385393
Model reduction
386394
---------------
387395

doc/nlsys.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
..currentmodule control
1+
.. currentmodule:: control
22

33
Nonlinear system models
44
=======================
@@ -111,7 +111,7 @@ Operating points and linearization
111111
----------------------------------
112112

113113
A nonlinear input/output system can be linearized around an equilibrium point
114-
to obtain a :class:`~control.StateSpace` linear system::
114+
to obtain a :class:`StateSpace` linear system::
115115

116116
sys_ss = ct.linearize(sys_nl, xeq, ueq)
117117

@@ -143,7 +143,7 @@ Simulations and plotting
143143
------------------------
144144

145145
To simulate an input/output system, use the
146-
:func:`~control.input_output_response` function::
146+
:func:`input_output_response` function::
147147

148148
resp = ct.input_output_response(io_sys, T, U, x0, params)
149149
t, y, x = resp.time, resp.outputs, resp.states
@@ -159,3 +159,32 @@ different plot elements. The :func:`combine_time_responses` function
159159
an be used to combine multiple time responses into a single
160160
`TimeResponseData` object. See the :ref:`response-chapter` chapter
161161
for more information on this functionality.
162+
163+
Nonlinear system properties
164+
---------------------------
165+
166+
The following basic attributes and methods are available for
167+
:class:`NonlinearIOSystem` objects:
168+
169+
.. autosummary::
170+
171+
~NonlinearIOSystem.dynamics
172+
~NonlinearIOSystem.output
173+
~NonlinearIOSystem.linearize
174+
~NonlinearIOSystem.__call__
175+
176+
The :func:`~NonlinearIOSystem.dynamics` method returns the right hand
177+
side of the differential or difference equation, evaluated at the
178+
current time, state, input, and (optionally) parameter values. The
179+
:func:`~NonlinearIOSystem.output` method returns the system output.
180+
For static nonlinear systems, it is also possible to obtain the value
181+
of the output by directly calling the system with the value of the
182+
input::
183+
184+
>>> sys = ct.nlsys(
185+
... None, lambda t, x, u, params: np.sin(u), inputs=1, outputs=1)
186+
>>> sys(1)
187+
np.float64(0.8414709848078965)
188+
189+
The :func:`~NonlinearIOSystem.linearize` method is equivalent to the
190+
:func:`linearize` function.

0 commit comments

Comments
 (0)