Write a single, efficient, general program, in MATLAB, Fortran, C that compares the performance of the three numerical methods:
Apply these methods to the inhomogeneous, linear Elliptic PDE (LEPDE):
0 = F(x,y,u,ux,uy,uxx,uyy) = A1*uxx + A2*uyy + B1(x,y)*ux + B2(x,y)*uy +C(x,y)*u + D(x,y);
Caveat Usor: You are responsible for checking the correctness of the formulas, given here and for any modifications needed to transform them to useful code.
Detailed Method Specifications:
The SOR and CGM methods are all derived from the Euler's explicit method which in the linear algebra formulation (with arrays marked with an M for matrix to avoid confusion with the model) is
AM*XM = BM; XM = {Ui,j | interior, row order:
for j = 1 : m2, i = 1 : m1};
XMk = XM(k);
XM(k)i+(j-1)*m1 = Ui,j(k);
AM = LM+UM-DM;
BM = {RHS vector, including boundary conditions};
hq = (bq - aq)/(mq+1);
for q = 1 : 2,
1. Successive Over Relaxation (SOR) Method:
Let XM0 = -w*DM-1*BM to start.
For k = 0 : kmax While (||RMk||2 > tol*||BM||2) Do:
XMk+1 = XMk - w*DM-1*RMk; %%SOR
RMk = BM-LM*XMk+1-(UM-DM)*XMk ;
(DM-w*LM)*XMk+1 = ((1-w)*DM + w*UM)*XMk-w*BM ;
Ui,j(k+1) = c0,0,i,j*Ui,j(k) + c-1,0,i,j*Ui-1,j(k+1) + c0,-1,i,j*Ui,j-1(k+1) + c1,0,i,j*Ui+1,j(k) + c0,1,i,j*Ui,j+1(k) + c0,i,j ,
2. Alternating Directions Implicit (ADI) Method:
The ADI method is based on operator splitting by dimension for a higher order approximation to replace the Crank-Nicolson Implicit Method CNIM in higher dimension to preserve the tridiagonal advantage in using the Thomas algorithm (See your class notes or Morton and Mayer, the second opinion text). The method specified here is a modification of the PRADI variant of ADI for the variable coefficients and extra drift-source terms here. Use the same initial condition X0 as for the SOR method. Let the ADI acceleration parameter be symbolically given by
p = padi = 0.5*Delta_t*Adh2max; where Adh2max = max_i[Ai/hi2] ;
Ri = (Ai/hi2)/Adh2max;
kamax = 0.5*kmax;
%%% X-ADI:
for k=0 : kamax
While (||U(k+1)-U(k)||2 >
tol*||U(k)||2) Do:
(1-p*R1*(delta12
+ 0.5*(B1,i,j/A1,i,j)*h1*Delta1 + 0.5*(Ci,j/A1,i,j)*h12*I))
[Ui,j(k+0.5)]
=(1+p*R2*(delta22
+ 0.5*(B2,i,j/A2,i,j)*h2*Delta2 + 0.5*(Ci,j/A2,i,j)*h22*I))
[Ui,j(k)] + 2*p*Di,j/Adh2max ;
%%% Y-ADI:
(1-p*R2*(delta22
+ 0.5*(B2,i,j/A2,i,j)*h2*Delta2 + 0.5*(Ci,j/A2,i,j)*h22*I))
[Ui,j(k+1)]
=(1+p*R1*(delta12
+ 0.5*(B1,i,j/A1,i,j)*h1*Delta1 + 0.5*(Ci,j/A1,i,j)*h12*I))
[Ui,j(k)] + 2*p*Di,j/Adh2max ;
3. Conjugate Gradient Method (CGM):
The CGM method is best modified to account for non-symmetric matrices A and for program efficiency.
For this method, use one of the following professional codes given in MATLAB from the NeTLib software archive (the class pseudo-code only gives the major ideas):
function [x, error, iter, flag] = cgs(A, x, b, M, max_it, tol)
function [x, error, iter, flag] = bicg(A, x, b, M, max_it, tol)
Test Case Specifications:
Your program should be fairly general and not made just for the particular values or functions here, but you can use the following values as a test case as long as your program is not specifically tailored to it. where a1 < x < b1, a2 < y < b2. On
A1 = exp(1.5); A2 = exp(1.25);
B1(x,y) = exp(-1.3)*(x-a1)/sqrt(1+x2+y2);
B2(x,y)=exp(-1.1)*(y-a2)/sqrt(1+x2+y2);
C(x,y) = -exp(1.5)/sqrt(1+x2+y2);
D(x,y) = -exp(-2.5)/sqrt(1+x2+y2);
u(x,a2)
= 6*exp(0.5)*(x-a1)/(b1-a1) ;
u(a1,y)
= 3*exp(0.5)*(y-a2)/(b2-a2) ;
u(x,b2)
= exp(0.5)*(3+(x-a1)/(b1-a1)) ;
u(b1,y)
= 2*exp(0.5)*(3-(y-a2)/(b2-a2)) ;
Output Specifications:
Efficiency Hints:
MCS 571 HomePage: http://www.math.uic.edu/~hanson/mcs571/
Email Comments or Questions to hanson A T uic edu