Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming assignment # 3 Numerical Methods for PDEs Spring 2007

Similar presentations


Presentation on theme: "Programming assignment # 3 Numerical Methods for PDEs Spring 2007"— Presentation transcript:

1 Programming assignment # 3 Numerical Methods for PDEs Spring 2007
Jim E. Jones

2 Programming Assignment #3
Problem 1 Problem 2 K=.01 K=1 K=100 K=1

3 Programming Assignment #3
Use your code to investigate these issues How does the variable K effect the computed solution. This is best seen by comparing plots of the solution to the two problems. How does the number of conjugate gradient iterations required compare to the number of Gauss-Seidel iterations required for the same tolerance.

4 Programming Assignment #3
On web page are three matlab codes: hw3gs: Gauss-Seidel hw3cg: Conjugate Gradient hw3pcg: Preconditioned Conjugate Gradient

5 Plots showing the effect of variable K on the solution
Constant K Variable K

6 Results: Iterations needed for tol=1e10-6
K=1 n=10 n=20 n=40 n=80 GS 132 474 1673 5790 CG 23 48 95 185 variable K n=10 n=20 n=40 n=80 GS 179 662 2424 8786 CG 227 1032 3106 7676

7 Conjugate gradient algorithm
To solve Au=f, starting from initial guess u0 r0=f-Au0 for k=1,2,3,… rk-1= (rk-1Trk-1) if k=1 p1= r0 else bk-1=rk-1/rk-2 pk=rk-1+bk-1pk-1 end if qk=Apk ak= rk-1/(pkTqk) xk=xk-1+akpk rk=rk-1-akqk Check convergence end for

8 Preconditioning The convergence of conjugate gradients for solving Ax=b depends on the eigenvalues of A (see Shewchuck). Sometimes it pays to modify the system by multiplying by a matrix, M-1Ax=M-1b. Now the convergence depends on eigenvalues of M-1A.

9 Preconditioned conjugate gradient algorithm
To solve Au=f, starting from initial guess u0 r0=f-Au0 for k=1,2,3,… sk-1= M-1rk-1 rk-1= (rk-1Tsk-1) if k=1 p1= s0 else bk-1=rk-1/rk-2 pk=sk-1+bk-1pk-1 end if qk=Apk ak= rk-1/(pkTqk) xk=xk-1+akpk rk=rk-1-akqk Check convergence end for

10 Preconditioning The preconditioner M should be “close” to A.
The preconditioner should be easy to invert. Simple preconditioner, M=D, the diagonal of A.

11 Results: Iterations needed for tol=1e10-6
K=1 n=10 n=20 n=40 n=80 GS 132 474 1673 5790 CG 23 48 95 185 PCG variable K n=10 n=20 n=40 n=80 GS 179 662 2424 8786 CG 227 1032 3106 7676 PCG 32 68 133 255

12 Upcoming Schedule March M W 12 14 19 21 26 28 April M W 2 4 9 11 16 18
April M W Upcoming Schedule Take home portion of exam handed out March 28 Take home due and in class exam April 2 Programming assignment #4 due April 9 Final Project presentations April 23 & 25

13 Upcoming Schedule March M W 12 14 19 21 26 28 April M W 2 4 9 11 16 18
April M W Upcoming Schedule Take home portion of exam handed out March 28 Take home due and in class exam April 2 Programming assignment #4 due April 9 Final Project presentations April 23 & 25 Optional: Will drop lowest programming assignment 13

14 Optional Programming assignment #4
Implement the finite difference method we talked about last time for the hyperbolic PDE: Exact solution

15 Optional Programming assignment #4
Investigate stability and accuracy issues What relationship between h and k must hold for stability? Do your results agree with the CFL condition? How does the error behave: O(h+k)? O(h2 + k)? O(h2 + k2)? ???


Download ppt "Programming assignment # 3 Numerical Methods for PDEs Spring 2007"

Similar presentations


Ads by Google