alpha754293 said:
I have been doing a lot of research and using a lot of various programs and in order to try and understand how these programs work, I've been reading about various solvers.
And in the documentation, they mention a series of different types of solvers and matrices and I was wondering if someone would be able to explain them to me?
- LU
- Sparse
(to name a few).
(in particular in Ansys CFX, and COMSOL)
For computational/modeling tools like Ansys CFX, everything boils down to how fast can you solve a linear system Ax = b, where A is a known NxN matrix, b is a known Nx1 vector, and x an unknown Nx1 vector that you're solving for.
The first way to solve this you learn in Linear Algebra class is Gaussian elimination, and one implementation of this is LU factorization. In this method, you factor the matrix A into L and U such that A = L*U where L is a lower triangular matrix and U is upper triangular. Now if you plug L*U into Ax=b and define y = U*x, you get two linear systems
Ax=b = L*U*x = b --> Ux = y , Ly = b
and first solve Ly=b for y, and then solve Ux=y for x. And since L and U are triangular, they are very cheap to solve (back substitution). So now the systems are really cheap to solve, but factoring A is really expensive - if A is dense (non-zeroes in almost every spot), the cost is O(N^3). However, if A is sparse (mostly filled with zeroes), the cost of factoring drops almost to O(N) (I think it can be as low as O(N^1.2)). So if A is sparse, LU is a great method. Also, if you are solving Ax=b many times for the same A but different b, you only have to factor A once, and then just solve Ly=b and Ux=y for different b, which is trivially cheap. So in that case, this method is super. One final benefit of this method is that the storage is relatively cheap. It's possible to factor A "in place", meaning if A is huge (N=100,000) and you only have enough RAM to store one copy of A, you can perform the factorization directly on A and store both L and U in what used to be the A matrix without having to store another matrix in the process of factoring.
A similar method for solving Ax=b is QR factorization. In this case you factor A such that A = Q*R where R is upper triangular and Q is orthogonal. Again, you get two systems to solve
Ax = Q*R*x = Qy = b
So first you solve Qy=b for y, then use y to solve Rx=y. So what's the benefit of this factorization? Since Q is orthogonal, Q*Q' = I, meaning Q' = inverse(Q) ==> y = Q'*b (where ' denotes transpose). So solving the first equation for y is trivial beause it's just a matrix vector product, and then solving Rx=y is easy because R is triangular. Unlike LU you can't do QR in place so it requires more storage, but QR has the ability to solve singular systems without freaking out, which LU can't do. But QR also stinks for dense systems.
So what do you do for dense systems? You turn to iterative methods (GCR, GMRES, MINRES,...) . In these methods you are trying to solve Ax = b by guessing x, computing Ax, and then checking if it is equal to b. If not, repeat. So the non-technical description would be: you start by guessing x0, compute Ax0, check if Ax0-b=0, and if not, guess x1, compute Ax1, check (Ax1-b), guess x2, ... and so on. The clever thing here is that you can use information in (Ax0-b) to cleverly pick x1, and then use information in (Ax1-b) to cleverly pick x2, and so on, and if you do it right, it turns out that your guesses converge to the solution x quite quickly. How fast you find the solution depends on the clustering of the eigenvalues of A. Solving a dense system using this method is O(kN^2), where k depends on the eigenvalue distribution and in the worst case k=N. In these methods all of the cost comes from computing matrix-vector products, and if you have a clever/fast way to do matrix-vector products, you can drop the cost to O(k Nlog(N)).
If your A matrix is symmetric, there's other things you can do make things even more efficient.
Anyway, the bottom line is, what most modeling tools do is look at the sparsity and structure of A, and then pick some method to efficiently solve Ax=b for that A.