# Solving 2d heat problem using meshgrid

18 Ansichten (letzte 30 Tage)
Ali am 4 Feb. 2024
Kommentiert: William Rose am 5 Feb. 2024

I need guidance to solve a two-dimensional heat transfer problem, as it is clear in the figure, it is necessary to solve the temperature between the outer circle and the inner square using the meshgrid method in both steady state and transients. The desired number of mesh points is 10 points in both x and y directions. The side of the square is 8 cm long and the diameter of the circle is 10 cm. And I also want to use the meshgrid as a square and that the result will be a 3D plot. Can anyone guide me in this matter?

##### 8 Kommentare6 ältere Kommentare anzeigen6 ältere Kommentare ausblenden
Torsten am 4 Feb. 2024
Sorry, but I've always solved such problems in a way that the grid matched with the domain boundaries. Maybe you were taught such an approximate method, but I don't know of such.
Ali am 4 Feb. 2024
No problem at all, thank you very much for your time.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

William Rose am 4 Feb. 2024
Bearbeitet: William Rose am 4 Feb. 2024
[edit: fix spelling erors]
A 10x10 mesh for this problem is so few points that it makes it hard to set up the problem and get reasonable results. I am going to make it with more points. You can adjust if you like.
One simple-minded way to do this is to create a 3D rectangular array. The third dimension is for time. You can adjust the time duration if you don't like the results.
x=-10.5:1:10.5; % x-coordinates of the grid points
y=x; % y-coordinates of the grid points
dt=0.5; % time step size
t=0:dt:100; % time values
Tout=130; % external temperature
T=Tout*ones(length(x),length(y),length(t)); % array for temperature
You will want to use a simple first-order difference equation to update the temperature at each time step.
You will need to initialize the temperature at t=0 so that it is 40 inside the square and 10 in the green area.
You will use a set of nested for loops to do this. The outer loop is time, the inner loops are x and y (order of the inner loops not important, as long as you check all the grid points).
At each time step, you will update the temperature at all the grid points, using the tepratures at the previous time step. Points inside the inner square, and points outside the circle, will not change with time. Points in the green area will change with each new time step, accortding to the difference equation which you will develop.
The difference equation will look somethink like this:
T(i,j,k)=T(i,j,k-1)+...
where k is the time index, and you should figure out what the "..." is.
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
William Rose am 5 Feb. 2024
@Ali, You are weelcome.
Here is a discussion of a similar problem. I am not endorsing the code by the original poster. That problem has 3 spatial dimensions. Array T in that problem is T(m,i,j,k), where index m is for time. That problem does not have an inner cut-out. The graphical display of results for that problem may be useful for you.
William Rose am 5 Feb. 2024

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Geometry and Mesh finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by