Monday, 17 December 2018

SCILAB TUTORIAL || 1D steady state heat conduction in a slab

Consider a 1D heat conduction through a plane slab of thickness 'L'. Both the end walls are maintained at a constant temperatures of T1 and T2. There is no heat generation inside the slab.
Let's see how is the temperature distribution inside the slab with the help of SCILAB...


SCILAB CODE :

      clc()
      L=input("Enter the thickness of the slab (in m)                 :")
      K=input("Enter the thermal conductivity of material (in W/mK)   :")
      T1=input("Enter the left wall temperature (in degree C)         :")
      T2=input("Enter the right wall temperature (in degree C)         :")
      N=input("Enter the numbaer of divisions                         :")
      n=input("Enter the number of iterations                         :")
      dx=L/N

      T=zeros(N+1)
      T(1)=T1
      T(N+1)=T2

      for k=1:1:n
          for i=2:1:N
              T(i)=(T(i+1)+T(i-1))/2
          end
      end

      x=[0:dx:L]

      //***PLOTTING THE GRAPH***//
      plot2d(x,T)


Consider :
          
          L=0.1m
          N=10
          K=237 W/mK
          n=100
          T1=150
          T2=50

Result :

Conclusion :

Temperature inside the slab varies linearly with the space.

No comments:

Post a Comment