Eigenvalue problem optimized with lqsnonlin

6 views (last 30 days)
Hello everyone,
I have the generalized eigenvalue problem (K-w^2*M)*R = 0 where
K is a 6x6 diagonal matrix whose values are unknown,
M is a 6x6 matrix whose values are known,
w^2 are the eigenvalues (typically called lambda) and they are known through f ( w = 2*pi*f )
R are the eigenvectors
I would like to obtain the diagonal values of K that minimize the difference between f_exact (my values) and f_calc evaluated through iterations.
I tried with lsqnonlin but the f_calc is far from my f_exact.
Does anyone know how to optimize in a better way?
Here's my code:
% M matrix
M = diag([1e3, 1e3, 1e3, 1e5, 1e5, 1e5]);
M(1,4) = 100; M(4,1) = 100; M(1,5) = 150; M(5,1) = 150;
M(2,6) = 10; M(6,2) = 10; M(3,6) = 1; M(6,3) = 1;
M(2,3) = 30; M(3,2) = 30; M(3,5) = 500; M(5,3) = 500;
f_exact = [30, 30, 100, 10, 10, 20]; %lambda = (2*pi*f)^2
K_guess = [1e8, 1e8, 1e8, 1e8, 1e8, 1e8]; %Initial guess
LB = [1, 1, 1, 1, 1, 1];
UB = [1e15, 1e15, 1e15, 1e15, 1e15, 1e15];
options = optimoptions('lsqnonlin','FunctionTolerance',1e-16);
K_opt = lsqnonlin(@(K) obj_function(K, M, f_exact),K_guess,LB,UB,options);
%% Check
K_check = diag(K_opt);
[R,L] = eig(K_check,M);
f_calc = diag(sqrt(L)./(2*pi));
function diff = obj_function(K, M, f_exact)
K_mat = diag(K);
[R,L] = eig(K_mat,M);
eig_calc = diag(L);
f_calc = sqrt(eig_calc)./(2*pi)
diff = f_calc - f_exact;
end
  2 Comments
Torsten
Torsten on 3 Aug 2023
At least you should sort given and calculated eigenvalues before comparing them.
Sam Chak
Sam Chak on 4 Aug 2023
It's good to learn optimization with lqsnonlin. However, in this eigenvalue problem, the algorithm is kind of defeating the purpose because your objective function depends eig() computation itself.
Might as well use eig() directly to find the eigenvalues. You can use eig() for checking the accuracy, but not relying on it to solve the problem.
The logical question is how can the objective function be formulated without eig()?

Sign in to comment.

Accepted Answer

Matt J
Matt J on 3 Aug 2023
Edited: Matt J on 3 Aug 2023
% M matrix
M = diag([1e3, 1e3, 1e3, 1e5, 1e5, 1e5]);
M(1,4) = 100; M(4,1) = 100; M(1,5) = 150; M(5,1) = 150;
M(2,6) = 10; M(6,2) = 10; M(3,6) = 1; M(6,3) = 1;
M(2,3) = 30; M(3,2) = 30; M(3,5) = 500; M(5,3) = 500;
f_exact = [30, 30, 100, 10, 10, 20];
K_guess = ((2*pi*f_exact(:)).^2.*diag(M))'; %<---- better initial guess
LB = [1, 1, 1, 1, 1, 1];
UB = [1e15, 1e15, 1e15, 1e15, 1e15, 1e15];
options = optimoptions('lsqnonlin','FunctionTolerance',1e-16,'StepTol',1e-16, 'OptimalityTol',1e-12,'MaxFunEvals',inf);
[K_opt,~,res] = lsqnonlin(@(K) obj_function(K, M, f_exact),K_guess,LB,UB,options);
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
%% Check
K_check = diag(K_opt);
[R,L] = eig(K_check,M);
f_calc = diag(sqrt(L)./(2*pi)).';
sort(f_calc) %<---compare sorted
ans = 1×6
9.9997 10.0000 20.0000 30.0000 30.0000 100.0000
sort(f_exact)
ans = 1×6
10 10 20 30 30 100
function diff = obj_function(K, M, f_exact)
K_mat = diag(K);
[R,L] = eig(K_mat,M);
eig_calc = diag(L).'; %<---transpose
f_calc = sqrt(eig_calc)./(2*pi);
diff = sort(f_calc) - sort(f_exact); %<---compare sorted
end
  7 Comments
Marina
Marina on 22 Oct 2024
Edited: Marina on 22 Oct 2024
Do you have any suggestion on how I can get my K stiffness matrix? with a better exact vs calculated values. Thank you!
Matt J
Matt J on 22 Oct 2024
I'm afraid not. I have no reason to believe it should work.

Sign in to comment.

More Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!