12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

446 chapter 17A less obvious improvement in the relaxation technique, known as successiveoverrelaxation (SOR), starts by writing the algorithm (17.25) in a form thatdetermines the new values of the potential U (new) as the old values U (old) plusa correction or residual r:U (new)i,j= U (old)i,j + r i,j . (17.29)While the Gauss–Seidel technique may still be used to incorporate the updatedvalues in U (old) to determine r, we rewrite the algorithm here in the general form:r i,j ≡ U (new)i,j − U (old)i,j= 1 []U (old)i+1,j4+ U (new)i−1,j + U (old)i,j+1 + U (new)i,j−1 − U (old)i,j . (17.30)The successive overrelaxation technique [Pres 94, Gar 00] proposes that if convergenceis obtained by adding r to U, then even more rapid convergence might beobtained by adding more or less of r:U (new)i,j= U (old)i,j + ωr i,j , (SOR), (17.31)where ω is a parameter that amplifies or reduces the residual. The nonacceleratedrelaxation algorithm (17.28) is obtained with ω =1, accelerated convergence (overrelaxation)is obtained with ω ≥ 1, and underrelaxation is obtained with ω2 may lead to numerical instabilities.Although a detailed analysis of the algorithm is needed to predict the optimal valuefor ω, we suggest that you explore different values for ω to see which one worksbest for your particular problem.17.4.2 Lattice PDE ImplementationIn Listing 17.1 we present the code LaplaceLine.java that solves the square-wireproblem (Figure 17.1). Here we have kept the code simple by setting the length ofthe box L = N max ∆ = 100 and by taking ∆=1:U(i, N max ) = 99 (top), U(1,j)=0 (left),U(N max ,j)= 0 (right), U(i, 1) = 0 (bottom),(17.32)We run the algorithm (17.27) for a fixed 1000 iterations. A better code would vary ∆and the dimensions and would quit iterating once the solution converges to sometolerance. Study, compile, and execute the basic code.−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 446

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!