SOLVING THE 2D HEAT EQUATION with a non-square domain

20 views (last 30 days)
Hi,
Im trying to solve the THE 2D HEAT EQUATION.
My code currently solves it for a square domain id like it to solve it for a different non symetric domain
%Jorge Clares
%Numerical Methods Course Project
%Spring 2022
clear;
clc;
%% Creating the Geometry of the Cockpit
width = 0.850; %width in meters
height = 0.450; %Height in meters
NGX = 100; %Number of grid points in X direction
NGY = 100; %Number of grid points in Y direction
DX = width/(NGX-1);
DY = height/(NGY-1);
%% Initial Conditions
T = 25*ones(NGX,NGY);
Tback = 100; %Back Wall temp in Celcius
Tfront = 20; %Front Wall temp in Celcius
Ttop = 20; %Top Wall temp in Celcius
Tbottom = 80; %Bottom Wall temp in Celcius
T(1,2:NGY-1) = Tback;
T(2:NGX-1,NGY) = Ttop;
T(NGX,2:NGY-1) = Tfront;
T(2:NGX-1,1) = Tbottom;
T(1,1) = (Tback+Tbottom)/2;
T(NGX,1) = (Tfront+Tbottom)/2;
T(1,NGY) = (Tback+Ttop)/2;
T(NGX,NGY) = (Tfront+Ttop)/2;
%% Solving 2d Heat Equation
E = 1e-3;
Error = 5;
while (Error>E)
Told = T;
for j = 2:NGY-1
for i = 2:NGX -1
T(i,j) = (T(i+1,j) + T(i-1,j)+ T(i,j+1) + T(i,j-1))/4;
end
end
Error = sqrt(sumsqr(T-Told));
end
%% Ploting Results
x = 0:DX:width;
y = 0:DY:height;
colormap("jet")
contourf(x,y,T');
colorbar;
title('plot')
xlabel('Width')
ylabel('height')
  7 Comments
Jorge Arturo Clares Pastrana
I want a similar output, but instead of having a square geometry I want somethig like the following geometry
Torsten
Torsten on 27 Apr 2022
I'd divide the geometry in two rectangles, apply your code to each rectangle separately and use the conditions of continuity of temperature and heat flux at the interface.

Sign in to comment.

Answers (0)

Categories

Find more on Thermal Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!