getting warning while using eigs on the matrices obtained from freefem++

I am trying to solve for the temporal stability of the incompressible viscous plane poiseuille flow using freefem++.
When i import the matrices and solve for eigen value using eigs , i get this warning:
Warning: The first input matrix, shifted by sigma, is close to singular or badly scaled (RCOND = 7.026665e-305) and results may be inaccurate. Consider specifying a perturbed numeric sigma value to improve the condition of the matrix.
Do i have to do some preconditioning in the matrices in freefem or is there some option in the MATLAB to do the same.

 Respuesta aceptada

If modifying the input sigma doesn't help, it's likely that for your call eigs(A, B, sigma, ...) the matrices are such that A - sigma*B is always singular for any sigma.
This would mean there is at least one vector v for which A*v = 0 and B*v = 0, meaning this is an "eigenvector" for every possible eigenvalue sigma. That means the eigenvalue problem is ill-posed.
This is not so uncommon for matrices coming from FEM, it basically means the matrix size is larger than than the degrees of freedom in the underlying problem.
I'm not an expert on FEM, but for example, if we apply Dirichlet conditions to the first basis, this likely means that the first row and column of both A and B is all zero. That would lead to exactly the issue above. Removing the first row and column of both A and B would result in a smaller and well-posed problem.
Possibly freefem++ provides some options that would cut out these additional degrees of freedom? I don't know the software well enough to help with this.

5 comentarios

I was taught one way to consider Dirichlet condition is to put zero on the corresponding row-column the boundary node and 1 (or constant different 0) on the diagonal, and Dirichlet value on the rhs. This modification is performed after assembling the matrix on looping on elements.
Beside I put 0 in one column and row in K and M matrices, and MATLAB R2023b does not return such warning-error reported by OP:
K=rand(3); K=K*K'; K(4,4)=0; K=sparse(K+K');
M=rand(3); M=M*M'; M(4,4)=0; M=sparse(M+M');
eigs(K,M)
ans = 4×1
NaN 901.9915 1.2308 0.3775
eigs(K,M,4,0)
ans = 4×1
0.3775 1.2308 901.9915 NaN
[V,D]=eigs(K,M,2,0)
V = 4×2
-0.5969 -0.5002 -0.0003 -1.0000 1.0000 0.4995 0 0
D = 2×2
0.3775 0 0 1.2308
Hi Bruno,
I think for a Dirichlet condition, it's not just the diagonal that is zero, but the whole row and column (in the sense that we know that value is fixed to be zero, and so has no effect on the operation). Then, we get this error:
K=rand(200); K=K*K'; K(1, :)=0; K(:, 1) = 0; K=sparse(K+K');
M=rand(200); M=M*M'; M(1,:)=0; M(:,1)=0; M=sparse(M+M');
%eigs(K,M, 3, 0.2)
% This gives the error "The first input matrix, shifted by sigma, is singular, therefore
% sigma is an eigenvalue of the first input matrix. Consider specifying a perturbed
% numeric sigma value to improve the condition of the matrix."
and ignoring the first row and column addresses it:
eigs(K(2:end,2:end),M(2:end,2:end), 3, 0.2)
ans = 3×1
0.1998 0.2056 0.1937
In practice, this is probably more complicated, if the system isn't 1D and as simplistic as I'm doing here. But the problem is both K and M are singular.
One way to start looking into this would be to make some relatively small matrices (100x100 or something) and call null(full(K - sigma*M)). This will return column vectors v for which (K - sigma*M)*v is zero - these are the degrees of freedom that need to be removed so that the problem is well-posed.
Odd for small dimension (3) there is no error message
K=rand(3); K=K*K'; K(1, :)=0; K(:, 1) = 0; K=sparse(K+K');
M=rand(3); M=M*M'; M(1,:)=0; M(:,1)=0; M=sparse(M+M');
eigs(K,M, 3, 0.2)
ans = 3×1
1.3870 NaN NaN
"I think for a Dirichlet condition, it's not just the diagonal that is zero"
Not that I said. I said that the row-columb is 0s but the diagonal term is NON-zero (eg., 1), and rhs set to the value of dirichlet value * K(1,1).
K = assemblymatrix();
K(1, :)=0; K(1,1) = 1; rhs(1) = u1; % u1 is value of solution u at node 1
If the requested number of eigenvalues is more than half the size of the matrix, eigs falls back to eig, since this is more efficient.
And eig will return something for this case, although as you can see there are some NaN eigenvalues, and the others don't match what would happen otherwise:
K=rand(4); K=K*K'; K(1, :)=0; K(:, 1) = 0; K=sparse(K+K');
M=rand(4); M=M*M'; M(1,:)=0; M(:,1)=0; M=sparse(M+M');
eig(full(K), full(M))
ans = 4×1
NaN 0.1363 0.7073 NaN
eig(full(K(2:end, 2:end)), full(M(2:end, 2:end)))
ans = 3×1
0.2181 0.5539 2.7989
This is because EIG is based on the QZ decomposition, which would not be affordable for the sparse case since it returns completely dense matrices. In EIGS, instead an LU decomposition of K-sigma*M is computed, which is used to solve linear systems; for this reason, EIGS errors if that matrix is singular.

Iniciar sesión para comentar.

Más respuestas (1)

Bruno Luong
Bruno Luong el 13 de Feb. de 2024
Try to follow the suggestion you get " Consider specifying a perturbed numeric sigma value to improve the condition of the matrix."

5 comentarios

I tried increasing sigma value but it does not improve the solution
What should be the value? my eigen values are complex.
You didn't tell us what sigma you use to call eigs, but it looks like to fall right on the eigenvalue. I would to perturb your sigma by
norm(M,2) * epsilon
with epsilon in 1e-12 to 1e-10 or something like that, M being your matrix.
i do know that real part of eigen values will lie between 0 to 0.8 and i used 5 for sigma. Also in eigs i have two matrices for MX=lambda N X eigen value problem.
Also following the above suggestion i get this message:
The first input matrix, shifted by sigma, is singular, therefore sigma is an eigenvalue of the first input matrix. Consider specifying a perturbed numeric sigma value to improve the condition of the matrix.
WarnIfIllConditioned(rcond(dAminusSigmaB), 'A', eigsSigma);
applyOP = AminusSigmaBSolve(A, B, innerOpts.sigma, Amatrix, n, ...
Error in eigs (line 122)
[applyOP, applyM] = getOps(A, B, n, spdB, shiftAndInvert, R, cholB, permB,...
Bruno Luong
Bruno Luong el 13 de Feb. de 2024
Editada: Bruno Luong el 13 de Feb. de 2024
"i do know that real part of eigen values will lie between 0 to 0.8 and i used 5 for sigma. "
Why you chose 5 if you know the realpart is in between 0 and 0.8? How exactly do you call eigs?
If the matrices is from FEM simulation, the chance that the eigen value is exactly 5 is zero.
I suspect the call eigs command is incorrect, sounds like you mix up k and sigma arguments and your matrix M is singular.

Iniciar sesión para comentar.

Categorías

Más información sobre Linear Algebra en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Preguntada:

el 13 de Feb. de 2024

Editada:

el 14 de Feb. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by