@@ -108,7 +108,7 @@ def hankel_singular_values(sys):
108108 return hsv [::- 1 ]
109109
110110
111- def model_reduction (sys , ELIM , method = 'matchdc' ):
111+ def model_reduction (sys , ELIM , method = 'matchdc' , warn_unstable = True ):
112112 """Model reduction by state elimination.
113113
114114 Model reduction of `sys` by eliminating the states in `ELIM` using a given
@@ -122,7 +122,9 @@ def model_reduction(sys, ELIM, method='matchdc'):
122122 Vector of states to eliminate.
123123 method : string
124124 Method of removing states in `ELIM`: either 'truncate' or
125- 'matchdc'.
125+ 'matchdc' (default).
126+ warn_unstable: bool, option
127+ If `False`, don't warn if system is unstable.
126128
127129 Returns
128130 -------
@@ -132,12 +134,14 @@ def model_reduction(sys, ELIM, method='matchdc'):
132134 Raises
133135 ------
134136 ValueError
135- Raised under the following conditions:
137+ If `method` is not either ``'matchdc'`` or ``'truncate'``.
138+ NotImplementedError
139+ If `sys` is a discrete time system.
136140
137- * if `method` is not either ``'matchdc'`` or ``'truncate'``
138-
139- * if eigenvalues of `sys.A` are not all in left half plane
140- ( `sys` must be stable)
141+ Warns
142+ -----
143+ UserWarning
144+ If eigenvalues of `sys.A` are not all stable.
141145
142146 Examples
143147 --------
@@ -162,8 +166,8 @@ def model_reduction(sys, ELIM, method='matchdc'):
162166 raise NotImplementedError ("Function not implemented in discrete time" )
163167
164168 # Check system is stable
165- if np .any (np .linalg .eigvals (sys .A ).real >= 0.0 ):
166- raise ValueError ( "Oops, the system is unstable! " )
169+ if np .any (np .linalg .eigvals (sys .A ).real >= 0.0 ) and warn_unstable :
170+ warnings . warn ( "System is unstable; reduction may be meaningless " )
167171
168172 ELIM = np .sort (ELIM )
169173 # Create list of elements not to eliminate (NELIM)
0 commit comments