MATLAB Solving Heat Transfer Problem In Matlab with Finite Difference Mesh

  • Thread starter Thread starter MattT1991
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion revolves around a problem with MATLAB while solving the heat equation using a finite difference mesh. The user, Matt, successfully implemented a downward calculation for a water layer but encountered issues when trying to implement an upward calculation for an air layer above it. Despite setting boundary conditions, the model fails to compute correctly, with second differentials returning zero. A suggestion was made to adjust the indexing to run from end-1 to 2 in a negative direction, but this approach did not resolve the issue. Ultimately, Matt found a workaround by introducing a new for loop to iterate through the array upwards, although he noted that this method is less elegant than desired. The discussion highlights challenges in implementing boundary conditions and mesh directionality in MATLAB for heat transfer simulations.
MattT1991
Messages
8
Reaction score
0
Hi everyone,

I am having a bit of a problem with Matlab. I am currently using a finite difference mesh to solve the heat equation across one spatial dimension - x and time. I had an water array with depth and time and a boundary condition given by heat transfer equations which set the top line. This ran perfectly fine downwards from 2 : end-1

I then added an array above it that was the same but had air properties. From this I set the bottom row to a boundary condition using the heat transfer equations and tried to run it the same way but upwards from end-1 : 2.

It will not work and just alters the bottom row. The second differentials from the finite difference model come up as 0 despite their consituent parts clearly not adding to 0 uppon logging.

(the model is trying to show heat interaction between an air layer sat on a water layer and heat transfer within the 2 layers in assumed to be conduction only)

Can anyone suggest a solution to this or a problem it may be?

Can MATLAB handle running upwards through a mesh?

Thanks for any help, ( I am happy to give you more information)

Matt
 
Physics news on Phys.org


If you want to step in the negative direction you need to tell MATLAB so.

Use: end-1 : -1: 2

That should work
 


Thanks, I will try it now

It didn't work. The only way I have been able to do it is by putting a new for loop in that runs a variable up the array and use that to work up the array but it looks a lot messier than it should be...
 
Last edited:

Similar threads

Replies
1
Views
2K
Replies
5
Views
3K
Replies
2
Views
4K
Replies
9
Views
3K
Back
Top