Find answers, ask questions, and connect with our <br>community around the world.

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

• FDM : UNSTEADY PROBLEMS(LECTURE 11)

Posted by on June 30, 2022 at 5:06 pm

I am not able to understand meaning of line
” for j=2:length(t) % loop for time step
T=Tcurrent “

PRASHANT PATHAK replied 1 year, 9 months ago 2 Members · 5 Replies
• 5 Replies
• PRASHANT

Member
July 1, 2022 at 2:37 pm

I have one more doubt
clc
clear all
% Geometrical parameters

xmin=0;
xmax = 0.2; % Length of Rod
N=50; % No of Nodes
dx=(xmax-xmin)/(N-1); % grid size
x=xmin:dx:xmax;
dt=1e-4 % 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(i-1));
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)
end

Solution is not converging………………graph obtained is still a curve and not a straight line…………..

• PRASHANT

Member
July 2, 2022 at 5:20 am

I have tried all the configurations and runned it for more time also but graph is not coming to be a straight line……………….Neither the graph is animating.

Try to run the code yourself and let me know the problem in it.