Finite Difference Method Code won't stop diverging?

1 view (last 30 days)
Hello, I'm working on a class project for heat and mass transfer, and we were tasked with using the finite difference method to get the steady state temperature distribution throughout the two materials up against each other in the attached picture. We also needed to find the time that it took to get to steady state, so it is a transient problem.
I have been working on the code (attached) for quite awhile and the temperatures are diverging extremely bad (I'm talking x 10^220 bad). I am trying to figure out if there is something wrong with my code syntax causing this or if my finite difference equations are wrong. The way I was planning to use this code was to keep changing the "finaltime" variable until the
temperatures remained the same (converged), thereby giving me the steady state distribution and the time needed to reach that point. I know there are probably more efficient ways of doing this but I am a MATLAB novice for sure.
Could someone please explain to me why my temperature distribution numbers are so incredibly high? Also, I don't know if this is helpful, but as I increase the "finaltime" variable, the temps get higher and higher.
Thanks in advance for any help you can provide!!!

Answers (0)

Community Treasure Hunt

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

Start Hunting!