2D Steady State Heat Transfer Program Matt and Chad, You've done a wonderful job with this program, and your validation cases are thorough and very persuasive. Thanks for a great quarter! L. O. Report Grade: A Mathew Angel and Chad Compton ME522 Advanced Finite Element Analysis Dr. Olson 23 May 2014 1 Table of Contents Table of Contents 1 List of Figures 2 Introduction 3 Program Structure 3 Program Validation 7 Test Case 1 8 Test Case 2 9 Test Case 3 11 Test Case 4 13 Summary and Conclusions 14 2 List of Figures Figure 1: Sample connectivity and coordinate matrices for the given meshed geometry 3 Figure 2: The plot of the geometry with the numbered boundary surfaces in the program 4 Figure 3: Example of direct assembly into a global stiffness matrix 5 Figure 4: Contour plot of the temperature distribution (left), quiver plot of the heat flux magnitude and direction (right) 6 Figure 5: Flow chart of the program’s logic 6 Figure 6: Graphical user interface control panel for the 2D steady state heat transfer program 7 Figure 7: geometry for the first test case 8 Figure 8: The 2D heat transfer program results for the first test case using quadrilateral elements, triangular elements, and different orientations 9 Figure 9: Geometry for the second test case 9 Figure 10: The 2D heat transfer program results for the second test case using quadrilateral elements, triangular elements, and different orientations 10 Figure 11: Geometry for the third test case 11 Figure 12: Circuit analogy for the third test case 11 Figure 13: The 2D heat transfer program results for the third test case using quadrilateral elements, triangular elements, and different orientations 12 Figure 14: The Ansys model of the more complicated geometry used in the fourth test case 13 Figure 15: 2D heat transfer program contour plot results for the fourth test case 14 3 Introduction The finite element program described in this paper is designed to perform two-dimensional static heat conduction analyses. The program does not include a mesh generator so the mesh must be imported from some other source. It can handle any mesh that consists of four-node quadrilateral elements or three-node triangular elements, although meshes containing combinations of the two are not permitted. Three kinds of boundary conditions are available for application inside the program and include convective heat transfer from a surface to the environment, heat flux at a surface, and a prescribed temperature at any surface. Thermal conductivity of the material as well as material thickness are treated as constant for the sake of simplicity. Furthermore, any heat generation in the material is treated as constant and uniform throughout the material. As program outputs, a contour plot of the temperature profile and a quiver plot displaying magnitude and direction of heat flux in each element are incorporated. All calculations are done using SI units so any necessary conversions must be made outside of the program if other unit systems are desired. Program Structure The geometry upon which an analysis is desired must be created and meshed outside of this program. Currently, the program is designed to accept data generated by the “ewrite” and “nwrite” commands in Ansys. This program then creates a connectivity matrix that details which nodes belong to each element and a coordinate matrix that locates each node in space. An example of a connectivity and coordinate matrix can be seen in Figure 1. Sample connectivity matrix Sample coordinate Matrix 1 0 0 1 1 2 5 6 [ ] 2 1 0 2 2 3 4 5 3 2 0 4 2 1 5 1 1 [6 0 1] Figure 1: Sample connectivity and coordinate matrices for the given meshed geometry. In order to effectively apply boundary conditions, there must be a way to identify each boundary in the system. The next thing that the program does is search through the nodal and elemental information and creates an individual connectivity matrix for each boundary that consists of two-node line elements. The program does this by recognizing that nodes located at boundaries are members of fewer elements than those located in the interior. Sharp corners serve as a break point between boundaries so that a rectangle, for example, would have four boundaries and a connectivity matrix to go with each. Exterior and interior boundaries are both identified so that any cutouts in the geometry can serve as an interface for boundary conditions. The program then plots all the boundaries and places a numeric label on each, which is shown in Figure 2. Each type of boundary condition has its own matrix in which you specify the boundary number and the relevant condition to be applied. For example, each row of the convective boundary matrix corresponds to a new condition being applied to a surface. The first column contains the number of the 4 surface. The second and third columns contain the convective heat transfer coefficient and the ambient temperature respectively. Figure 2: The plot of the geometry with the numbered boundary surfaces in the program. Next, the stiffness matrices for each element and the components of the forcing vector resulting from heat generation are calculated from the fundamental 2D heat conduction equation. This equation is weighted and integrated to produce its weak form as seen in equation 1. Evaluation of the integral and the structure of the shape functions ultimately dictate what goes into the stiffness and forcing arrays. The integrals are evaluated numerically using a second order Gaussian quadrature. ∫ ∫ (1) [ ] (2) (3) [ ] A similar process is used to produce the components of the stiffness and forcing that arise from the convective and heat flux boundary conditions. The resulting components are shown in equations 4 through 6. 1 [ ] 2 1 (4) 5 2 [ 6 1 [ ] 1 (5) 2 1 ] 1 2 (6) Component stiffness and forcing arrays must be assembled into a global system. This program uses a direct assembly method to accomplish the task. The global stiffness matrix is initialized as a square matrix full of zeroes with a side length corresponding to the number of nodes in the system. Each local stiffness matrix is then placed into the global stiffness at the locations that correspond to the nodes represented by that matrix. The global forcing vector is constructed in a similar manner. It is initialized as a column vector of zeroes of length where is the number of nodes in the system. Then the component forcing vectors are placed into the global vector at the locations corresponding to the nodes represented by that individual vector. [ ][ ] 0 [ ] 0 [ ][ ] 0 [ 0 ][ ] 0 [ ] 0 [0] Figure 3: Example of direct assembly into a global stiffness matrix. Once the global stiffness and forcing arrays have been generated, any boundary conditions regarding a prescribed temperature are handled. This program uses the penalty method to accomplish this which can be seen in equation 7. The penalty method places a stiffness value on the diagonal of the node of interest. This stiffness value is several orders of magnitude larger than any other values in the stiffness matrix. The large stiffness value multiplied by the temperature being specified is placed in the global forcing vector at the node of interest so that the temperature solution at that node is forced to what is prescribed. [ ][ ] [ ] (7) At this point, the entire system is fully constrained and ready to be solved. This program uses the left matrix division command in Matlab which is an efficient way to solve large matrix systems of equations. The solution syntax is shown in equation 8. (8) The program has two options for post processing. The temperature profile can be displayed in a contour plot along with a color-bar that shows the maximum and minimum temperatures and an evenly spaced scale in between. The second option is a quiver plot of heat fluxes in the object. An arrow emanates 6 from the center of each element that shows magnitude and direction of heat flux at the center of that element. The maximum and minimum heat flux in the object is also displayed to give a reference to the magnitude of the arrow length. Both of these plot options can be seen in Figure 4. Figure 4: Contour plot of the temperature distribution (left), quiver plot of the heat flux magnitude and direction (right). The structure of the program is summarized by the flowchart in Figure 5 below. Figure 5: Flow chart of the program’s logic. 7 For convenience to the user, the program has been incorporated into a graphical user interface (GUI) that significantly improves usability. A screen shot of the control panel is shown in Figure 6. Figure 6: Graphical user interface control panel for the 2D steady state heat transfer program. When operating the GUI, first the nodal and elemental data must be selected. Then the boundaries should be displayed so that they can be used in the boundary condition specification. Then, all boundary conditions should be specified along with material and geometric properties. At that point, the user can click solve. When the program has solved, the progress bar will change from red to green. Finally, the desired output can be chosen and then plotted. Program Validation To validate that the program was written correctly and produces correct results no matter the geometry and orientation, four test cases were conducted. The first three test cases were checked against onedimensional heat transfer hand calculations to test each type of boundary condition. The final test case used a more complicated geometry and boundary conditions, which was checked against Ansys output. 8 Test Case 1 For the first test case, a rectangular geometry was used that had a prescribed temperature on the left face and a heat flux flowing into the geometry on the right face. The geometry had a length, of 4 meters, a prescribed temperature, of 400 degrees kelvin, a thermal conductivity, of 1 Watt per meter kelvin, and a heat flux, of -10 Watts per meter squared. This geometry can be seen in Figure 7. Figure 7: Geometry for the first test case. The temperature on the right face of the geometry, was the temperature being solved for. To solve for this temperature by hand, a one-dimensional heat transfer equation was derived. To derive the onedimensional heat transfer equation, the fundamental heat transfer equation ( ) (9) was used. By integrating twice and using the boundary conditions (0) 10 400 and , the heat transfer equation (10) was derived. By entering the given values into the equation, was found to be 440 degrees kelvin. Once the hand calculation was completed, a series of cases were run with the 2D heat transfer program to make sure that the program was yielding the same results as the hand calculation. To verify the program gave the same result with any orientation or mesh, the test case was ran with both quadrilateral and triangular mesh elements, each run with the geometry being oriented at 0 degrees, 45 degrees, and 90 degrees. The results of these trials can be seen in Figure 8 below. 9 I really like the way you have presented these results. It is very concise and effective. Figure 8: The 2D heat transfer program results for the first test case using quadrilateral elements, triangular elements, and different orientations. The 2D heat transfer program yielded the same results as the hand calculation for each mesh and orientation. By confirming that the program obtained the same temperature value of 440 degrees kelvin on the right face of the object, it validated that the 2D program can solve for a temperature distribution within a geometry using a heat flux boundary condition. Test Case 2 For the second test case, the same rectangular geometry was used that had a prescribed temperature on the left face, and had a constant uniform heat generation. The geometry had a length, of 4 meters, a prescribed temperature, of 400 degrees kelvin, a thermal conductivity, of 1 Watt per meter kelvin, and a heat generation, of 3 Watts per meter cubed. This geometry can be seen in Figure 9. Figure 9: Geometry for the second test case. The temperature on the right face of the geometry, was the temperature being solved for. To solve for this temperature by hand, a one-dimensional heat transfer equation was derived. To derive the onedimensional heat transfer equation, the fundamental heat transfer equation 10 ( ) (11) was used. By integrating twice and using the boundary condition equation (0) 400 , the heat transfer (12) 2 was derived. By entering the given values into the equation, was found to be 424 degrees kelvin. Once the hand calculation was completed, a series of cases were run with the 2D heat transfer program to make sure that the program was yielding the same results as the hand calculation. To verify the program gave the same result with any orientation or mesh, the test case was run with both quadrilateral and triangular mesh elements, each with the geometry being oriented at 0 degrees, 45 degrees, and 90 degrees. The results of these trials can be seen in Figure 10 below. Figure 10: The 2D heat transfer program results for the second test case using quadrilateral elements, triangular elements, and different orientations. The 2D heat transfer program yielded the same results as the hand calculation for each mesh and orientation. By confirming that the program obtained the same temperature value of 424 degrees kelvin on the right face of the object, it validated that the 2D program can solve for a temperature distribution within a geometry having heat generation. 11 Test Case 3 For the third test case, the same rectangular geometry was used once again, where it had a prescribed temperature on the left face, and convection acting on the right face. The geometry had a length, of 4 meters, a prescribed temperature, of 400 degrees kelvin, a thermal conductivity, of 1 Watt per meter kelvin, and a convection heat transfer coefficient, of 2 Watts per meter squared kelvin, and an ambient temperature, of 100 degrees kelvin. This geometry can be seen in Figure 11. Figure 11: geometry for the third test case. The temperature on the right face of the geometry, was the temperature being solved for. To solve for this temperature by hand, a one-dimensional heat transfer equation was derived. To derive the onedimensional heat transfer equation a circuit analogy was used, which can be seen in Figure 12. Figure 12: Circuit analogy for the third test case. In this analogy, the temperatures are the nodes in the circuit, and the resistances are taken into account through the geometry’s resistance to conductivity and convection. To use this analogy, it can be said that the equation (13) is equivalent to (14) in heat transfer terms. Where 1 (15) 12 By solving for and assuming that there is steady state heat transfer acting on the right face of the ̇ , it can be shown that geometry where ̇ 1 From this equation, (16) was solved for and an expression was obtained in variable form. ( ) (17) By entering the given values into the equation 17, was found to be 133.33 degrees kelvin. Once the hand calculation was completed, a series of cases were run with the 2D heat transfer program to make sure that the program was yielding the same results as the hand calculation. To verify the program gave the same result with any orientation or mesh, the test case was run with both quadrilateral and triangular mesh elements, each with the geometry being oriented at 0 degrees, 45 degrees, and 90 degrees. The results of these trials can be seen in Figure 13 below. Figure 13: The 2D heat transfer program results for the third test case using quadrilateral elements, triangular elements, and different orientations. The 2D heat transfer program yielded the same results as the hand calculation for each mesh and orientation. By confirming that the program obtained the same temperature value of 133.33 degrees kelvin on the right face of the object, it validated that the 2D program can solve for a temperature distribution within a geometry using a convection boundary condition. 13 Test Case 4 For the fourth and final test case, a more complicated geometry was used with more than one boundary condition. First, an Ansys model was created with all of the applied boundary conditions. A prescribed temperature of 400 degrees kelvin was applied on the left face. Convection was applied to the face of the circular cutout with a heat transfer coefficient, of 20 Watts per meter squared kelvin and an ambient temperature, of 420 degrees kelvin. Convection was also applied to the bottom face of the geometry with a heat transfer coefficient, of 3 Watts per meter squared kelvin and an ambient temperature of 100 degrees kelvin. Constant heat generation, was also applied to the geometry with a value of 10 Watts per meter cubed. Lastly, the geometry was given a conductivity of 1 Watt per meter kelvin. After applying all of the boundary conditions to the Ansys model it was then solved. The model converged and produced a result with the maximum temperature of 407.57 degrees kelvin and the minimum temperature being 206.53 degrees kelvin. The Ansys geometry and results can be seen in Figure 14 below. Figure 14: The Ansys model of the more complicated geometry used in the fourth test case. After computing the solution in Ansys, the 2D heat transfer program was then used to solve the same problem. The meshing coordinates and elemental data were imported into the program and the boundary conditions were set. When solved, the program plotted the temperature contour and gave the maximum temperature value of 407.57 degrees kelvin and a minimum temperature value of 206.53 degrees kelvin. These results can be seen in Figure 15 below. 14 Figure 15: 2D heat transfer program contour plot results for the fourth test case. With these results, it can be concluded that the 2D steady state heat transfer program is written correctly, and can provide accurate results no matter what mesh elements are being used, what boundary conditions are applied, and what geometry is used. Summary and Conclusions We successfully created a two-dimensional static heat conduction finite element analysis program. We are confident that it performs as intended based on the extensive testing and validation that was conducted. The program not only produces expected results compared to the by-hand calculations but matches the output of Ansys to a high degree of accuracy. Despite the success of the current iteration of this program, there are several aspects that can be improved upon and features that could be added. The largest flaw in the program as it currently exists is that the boundary generator does not work perfectly. As geometries become increasingly complicated, the likelihood of an error occurring increases. Additionally, if two boundaries are less than three elements apart, the function struggles. This function is an essential part of the structure of the program so it needs to work flawlessly for this to be a robust program. The analysis of combination quad/tri meshes is one aspect that prevents this program from running as smoothly as it could. Often times it is easier to generate a mesh that utilizes both element shapes so some conditional handling of the element generation would drastically improve the program. Importing the mesh from an outside program is not optimal and prevents this program from being standalone. With more time and research, the addition of a mesh generator might be feasible. There are 15 also other boundary conditions that could be implemented. We do not consider radiative heat transfer for example. Alternate solution output methods might also be beneficial. An option to display directional heat flux is one thing that could be added in those regards. The last and most general thing that we have considered adding is more comprehensive error handling. There are many ways in which you can click buttons out of order in the GUI and in most of those cases, the program just will not run. The best example of this is the nodal and elemental information selection. If you mix up the two text files, the program itself will not throw a flag, but it will not produce any results. We would like to have the program force the user to make the right choice of file. The user should not be able to do anything to break the program. Despite the potential work still to be done, the program itself was very successful in accurately executing the finite element analyses that we tested. This program would be a great jumping off point for someone looking to make an advanced 2D static heat conduction program. Radiation is nonlinear, because it depends on the 4th power of the temperature. You might not want to go that direction.