All Courses
All Courses
clear all close all clc %% Definig the Problem Domain n_points = 101; dom_length = 1; h = dom_length/(n_points-1); x = 0:h:dom_length; % x domain space y = 0:h:dom_length; % y domain space % Initializing the problem T(1,1:n_points) = 1; T(1:n_points,1) = 1; T_new(1,1:n_points) = 1; T_new(1:n_points,1) = 1; rho = 1; u =…
Amith Ganta
updated on 24 May 2021
clear all
close all
clc
%% Definig the Problem Domain
n_points = 101;
dom_length = 1;
h = dom_length/(n_points-1);
x = 0:h:dom_length; % x domain space
y = 0:h:dom_length; % y domain space
% Initializing the problem
T(1,1:n_points) = 1;
T(1:n_points,1) = 1;
T_new(1,1:n_points) = 1;
T_new(1:n_points,1) = 1;
rho = 1;
u = 1;
v = 1;
gamma = 0.0025;
P = rho*u*h/gamma;
%% Differencing Scheme
error = 1;
iterations = 0;
while error > 1e-7
for i = 2:n_points - 1;
for j = 2:n_points -1;
a_E = gamma;
a_W = gamma + rho*u*h;
a_N = gamma;
a_S = gamma + rho*v*h;
a_P = rho*u*h + rho*v*h + gamma + gamma + gamma + gamma;
T_new(i,j) = (a_E*T(i+1,j) + a_W*T(i-1,j) + a_N*T(i,j-1) + a_S*T(i,j+1))/a_P;
end
end
iterations = iterations + 1;
error = 0;
for i = 2 : n_points -1;
for j = 2:n_points - 1;
error = error + abs(T(i,j) - T_new(i,j));
end
end
T = T_new;
end
%% Plotting
x_dom = ((1:n_points)-1).*h;
y_dom = 1 - ((1:n_points)-1).*h
[X,Y] = meshgrid(x_dom,y_dom);
contourf(X,Y,T, 50)
colorbar
%% Centreline temperature
figure;
plot(1-y,T(:,(n_points+1)/2),'--o')
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...
Quater car modelling using Matlab
Quarter Car model …
22 Nov 2022 09:11 PM IST
Single cylinder SI engine modelling using GT-Suite
Introduction to GT Suite Effective utilization of simulation software with human intelligence is required…
03 Apr 2022 12:50 AM IST
internship formulas
∂ωx∂t=[2⋅a2a2+c2−2⋅a2a2+b2]⋅ωz⋅ωy+Posin(t)⋅2⋅a2a2+b2⋅ωZ+2⋅a2a2+c2⋅ωy+Posin(t)+L⋅τx ∂ωy∂t=[2⋅b2a2+b2−2⋅b2b2+c2]⋅ωx⋅ωz+Pocos(t)⋅2⋅b2a2+b2⋅ωZ−2⋅b2b2+c2⋅ωx+Pocos(t)+L⋅τy…
30 Oct 2021 02:16 PM IST
CI engine modelling of 2019 Chevrolet Silverado Duramax Diesel Engine Using GT Suite
Introduction to CI engines Compression - ignition or diesel engine…
17 Sep 2021 09:30 AM IST
Related Courses
0 Hours of Content