## Iterative Solvers for linear systems

Google Drive Link for all sorce code files and functions files

Outputs:

1. Jacobi Method

The program also showed the following output in the command window

"The Jacobi Solver could not converge for the following case for spectral radius 1.020416e+00"

2. Gauss Siedel Method

The program also showed the following output in the command window

"The Gauss Siedel Solver could not converge for the following case for spectral radius 1.381472e+00"

3. Successive Over Relaxation Method

The program ran endlessly when the magnification factor was set to 0.5 as the spectral radius went up to 1.5815 and was unable to converge.

Conclusions and Observations:

We made the following observations:

1. The no. of iterations any solver takes to converge is directly proportional to spectral radius of the iteration matrix i.e. as the spectral radius goes up, the number of iterations neede to converge also goes up.

2. As the Spectral Radius goes above 1, the system becomes unsolvable by iterative solvers.

3. As we increase/magnify the diagonal elements of the coefficient matrix, the spectral radius decreases and vice versa.

%Effect of Diagonal Magnification on spectral radius and number of iterations for various iterative methods

clear all
close all
clc

%Please input the solver to be used
solver=3;
%jacobi=1;gauss sidel=2;SOR=3

%Please Input a system of 3 linear equation in the form of 3x3 matrix
A=[5 1 2; -3 9 4;1 2 -7];
B=[10; -14; 33];
w=1.2 ;   %Over Relaxation Factor
m=[0.5 1 2 3 4 5];   %diagonal magnification

%Direct Solver/Inverting Matrix
X=inv(A)*B;

%AX=B

%Matrix Decomposition
Lo=[0 0 0; A(2,1) 0 0 ; A(3,1) A(3,2) 0];
Up=[0 A(1,2) A(1,3); 0 0 A(2,3); 0 0 0 ];
D=[A(1,1) 0 0 ; 0 A(2,2) 0; 0 0 A(3,3)];

I=eye(3);                         %Identity Matrix
syms f(L);

%Jacobi
if solver ==1

rho_T_jac=zeros(1,length(m));
iter_jac=zeros(1,length(m));

for i=1:length(m)

A=m(i)*D + Lo + Up;

%Iteration Matrix For Jacobi
T_jac= inv(m(i)*D)*(Lo+Up);

%Finding Eigen Values for iteration matrix, spectral readius for JACOBI
f(L)=det(T_jac-L*I);              %Characteristic Equation
C=double(coeffs(f,L,'All'));      %Coefficient Matrix

eig_T_jac=roots(C);               %Eigen-Values of Iteration Matrix of jacobi method
rho_T_jac(i)=max(abs(eig_T_jac));    %Spectral Radius of Iteration Matrix of jacobi method

[iter_jac(i),x_jac]=jacobi(A,B);

N=isnan(x_jac);
if max(N)==1

txt=sprintf('The Jacobi Solver could not converge for the following case for spectral radius %d',rho_T_jac(i));
disp(txt);

end

end

subplot(2,1,1);
plot(m,rho_T_jac);
xlabel('Diagonal Magnification');
ylabel('Spectral Radius , \rho');
title('Effect of Diagonal Magnification on Spectral Radius');

subplot(2,1,2)
loglog(rho_T_jac,iter_jac,'r');
xlabel('Spectral Radius , \rho');
ylabel('No. of Iterations');
title('Effect of Spectral Radius on No. of Iterations for Jacobi Method');

end

%Gauss Siedel
if solver==2

rho_T_gs=zeros(1,length(m));
iter_gs=zeros(1,length(i));

for i=1:length(m)

A=m(i)*D + Lo + Up;

%Iteration Matrix For gs
T_gs= inv(m(i)*D+Lo)*(Up);

%Finding Eigen Values for iteration matrix, spectral readius for GAUSS SIEDEL
f(L)=det(T_gs-L*I);              %Characteristic Equation
C=double(coeffs(f,L,'All'));      %Coefficient Matrix

eig_T_gs=roots(C);               %Eigen-Values of Iteration Matrix of gs method
rho_T_gs(i)=max(abs(eig_T_gs));    %Spectral Radius of Iteration Matrix of gs method

[iter_gs(i),x_gs]=gs(A,B);

N=isnan(x_gs);
if max(N)==1

txt=sprintf('The Gauss Siedel Solver could not converge for the following case for spectral radius %d',rho_T_gs(i));
disp(txt);

end

end

subplot(2,1,1);
plot(m,rho_T_gs);
xlabel('Diagonal Magnification');
ylabel('Spectral Radius , \rho');
title('Effect of Diagonal Magnification on Spectral Radius');

subplot(2,1,2)
loglog(rho_T_gs,iter_gs,'r');
xlabel('Spectral Radius , \rho');
ylabel('No. of Iterations');
title('Effect of Spectral Radius on No. of Iterations for Gauss Siedel Method');

