Skip to content

I/O system improvements: linearize, interconnect, docstrings #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 5, 2021
Merged
7 changes: 7 additions & 0 deletions control/bdalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ def connect(sys, Q, inputv, outputv):
>>> Q = [[1, 2], [2, -1]] # negative feedback interconnection
>>> sysc = connect(sys, Q, [2], [1, 2])

Notes
-----
The :func:`~control.interconnect` function in the
:ref:`input/output systems <iosys-module>` module allows the use
of named signals and provides an alternative method for
interconnecting multiple systems.

"""
inputv, outputv, Q = np.asarray(inputv), np.asarray(outputv), np.asarray(Q)
# check indices
Expand Down
8 changes: 8 additions & 0 deletions control/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,15 @@ def use_legacy_defaults(version):
if major == 0 and minor < 9:
# switched to 'array' as default for state space objects
set_defaults('statesp', use_numpy_matrix=True)

# switched to 0 (=continuous) as default timestep
set_defaults('control', default_dt=None)

# changed iosys naming conventions
set_defaults('iosys', state_name_delim='.',
duplicate_system_name_prefix='copy of ',
duplicate_system_name_suffix='',
linearized_system_name_prefix='',
linearized_system_name_suffix='_linearized')

return (major, minor, patch)
693 changes: 448 additions & 245 deletions control/iosys.py

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ def _convertToStateSpace(sys, **kw):


# TODO: add discrete time option
def _rss_generate(states, inputs, outputs, type):
def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
"""Generate a random state space.

This does the actual random state space generation expected from rss and
Expand Down Expand Up @@ -1374,7 +1374,7 @@ def _rss_generate(states, inputs, outputs, type):
# Apply masks.
B = B * Bmask
C = C * Cmask
D = D * Dmask
D = D * Dmask if not strictly_proper else zeros(D.shape)

return StateSpace(A, B, C, D)

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


def rss(states=1, outputs=1, inputs=1):
def rss(states=1, outputs=1, inputs=1, strictly_proper=False):
"""
Create a stable *continuous* random state space object.

Expand All @@ -1661,6 +1661,9 @@ def rss(states=1, outputs=1, inputs=1):
Number of system inputs
outputs : integer
Number of system outputs
strictly_proper : bool, optional
If set to 'True', returns a proper system (no direct term). Default
value is 'False'.

Returns
-------
Expand All @@ -1684,10 +1687,11 @@ def rss(states=1, outputs=1, inputs=1):

"""

return _rss_generate(states, inputs, outputs, 'c')
return _rss_generate(states, inputs, outputs, 'c',
strictly_proper=strictly_proper)


def drss(states=1, outputs=1, inputs=1):
def drss(states=1, outputs=1, inputs=1, strictly_proper=False):
"""
Create a stable *discrete* random state space object.

Expand Down Expand Up @@ -1722,7 +1726,8 @@ def drss(states=1, outputs=1, inputs=1):

"""

return _rss_generate(states, inputs, outputs, 'd')
return _rss_generate(states, inputs, outputs, 'd',
strictly_proper=strictly_proper)


def ssdata(sys):
Expand Down
Loading