## Author: M Turhan ÇOBAN
## Created: 2021-10-28
## HT_plane_wall_2

   h=600.0;
   kc=43;
   alpha=1.2e-5;
   L=0.05;
   t=[0.0,100.0,200.0,300.0,478.8]
   k=length(t);
   Tinf=40;
   Ti=240;
   T=Ti-Tinf;
   Bi=h/kc*L
   Fo=alpha*t(1)/(L*L);
   f=@(x1)x1*sin(x1)-Bi*cos(x1);
   F1=@(x1)(Ti-Tinf)*(1.0-0.1*(x1/L)*(x1/L));
   a=0.0;
   b=30.0;
   x=0;
   m=100;
   dx=L/(m-1);
   ksi=roots_bisection(f,0.0,30.0);
   n=length(ksi);
   Nbeta=0.0;
   for i=1:n 
     beta=ksi(i)/L;
	   Nbeta=L/2.0+sin(2.0*beta*L)/(4.0*beta);
	   Fcos_beta=@(x1)F1(x1)*cos(beta*x1);
	   Cn(i)=1.0/Nbeta*Gauss_Legendre_integral(Fcos_beta,0.0,L);
   endfor
   TT=zeros(k,m);
   for l=1:k
     theta=0.0;
     Fo=alpha*t(l)/(L*L)
     for j=1:m
       theta=0.0;
       x=j*dx;
       for i=1:n
         theta+=Cn(i)*exp(-ksi(i)*ksi(i)*Fo)*cos(ksi(i)*x/L);
       endfor  
       TT(l,j)=theta+Tinf;
       xx(j)=x;
     endfor
   endfor
   plot(xx,TT(1,:));
   title('Temperature profile t=0,100,200,300,478.8 s');
   xlabel('x') 
   ylabel('T* degree C') 
   hold on
   for i=2:k
     plot(xx,TT(i,:));
   endfor
   hold off
