How to solve a sparse matrix efficiently?

14 次查看(过去 30 天)
Nils
Nils 2014-3-10
评论: Nils 2014-3-11
Hallo everyone,
I am trying to solve a linear equation system A*x=b that describes a 3D grid and heat transfer between adjecent cells and mass convection by an upwind scheme. As the upwind scheme is somewhat asymmetric, the sparse Matrix that looks like the one below. So far I use x = A\b, but when the problem starts to get bigger this appears to be rather slow. Therefore I am looking for a way to speed up the computation. As the thermal conductivity and so are temperature dependent, I have to solve this equation system a couple of times till a global convergence is achieved.
There are some iterative methods implemented (<http://www.mathworks.de/de/help/matlab/linear-equations-iterative-methods.html>) but I am not sure, which one to chose.
I guess, that lsqr(A,b,tol,maxit,M1,M2,x0) might be a good choice (just maybe ;-) ) but now I am wondering how to chose an appropriate preconditioning M1 and M2. As mentioned before, I have to solve this problem a couple of times, therefore I think that I should be able to provide an good guess on x0 the second time a try to solve this problem - but I am not really sure how to do this... Plus: when I use lsqr or bicq without any changes, the results looks like crap ;-)
You might have figured, that I am more of an engineer than a mathematician, therefore I'm not really sure what to do.
It would be so great, if you could give me decent advice :-)
Best regards Nils
  5 个评论
Patrik Ek
Patrik Ek 2014-3-10
编辑:Patrik Ek 2014-3-10
You should try wikipedia instead, matlabs function svd, does a singular value decomposition. It does not invert matrices. However, this can be used as a tool for matrix inversion. I know that this is nothing automatical or even simple, but if matlabs functions does not work, this may be necessary. I am not sure it works, but it is worth a try. The thing is that one application of svd is that its relation to pseudo inverses makes it possible to split up the matrix and calculate the inverse of all the non-zero parts.
@John D'Errico, are you sure pinv is still slower if the matrix is sparse?
Nils
Nils 2014-3-11
I think that pinv does now work for sparse matrixes, at least in Matlab 2013.

请先登录,再进行评论。

回答(2 个)

Paul
Paul 2014-3-10
Did you try defining A and b as sparse? So:
A=sparse(A);
b=sparse(b);
x=A\b;

Nils
Nils 2014-3-10
Hi,
yes I dis this. Really nice speed up :-) But it still starts to get slow as the problem becomes bigger.
  6 个评论
Paul
Paul 2014-3-10
Well, a solution may not exist. Are you sure you need to solve x=A\b, because afaik an upwind scheme for solving differential equations means that you use values from the previous time step and at the grid points around the point you consider to calculate the new value. What you basically do is :
x_new = A * x_old
Where A is the matrix which defines the points you use for the calculation at each point. So you really don't need to find the inverse since this is just a simple matrix multiplication.
Nils
Nils 2014-3-11
编辑:Nils 2014-3-11
I try to solve a steady temperature distribution. I consider the following phenomena:
  • Thermal conduction (central differences)
  • Enthalpy flow by mass flux (upwind scheme)
  • Boundary conditions
  • 3D geometry
As is solve for a steady state problem, I put all the dependencies between the cells into a Matrix and solve for the equilibrium temperature distribution. Of course now the thermal conductivity and so on changes, that is why I have to repeat this step a couple of times. When I solve this problem using mldevide the solution looks physically correct and, by the way, is identical to the solution that I can compute using ANSYS FLUENT. Therefore I think that a solution exists. Sadly the convection term in the equation is rather big compared to the thermal conduction and also the heat capacity behaves quite rough. Therefore I read that an upwind scheme (I use fourth order) should be appropriate. I should be able to use a symmetric central differencing scheme for the convection in large parts of the domain, but I certainly can't use a symmetric scheme on the borders leading to an asymmetric matrix anyway.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by