end

%SOR Method
if solver==3

rho_T_sor=zeros(1,length(m));
iter_sor=zeros(1,length(i));

for i=1:length(m)

A=m(i)*D + Lo + Up;
%Iteration Matrix For SOR
T_sor= inv(Lo+m(i)*D)*(Up-(Lo+m(i)*D)*(1-w));

%Finding Eigen Values for iteration matrix, spectral readius for SOR
f(L)=det(T_sor-L*I);              %Characteristic Equation
C=double(coeffs(f,L,'All'));      %Coefficient Matrix

eig_T_sor=roots(C);               %Eigen-Values of Iteration Matrix of sor method
rho_T_sor(i)=max(abs(eig_T_sor));    %Spectral Radius of Iteration Matrix of sor method

[iter_sor(i),x_sor]=sor(A,B,w);

N=isnan(x_sor);
if max(N)==1

txt=sprintf('The SOR Solver could not converge for the following case for spectral radius %d',rho_T_sor(i));
disp(txt);

end

end

subplot(2,1,1);
plot(m,rho_T_sor);
xlabel('Diagonal Magnification');
ylabel('Spectral Radius , \rho');
title('Effect of Diagonal Magnification on Spectral Radius');

subplot(2,1,2)
loglog(rho_T_sor,iter_sor,'r');
xlabel('Spectral Radius , \rho');
ylabel('No. of Iterations');
title('Effect of Spectral Radius on No. of Iterations for SOR Method');

end



### Flow over a backward facing step Utkarsh Garg · 2019-01-19 07:43:25

The backward facing step flow project was performed as a part of skill lync challenge. The simulation was performed on three base grid sizes: 1. 3e-4m 2. 2.5e-4m 3. 2e-4m The above grid sizes were chosen due to lack of computation power.   The Results a Read more

### Channel Flow using CONVERGE STUDIO Utkarsh Garg · 2019-01-04 18:07:51

The simulation was run by refining the grid size successively in three steps as follows: Grid Size 1. 2e-4 m 2. 1.5e-4 m 3. 1.2e-4 m   The post-processing results of the three cases are as follows: 1. 2e-4 m Velocity Magnitude Mass Flow Rate Spec Read more

### Centrifugal Pump design and Performance Analysis Utkarsh Garg · 2018-10-11 17:14:09

CENTRIFUGAL PUMP DESIGN AND PERFORMANCE ANALYSIS   1. Geometry: PUMP   IMPELLER      2. Performance Analysis of the Centrifugal Pump Performance Analysis of a Centrifugal Pump Velocity normal to face (Outlet Velocity) [m/ Read more

### Flowbench Simulation for Intake Port Utkarsh Garg · 2018-08-12 12:20:33

1. Geometry: All dimensions in mm.   2. Boundary Conditions: Total pressure inlet = 4 bar Static pressure outlet = 1 bar Real wall = all inner surfaces of the cylinder, valve, and intake.   3. Grid dependence study: Goal (Value) Design Point Read more

### Symmetry vs Wedge boundary conditions openFoam Utkarsh Garg · 2018-08-12 08:38:12

Project Report   Assumptions (same as in previous challenge): 1. Reynolds Number = 1000 (For Laminar Flow) 2. Temperature= 20 degree Celsius 3. Length of pipe = 1 m 4. Diameter of pipe = 20 mm 5. At 20 Degrees Celsius (Ref: Saturated Water tables from Cengel Read more

### Flow over NACA0008 for various Angles of attack Utkarsh Garg · 2018-06-25 18:41:04

Google drive link to all the contours and plot: https://drive.google.com/open?id=1fBI5Zcassvv2ut9o2Qsy7ktrIq3LQx10 The link contains all the plots for various angles of attack and the pressure and velocity distribution for all cases.   The airfoil used was NACA Read more

### Hagen Poiseuille s Flow Utkarsh Garg · 2018-06-15 20:28:52

Google drive link to all the blockMeshDict file for various angles: https://drive.google.com/open?id=1GuYMGjgkJHC8hovIfkqA1sp4k1OdNR1t Google drive link to all the plots and source code: https://drive.google.com/open?id=1ntyenSwIed9JrNxDXwMKVZIeMk0-xNrk   Assu Read more

### Simulation of a 1D Quasi Super-sonic nozzle flow simulation using Maccormack Method Utkarsh Garg · 2018-05-31 14:26:55

Google drive link containing source code for both functions and all the plots https://drive.google.com/open?id=1q-2do7AV4YP2U5ilL54n37U3CXuNoeNK   Observations and Conclusions: 1. Normalized Mass flow rate We see that in case of conservative form of governing Read more