Beruflich Dokumente
Kultur Dokumente
Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
M. Dumbser 1 / 18
30 /01/2012
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
A X ! B
with an N x N matrix Example:
A and an N x M matrix B
x1 x2 4 x1 4 x2 x1 2 x2
x3 4 x3 x3
! 1 ! 2 ! 1 1 B ! 2 1
1 1 1 A ! 4 4 4 1 2 1
M. Dumbser 2 / 18
N ! 3, M ! 1
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
T T A x ! b
A {0
An infinite number of solutions if D, the determinant of A is zero and the determinants Dk of all matrices formed by the matrix A in which one column k has been substituted by b are also zero:
D ! A ! 0 Dk ! Aij bi ! 0 with
j { k k _,2..., N a 1
A !0
M. Dumbser 3 / 18
A b
{ 0
ij i
with
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
A X ! B
Iterative Methods (not exhaustive) Solve the problem starting with an initial guess x0 and generating a sequence of iterative solutions xi+1=L(xi) Jacobi, Gau-Seidel and SOR method simple and general, do not converge for all matrices A. Conjugate Gradient (CG) method Works only for symmetric positive definite matrices. Optimal method (convergence to exact solution after N iterations). GMRES method [Saad & Schulz, 1986] Works for general matrices. Optimal method (convergence to exact solution after N iterations). Much more complex and expensive than CG.
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
Linear Algebra
The systematic solution of this problem is given by the so-called Gau-algorithm, named after the German mathematician Carl-Friedrich Gau (1777-1855) Define an auxiliary matrix C as
C ! A, B
Now the matrix C is modified by a sequence of operations on its rows to transform its left part into the unit matrix. The admissible row-operations are: (1) addition / subtraction of multiples of rows (2) multiplication / division of a row by a constant factor (3) exchange of rows When the left part of the matrix C has been transformed into the unit matrix, the right part contains the solution X of the equation system.
M. Dumbser 5 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
M. Dumbser 7 / 18
A X ! I
X !A
1
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
s ! 8N ( N M )
The computational effort (i.e. the necessary number of floating point operations) for the execution of the Gau algorithm is proportional to N to the cube. This makes the algorithm very expensive and not feasible for very large matrices (apart from the above-mentioned memory storage problem).
# flop ~ N 3
In practice, very often iterative solution methods are used, in particular when the matrix A is sparse, i.e. it contains a very large number of zero elements.
M. Dumbser 8 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
f 1
s
as
r
x ! s f 2e 1s V ! 1
p
with
e ! E B, B ! 2 r 1 1
Hence, there exist very small but finite numbers V < I for which
M. Dumbser 9 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
Vx1 2 x2 ! 1 x1 x2 ! 1 2 1 V 1 1 1 V 1
1 V 1 1 1 } x1 ! } , x2 ! 2 V 2 2 V 2
1 0 1 V 1 V 2V
V C ! 1
2 1 1 1
2 1 1 V V 2 1 0 1 1 V V
2 V 1
1 0 0 1
M. Dumbser 10 / 18
1 2 1 V V 2 1 2
1 0 0 1
1 1 V V 1 2
1 0 0 1 0 1 2
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
Vx1 2 x2 ! 1 x1 x2 ! 1
1 V 1 1 1 } x1 ! } , x2 ! 2 V 2 2 V 2
V C ! 1
2 1 1 1
1 V
1 1 2 1 1 1 0 2 0 1 1 2
1 1 1 0 2 V 1 V
1 1 1 0 2 1
1 1 1 1 0 1 2
M. Dumbser 11 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
M. Dumbser 12 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
b1 a2 0 A! 0 0 0
c1 0 b2 c2 a3 b3 0 ai 0 0 0 0
0 0 c3 bi a N 1 0
0 0 0 0 0 0 0 ci bN 1 cN 1 aN bN
d1 d2 B ! di d N 1 d N
there is a very fast and efficient special case of the Gau-algorithm, called the Thomas-algorithm. Since it is a variation of the Gau-algorithm, the Thomas algorithm is a direct method to solve general linear tridiagonal systems. As the original Gau-algorithm, it proceeds in two stages, one forward elimination and one back-substitution.
M. Dumbser 13 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
The Thomas-Algorithm
Part I: Forward elimination.
c1 :! c1 / b1 ; d1 :! d1 / b1
DO i = 2, N
K :! 1 / bi ci 1ai
ci :! ci K d i :! d i ai d i 1
K
END DO
xN ! d N
DO i = N-1, 1, -1
xi ! d i ci xi 1
END DO
M. Dumbser 14 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
A !A
T
and
T T T x T A x " 0 x { 0 T T A x ! b as
(2) Two vectors u and v are called conjugate with respect to matrix A if
T T uT A v ! 0
T T T T x ! E1 p1 E 2 p2 ... E N pN
The coefficients E are given by:
TT pT b Ej ! Tj T pT A p j j
M. Dumbser 15 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
T 1 T T TT g ( x ) ! x T Ax b T x 2 T T T x ! xk P p
T T T xg T! Ax b ! r xx
Using the steepest descent method in direction p, we obtain the minimum of g starting from xk as follows:
TT xg xx xg T T T ! ! T pT Ax b ! 0 xP xP xx T T T T pT AxK Pp b ! 0
TT T TT pT b AxK pT rk P! T T ! T T p T Ap pT Ap
M. Dumbser 16 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
T x0 ! 0
T T T r0 ! b Ax0
T T p0 ! r0
DO k = 0... N - 1
T T vk ! Apk TT T pk rk Pk ! T T 1D minimization along direction pk T pk vk T T T Move point x into the minimum along direction pk xk 1 ! xk Pk pk T T T T T T rk 1 ! b Axk 1 ! b Axk Pk vk Compute new residual ( = negative gradient T T X = steepest descent direction) rk 1 ! rk Pk vk T T k p j Ark 1 T T T Do not move in the steepest descent direction, pk 1 ! rk 1 T T p j but compute a new conjugate direction pk+1 that pj Apj j !0 takes into account all the previous search
From definition (3) we know that the algorithm will terminate with the exact solution after at most N iterations
ENDDO
M. Dumbser 17 / 18
Universit degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Prof. Dr.-Ing. Michael Dumbser
Numerical Methods for Free Surface Hydrodynamics Solution of linear algebraic equation systems
T X x0 ! b
T T T r0 ! b Ax0
T T p0 ! r0
TT E 0 ! r0T r0
DO k = 0... N - 1