NUMERICAL ANALYSIS FOR ENGINEERING TERM PROJECT TRANSIENT HEAT CONDUCTION IN A PLANE WALL Author: Rene J Hernandez Due: April 17, 2001 1 TABLE OF CONTENTS Introduction…………………………………………………………………………….3 Problem Description and Formulation…………………………………………………3 Numerical Solution Approaches……………………………………………………….4 Results………………………………………………………………………………….5 Discussion and Error Analysis…………………………………………………………8 Conclusions……………………………………………………………………………11 References……………………………………………………………………………..12 Appendix A : Matlab Code Appendix B : CASE 1 Solution table Appendix C : CASE 2 Solution table LIST OF SYMBOLS Bi Fo h k m q T t u w x Biot number Fourier number Convection coefficient Thermal conductivity Node index Heat transferred/Heat generated Temperature Time Generic variable for differential equation representation Generic variable for solution of differential equation Position Thermal diffusivity Eigenvalue Mean time value Truncation error Mean position value 2 INTRODUCTION Although exact analytical solutions have been obtained for transient heat conduction problems, they often apply to simple geometry cases. Most practical problems, however, require the development of extensive solutions that are simplified by using appropriate assumptions making these analytical solutions approximate. Numerical mathematics can approach these problems in a faster and more convenient manner by also providing an approximated solution whose error depends on the assumptions made and the number of iterations. In this project, a numerical solution will be developed to solve transient heat conduction problems for the specific case of the plane wall. Using finite-difference methods for prescribed boundary conditions, this numerical solution will generate the temperature distribution across the width of the wall with respect to time. The numerical solution will be applied to the following baseline cases: - Wall with initial uniform temperature distribution with convective boundaries. - Wall with initial distribution of the form T(x)=sin(x) with fixed temperature boundaries. Since the analytical solution for these cases is known, the results from the numerical and analytical methods will be compared, showing the accuracy and validity of the numerical approach. PROBLEM DESCRIPTION AND FORMULATION A wall of infinite length, uniform thermal conductivity (k) and diffusivity (), and thickness (w) has an initial temperature distribution. For given boundary conditions, the problem consists of determining the one-dimensional transient temperature distribution of the wall as the internal temperature changes with time due to the influence of the boundary conditions. The x locations are designated by the m index of each nodal point. FIGURE 1: NODAL NETWORK ON A PLANE WALL (FLAT PLATE) 3 NUMERICAL SOLUTION APPROACHES Using Parabolic Partial Differential Equations will solve the mathematical problem described above, specifically the explicit method (Burden and Faires, chapter 12.2) is implemented. The approach used to approximate the solution involves finite differences. The heat diffusion equation looks like: u 2u ( x, t ) 2 2 ( x, t ) for 0<x<1, t>0 t x subject to the initial conditions: u(0,t)=u(l,t)=0, t>0, and u(x,0)=f(x), 0<=x<=l After selecting an integer m>0, defining h=l/m, and selecting a time-step size k, the grid points are (xi,tj), where xi=ih, for I=0,1,..m, and tj = jk, for j=0,1,… The difference method is obtained by using the Taylor series in t to form the difference quotient: u( x i , t j k ) u( x i , t j ) k 2 u u ( xi , t j ) ( x i , j ), t k 2 t 2 for some j (tj, t j+1), and the Taylor series in x to form the difference quotient: u( x i h, t j ) 2u( x i , t j ) u( x i h, t j ) h 2 4 u 2u ( x , t ) ( i , t j ), i j 12 x 4 x 2 h2 where i (x i-1, x i+1), Therefore for the interior gridpoint: u 2u ( x i , t j ) 2 2 ( x i , t j ) 0, t x so the difference method using the difference quotients is: wi , j 1 w j wi 1, j 2 wi , j wi 1, j 2 0, k h2 Solving this equation for w i,j+1 2 2 k k wi , j 1 1 2 wij 2 2 ( wi 1, j wi 1, j ) h h The explicit or Forward Difference method is conditionally stable, and it converges to a solution with rate of convergence O(k+h2), provided that: k 1 2 2 2 h The next step is to develop computer code in MATLAB. The computer code will use the forward-difference method to obtain the temperature distribution in a plane wall for the following cases: Initial Temperature Distribution: - Temperature vs. position as a function f(x) specified by the user. - User input of the temperature at the specific nodes. Boundary conditions: - Convective - Fixed temperature - Adiabatic 4 By expressing the temperature gradients as a function of the nodal temperatures and by assuming a one- dimensional system, the value of derivative 2T/x2 at the node m can be approximated as (Incropera and DeWitt, Chapter 5): T T m 1 / 2 m 1 / 2 2 T x x m x x 2 or written in a “numerical form” for MATLAB coding. T Tm1 2Tm 2T For a node at a given instant t m 1 2 m x x 2 Likewise, integer p is introduced to establish a time index: t pt After defining the time index p, the finite-difference approximation to the time derivative can be expressed as: Tmp 1 Tmp T m t t By combining the previous equations and adding a heat generation term, the explicit finite-difference method yields the following nodal equations. FINAL EQUATIONS IN MATLAB CODE FOR INDIVIDUAL NODES: For an interior node: 2 q x 1 2 FoTmp Tmp 1 Fo Tmp1 Tmp1 k Stability Criterion: Fo<=1/4 For an external node with convection 2 p q x p 1 1 2 Fo 2 BiFo Tmp Tm 2 Fo Tm 1,n BiT 2k Stability Criterion: Fo(2+Bi)<=1/2 For complete numerical solution in MATLAB refer to Appendix A. RESULTS To validate the numerical solution, the results will be compared against existing analytical solutions. Two cases will be considered: CASE 1: Uniform initial temperature; solve for convection at exterior surface The analytical solution for a flat plate is obtained by solving the heat equation by the method of separation of variables (Geiger and Poirier, Chapter 9). For the case of initial uniform temperature and convection at the surface, the analytical solution has the form: 5 sin( n L T Tf 2 exp( 2nt ) cos( n x ) Ti Tf n 1 n L sin( n L) cos( n L) where the discrete values (eigenvalues) of n are the positive roots of the equation: 1 cot( n L) ( n L) h L k The analytical solution will be applied to the following problem: Example 5.3, p231, Incropera and DeWitt Known: Wall subjected to sudden change in convective surface conditions. Data: Plane Wall material: steel AISI 1010, k=63.9 W/mK, =18.8e-6 m2/s. thickness : L =40mm initial temperature : Ti=-20 C Fluid Temperature : Tf = 60 C convection coefficient : h = 500 W/m2K Find : Plot temperature at the adiabatic surface during first 8 minutes. The first step is to find the eigenvalues for the first 4 terms of the infinite series, which will yield a highly accurate result. The first four eigenvalues are obtained by finding the roots of the following equation for the corresponding interval (n,(n+1)). 1 f ( x ) cot( n L) ( n L) h L k Bisection Method For (1L) in the interval (0,) Approximate solution = 0.53189087 Number of iterations = 16 Tolerance = 1.00000000e-005 For (2L) in the interval (,2) Approximate solution = 3.23796082 Number of iterations = 15 Tolerance = 1.00000000e-005 For (3L) in the interval (2,3) Approximate solution = 6.33257446 Number of iterations = 16 Tolerance = 1.00000000e-005 For (4L) in the interval (3,4 ) Approximate solution = 9.45785522 Number of iterations = 16 Tolerance = 1.00000000e-005 After the first four eigenvalues are found, the analytical solution can be solved for the first four terms of the infinite series. 6 The following graph shows a comparison of the analytical (pink color) and the numerical (blue color)MATLAB solution for this case. TRANSIENT TEMPERATURE AT THE ADIABATIC SURFACE 50 TEMPERATURE (C) 40 30 20 10 0 NUMERICAL SOLUTION -10 ANALITYCAL SOLUTION -20 0 40 80 120 160 200 240 280 320 360 400 440 480 TIME (seconds) FIGURE 2 : TEMPERATURE DURING FIRST 8 MINUTES As it can be observed, the numerical MATLAB solution closely matches the analytical results. CASE 2: Initial temperature distribution T=sin(x); solve for fixed temperature boundary conditions The analytical solution for CASE 2 is found at Burden and Faires, Chapter 12, page 706, example 1. This example will also be solved with the numerical MATLAB solution. Example 1, page 706, Burden and Faires The analytical solution has the form: T(x)=exp(-2t)sin(x) Known: Initial conditions T(x,0)=sin(x), in the interval 0 x 1 Boundary conditions T(0,t)=T(1,t)=0, for 0 t Find: Plot the temperature distribution inside the wall at t=0 sec, t=0.04 sec, t=0.12 sec, t=0.2 sec, t=0.4 sec. 7 The following graph shows a comparison of the analytical (pink color) and the numerical (blue color)MATLAB solution for this case. TEMPERATURE DISTRIBUTION Analytical Numerical 1 t = 0 sec TEMPERATURE ( deg) 0.8 t = 0.04 sec sec 0.6 0.4 t = 0.12 sec 0.2 t = 0.2 sec t = 0.4 sec 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 POSITION ( x ) FIGURE 3 : TEMPERATURE DISTRIBUTION AT DIFFERENT TIMES As it can be observed, the numerical MATLAB solution closely matches the analytical results. DISCUSSION AND ERROR ANALYSIS The graphic results show that fast and highly accurate result can be obtained with the MATLAB numerical solution. For CASE 1, the analytical solution involved the calculation of the eigenvalues, which required the use of the bisection method. After the eigenvalues were calculated, the series solution was found for the first four terms. This process required more time and calculations than a quick run with the MATLAB numerical solution. For CASE 2, the analytical and the numerical solution were as easy to compute; however, it should be noted that this is a very simple case and that the solution was already available. While different methods and equations had to be considered for each of the analytical cases, the numerical solution for both methods was obtained by running the same MATLAB code. 8 When using the explicit finite-difference method, the truncation error for the difference equation is: 2 4 k 2u 2 h u i, j ( xi , j ) ( i , t j ) 2 t 2 12 x 4 A truncation error of order (k+h2) is expected when the explicit finite-difference method is used. If an error is made in representing the initial condition , the error will propagate. Moreover, if the time step is not carefully selected the error will grow as the number of time steps increases, making this method conditionally stable. The time step in the MATLAB program is calculated so the stability condition is respected. Since the analytical solution was available for both cases, the absolute error produced by the MATLAB numerical computations can be obtained for each time step for any position. In order to illustrate the effect of the mesh size on the accuracy of the results, the temperature error at 10 seconds was computed for CASE 1 and the results shown in figure 4. The graph shape reflects the expected order (k+h2), as the mesh size h is expressed in the x-axis as the percent of the nodal distance over the total wall thickness. However it should be noted that even for the case of 50 % (nodal distance is one half of the total thickness), the accuracy of the result was within 0.5 degrees. It should also be noted that the as the nodal distance was changed, so was the time step k since the stability criterion needs to be satisfied to guarantee convergence. TEMPERATURE ERROR FOR DIFFERENT MESH SIZES TEMPERATURE ERROR (C) 0.4 0.3 0.2 0.1 0 0 5 10 15 20 25 30 35 40 45 50 PERCENT NODAL DISTANCE OF THE TOTAL WALL THICKNESS (%) FIGURE 4: TEMPERATURE ERROR FOR CASE 1 AT 10 SECONDS 9 The following table shows a comparison of the numerical vs. the analytical method, and the absolute value of the absolute error for CASE 1. time numerical analytical error 0 -20 -19.8054 0.1946 1 -20 -19.9602 0.0398 2 -20 -19.9929 0.0071 3 -20 -19.9983 0.0017 4 -20 -19.9953 0.0047 5 -19.994 -19.9829 0.0111 6 -19.9745 -19.9565 0.018 7 -19.937 -19.9128 0.0242 8 -19.8794 -19.8503 0.0291 9 -19.8016 -19.7688 0.0328 ……………………………………………………. 470 471 472 473 474 475 476 477 478 479 480 42.4687 42.5269 42.585 42.6428 42.7005 42.758 42.8152 42.8723 42.9292 42.986 43.0425 42.444 42.5023 42.5603 42.6182 42.6759 42.7334 42.7907 42.8478 42.9047 42.9615 43.018 0.0247 0.0246 0.0247 0.0246 0.0246 0.0246 0.0245 0.0245 0.0245 0.0245 0.0245 TABLE 1 : SAMPLE OF RESULTS FOR CASE 1 Analysis of the data shows that the greatest error is observed at the initial condition, this error is due to the fact that only the first four terms of the infinite series solution were considered for the analytical case. Using more terms in the series solution would have increased the accuracy of the analytical solution for the first 4 seconds, as shown for the cases of 4 and 6 term series in table 4. Since this effect is negligible after 4 seconds and the problem is to be solved for 8 minutes, the accuracy of 4-term-series solution is considered to be valid for this particular case. Should higher accuracy be required for the analytical solution, more terms could be added to the series until the desired accuracy is reached. time 0 1 2 3 4 5 6 7 8 9 10 numerical -20 -20 -20 -20 -20 -19.994 -19.9745 -19.937 -19.8794 -19.8016 -19.7043 4-term-series 6-term-series -19.8054 -19.9182 -19.9602 -19.9981 -19.9929 -19.9999 -19.9983 -19.9994 -19.9953 -19.9955 -19.9829 -19.9829 -19.9565 -19.9565 -19.9128 -19.9128 -19.8503 -19.8503 -19.7688 -19.7688 -19.669 -19.669 TABLE 2 : EFFECT OF USING MORE TERMS IN ANALYTICAL SERIES SOLUTION FOR CASE 1 10 After the first 4 seconds the maximum error observed is e=0.0382, which is caused by the truncation effect of the numerical method. The solution at time = 480 seconds shows a relative error of 0.05%, which is a highly accurate result in the context of the problem. As in CASE 1, the error due to the truncation effect is observed in CASE 2. Even though the absolute results show that the numerical and the analytical solution closely match, the relative error increases. This is because the base value that the error is being compared to is approaching zero as time steps are incremented. The following table shows a comparison of the numerical vs. the analytical method, and the absolute value of the absolute error. time 0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 numerical 1 0.6665 0.4442 0.296 0.1973 0.1315 0.0876 0.0584 0.0389 0.0259 0.0173 0.0115 0.0077 analytical 1 0.673825 0.454041 0.305944 0.206153 0.138911 0.093602 0.063071 0.042499 0.028637 0.019296 0.013002 0.008761 error 0 0.007325 0.009841 0.009944 0.008853 0.007411 0.006002 0.004671 0.003599 0.002737 0.001996 0.001502 0.001061 % error 0 1.1 2.2 3.3 4.3 5.3 6.4 7.4 8.5 9.6 10.3 11.6 12.1 TABLE 3 : SAMPLE OF RESULTS FOR CASE 2 CONCLUSIONS The MATLAB numerical method based on the explicit finite-difference method provided a solution that closely matched the analytical result. For the two cases solved, the error was found to be so small that the result was not impacted by the use of the numerical solution. Mesh size or truncation errors were also not significant for the two cases considered; mesh sizes of up to 50 % the thickness of the wall would have yielded acceptable solutions for the cases studied. Although the analytical solution is considered to be an exact result, arriving at those solutions required a higher use of time, hand calculations, and each case had to be solved individually. On the contrary, by programming the numerical solution in MATLAB, the same code can find the solution for an infinite number of cases and the computer makes all the computations. In conclusion, the MATLAB numerical solution can be used to find the transient temperature distribution for the case of the plane wall, since accurate and reliable results can be computed faster and easier than with the use of analytical methods. 11 REFERENCES 1. Burden, R. L. and Faires, J. D., Numerical Analysis, 7th edition, Brooks/Cole, Pacific Grove, 2001, chapter 12. 2. Geiger, G. H. and Poirier, D. R., Transport Phenomena in Metallurgy, AddisonWesley Publishing Co. Massachusetts. 3. Incropera, Frank P. and DeWitt, David P., Introduction to Heat Transfer, 3rd edition, John Wiley & Sons, New York, 1996, chapter 5. 12 APPENDIX A MATLAB CODE % Numerical Analysis for Engineering % Term Project % MATLAB CODE % % author : Rene J. Hernandez % Date : 04/10/2001 %--------------------------------------------------------------% This program calculates the transient temperature distribution % for the specific case of the plane wall. No input file is % needed; all inputs are interactively entered by the user. % The numerical explicit finite-difference method is used. % -------------------------------------------------------------% The user defines: % - Wall properties % - Number of nodes % - Wall internal uniform heat generation % - Boundary conditions % The initial temperature for the wall can be defined: % - User defined function T(x)=f(x) % - Specific initial temperature for each node % The boundary conditions for each side of the wall can be: % - Convection % - Fixed Temperature % - Adiabatic surface % Solution in : MATLAB variable tmatrixc(x,t) % Note : The program assumes constant properties during the % transient calculations %--------------------------------------------------------------clear syms('x','s') % general data input fprintf(1,'\n___________________________________________\n'); fprintf(1,'NUMERICAL SOLUTION FOR TRANSIENT CONDUCTION \n'); fprintf(1,' PLANE WALL \n\n'); fprintf(1,'WALL DATA INPUT\n'); fprintf(1,'Enter wall thickness in (m)\n'); thickness = input(' '); fprintf(1,'Enter wall thermal conductivity (k) in (W/mK)\n'); k = input(' '); fprintf(1,'Enter wall thermal diffusivity (alpha) in (m^2/s)\n'); alpha = input(' '); fprintf(1,'\nNUMERICAL SOLUTION INPUT .\n'); fprintf(1,'Enter the number of nodal points \n'); 13 NNODES = input(' '); deltax=thickness/(NNODES-1); % % Initial Conditions (prior to transient event) % badinput1=1; while (badinput1)==1 fprintf(1,'\nWALL INITIAL TEMPERATURE (prior to transient event).\n\n'); fprintf(1,' 1 - User defined function T(x)=f(x)\n'); fprintf(1,' 2 - Specific initial temperature for each node\n'); fprintf(1,' Enter option\n'); OPTION = input(' '); n = 0; switch OPTION case {1} % Specific Function fprintf(1,'Input the function F(x) in terms of x (degree C)\n'); fprintf(1,'For example: cos(x)\n '); s = input(' ','s'); F = inline(s,'x'); for m=1:NNODES inimatrix(m)= F(n); n = n + deltax; end badinput1=0; case {2} % Manual Input for m=1:NNODES fprintf('\nTemperature (degree C) At Position %6.3f (m)\n',n); manin = input(' '); inimatrix(m)= manin; n = n + deltax; end badinput1=0; end end inimatrix=inimatrix+273; % % TRANSIENT SECTION % fprintf(1,'\nTRANSIENT EVENT CONDITIONS.\n\n'); fprintf(1,'Enter wall internal uniform volumetric heat generation rate W/m^3\n'); qtr = input(' '); fprintf(1,'\nSURFACE BOUNDARY OPTION NUMBER.\n'); fprintf(1,'Convection 1.\n'); fprintf(1,'Fixed Temperature 2.\n'); fprintf(1,'Adiabatic 3.\n'); fprintf(1,'Boundary Conditions at surface 1. Enter option\n'); 14 NODETYPEF = input(' '); fprintf(1,'Boundary Conditions at surface 2. Enter option\n'); NODETYPEL = input(' '); switch NODETYPEF % uses the req. eq. based on node type case {1} % Convection at surface f fprintf(1,'Convection at surface 1.\n'); fprintf(1,'Input Fluid Temperature in deg C\n'); tinff = input(' '); fprintf(1,'Input the convection coefficient h in W/m^2K\n '); hf = input(' '); tinff=tinff + 273; Bif=hf*deltax/k; % Biot number Fof=0.5/(1+Bif); % Fourier number for stability deltatf=(Fof*deltax^2)/alpha; case {2} % Prescribed emperature at surface f fprintf(1,'Fixed Temperature at surface 1.\n'); fprintf(1,'Input T-surface in deg C\n'); tsurff = input(' '); tsurff=tsurff + 273; Fof = 0.5; % Fourier number for stability deltatf=(Fof*deltax^2)/alpha; case {3} % Adiabatic surface f Fof = 0.5; % Fourier number for stability deltatf=(Fof*deltax^2)/alpha; end switch NODETYPEL % uses the req. eq. based on node type case {1} % Convection at surface l fprintf(1,'Convection at surface 2.\n'); fprintf(1,'Input Fluid Temperature in deg C\n'); tinfl = input(' '); fprintf(1,'Input the convection coefficient h in W/m^2K\n '); hl = input(' '); tinfl=tinfl + 273; Bil=hl*deltax/k; % Biot number Fol=0.5/(1+Bil); % Fourier number for stability deltatl=(Fol*deltax^2)/alpha; case {2} % Prescribed emperature at surface l fprintf(1,'Fixed Temperature at surface 2.\n'); fprintf(1,'Input T-surface in deg C\n'); tsurfl = input(' '); tsurfl=tsurfl + 273; Fol=0.5; % Fourier number for stability deltatl=(Fol*deltax^2)/alpha; case {3} % Adiabatic surface l Fol=0.5; % Fourier number for stability deltatl=(Fol*deltax^2)/alpha; 15 end % calculating the minimum deltat and Fo number if deltatf<deltatl deltat=deltatf; else deltat=deltatl; end deltatint=(0.5*deltax^2)/alpha; if deltatint<deltat deltat=deltaint; end deltatnc=deltat; % Calculating a userfriendly time interval if (deltat<1000)&(deltat>=500) deltat=500; elseif (deltat<500)&(deltat>=250) deltat=250; elseif (deltat<250)&(deltat>=100) deltat=100; elseif (deltat<100)&(deltat>=50) deltat=50; elseif (deltat<50)&(deltat>=25) deltat=25; elseif (deltat<25)&(deltat>=10) deltat=10; elseif (deltat<10)&(deltat>=5) deltat=5; elseif (deltat<5)&(deltat>=2.5) deltat=2.5; elseif (deltat<2.5)&(deltat>=1) deltat=1; elseif (deltat<1)&(deltat>=0.5) deltat=0.5; elseif (deltat<0.5)&(deltat>=0.25) deltat=0.25; elseif (deltat<0.25)&(deltat>=0.1) deltat=0.1; elseif (deltat<0.1)&(deltat>=0.05) deltat=0.05; elseif (deltat<0.05)&(deltat>=0.025) deltat=0.025; elseif (deltat<0.025)&(deltat>=0.01) deltat=0.01; elseif (deltat<0.01)&(deltat>=0.005) deltat=0.005; elseif (deltat<0.005)&(deltat>=0.0025) 16 deltat=0.0025; elseif (deltat<0.0025)&(deltat>=0.001) deltat=0.001; else deltat=deltat; end fprintf(1,'\nTRANSIENT EVENT TOTAL TIME \n'); fprintf(1,'Enter time for transient event (sec)\n'); TOTIME = input (' '); if TOTIME <= deltat TOTIME = deltat; fprintf('\n Transient time too small.\n'); end NTIMEINTR = TOTIME / deltat; NTIMEINT = floor(NTIMEINTR) + 1; % initiallizing the temperature matrix for p=1:NTIMEINT for m=1:NNODES tmatrix(m,p)=inimatrix(m); end end % Output selection fprintf(1,'\n OUTPUT SELECTION \n'); fprintf(1,'\n Plot specific node vs time - 1 '); fprintf(1,'\n Display in tabular form - 2 '); fprintf(1,'\nEnter option\n'); DISPSEL = input(' '); if DISPSEL==1 fprintf(1,'\nEnter node number (ex: 1,2,...)\n'); nodeplot = input(' '); else DISPSEL=2; end % Calculating Fourier Nunber Fo = (alpha*deltat)/(deltax^2); % solving the temperature matrix in degree Kelvin for p=2:NTIMEINT switch NODETYPEF % uses the req. eq. based on node type case {1} tmatrix(1,p)= 2*Fo*(tmatrix(2,p-1)+Bif*tinff+(qtr*(deltax^2)/(2*k)))+(1-2*Fo2*Bif*Fo)*tmatrix(1,p-1); case {2} tmatrix(1,p)=tsurff+(qtr*(deltax^2)/k); case {3} tmatrix(1,p)=Fo*(2*tmatrix(2,p-1)+(qtr*(deltax^2)/k))+(1-2*Fo)*tmatrix(1,p-1); end 17 for m=2:(NNODES-1) tmatrix(m,p)=Fo*(tmatrix(m+1,p-1)+tmatrix(m-1,p-1)+(qtr*(deltax^2)/k))+(12*Fo)*tmatrix(m,p-1); end switch NODETYPEL % uses the req. eq. based on node type case {1} tmatrix(NNODES,p)=2*Fo*(tmatrix(NNODES-1,p1)+Bil*tinfl+(qtr*(deltax^2)/(2*k)))+(1-2*Fo-2*Bil*Fo)*tmatrix(NNODES,p-1); case {2} tmatrix(NNODES,p)=tsurfl+(qtr*(deltax^2)/k); case {3} tmatrix(NNODES,p)=Fo*(2*tmatrix(NNODES-1,p-1)+(qtr*(deltax^2)/k))+(12*Fo)*tmatrix(NNODES,p-1); end end % Converting to deg C for p=1:NTIMEINT for m=1:NNODES tmatrixc(m,p)=tmatrix(m,p) - 273; end end % Output switch DISPSEL case {1} time=0; for p=1:NTIMEINT ptarray(p)=tmatrixc(nodeplot,p); tim(p)=time; time = time + deltat; end plot(tim,ptarray) xlabel('TIME (sec)'),ylabel('TEMPERATURE (C)') title('Temperature at the selected node vs. time') case {2} if NTIMEINT >= 30 OUTYPE = 2; else OUTYPE = 1; end pos=0; fprintf('Time(s)'); for m=1:NNODES fprintf(' x=%6.3f',pos); pos = pos + deltax; 18 end switch OUTYPE % To avoid excees output case {1} % For less than 30 time intervals time=0; fprintf('\n'); for p=1:NTIMEINT fprintf('%7.3f',time); for m=1:NNODES fprintf(' %8.1f',tmatrixc(m,p)); end fprintf('\n'); time = time + deltat; end case {2} % For more than 30 time intervals time=0; fprintf('\n'); for p=1:10 fprintf('%7.3f',time); for m=1:NNODES fprintf(' %8.1f',tmatrixc(m,p)); end fprintf('\n'); time = time + deltat; end fprintf('\n ..... Iterations not shown'); fprintf('\n ..... stored in variable'); fprintf('\n ..... tmatrixc(x,t)\n'); initimou=(NTIMEINT-10); time=initimou*deltat; fprintf('\n'); for p=initimou:NTIMEINT fprintf('%7.3f',time); for m=1:NNODES fprintf(' %8.1f',tmatrixc(m,p)); end fprintf('\n'); time = time + deltat; end end end 19 APPENDIX B CASE 1 data time 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 numerical analitycal error -20 -19.8054 0.1946 -20 -19.9602 0.0398 -20 -19.9929 0.0071 -20 -19.9983 0.0017 -20 -19.9953 0.0047 -19.994 -19.9829 0.0111 -19.9745 -19.9565 0.018 -19.937 -19.9128 0.0242 -19.8794 -19.8503 0.0291 -19.8016 -19.7688 0.0328 -19.7043 -19.669 0.0353 -19.5891 -19.5522 0.0369 -19.4575 -19.4197 0.0378 -19.3112 -19.273 0.0382 -19.1518 -19.1138 0.038 -18.9809 -18.9433 0.0376 -18.7998 -18.7628 0.037 -18.6098 -18.5736 0.0362 -18.412 -18.3767 0.0353 -18.2074 -18.1731 0.0343 -17.9968 -17.9637 0.0331 -17.7812 -17.7492 0.032 -17.5612 -17.5303 0.0309 -17.3374 -17.3075 0.0299 -17.1103 -17.0815 0.0288 -16.8804 -16.8528 0.0276 -16.6482 -16.6216 0.0266 -16.4141 -16.3885 0.0256 -16.1783 -16.1536 0.0247 -15.9411 -15.9174 0.0237 -15.7029 -15.6801 0.0228 -15.4638 -15.4418 0.022 -15.224 -15.2029 0.0211 -14.9837 -14.9634 0.0203 -14.7431 -14.7235 0.0196 -14.5023 -14.4834 0.0189 -14.2614 -14.2432 0.0182 -14.0205 -14.003 0.0175 -13.7797 -13.7629 0.0168 -13.5392 -13.5229 0.0163 -13.2989 -13.2832 0.0157 -13.0589 -13.0437 0.0152 -12.8193 -12.8046 0.0147 -12.5801 -12.566 0.0141 -12.3414 -12.3278 0.0136 -12.1032 -12.09 0.0132 -11.8655 -11.8528 0.0127 -11.6284 -11.6162 0.0122 -11.3919 -11.3801 0.0118 time 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 numerical -11.156 -10.9207 -10.6861 -10.4522 -10.2189 -9.9863 -9.7544 -9.5232 -9.2927 -9.0629 -8.8338 -8.6054 -8.3778 -8.1509 -7.9247 -7.6992 -7.4745 -7.2504 -7.0271 -6.8046 -6.5827 -6.3616 -6.1412 -5.9216 -5.7026 -5.4844 -5.2669 -5.0501 -4.834 -4.6186 -4.404 -4.19 -3.9768 -3.7643 -3.5524 -3.3413 -3.1309 -2.9212 -2.7121 -2.5038 -2.2961 -2.0892 -1.8829 -1.6773 -1.4724 -1.2682 -1.0646 -0.8618 -0.6596 analitycal error -11.1446 0.0114 -10.9097 0.011 -10.6755 0.0106 -10.4419 0.0103 -10.209 0.0099 -9.9768 0.0095 -9.7452 0.0092 -9.5144 0.0088 -9.2842 0.0085 -9.0547 0.0082 -8.826 0.0078 -8.5979 0.0075 -8.3706 0.0072 -8.144 0.0069 -7.9181 0.0066 -7.6929 0.0063 -7.4685 0.006 -7.2447 0.0057 -7.0217 0.0054 -6.7994 0.0052 -6.5779 0.0048 -6.357 0.0046 -6.1369 0.0043 -5.9175 0.0041 -5.6988 0.0038 -5.4808 0.0036 -5.2636 0.0033 -5.0471 0.003 -4.8312 0.0028 -4.6161 0.0025 -4.4017 0.0023 -4.188 0.002 -3.975 0.0018 -3.7627 0.0016 -3.5512 0.0012 -3.3403 0.001 -3.1301 0.0008 -2.9206 0.0006 -2.7118 0.0003 -2.5037 0.0001 -2.2963 0.0002 -2.0895 0.0003 -1.8835 0.0006 -1.6781 0.0008 -1.4735 0.0011 -1.2695 0.0013 -1.0661 0.0015 -0.8635 0.0017 -0.6615 0.0019 20 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 -0.458 -0.2572 -0.057 0.1425 0.3414 0.5396 0.7372 0.934 1.1303 1.3259 1.5208 1.7151 1.9087 2.1017 2.2941 2.4858 2.6769 2.8673 3.0571 3.2463 3.4349 3.6228 3.8101 3.9968 4.1828 4.3683 4.5531 4.7373 4.9209 5.1039 5.2863 5.4681 5.6492 5.8298 6.0098 6.1892 6.3679 6.5461 6.7237 6.9007 7.0771 7.2529 7.4282 7.6028 7.7769 7.9504 8.1234 8.2957 8.4675 8.6387 -0.4602 -0.2595 -0.0596 0.1398 0.3384 0.5364 0.7337 0.9304 1.1265 1.3218 1.5166 1.7106 1.9041 2.0969 2.289 2.4806 2.6715 2.8617 3.0513 3.2403 3.4287 3.6164 3.8035 3.99 4.1759 4.3612 4.5458 4.7299 4.9133 5.0961 5.2783 5.4599 5.6409 5.8213 6.0011 6.1803 6.3589 6.5369 6.7144 6.8912 7.0674 7.2431 7.4182 7.5927 7.7666 7.94 8.1127 8.2849 8.4565 8.6276 0.0022 0.0023 0.0026 0.0027 0.003 0.0032 0.0035 0.0036 0.0038 0.0041 0.0042 0.0045 0.0046 0.0048 0.0051 0.0052 0.0054 0.0056 0.0058 0.006 0.0062 0.0064 0.0066 0.0068 0.0069 0.0071 0.0073 0.0074 0.0076 0.0078 0.008 0.0082 0.0083 0.0085 0.0087 0.0089 0.009 0.0092 0.0093 0.0095 0.0097 0.0098 0.01 0.0101 0.0103 0.0104 0.0107 0.0108 0.011 0.0111 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 8.8093 8.9794 9.1489 9.3179 9.4862 9.6541 9.8213 9.988 10.1542 10.3198 10.4848 10.6494 10.8133 10.9767 11.1396 11.3019 11.4637 11.625 11.7857 11.9459 12.1055 12.2646 12.4232 12.5813 12.7388 12.8959 13.0523 13.2083 13.3638 13.5187 13.6731 13.8271 13.9805 14.1334 14.2857 14.4376 14.589 14.7399 14.8902 15.0401 15.1895 15.3383 15.4867 15.6346 15.782 15.9289 16.0753 16.2213 16.3667 16.5117 8.7981 8.968 9.1374 9.3062 9.4744 9.6421 9.8092 9.9758 10.1418 10.3072 10.4721 10.6365 10.8003 10.9636 11.1263 11.2885 11.4502 11.6113 11.7719 11.9319 12.0915 12.2505 12.4089 12.5669 12.7243 12.8812 13.0375 13.1934 13.3487 13.5035 13.6578 13.8116 13.9649 14.1177 14.27 14.4217 14.573 14.7237 14.874 15.0238 15.173 15.3218 15.4701 15.6178 15.7651 15.9119 16.0582 16.2041 16.3494 16.4943 21 0.0112 0.0114 0.0115 0.0117 0.0118 0.012 0.0121 0.0122 0.0124 0.0126 0.0127 0.0129 0.013 0.0131 0.0133 0.0134 0.0135 0.0137 0.0138 0.014 0.014 0.0141 0.0143 0.0144 0.0145 0.0147 0.0148 0.0149 0.0151 0.0152 0.0153 0.0155 0.0156 0.0157 0.0157 0.0159 0.016 0.0162 0.0162 0.0163 0.0165 0.0165 0.0166 0.0168 0.0169 0.017 0.0171 0.0172 0.0173 0.0174 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 16.6562 16.8002 16.9437 17.0867 17.2293 17.3714 17.513 17.6542 17.7949 17.9351 18.0748 18.2141 18.3529 18.4913 18.6292 18.7667 18.9037 19.0402 19.1763 19.3119 19.4471 19.5818 19.7161 19.8499 19.9833 20.1163 20.2488 20.3808 20.5125 20.6437 20.7744 20.9047 21.0346 21.1641 21.2931 21.4217 21.5499 21.6776 21.8049 21.9318 22.0583 22.1844 22.31 22.4352 22.56 22.6844 22.8084 22.9319 23.0551 23.1778 23.3002 16.6386 16.7825 16.926 17.0689 17.2114 17.3534 17.4949 17.636 17.7766 17.9167 18.0564 18.1956 18.3343 18.4726 18.6104 18.7477 18.8846 19.0211 19.1571 19.2926 19.4277 19.5624 19.6966 19.8303 19.9636 20.0965 20.2289 20.3609 20.4924 20.6236 20.7542 20.8845 21.0143 21.1437 21.2726 21.4011 21.5292 21.6569 21.7842 21.911 22.0374 22.1634 22.2889 22.4141 22.5388 22.6631 22.787 22.9105 23.0336 23.1563 23.2786 0.0176 0.0177 0.0177 0.0178 0.0179 0.018 0.0181 0.0182 0.0183 0.0184 0.0184 0.0185 0.0186 0.0187 0.0188 0.019 0.0191 0.0191 0.0192 0.0193 0.0194 0.0194 0.0195 0.0196 0.0197 0.0198 0.0199 0.0199 0.0201 0.0201 0.0202 0.0202 0.0203 0.0204 0.0205 0.0206 0.0207 0.0207 0.0207 0.0208 0.0209 0.021 0.0211 0.0211 0.0212 0.0213 0.0214 0.0214 0.0215 0.0215 0.0216 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 23.5436 23.6647 23.7855 23.9058 24.0257 24.1452 24.2643 24.3831 24.5014 24.6193 24.7369 24.854 24.9708 25.0872 25.2032 25.3188 25.434 25.5488 25.6633 25.7774 25.8911 26.0044 26.1173 26.2299 26.3421 26.4539 26.5654 26.6764 26.7872 26.8975 27.0075 27.1171 27.2263 27.3352 27.4437 27.5519 27.6597 27.7672 27.8742 27.981 28.0873 28.1934 28.299 28.4044 28.5093 28.614 28.7182 28.8222 28.9257 29.029 29.1319 23.5219 23.643 23.7636 23.8839 24.0037 24.1232 24.2423 24.3609 24.4792 24.5971 24.7146 24.8317 24.9484 25.0647 25.1806 25.2962 25.4114 25.5262 25.6406 25.7546 25.8682 25.9815 26.0944 26.2069 26.3191 26.4308 26.5422 26.6533 26.7639 26.8742 26.9842 27.0937 27.203 27.3118 27.4203 27.5284 27.6362 27.7436 27.8506 27.9573 28.0636 28.1696 28.2753 28.3805 28.4855 28.5901 28.6943 28.7982 28.9017 29.0049 29.1078 22 0.0217 0.0217 0.0219 0.0219 0.022 0.022 0.022 0.0222 0.0222 0.0222 0.0223 0.0223 0.0224 0.0225 0.0226 0.0226 0.0226 0.0226 0.0227 0.0228 0.0229 0.0229 0.0229 0.023 0.023 0.0231 0.0232 0.0231 0.0233 0.0233 0.0233 0.0234 0.0233 0.0234 0.0234 0.0235 0.0235 0.0236 0.0236 0.0237 0.0237 0.0238 0.0237 0.0239 0.0238 0.0239 0.0239 0.024 0.024 0.0241 0.0241 249 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 23.4221 29.3366 29.4385 29.5401 29.6412 29.7421 29.8426 29.9428 30.0427 30.1422 30.2414 30.3403 30.4388 30.537 30.6349 30.7325 30.8297 30.9266 31.0232 31.1195 31.2154 31.3111 31.4064 31.5014 31.5961 31.6904 31.7845 31.8782 31.9717 32.0648 32.1576 32.2501 32.3423 32.4342 32.5257 32.617 32.708 32.7987 32.889 32.9791 33.0689 33.1584 33.2475 33.3364 33.425 33.5133 33.6013 33.689 33.7764 33.8635 33.9504 34.0369 23.4004 29.3125 29.4143 29.5159 29.617 29.7178 29.8183 29.9185 30.0183 30.1178 30.217 30.3158 30.4144 30.5125 30.6104 30.7079 30.8051 30.902 30.9986 31.0948 31.1908 31.2864 31.3817 31.4766 31.5713 31.6656 31.7597 31.8534 31.9468 32.0399 32.1327 32.2252 32.3173 32.4092 32.5008 32.592 32.683 32.7737 32.864 32.9541 33.0438 33.1333 33.2224 33.3113 33.3999 33.4882 33.5761 33.6638 33.7512 33.8383 33.9252 34.0117 0.0217 0.0241 0.0242 0.0242 0.0242 0.0243 0.0243 0.0243 0.0244 0.0244 0.0244 0.0245 0.0244 0.0245 0.0245 0.0246 0.0246 0.0246 0.0246 0.0247 0.0246 0.0247 0.0247 0.0248 0.0248 0.0248 0.0248 0.0248 0.0249 0.0249 0.0249 0.0249 0.025 0.025 0.0249 0.025 0.025 0.025 0.025 0.025 0.0251 0.0251 0.0251 0.0251 0.0251 0.0251 0.0252 0.0252 0.0252 0.0252 0.0252 0.0252 301 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 29.2344 34.2091 34.2948 34.3802 34.4653 34.5502 34.6347 34.719 34.803 34.8867 34.9701 35.0533 35.1362 35.2188 35.3011 35.3832 35.465 35.5465 35.6277 35.7087 35.7894 35.8698 35.95 36.0299 36.1095 36.1889 36.268 36.3469 36.4254 36.5038 36.5818 36.6596 36.7372 36.8145 36.8915 36.9683 37.0448 37.121 37.1971 37.2728 37.3483 37.4236 37.4986 37.5733 37.6478 37.7221 37.7961 37.8699 37.9434 38.0167 38.0897 38.1625 29.2103 34.1839 34.2696 34.355 34.4401 34.5249 34.6094 34.6937 34.7777 34.8614 34.9448 35.028 35.1108 35.1934 35.2758 35.3578 35.4396 35.5211 35.6023 35.6833 35.764 35.8444 35.9246 36.0045 36.0841 36.1635 36.2426 36.3214 36.4 36.4783 36.5564 36.6342 36.7117 36.789 36.8661 36.9428 37.0193 37.0956 37.1716 37.2474 37.3229 37.3982 37.4732 37.5479 37.6224 37.6967 37.7707 37.8445 37.918 37.9913 38.0643 38.1371 23 0.0241 0.0252 0.0252 0.0252 0.0252 0.0253 0.0253 0.0253 0.0253 0.0253 0.0253 0.0253 0.0254 0.0254 0.0253 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0255 0.0254 0.0255 0.0254 0.0254 0.0255 0.0255 0.0254 0.0255 0.0255 0.0254 0.0255 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 0.0254 353 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 34.1232 38.3074 38.3795 38.4513 38.5229 38.5942 38.6653 38.7362 38.8069 38.8773 38.9475 39.0174 39.0871 39.1566 39.2258 39.2949 39.3636 39.4322 39.5005 39.5686 39.6365 39.7042 39.7716 39.8388 39.9058 39.9726 40.0391 40.1054 40.1715 40.2374 40.303 40.3685 40.4337 40.4987 40.5635 40.6281 40.6924 40.7566 40.8205 40.8842 40.9477 41.011 41.0741 41.137 41.1997 41.2621 41.3244 41.3864 41.4483 41.5099 41.5713 41.6326 34.0979 38.282 38.3541 38.4259 38.4975 38.5689 38.64 38.7109 38.7815 38.8519 38.9221 38.9921 39.0618 39.1313 39.2005 39.2696 39.3384 39.4069 39.4753 39.5434 39.6113 39.6789 39.7464 39.8136 39.8806 39.9473 40.0139 40.0802 40.1463 40.2122 40.2779 40.3433 40.4086 40.4736 40.5384 40.603 40.6673 40.7315 40.7954 40.8592 40.9227 40.986 41.0491 41.112 41.1747 41.2372 41.2994 41.3615 41.4233 41.485 41.5464 41.6077 0.0253 0.0254 0.0254 0.0254 0.0254 0.0253 0.0253 0.0253 0.0254 0.0254 0.0254 0.0253 0.0253 0.0253 0.0253 0.0253 0.0252 0.0253 0.0252 0.0252 0.0252 0.0253 0.0252 0.0252 0.0252 0.0253 0.0252 0.0252 0.0252 0.0252 0.0251 0.0252 0.0251 0.0251 0.0251 0.0251 0.0251 0.0251 0.0251 0.025 0.025 0.025 0.025 0.025 0.025 0.0249 0.025 0.0249 0.025 0.0249 0.0249 0.0249 405 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 38.2351 41.7544 41.815 41.8754 41.9357 41.9957 42.0555 42.1151 42.1745 42.2337 42.2928 42.3516 42.4102 42.4687 42.5269 42.585 42.6428 42.7005 42.758 42.8152 42.8723 42.9292 42.986 43.0425 38.2097 41.7295 41.7902 41.8506 41.9108 41.9709 42.0307 42.0903 42.1498 42.209 42.2681 42.3269 42.3856 42.444 42.5023 42.5603 42.6182 42.6759 42.7334 42.7907 42.8478 42.9047 42.9615 43.018 24 0.0254 0.0249 0.0248 0.0248 0.0249 0.0248 0.0248 0.0248 0.0247 0.0247 0.0247 0.0247 0.0246 0.0247 0.0246 0.0247 0.0246 0.0246 0.0246 0.0245 0.0245 0.0245 0.0245 0.0245 APPENDIX C CASE 2 data X time 0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 ANALYTICAL SOLUTION X X X 0 0.166667 0.333333 0.5 0 0.5 0.866025 1 0 0.336913 0.58355 0.6738255 0 0.22702 0.393211 0.4540407 0 0.152972 0.264955 0.3059442 0 0.103076 0.178534 0.206153 0 0.069456 0.120301 0.1389111 0 0.046801 0.081062 0.0936019 0 0.031536 0.054621 0.0630713 0 0.02125 0.036805 0.0424991 0 0.014318 0.0248 0.0286369 0 0.009648 0.016711 0.0192963 0 0.006501 0.01126 0.0130023 0 0.004381 0.007588 0.0087613 NUMERICAL SOLUTION 0 0.5 0.866 1 0 0.3332 0.5772 0.6665 0 0.2221 0.3847 0.4442 0 0.148 0.2564 0.296 0 0.0987 0.1709 0.1973 0 0.0658 0.1139 0.1315 0 0.0438 0.0759 0.0876 0 0.0292 0.0506 0.0584 0 0.0195 0.0337 0.0389 0 0.013 0.0225 0.0259 0 0.0086 0.015 0.0173 0 0.0058 0.01 0.0115 0 0.0038 0.0067 0.0077 X 0.666667 0.866025 0.58355 0.393211 0.264955 0.178534 0.120301 0.081062 0.054621 0.036805 0.0248 0.016711 0.01126 0.007588 X 0.833333 0.5 0.336913 0.22702 0.152972 0.103076 0.069456 0.046801 0.031536 0.02125 0.014318 0.009648 0.006501 0.004381 X 1 -4.10207E-10 -2.76408E-10 -1.86251E-10 -1.255E-10 -8.45654E-11 -5.69823E-11 -3.83961E-11 -2.58723E-11 -1.74334E-11 -1.17471E-11 -7.91548E-12 -5.33365E-12 -3.59395E-12 0.866 0.5772 0.3847 0.2564 0.1709 0.1139 0.0759 0.0506 0.0337 0.0225 0.015 0.01 0.0067 0.5 0.3332 0.2221 0.148 0.0987 0.0658 0.0438 0.0292 0.0195 0.013 0.0086 0.0058 0.0038 0 0 0 0 0 0 0 0 0 0 0 0 0 25