I'm attempting to find the heat distribution and time required to reach steady state for a 1d rod using a finite difference method (explicit), which has fixed temperature on both its left and right hand sides
I'm having problems trying to write a loop to calculate (and replace) the elements of my matrix using my function which is New temperature= Current temperature at point +alpha*dt((T(j+1)-2*T(j)+T(j-1))/dx^2)
What I have so far:
TR=25 %Temperature (right side)
TL=100 %temperature (left side)
TM=20 %temperature across rod
k=54; %thermal conductivity of slab
rho=7800; %density
c=490; %specific heat
alpha=k/(rho*c);
W=0.05 %width of rod
dx=0.01 %space between grid points
dt=3 %change in time
nx=6;
ny=1
T(1:ny,1:nx)=TM; %make all values of grid =TM can also use TM*ones(26,51)
T(:,nx)=TR; % change values of last column to TR
T(:,1)=TL; %change values of first column to TL
tstart=0 %start time
I also want to calculate the time required for my rod to achieve the steady state condition
How could I go about doing this?