All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective : To investigate convergence rate of steady and Unsteady methods: Matlab code for steady convergence rate : close all clear all clc nx = 20; ny = 20; nt = 1000; x = linspace(0,1,nx); y = linspace(0,1,ny); d_x = x(2) - x(1); d_y = y(2) - y(1); y1 = 1; error = 9e9; tolerance = 1e-4; dt = 1e-4; T_L = 400; T_R =…
Epuri Yoga Narasimha
updated on 18 Feb 2021
Objective : To investigate convergence rate of steady and Unsteady methods:
Matlab code for steady convergence rate :
close all
clear all
clc
nx = 20;
ny = 20;
nt = 1000;
x = linspace(0,1,nx);
y = linspace(0,1,ny);
d_x = x(2) - x(1);
d_y = y(2) - y(1);
y1 = 1;
error = 9e9;
tolerance = 1e-4;
dt = 1e-4;
T_L = 400;
T_R = 800;
T_T = 600;
T_B = 900;
T = 300*ones(nx,ny);
T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(ny,2:ny-1) = T_B;
T(1,1) = (T_L + T_T)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_L + T_B)/2;
k = 2*((d_x^2 + d_y^2)/(d_x^2*d_y^2));
k1 = (1.6*dt)/d_x^2;
k2 = (1.6*dt)/d_y^2;
term1 = (1/(1+2*k1+2*k2));
term2 = (k1*term1);
term3 = (k2*term1);
w_opt = 1.4;
kj = 1;
kc = 0;
T_new2 = T;
T1 = T;
T2 = T;
T_new1 = T;
T_new = T;
kl = 1;
while error > 1e-4
for i=2:nx-1
for j = 2:ny-1
T_new(i,j) = (1/k)*(((T(i-1,j) + T(i+1,j))/d_x^2) + ((T(i,j-1) + T(i,j+1))/d_x^2));
T_new1(i,j) = (1/k)*((T_new1(i-1,j)+T1(i+1,j))/d_x^2) + (1/k)*((T_new1(i,j-1) + T1(i,j+1))/d_y^2);
T_new2(i,j) = (1-w_opt)*T2(i,j) + w_opt*(((1/k)*((T_new2(i-1,j)+T2(i+1,j))/d_x^2) + (1/k)*((T_new2(i,j-1) + T2(i,j+1))/d_y^2)));
end
end
error = max(max(abs(T_new - T)));
error1 = max(max(abs(T_new1 - T1)));
error2 = max(max(abs(T_new2 - T2)));
if kj == 1
fg = error;
fg1 = error1;
fg2 = error2;
end
if kj>=2
loglog([kj-1,kj],[fg,error],'color','r')
axis([0 1000 1e-4 400])
hold on
loglog([kj-1,kj],[fg1,error1],'color','b')
loglog([kj-1,kj],[fg2,error2],'color','cyan')
legend('jacobi','Gauss-siedel','SOR-g-s')
pause(0.0000000000001)
title('convergence rate of iterative methods for steady conuction equation',kj)
xlabel('log(iterations)')
ylabel('log(error)')
end
fg = error;
fg1 = error1;
fg2 = error2;
kj = kj +1;
kc = kc+1;
T = T_new;
T1 = T_new1;
T2 = T_new2;
end
Results :
Observations :
1. SOR takes less iterations than jacobi and gauss siedel.
2. plotted using loglog command , so it would be easy to visualize.
Matlab code for both steady and unsteady methods :
close all
clear all
clc
nx = 20;
ny = 20;
nt = 1000;
x = linspace(0,1,nx);
y = linspace(0,1,ny);
d_x = x(2) - x(1);
d_y = y(2) - y(1);
y1 = 1;
error = 9e9;
tolerance = 1e-4;
dt = 1e-4;
T_L = 400;
T_R = 800;
T_T = 600;
T_B = 900;
T = 300*ones(nx,ny);
T(2:ny-1,1) = T_L;
T(2:ny-1,nx) = T_R;
T(1,2:nx-1) = T_T;
T(ny,2:ny-1) = T_B;
T(1,1) = (T_L + T_T)/2;
T(nx,ny) = (T_R + T_B)/2;
T(1,ny) = (T_T + T_R)/2;
T(nx,1) = (T_L + T_B)/2;
k = 2*((d_x^2 + d_y^2)/(d_x^2*d_y^2));
k1 = (1.6*dt)/d_x^2;
k2 = (1.6*dt)/d_y^2;
term1 = (1/(1+2*k1+2*k2));
term2 = (k1*term1);
term3 = (k2*term1);
w_opt = 1.5;
kj = 1;
kc = 0;
T_new = T;
T_prev=T;
kl = 1;
fprintf('Solver 1 : Steady n Solver 2 : Unsteady n ' )
Solver = input('enter the number you want to select the solver :')
fprintf(' method 1 : Jacobi n method 2 : Gauss siedel n method 3 : SOR-g-s ')
method = input('enter the number you want to select the method :')
tic
while error > 1e-4
for i=2:nx-1
for j = 2:ny-1
if solver == 1
if method == 1
T_new(i,j) = (1/k)*(((T(i-1,j) + T(i+1,j))/d_x^2) + ((T(i,j-1) + T(i,j+1))/d_x^2));
elseif method == 2
T_new(i,j) = (1/k)*((T_new(i-1,j)+T(i+1,j))/d_x^2) + (1/k)*((T_new(i,j-1) + T(i,j+1))/d_y^2);
elseif method == 3
T_new(i,j) = (1-w_opt)*T(i,j) + w_opt*(((1/k)*((T_new(i-1,j)+T(i+1,j))/d_x^2) + (1/k)*((T_new(i,j-1) + T(i,j+1))/d_y^2)));
end
end
if solver ==2
if method == 1
T_new(i,j) = ((term1)*T_prev(i,j)) + ((term2)*(T(i+1,j) + T(i-1,j))) + ((term3)*(T(i,j+1) + T(i,j-1)));
elseif method == 2
T_new(i,j) = ((term1)*T_prev(i,j)) + ((term2)*(T_new(i-1,j) + T(i+1,j))) + ((term3)*(T_new(i,j-1) + T(i,j+1)));
elseif method == 3
T_new(i,j) = (1-w_opt)*T(i,j) + w_opt*(((term1)*T_prev(i,j)) + ((term2)*(T(i+1,j) + T(i-1,j))) + ((term3)*(T(i,j+1) + T(i,j-1))));
end
end
end
end
error = max(max(abs(T_new - T)))
if kj == 1
fg = error;
end
if kj>=2
loglog([kj-1,kj],[(fg),(error)],'color','r')
axis([0 10000 1e-4 10000])
hold on
if method == 1
legend('jacobi')
elseif method == 2
legend('Gauss-siedel')
else
legend('SOR-g-s')
end
title('convergence rate of iterative methods for Unsteady conuction equation time @ Iteration @',[toc kj])
xlabel('log(iterations)')
ylabel('log(error)')
end
fg = error;
kj = kj +1;
kc = kc+1;
pause(0.00000000001)
T = T_new;
T_prev = T_new;
end
Results :
Jacobi steady and unsteady :
Gauss siedel steady and unsteady :
SOR steady and unsteady :
Transient Explicit Results :
Number of Iterations : 1436.
Note :
Using function defination this execution would be simpler.
Observations :
1. Succcessive over relaxation method is faster than other two methods.
2. Explicit Transient takes less iterations than Implicit successive over relaxation.
3. Implicit approach takes more iterations and more time to execute.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 4
Objective 1. Detect lanes using Hough Transform Method. Steps in lane Detection 1. Detect Edges using Canny Edge Detection Method. 2. Capture the Region of Interest in Image. 3. Detect lines using Hough Transform. 4. Calculate the actual left and right lanes from all lines. 6. Find the coordinates of the lines. 7. Display…
21 Feb 2023 05:22 AM IST
Lane Detection using Hough Transform
Objective 1. Detect lanes using Hough Transform Method. Steps in lane Detection 1. Detect Edges using Canny Edge Detection Method. 2. Capture the Region of Interest in Image. 3. Detect lines using Hough Transform. 4. Calculate the actual left and right lanes from all lines. 6. Find the coordinates of the lines. 7. Display…
21 Feb 2023 05:20 AM IST
Edge Detection and Hough Transform
Objective: Detecting Edges using Canny Edge Detector. Understand and display the outputs of all steps in the canny Edge Detection process. Effect on the output on changing the parameters of the Non-Maximum Suppression. Understand Hough Transform and Lane Detection using Hough Transform. Steps Follow in the Discussion:…
28 Dec 2022 09:58 PM IST
week 2 : Image Filtering
Objective: Apply Prewitt and Laplacian filter on the image Libraries used: Opencv Open Source computer vision library. cross-platform supported. can perform through c, c++, and python. numpy Mathematical library to work in the domain of Linear algebra, Fourier transform, and matrices. Image Filtering…
09 Jul 2022 06:36 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.