Wednesday 12 December 2018

SCILAB TUTORIAL || Temperature distribution within a 2D plate subjected to constant temperatures at four walls

           ➤DIAGRAM :

           BOUNDARY CONDITIONS :

Left wall                                                       :  Any temperature (℃)
Bottom wall                                                 :  Any temperature (℃)
Right wall                                                     :  Any temperature (℃)
Top wall                                                        :  Any temperature (℃)

SCILAB CODE :

                    clc
                    disp("********2D CONSTANT WALL TEMPERATURE PROBLEM********")

                    disp("GEOMETRIC DETAILS")
                    L=input("Domain Length (in m):")
                    H=input("Domain Height (in m):")

                    disp("GRID DETAILS")
                    Nx=input("No. of divisions in X direction   :")
                    Ny=input("No. of divisions in Y direction   :")

                    dx=L/Nx
                    dy=H/Ny
                    m=(dx/dy)

                    disp("DOMAIN PROPERTIES")
                    K=input("Enter the thermal conductivity of plate material (in W/mK) :")

                    disp("BOUNDARY CONDITIONS")
                    Tl=input("Enter the left wall temperature (in Degree C)          :")
                    Tb=input("Enter the bottom wall temperature (in Degree C)        :")
                    Tr=input("Enter the right wall temperature (in Degree C)         :")
                    Tt=input("Enter the top wall temperature (in Degree C)           :")
                    Ta=input("Enter the ambient temperature (in Degree C)            :")

                    n=input("Enter the number of iterations                   :")

                    //***INITIAL TEMPERATURE OF DOMAIN***//
                    T=Ta*ones(Nx+1,Ny+1)

                    //***LEFT WALL TEMPERATURE***//
                   for j=2:1:Ny
                      T(1,j)=Tl
                   end

                   //***LEFT BOTTOM TEMPERATURE***// 
                  for i=2:1:Nx
                     T(i,1)=Tb
                  end

                  //***LEFT RIGHT TEMPERATURE***//
                 for j=2:1:Ny
                    T(Nx+1,j)=Tr
                 end

                 //***LEFT TOP TEMPERATURE***//
                 for i=2:1:Nx
                    T(i,Ny+1)=Tt
                 end

                 //***CORNER POINT TEMPERATURES***//
                T(1,1)=(Tl+Tb)/2
                T(Nx+1,1)=(Tr+Tb)/2
                T(Nx+1,Ny+1)=(Tr+Tt)/2
                T(1,Ny+1)=(Tl+Tt)/2

                 //***TEMPERATURE DISTRIBUTION IN INTERIOR POINTS***//
                for k=1:1:n
                   for j=2:1:Ny
                      for i=2:1:Nx
                         T(i,j)=(T(i+1,j)+T(i-1,j)+(m^2)*(T(i,j+1)+T(i,j-1)))/(2*(1+m^2))
                      end
                   end
                end

                //***PLOTTING CONTOUR FOR TEMPERATURE DISTRIBUTION***//
               Tmax=0
               Tmin=0
               xp=0:dx:L
               yp=0:dy:H
               for j=1:1:Ny+1
                  for i=1:1:Nx+1
                     if T(i,j)<Tmin then
                        Tmin=T(i,j)
                     end
                     if T(i,j)>Tmax then
                        Tmax=T(i,j)
                     end
                  end
               end

               clf()
               f=gcf();
               f.color_map=jetcolormap(64);
               colorbar(Tmin,Tmax)
               Sgrayplot(xp,yp,T,strf="041")

              //***TEMPERATURE DISTRIBUTION AT HORIZONTAL MID LINE***//
              xset('window',1)
              plot2d(xp,T(:,(Ny/2)+1))

              //***TEMPERATURE DISTRIBUTION AT VERTICAL MID LINE***//
              xset('window',2)
              plot2d(yp,T((Nx/2)+1,:))
              disp(T)

              //***END***//


          CONSIDER :
          
          No. of divisions in x & y directions : 100
          Thermal conductivity of plate material : 237 W/mK
          No. of iterations : 1000

         RESULT :
         
         For Tl=100
               Tb=Tr=Tt=25


No comments:

Post a Comment