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

Home Forums CFD foundation course: Forum unsteady problem

Posted by on August 19, 2022 at 11:13 am

xmin = 0;
xmax = 0.2;
N = 10; # Nodes to be made
dx = (xmax-xmin)/(N-1);
x = xmin:dx:xmax;
dt = 1e-3 # time step
tmax = 0.5;
t = 0:dt:tmax;

alpha = 0.05; # Material Property defined

# Initial Boundary Condition def
Tcurrent = ones(1,N)*50; # Temp is initiated from step 1
Tb = 300;
Ttip = 50;

# Solution
d = alpha * dt/dx^2

for j = 2:length(t)

T = Tcurrent;
for i=1:N
if i==1
T(i) = Tb;

endif 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]’,’Font Size’,14)
ylabel(‘Temperature [{o}C]’,’Font Size’,14)
set(gca,’Fontsize’,16)
str1 = sprintf(‘Value of d = %d’,d);
str2 = sprintf(‘Time value = %d’s,time);
text(0.15,150,str1,’Fontsize’,14);
text(0.15,150,str2,’Fontsize’,14);
shg
pause(0.01)
end
i could not see plots .

2 Members · 2 Replies
• 2 Replies