In this tutorial, we address a stationary heat transfer problem within a 2D rectangular domain. This is a typical cooling fin problem. Cooling fins are commonly used to increase the area available for heat transfer between metal walls and poorly conducting fluids such as air.
Steady heat conduction is described by the Laplace equation: \(\nabla^{2}T(x,y) = 0\), where \(T\) signifies the temperature values.
The above schematic illustrates the problem domain and outlines the associated boundary conditions. The constant temperature boundary conditions are implemented as Dirichlet types in the finite element code. The symmetry boundary condition is implemented as a Neumann zero-flux type \( \left( \frac{dT}{dx}|_{x=0}=0 \right) \), while the convective cooling boundary condition is of the Robin type. Specifically, the latter is expressed as \(\frac{dT}{dy}|_{y=4}=-{\frac{h}{k}}(T-T_0)\), where \(h\) is the heat transfer coefficient, \(k\) the thermal conductivity and \(T_0\) is the external temperature. We assume here that \({\frac{h}{k}}\) = 1 m-1 and \(T_0\) = 20 °C.
Below is a demonstration of how to use the FEAScript library to solve the stationary heat transfer problem in your web browser. You only need a simple HTML page to run this example where the following code snippets should be included. First, we should load the required external libraries:
<head> . . . <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.0.0/math.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.27.0/plotly.min.js"></script> . . . </head>
We should then define the problem parameters, such as the solver type, the geometry configuration, and the boundary conditions. This is performed using JavaScript objects directly in the HTML file:
<body> . . . <script type="module"> // Import the FEAScript library import { FEAScriptModel, plotSolution, printVersion } from "https://feascript.github.io/FEAScript-core/src/index.js"; window.addEventListener("DOMContentLoaded", (event) => { // Print FEAScript version printVersion(); // Create a new FEAScript model const model = new FEAScriptModel(); // Set solver configuration model.setSolverConfig("solidHeatTransferScript"); // Set solver method model.setSolverMethod("lusolve"); // Define mesh configuration model.setMeshConfig({ meshDimension: "2D", elementOrder: "quadratic", numElementsX: 8, numElementsY: 4, maxX: 4, maxY: 2, }); // Define boundary conditions model.addBoundaryCondition("0", ["constantTemp", 200]); model.addBoundaryCondition("1", ["symmetry"]); model.addBoundaryCondition("2", ["convection", 1, 20]); model.addBoundaryCondition("3", ["constantTemp", 200]); // Set solver method (optional) - 'lusolve' uses LU decomposition model.setSolverMethod("lusolve"); // Solve the problem and get the solution const { solutionVector, nodesCoordinates } = model.solve(); // Plot the solution as a 2D contour plot plotSolution( solutionVector, nodesCoordinates, model.solverConfig, model.meshConfig.meshDimension, "contour", "solutionPlot" ); }); </script> . . . </body>
In the boundary condition definition, the numbers at the left side (from 0 to 3) indicate the boundaries of the geometry (the mesh generator of FEAScript has assigned numbers to the boundaries, starting from the bottom boundary and proceeding clockwise). The `constantTemp` condition sets a constant temperature value. The `symmetry` boundary condition represents a zero-flux type. Finally, the `convection` condition describes a convective heat transfer scenario. In addition, the second argument of the `constantTemp` boundary condition corresponds to the constant temperature value. For a `convection` boundary condition, the second argument represents the \({\frac{h}{k}}\) value, and the third argument indicates the external temperature \(T_0\).
After solving the case, the results are demonstrated in a 2D contour plot. To visualize it, include an HTML container where the plot will render:
<body> . . . <div id="solutionPlot"></div> . . . </body>
The `solutionPlot` is the id of the div where the plot will be rendered. This id is passed as an argument to the plotSolution function to specify the target div for the plot.
Below is the 2D contour plot of the computed temperature distribution. This plot is generated in real time using FEAScript. You can find a minimal example of this tutorial in the example directory.
© 2023- FEAScript