|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | +<!-- ______ ______ _____ _ _ --> |
| 4 | +<!-- | ____| ____| /\ / ____| (_) | | --> |
| 5 | +<!-- | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ --> |
| 6 | +<!-- | __| | __| / /\ \ \___ \ / __| __| | _ \| __| --> |
| 7 | +<!-- | | | |____ / ____ \ ____) | (__| | | | |_) | | --> |
| 8 | +<!-- |_| |______/_/ \_\_____/ \___|_| |_| __/| | --> |
| 9 | +<!-- | | | | --> |
| 10 | +<!-- |_| | |_ --> |
| 11 | +<!-- Website: https://feascript.com/ \__| --> |
| 12 | + |
| 13 | +<html lang="en"> |
| 14 | + <head> |
| 15 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 16 | + <meta name="viewport" content="width=device-width" /> |
| 17 | + <title>FEAScript: Heat Conduction Through a Wall Example</title> |
| 18 | + |
| 19 | + <!-- Math.js and Plotly.js libraries --> |
| 20 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.0.0/math.min.js"></script> |
| 21 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.27.0/plotly.min.js"></script> |
| 22 | + |
| 23 | + <!-- Link to the CSS files --> |
| 24 | + <link href="https://feascript.com/FEAScript-website.css" rel="stylesheet" type="text/css" /> |
| 25 | + <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet" /> |
| 26 | + </head> |
| 27 | + |
| 28 | + <body> |
| 29 | + <h1>Heat Conduction Through a Wall Example</h1> |
| 30 | + <div id="solutionPlot"></div> |
| 31 | + |
| 32 | + <p> |
| 33 | + This example demonstrates heat conduction through a wall using a one-dimensional model. The mesh |
| 34 | + configuration and boundary conditions are defined directly within the JavaScript code. Please refresh |
| 35 | + the page to update the results. Detailed instructions for this example can be found in the corresponding |
| 36 | + <a href="https://feascript.com/tutorials/HeatConduction1DWall.html" target="_blank" |
| 37 | + >FEAScript tutorial</a |
| 38 | + >. If you need further assistance, you can visit the |
| 39 | + <a href="https://feascript.com/" target="_blank">FEAScript website</a>. |
| 40 | + </p> |
| 41 | + |
| 42 | + <p>© 2023-<span id="currentYear"></span> FEAScript</p> |
| 43 | + <script> |
| 44 | + document.getElementById("currentYear").innerHTML = new Date().getFullYear(); |
| 45 | + </script> |
| 46 | + |
| 47 | + <!-- Import FEAScript library --> |
| 48 | + <script type="module"> |
| 49 | + import { FEAScriptModel, plotSolution, printVersion } from "https://core.feascript.com/src/index.js"; |
| 50 | + |
| 51 | + window.addEventListener("DOMContentLoaded", () => { |
| 52 | + // Print FEAScript version in the console |
| 53 | + printVersion(); |
| 54 | + |
| 55 | + // Create a new FEAScript model |
| 56 | + const model = new FEAScriptModel(); |
| 57 | + |
| 58 | + // Set solver configuration |
| 59 | + model.setSolverConfig("solidHeatTransferScript"); |
| 60 | + |
| 61 | + // Define mesh configuration |
| 62 | + model.setMeshConfig({ |
| 63 | + meshDimension: "1D", |
| 64 | + elementOrder: "linear", |
| 65 | + numElementsX: 10, |
| 66 | + maxX: 0.15, |
| 67 | + }); |
| 68 | + |
| 69 | + // Define boundary conditions |
| 70 | + model.addBoundaryCondition("0", ["convection", 1, 25]); |
| 71 | + model.addBoundaryCondition("1", ["constantTemp", 5]); |
| 72 | + |
| 73 | + // Set solver method (optional) - 'lusolve' uses LU decomposition |
| 74 | + model.setSolverMethod("lusolve"); |
| 75 | + |
| 76 | + // Solve the problem and get the solution |
| 77 | + const { solutionVector, nodesCoordinates } = model.solve(); |
| 78 | + |
| 79 | + // Plot the solution as a 1D line plot |
| 80 | + plotSolution( |
| 81 | + solutionVector, |
| 82 | + nodesCoordinates, |
| 83 | + model.solverConfig, |
| 84 | + model.meshConfig.meshDimension, |
| 85 | + "line", |
| 86 | + "solutionPlot" |
| 87 | + ); |
| 88 | + }); |
| 89 | + </script> |
| 90 | + </body> |
| 91 | +</html> |
0 commit comments