8000 Merge pull request #497 from murrayrm/linearize_named_signals · python-control/python-control@4103688 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 4103688

Browse files
authored
Merge pull request #497 from murrayrm/linearize_named_signals
I/O system improvements: linearize, interconnect, docstrings
2 parents 8f5d8e5 + 5ed0f96 commit 4103688

File tree

11 files changed

+847
-357
lines changed

11 files changed

+847
-357
lines changed

control/bdalg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ def connect(sys, Q, inputv, outputv):
326326
>>> Q = [[1, 2], [2, -1]] # negative feedback interconnection
327327
>>> sysc = connect(sys, Q, [2], [1, 2])
328328
329+
Notes
330+
-----
331+
The :func:`~control.interconnect` function in the
332+
:ref:`input/output systems <iosys-module>` module allows the use
333+
of named signals and provides an alternative method for
334+
interconnecting multiple systems.
335+
329336
"""
330337
inputv, outputv, Q = np.asarray(inputv), np.asarray(outputv), np.asarray(Q)
331338
# check indices

control/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,15 @@ def use_legacy_defaults(version):
215215
if major == 0 and minor < 9:
216216
# switched to 'array' as default for state space objects
217217
set_defaults('statesp', use_numpy_matrix=True)
218+
218219
# switched to 0 (=continuous) as default timestep
219220
set_defaults('control', default_dt=None)
220221

222+
# changed iosys naming conventions
223+
set_defaults('iosys', state_name_delim='.',
224+
duplicate_system_name_prefix='copy of ',
225+
duplicate_system_name_suffix='',
226+
linearized_system_name_prefix='',
227+
linearized_system_name_suffix='_linearized')
228+
221229
return (major, minor, patch)

control/iosys.py

Lines changed: 448 additions & 245 deletions
Large diffs are not rendered by default.

control/statesp.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def _convertToStateSpace(sys, **kw):
12641264

12651265

12661266
# TODO: add discrete time option
1267-
def _rss_generate(states, inputs, outputs, type):
1267+
def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
12681268
"""Generate a random state space.
12691269
12701270
This does the actual random state space generation expected from rss and
@@ -1374,7 +1374,7 @@ def _rss_generate(states, inputs, outputs, type):
13741374
# Apply masks.
13751375
B = B * Bmask
13761376
C = C * Cmask
1377-
D = D * Dmask
1377+
D = D * Dmask if not strictly_proper else zeros(D.shape)
13781378

13791379
return StateSpace(A, B, C, D)
13801380

@@ -1649,7 +1649,7 @@ def tf2ss(*args):
16491649
raise ValueError("Needs 1 or 2 arguments; received %i." % len(args))
16501650

16511651

1652-
def rss(states=1, outputs=1, inputs=1):
1652+
def rss(states=1, outputs=1, inputs=1, strictly_proper=False):
16531653
"""
16541654
Create a stable *continuous* random state space object.
16551655
@@ -1661,6 +1661,9 @@ def rss(states=1, outputs=1, inputs=1):
16611661
Number of system inputs
16621662
outputs : integer
16631663
Number of system outputs
1664+
strictly_proper : bool, optional
1665+
If set to 'True', returns a proper system (no direct term). Default
1666+
value is 'False'.
16641667
16651668
Returns
16661669
-------
@@ -1684,10 +1687,11 @@ def rss(states=1, outputs=1, inputs=1):
16841687
16851688
"""
16861689

1687-
return _rss_generate(states, inputs, outputs, 'c')
1690+
return _rss_generate(states, inputs, outputs, 'c',
1691+
strictly_proper=strictly_proper)
16881692

16891693

1690-
def drss(states=1, outputs=1, inputs=1):
1694+
def drss(states=1, outputs=1, inputs=1, strictly_proper=False):
16911695
"""
16921696
Create a stable *discrete* random state space object.
16931697
@@ -1722,7 +1726,8 @@ def drss(states=1, outputs=1, inputs=1):
17221726
17231727
"""
17241728

1725-
return _rss_generate(states, inputs, outputs, 'd')
1729+
return _rss_generate(states, inputs, outputs, 'd',
1730+
strictly_proper=strictly_proper)
17261731

17271732

17281733
def ssdata(sys):

0 commit comments

Comments
 (0)
0