Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Heat diffusion on a rod over the time In class we learned analytical solution of 1-D heat equation Below is the MATLAB code which simulates

Heat diffusion on a rod over the time

In class we learned analytical solution of 1-D heat equation

Below is the MATLAB code which simulates finite difference method to solve the above 1-D heat equation.

%1-D Heat equation

%example 1 at page 782

%lambdat=c.k/h^2

%T(x,t)=temperature along the rod

%by finite difference method

%(T(x,t+dt)-T(x,t))/dt = (T(x+dx,t)-2T(x,t)+T(x-dx,t))/dx^2

%solve for T(x,t+dt) by iteration

%heat constant

closeall

clearall

c=1;

L=1%length of the rod

N=5%# of elements

%dicretize Xspace

h=L/N;

x_vec=0:h:L;

%discretize time

T=0.5;

M=50;

k=T/M;

t_vec=0:k:T;

%temperature matrix

T_mat=zeros(length(x_vec),length(t_vec));

%boundary conditions

T_mat(1,:)=0;

T_mat(end,:)=0;

%initial conditions

T_mat(:,1)= sin(pi.*x_vec);

[tt,xx]=meshgrid(t_vec,x_vec);

subplot(2,1,1);

mesh(xx,tt,T_mat);

title('Analytical vs numerical in 3D');

T_mat_calc=zeros(length(x_vec),length(t_vec));

T_mat_calc(:,1)= sin(pi.*x_vec);

lamda=(c*k/(h^2));

for tdx=1:length(t_vec)-1

for idx=2:length(x_vec)-1

T_mat(idx,tdx+1)=T_mat(idx,tdx)+lamda*((T_mat(idx+1,tdx)-2*T_mat(idx,tdx)+T_mat(idx-1,tdx)));

T_mat_calc(idx,tdx+1)= (exp((-pi^2)*(t_vec(tdx+1))))*sin(pi*(x_vec(idx)));

end

end

%plot

subplot(2,1,2)

[tt,xx]=meshgrid(t_vec,x_vec);

mesh(xx,tt,T_mat);

figure

plot(x_vec,T_mat(:,1),x_vec,T_mat(:,11),x_vec,T_mat(:,21),x_vec,T_mat(:,31),x_vec,T_mat(:,41),x_vec,T_mat(:,51));

xlabel('Rod length (m)'); ylabel('Temperature (C)');

legend('Initially','At t=0.1sec','At t=0.2 secs','At t=0.3 secs',' At t=0.4 secs',' At t=0.5 secs');

title('Numerical Solution');

figure

plot(x_vec,T_mat_calc(:,1),x_vec,T_mat_calc(:,11),x_vec,T_mat_calc(:,21),x_vec,T_mat_calc(:,31),x_vec,T_mat_calc(:,41),x_vec,T_mat_calc(:,51));

xlabel('Rod length (m)'); ylabel('Temperature (C)');

legend('Initially','At t=0.1sec','At t=0.2 secs','At t=0.3 secs',' At t=0.4 secs',' At t=0.5 secs');

title('Analytical Solution');

Copy and paste the above code in the MATLAB editor and run in the MATLAB. Look at how temperature changes at the times indicated in the graph.

  • What is the initial condition for the temperature on this rod?
  • What are the boundary conditions?
  • Analytical Solution: Hand calculate the solution by using separation of variables and include in your submitted homework. You will use heat equation solution from chapter 13. You must insert the analytical solution into the code above.
  • Do you expect to see the heat diffusing the way you see in the graph? Justify your answer by comparing analytical solution with numerical solution.

Submit your typed or printed answers to the above questions and plot and submit analytical solution and numerical solutions and your code. (In the code T_mat matrix is the numerical solution)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Materials Science and Engineering

Authors: Donald R. Askeland, Wendelin J. Wright

3rd edition

978-1111576868, 1111576866, 978-1285677620, 1285677625, 978-1111576851

More Books

Students also viewed these Mechanical Engineering questions

Question

Find the radius of convergence of? 1.2.3 1.3.5 (2n-1) r2n+1 -1

Answered: 1 week ago