Matlab program using implicit Finite Difference

1 reply · 5K views · last reply
tactical
Messages
6
Reaction score
0
Hello,

I need help writing a MATLAB program to solve a heat transfer problem implicitly. For some reason this is very confusing to me. The problem is stated below. Any help is greatly appriciated. Let me know if you need a little more info.

I need to write a program to solve this problem. I want to solve for a temperature T(i,n) using the temperature at the 3 nodes ahead of it. Essentially it's going to be a tridiagonal matrix in which you can solve using Thomas Algorithm. I just need help writing a program to get this tridiagonal matrix.
Implicit finite difference stencil for heat equation with formula T_i^n = -λ·T_{i-1}^{n+1} + (1+2λ)·T_i^{n+1} - λ·T_{i+1}^{n+1}, a grid diagram of three blue nodes at time n+1 and one black node at time n, and boundary conditions T(i,0)=0, T(0,n)=1, and ∂T/∂x(1,n)=0.


Edit: Also, all variable are dimensionless, therefore time goes from 0 to 1 and x also goes from 0 to 1. time is broken up into Δn parts and x is broken up into Δi parts. λ = Δt/Δx2
 
I guess this might help some:

This what the PDE that was discretized

Dimensionless heat equation: second partial derivative of theta with respect to X squared equals partial derivative of theta with respect to tau, where X = x/L, tau = alpha t^2/L^2, and theta = (T - T0)/(Ts - T0).