The document describes a 1D unsteady heat transfer simulation using three different numerical methods: explicit, Crank-Nicolson, and implicit. It involves discretizing a bar into grid points, defining conductivity and heat capacity properties, and iterating the temperature calculation at each point over time using the specified method. The results show the temperature profile at each timestep for verification of the different methods.
The document describes a 1D unsteady heat transfer simulation using three different numerical methods: explicit, Crank-Nicolson, and implicit. It involves discretizing a bar into grid points, defining conductivity and heat capacity properties, and iterating the temperature calculation at each point over time using the specified method. The results show the temperature profile at each timestep for verification of the different methods.
The document describes a 1D unsteady heat transfer simulation using three different numerical methods: explicit, Crank-Nicolson, and implicit. It involves discretizing a bar into grid points, defining conductivity and heat capacity properties, and iterating the temperature calculation at each point over time using the specified method. The results show the temperature profile at each timestep for verification of the different methods.
%CFD 1D Unsteady clc; clear; n=input('number of grid points of control volume= '); L=input('Enter the length of bar='); K=input('Enter the value of thermal conductivity='); C=input('Enter the value of volumetric heat capacity ='); T_initial = input('Enter value of initial tenmperature (at Time=0) ='); T_b=input('Boundry temperature='); x=L/n; Time_initial = input ('Enter starting time = '); Time_final = input ('Enter final time = '); method = input('Explicit Method = 1 Crank-Nicolson Method = 2 Implicit Method = 3.... Method= '); y(1)=0; y(2)=x/2; for i=3:n+1; y(i)=y(i-1)+x; end for i=1:n+1 T(i)=T_initial; end T(n+2)=T_b; y(n+2)=L; aw(2)=2*K/x; ae(2)=K/x; aw(n+1)=K/x; ae(n+1)=2*K/x; for i=3:n; aw(i)=K/x; ae(i)=K/x; end if method==1 delT=C*(x^2)/(4*K); for i=1:delT:Time_final; Told=T; ap_old=C*x/delT; ap=ap_old; T(n+2)=0; for j=2:n+1; T(j)=((aw(j).*Told(j-1))+(ae(j).*Told(j+1))+((ap_old-aw(j)- ae(j))*Told(j)))/ap; disp (T); end T(1)=T(2); end elseif method==2 delT=C*(x^2)/(2*K); for i=1:delT:Time_final; Told=T; ap_old=C*x/delT; a(1)=1; b(1)=0; c(1)=0; d(1)=-1; for j=2:n+1 ap(j)=ap_old+(aw(j)/2)+(ae(j)/2); a(j)=ae(j)/2; b(j)=aw(j)/2; c(j)=-((b(j)*Told(j-1))+(a(j)*Told(j+1))+((ap_old-a(j)-b(j))*Told(j))); d(j)=-ap(j); end a(n+2)=0; b(n+2)=0; c(n+2)=T_b; d(n+2)=1; e(1)=d(1); f(1)=c(1); for j=2:(n+2); e(j)=d(j)-((a(j-1).*b(j))./e(j-1)); f(j)=(c(j)-((b(j).*f(j-1))./e(j-1))); end T(n+2)=f(n+2)./e(n+2); for j=(n+1):-1:1; T(j)=(f(j)-(a(j).*T(j+1)))./e(j); disp (T); end end elseif method==3; delT=input('suitable time interval='); for i=1:delT:Time_final; Told=T; ap_old=C*x/delT; a(1)=1; b(1)=0; c(1)=0; d(1)=-1; for j=2:n+1 ap(j)=ap_old+(aw(j))+(ae(j)); a(j)=ae(j); b(j)=aw(j); c(j)=-((ap_old)*Told(j)); d(j)=-ap(j); end a(n+2)=0; b(n+2)=0; c(n+2)=T_b; d(n+2)=1; e(1)=d(1); f(1)=c(1); for j=2:(n+2); e(j)=d(j)-((a(j-1).*b(j))./e(j-1)); f(j)=(c(j)-((b(j).*f(j-1))./e(j-1))); end T(n+2)=f(n+2)./e(n+2); for j=(n+1):-1:1; T(j)=(f(j)-(a(j).*T(j+1)))./e(j); disp (T); end end end Output
Explicit Output
number of grid points of control volume= 5
Enter the length of bar=0.02 Enter the value of thermal conductivity=10 Enter the value of volumetric heat capacity =10^6 Enter value of initial tenmperature (at Time=0) =200 Boundry temperature=0 Enter starting time = 0 Enter final time = 2 Explicit Method = 1 Crank-Nicolson Method = 2 Implicit Method = 3.... Method= 1 200 200 200 200 200 200 0
Enter the length of bar=0.02 Enter the value of thermal conductivity=10 Enter the value of volumetric heat capacity =10^6 Enter value of initial tenmperature (at Time=0) =200 Boundry temperature=0 Enter starting time = 0 Enter final time = 2 Explicit Method = 1 Crank-Nicolson Method = 2 Implicit Method = 3.... Method= 2 200.0000 200.0000 200.0000 200.0000 200.0000 82.8427 0
Enter the length of bar=0.02 Enter the value of thermal conductivity=10 Enter the value of volumetric heat capacity =10^6 Enter value of initial tenmperature (at Time=0) =200 Boundry temperature=0 Enter starting time = 0 Enter final time = 2 Explicit Method = 1 Crank-Nicolson Method = 2 Implicit Method = 3.... Method= 3 suitable time interval=0.5 200.0000 200.0000 200.0000 200.0000 200.0000 133.3333 0