Solving Heat Transfer Problem In Matlab with Finite Difference Mesh

  • Context: MATLAB 
  • Thread starter Thread starter MattT1991
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The forum discussion focuses on solving a heat transfer problem in MATLAB using a finite difference mesh. The user, Matt, encountered issues when attempting to implement boundary conditions for an air layer above a water layer, specifically when running calculations upwards through the mesh. The suggested solution involved using the syntax "end-1 : -1 : 2" to correctly iterate in the negative direction. However, Matt found that this did not resolve the issue, leading him to implement a new for loop to manage the upward calculations, which he deemed less efficient.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Knowledge of finite difference methods for solving differential equations
  • Familiarity with heat transfer principles, particularly conduction
  • Experience with boundary condition implementation in numerical models
NEXT STEPS
  • Research MATLAB's finite difference mesh capabilities and syntax
  • Explore advanced boundary condition techniques in heat transfer simulations
  • Learn about optimizing loops in MATLAB for better performance
  • Investigate alternative numerical methods for heat transfer problems, such as implicit methods
USEFUL FOR

This discussion is beneficial for MATLAB users, engineers, and researchers involved in thermal analysis, particularly those working with heat transfer simulations in multi-layer systems.

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 5 ·
Replies
5
Views
7K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K