Skip to content

Commit 3797c1b

Browse files
author
Kevin Chen
committed
Changed docstrings for hsv, balred, modred
Steven Brunton <sbrunton@princeton.edu>
1 parent 5d05959 commit 3797c1b

1 file changed

Lines changed: 51 additions & 36 deletions

File tree

src/modelsimp.py

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,26 @@
5151
def hsvd(sys):
5252
"""Calculate the Hankel singular values
5353
54-
Usage
55-
=====
56-
H = hsvd(sys)
57-
58-
The Hankel singular values are the singular values of the Hankel operator. In practice, we compute the square root of the eigenvalues of the matrix formed by taking the product of the observability and controllability gramians. There are other (more efficient) methods based on solving the Lyapunov equation in a particular way (more details soon).
59-
60-
Inputs
61-
------
54+
Parameters
55+
----------
6256
sys : a state space system
6357
64-
Outputs
58+
Returns
6559
-------
6660
H : a list of Hankel singular values
6761
62+
See Also
63+
--------
64+
gram
65+
66+
Notes
67+
-----
68+
The Hankel singular values are the singular values of the Hankel operator. In practice, we compute the square root of the eigenvalues of the matrix formed by taking the product of the observability and controllability gramians. There are other (more efficient) methods based on solving the Lyapunov equation in a particular way (more details soon).
69+
70+
Examples
71+
--------
72+
H = hsvd(sys)
73+
6874
"""
6975

7076
Wc = gram(sys,'c')
@@ -83,19 +89,25 @@ def hsvd(sys):
8389
def modred(sys,ELIM,method):
8490
"""Model reduction of sys by eliminating the states in ELIM using a given method
8591
86-
Usage
87-
=====
88-
rsys = modred(sys,ELIM,method)
92+
Parameters
93+
----------
94+
sys: original system to reduce
95+
ELIM: vector of states to eliminate
96+
method: method of removing states in ELIM (truncate or matchdc)
8997
90-
Inputs
91-
======
92-
sys : original system to reduce
93-
ELIM : vector of states to eliminate
94-
method : method of removing states in ELIM (truncate or matchdc)
98+
Returns
99+
-------
100+
rsys: a reduced order model
95101
96-
Outputs
97-
=======
98-
rsys : a reduced order model
102+
Raises
103+
------
104+
ValueError
105+
if `method` is not either `matchdc` or `truncate`
106+
if eigenvalues of `sys.A` are not all in left half plane (sys must be stable)
107+
108+
Examples
109+
--------
110+
rsys = modred(sys,ELIM,method)
99111
100112
"""
101113

@@ -114,15 +126,12 @@ def modred(sys,ELIM,method):
114126
for e in D:
115127
if e.real >= 0:
116128
raise ValueError, "Oops, the system is unstable!"
117-
print ELIM
118129
ELIM = np.sort(ELIM)
119-
print ELIM
120130
NELIM = []
121131
# Create list of elements not to eliminate (NELIM)
122132
for i in range(0,len(sys.A)):
123133
if i not in ELIM:
124134
NELIM.append(i)
125-
print NELIM
126135
# A1 is a matrix of all columns of sys.A not to eliminate
127136
A1 = sys.A[:,NELIM[0]]
128137
for i in NELIM[1:]:
@@ -141,7 +150,6 @@ def modred(sys,ELIM,method):
141150
B1 = sys.B[NELIM,:]
142151
B2 = sys.B[ELIM,:]
143152

144-
print np.shape(A22)
145153
A22I = np.linalg.inv(A22)
146154

147155
if method=='matchdc':
@@ -165,20 +173,27 @@ def modred(sys,ELIM,method):
165173
def balred(sys,orders,method='truncate'):
166174
"""Balanced reduced order model of sys of a given order. States are eliminated based on Hankel singular value.
167175
168-
Usage
169-
=====
170-
rsys = balred(sys,order,elimination,method)
176+
Parameters
177+
----------
178+
sys: original system to reduce
179+
orders: desired order of reduced order model (if a vector, returns a vector of systems)
180+
method: method of removing states (truncate or matchdc)
171181
172-
Inputs
173-
======
174-
sys : original system to reduce
175-
orders : desired order of reduced order model (if a vector, returns a vector of systems)
176-
elimination : if elimination is specified, use 'method'
177-
method : method of removing states (truncate or matchdc)
182+
Returns
183+
-------
184+
rsys: a reduced order model
178185
179-
Outputs
180-
=======
181-
rsys : a reduced order model
186+
Raises
187+
------
188+
ValueError
189+
if `method` is not `truncate`
190+
if eigenvalues of `sys.A` are not all in left half plane (sys must be stable)
191+
ImportError
192+
if slycot routine ab09ad is not found
193+
194+
Examples
195+
--------
196+
rsys = balred(sys,order,elimination,method)
182197
183198
"""
184199

0 commit comments

Comments
 (0)