Home › Forums › CFD foundation course: Forum › FDM : UNSTEADY PROBLEMS(LECTURE 11) › Reply To: FDM : UNSTEADY PROBLEMS(LECTURE 11)

I have one more doubt
clc
clear all
% Geometrical parametersxmin=0;
xmax = 0.2; % Length of Rod
N=50; % No of Nodes
dx=(xmaxxmin)/(N1); % grid size
x=xmin:dx:xmax;
dt=1e4 % time step size
tmax=0.2; % Max time to simulate
t=0:dt:tmax;
alpha= 0.05; % diffusion coefficient% Initial and Boundary conditions
Tcurrent = ones(1,N)*30; % initial condition
Tb = 300; % Boundary condition,T base
Ttip = 50; % Boundary condition, T tip% solution
d=alpha*dt/dx^2
for j=2:length(t) % loop for time step
T=Tcurrent
end
for i=1:N % Space Stepping
if i==1
T(i)=Tb;
else if i==N
T(i)=Ttip;
else
T(i)=T(i)+d*(T(i+1)2*T(i)+T(i1));
end
end
Tcurrent=T;
time=j*dt;
plot(x,Tcurrent)
xlabel(‘Length of rod [m]’,’FontSize’,14)
ylabel(‘Temperature [^{0}C]’,’FontSize’,14)
set(gca,’Fontsize’,16)
str1= sprintf(‘value of d = %d’,d);
str2= sprintf(‘Time value = %dS’,time);
text(0.12,150,str1,’FontSize’,14);
text(0.12,130,str2,’Fontsize’,14);shg
pause(0.01)
endSolution is not converging………………graph obtained is still a curve and not a straight line…………..