|
From: <kk...@us...> - 2011-02-08 22:13:19
|
Revision: 42
http://python-control.svn.sourceforge.net/python-control/?rev=42&view=rev
Author: kkchen
Date: 2011-02-08 22:13:13 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
Initial gram algorithm in statefbk.py. Passes initial tests.
Steven Brunton <sbr...@pr...>
Modified Paths:
--------------
branches/control-0.4a/src/statefbk.py
Modified: branches/control-0.4a/src/statefbk.py
===================================================================
--- branches/control-0.4a/src/statefbk.py 2011-02-08 22:13:09 UTC (rev 41)
+++ branches/control-0.4a/src/statefbk.py 2011-02-08 22:13:13 UTC (rev 42)
@@ -246,13 +246,44 @@
Wc = gram(sys,'c')
Wo = gram(sys,'o')
"""
-
+
+ #Check for ss system object, need a utility for this?
+
+ #TODO: Check for continous or discrete, only continuous supported right now
+ # if isCont():
+ # dico = 'C'
+ # elif isDisc():
+ # dico = 'D'
+ # else:
+ dico = 'C'
+
+ #TODO: Check system is stable, perhaps a utility in ctrlutil.py
+ # or a method of the StateSpace class?
+ D,V = np.linalg.eig(sys.A)
+ for e in D:
+ if e.real >= 0:
+ raise ValueError, "Oops, the system is unstable!"
+
if type=='c':
print "controllable"
+ trana = 'T'
+ C = -sys.B*sys.B.transpose()
elif type=='o':
print "observable"
- else:
+ trana = 'N'
+ C = -sys.C.transpose()*sys.C
+ else:
raise ValueError, "Oops, neither observable, nor controllable!"
- gram = 0.
+ #Compute Gramian by the Slycot routine sb03md
+ #make sure Slycot is installed
+ try:
+ from slycot import sb03md
+ except ImportError:
+ raise ControlSlycot("can't find slycot module 'sb03md'")
+ n = sys.states
+ U = np.zeros((n,n))
+ out = sb03md(n, C, sys.A, U, dico, 'X', 'N', trana)
+ gram = out[0]
return gram
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|