Skip to content

Commit 85e35b4

Browse files
committed
sort state space solution, example for realify modes.
1 parent e4c907c commit 85e35b4

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

vibrationtesting/system.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,8 @@ def mode_expansion_from_model(Psi, omega, M, K, measured):
707707
708708
Notes
709709
-----
710-
.. seealso:: incomplete multi-mode update
710+
.. seealso:: incomplete multi-mode update. Would require each at a
711+
different frequency.
711712
712713
"""
713714
measured = measured.reshape(-1) # retained dofs
@@ -913,13 +914,32 @@ def real_modes(Psi, autorotate = True):
913914
Psi : float array
914915
Real modes
915916
917+
Examples
918+
--------
919+
>>> import vibrationtesting as vt
920+
>>> M = np.array([[4, 0, 0],
921+
... [0, 4, 0],
922+
... [0, 0, 4]])
923+
>>> Cso = np.array([[.1,0,0],
924+
... [0,0,0],
925+
... [0,0,0]])
926+
>>> K = np.array([[8, -4, 0],
927+
... [-4, 8, -4],
928+
... [0, -4, 4]])
929+
>>> Bt = np.array([[1],[0],[0]])
930+
>>> Ca = np.array([[1,0,0]])
931+
>>> Cd = Cv = np.zeros_like(Ca)
932+
>>> A, B, C, D = vt.so2ss(M, Cso, K, Bt, Cd, Cv, Ca)
933+
>>> Am, Bm, Cm, Dm, eigenvalues, modes = vt.ss_modal(A, B, C, D)
934+
>>> Psi = vt.real_modes(modes[:,0::2])
935+
916936
Notes
917937
-----
918938
.. note:: Rotation of modes should be performed to get them as close to real
919939
as possible first.
920940
.. warnings:: Current autorotate bases the rotation on de-rotating the first
921941
element of each vector. User can use their own pre-process by doing to
922-
and setting `autorotate` to False
942+
and setting `autorotate` to False.
923943
924944
"""
925945
if autorotate is True:
@@ -977,8 +997,8 @@ def ss_modal(A, B = None, C = None, D = None):
977997
>>> print(Cm)
978998
[[ 0.0241-0.9307j 0.0241+0.9307j 0.0039-0.717j 0.0039+0.717j
979999
0.0594-0.0001j 0.0594+0.0001j]]
980-
"""
9811000
1001+
"""
9821002
if B is None:
9831003
B = np.zeros_like(A)
9841004

@@ -989,6 +1009,11 @@ def ss_modal(A, B = None, C = None, D = None):
9891009
D = np.zeros_like(A)
9901010

9911011
eigenvalues, vectors = la.eig(A)
1012+
1013+
idxp = abs(eigenvalues).argsort()
1014+
eigenvalues = eigenvalues[idxp]
1015+
vectors = vectors[:, idxp]
1016+
9921017
A_modal = la.solve(vectors,A)@vectors
9931018
B_modal = la.solve(vectors,B)
9941019
C_modal = C@vectors

0 commit comments

Comments
 (0)