Deprecated: Assigning the return value of new by reference is deprecated in /customers/1/f/c/dahoiv.net/httpd.www/programmering/wp-includes/cache.php on line 36 Deprecated: Assigning the return value of new by reference is deprecated in /customers/1/f/c/dahoiv.net/httpd.www/programmering/wp-includes/query.php on line 21 Deprecated: Assigning the return value of new by reference is deprecated in /customers/1/f/c/dahoiv.net/httpd.www/programmering/wp-includes/theme.php on line 507 Successive over-relaxation (SOR)

Successive over-relaxation

June 2nd, 2008 by Daniel Høyer Iversen

Successive over-relaxation (SOR), written in Matlab to solve the Advection-diffusion equation. The matrix A (in A x= b) is a block pentadiagonal matrix.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
function Z = solver(A,b)
%Successive over-relaxation, forbedret Gauss-Seidel
 
w=1.95;
 
p=params(0,0);
 
Z=p.noder(:,1)*0;
 
e=A(1,1);
 
for j=1:540
 
Z(1)= (1-w)*Z(1)+w/e*( b(1)- Z(2)*A(1,2)-Z(1+p.N)*A(1,1+p.N));
for i=2:p.N
Z(i)= (1-w)*Z(i)+w/e*( b(i)- Z(i-1)*A(i,i-1)-Z(i+1)*A(i,i+1)-Z(i+p.N)*A(i,i+p.N));
end
 
for i=p.N+1:p.NM-p.N
Z(i)= (1-w)*Z(i)+w/e*( b(i)- Z(i-p.N)*A(i,i-p.N)-Z(i-1)*A(i,i-1)-Z(i+1)*A(i,i+1)-Z(i+p.N)*A(i,i+p.N));
end
 
for i=p.NM-p.N+1:p.NM-1
Z(i)= (1-w)*Z(i)+w/e*( b(i)- Z(i-p.N)*A(i,i-p.N)- Z(i-1)*A(i,i-1)-Z(i+1)*A(i,i+1));
end
Z(p.NM)= (1-w)*Z(p.NM)+w/e*( b(p.NM)- Z(i-p.N)*A(i,i-p.N)-Z(p.NM-1)*A(p.NM,p.NM-1));
 
end
Do you want to use this code?

13 Responses to “Successive over-relaxation”

  1. http://en.wikipedia.org/wiki/Successive_over-relaxation :
    Successive over-relaxation (SOR) is a numerical method used to speed up convergence of the Gauss–Seidel method for solving a linear system of equations. A similar method can be used for any slowly converging iterative process. It was devised simultaneously by David M. Young and by H. Frankel in 1950 for the purpose of automatically solving linear systems on digital computers. Over-relaxation methods have been used before the work of Young and Frankel. For instance, the method of Lewis Fry Richardson, and the methods developed by R. V. Southwell. However, these methods were designed for computation by human calculators, and they required some expertise to ensure convergence to the solution which made them inapplicable for programming on digital computers. These aspects are discussed in the thesis of David M. Young.

  2. feby

    tolong kirimkan program SOR dengan menggunakan matlab. thanks.

  3. hadi

    hi
    I am going to use this code but i am not sure it could help me to sove my problem or not. any way thanks a lot for your code.
    best regards
    hadi

  4. majid

    pls send me the code tq

    hi
    I am going to use this code but i am not sure it could help me to sove my problem or not. any way thanks a lot for your code.
    best regards
    hadi

  5. pauline

    hi,

    im going to use this code. plz send to me.
    Thank you.

    Best regard,
    pauline

  6. garima

    sor is a very useful method for calculating steady state probabilities. and this code indeed helps us to do that. thanks!

  7. ned

    I wiil try this code.
    thanks.

  8. Taylor Thompson

    I plan to use this code in a demonstration on a project explaining SOR. Thanks for the hard work!

  9. Sofoane

    Thank you

  10. Daniel

    Thanks!!!

  11. elea

    hi
    i wish this code help me to solve my probleeeeeeeeeeeeeeem

    thanks

  12. elea

    thanks

  13. Wow, this article is fastidious, my younger sister is analyzing such things,
    therefore I am going to tell her.

Leave a Response