Python Vibration Analysis iteration method to calculate higher-order feature values and feature vectors, python Higher-Order
Reference books:
<Vibration Analysis>Zhang Zun, Wang Fengquan, edited by the Southeast University Press ISBN 7-80123-583-4
References: 4.6.2 and 4.6.3
<Numerical analysis>Cui ruicai Xie weisong, Tianjin University Press, ISBN 7-5618-1366-X
Reference: 3.1
References:
<Calculate all the feature values of a matrix by alternating power and descending order methods>: Https://pan.baidu.com/s/1fmNMnS8zyaMv4B_6jd7rnQ
Notes
1. solver code
Import numpy as npclass EigenValueModule (object): K = np. mat ([[1]) # K matrix M = np. mat ([[1]) # M matrix s = 1 # first s order Lambdas = [] Xs = [] def GetMax (self, Mat): position = np. argmax (Mat) row, column = Mat. shape row, column = divmod (position, column) Result = Mat [row, column] return Result def IsValid (self, LambdaLast, LambdaNext ): # used to determine whether the iterative feature value meets the requirements # requirement Abs (LambdaLast-LambdaNext)/LambdaLast <Epsilon myResult = False Epsilon = 1e-3 #0. 001 Ratio = abs (LambdaLast-LambdaNext)/LambdaLast if Ratio <Epsilon: myResult = True return myResult def performanceorder (self, A, X ): a = A [0] X = X/X [0, 0] aX = X * a myResult = A-aX myResult = np. delete (myResult, 0, 0) myResult = np. delete (myResult, 0, 1) return myResult def solve (self): self. lambdas = [] self. xs = [] # import external variable K = self. k m = self. M s = self. s # initialize R = K. I a = R * M # Calculate for I in range (s): X = self. childSolve (A) A = self. objective C EOrder (A, X) def solveA (self, A): self. lambdas = [] self. xs = [] s = self. s # Calculate for I in range (s): X = self. childSolve (A) print (A) A = self. performanceorder (A, X) def ChildSolve (self, A): # A single computing process n = len (A) X = np. mat (np. ones (1, n ))). T # create a trial vector XMax = self. getMax (X) LambdaLast = XMax # The first Lambda Y = X/XMax X = A * Y XMax = self. getMax (X) LambdaNext = XMax # Next Lambda while self. isValid (LambdaLast, LambdaNext )! = True: # Lambda does not meet the requirements LambdaLast = LambdaNext # update Lambda Y = X/XMax X = A * Y XMax = self. getMax (X) LambdaNext = XMax # update Lambda self. lambdas. append (LambdaNext) self. xs. append (X) return X
2. debug the code
Debug code 1
import numpy as npfrom SolveEigenValue import EigenValueModuleFigure=EigenValueModule()Figure.M=np.mat([[1,0,0],[0,1,0],[0,0,1]])Figure.K=np.mat([[2,-1,0],[-1,2,-1],[0,-1,1]])Figure.s=3Figure.solve()print(Figure.Lambdas)
Debug Code 2
import numpy as npfrom SolveEigenValue import EigenValueModuleFigure=EigenValueModule()Figure.s=3A=np.mat([[1,7,8,9,3],[0,2,5,8,6],[0,2,4,2,2],[0,0,1,6,5],[0,0,0,0,9]])Figure.solveA(A)print(Figure.Lambdas)