@@ -96,14 +96,17 @@ <h2 id="mathematicalformulation"><a name="Mathematical formulation"></a>Mathemat
9696 within common engineering components like house walls.
9797 </ p >
9898
99- < img src ="../assets/HeatConduction1DWall.png " width ="150 " />
99+ < img src ="../assets/HeatConduction1DWall.png " width ="100 " />
100100
101101 < p >
102102 The above schematic illustrates the problem domain and outlines the associated boundary conditions. In
103103 particular, a convection boundary condition, implemented as Robin type, is applied at the inner side of
104- the wall (\(x = 0\)). Morevover, at the outer side of the wall (\(x = W\), where \(W\) is the width of
105- the wall), we apply a constant temperature (\(T_0\)) boundary condition, implemented as Dirichlet type
106- in the finite element code.
104+ the wall (\(x = 0\)). The latter is expressed as \(\frac{dT}{dx}|_{x=0}=-{\frac{h}{k}}(T-T_{in})\),
105+ where \(h\) is the heat transfer coefficient, \(k\) the thermal conductivity and \(T_{in}\) is the
106+ internal temperature. We assume here that \({\frac{h}{k}}\) = 1 m< sup > -1</ sup > and \(T_{in}\) = 25
107+ °C. At the outer side of the wall (\(x = W\), where \(W\) = 0.15 m, is the width of the wall), we
108+ apply a constant temperature (\(T_0\) = 5 °C) boundary condition, implemented as Dirichlet type in
109+ the finite element code.
107110 </ p >
108111
109112 < h2 id ="solvingwithfeascript "> < a name ="Solving with FEAScript "> </ a > Solving with FEAScript</ h2 >
@@ -120,6 +123,60 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
120123 . . .
121124</head></ pre
122125 >
126+ < p >
127+ We should then define the problem parameters, such as the solver type, the geometry configuration, and
128+ the boundary conditions. This is performed using JavaScript objects directly in the HTML file:
129+ </ p >
130+ < pre class ="prettyprint ">
131+ <body>
132+ . . .
133+ <script type="module">
134+ // Import the FEAScript library
135+ import { FEAScriptModel, plotSolution, printVersion } from "https://feascript.github.io/FEAScript-core/src/index.js";
136+ window.addEventListener("DOMContentLoaded", (event) => {
137+
138+ // Print FEAScript version
139+ printVersion();
140+
141+ // Create a new FEAScript model
142+ const model = new FEAScriptModel();
143+
144+ // Set solver configuration
145+ model.setSolverConfig("solidHeatTransferScript");
146+
147+ // Define mesh configuration
148+ model.setMeshConfig({
149+ meshDimension: "1D",
150+ elementOrder: "linear",
151+ numElementsX: 10,
152+ maxX: 0.15,
153+ });
154+
155+ // Define boundary conditions
156+ model.addBoundaryCondition("0", ["convection", 1, 25]);
157+ model.addBoundaryCondition("1", ["constantTemp", 5]);
158+
159+ // Set solver method
160+ model.setSolverMethod("lusolve");
161+
162+ // Solve the problem and get the solution
163+ const { solutionVector, nodesCoordinates } = model.solve();
164+
165+ // Plot the solution as a 1D line plot
166+ plotSolution(
167+ solutionVector,
168+ nodesCoordinates,
169+ model.solverConfig,
170+ model.meshConfig.meshDimension,
171+ "line",
172+ "solutionPlot"
173+ );
174+
175+ });
176+ </script>
177+ . . .
178+ </body></ pre
179+ >
123180
124181 < h2 id ="results "> < a name ="Results "> </ a > Results</ h2 >
125182
@@ -162,22 +219,19 @@ <h2 id="results"><a name="Results"></a>Results</h2>
162219 // Set solver configuration
163220 model . setSolverConfig ( "solidHeatTransferScript" ) ;
164221
165- // Set solver method
166- model . setSolverMethod ( "lusolve" ) ;
167-
168222 // Define mesh configuration
169223 model . setMeshConfig ( {
170224 meshDimension : "1D" ,
171225 elementOrder : "linear" ,
172226 numElementsX : 10 ,
173- maxX : 1 ,
227+ maxX : 0.15 ,
174228 } ) ;
175229
176230 // Define boundary conditions
177- model . addBoundaryCondition ( "0" , [ "constantTemp " , 100 ] ) ;
178- model . addBoundaryCondition ( "1" , [ "constantTemp" , 50 ] ) ;
231+ model . addBoundaryCondition ( "0" , [ "convection " , 1 , 25 ] ) ;
232+ model . addBoundaryCondition ( "1" , [ "constantTemp" , 5 ] ) ;
179233
180- // Set solver method (optional) - 'lusolve' uses LU decomposition
234+ // Set solver method
181235 model . setSolverMethod ( "lusolve" ) ;
182236
183237 // Solve the problem and get the solution
@@ -212,22 +266,19 @@ <h2 id="results"><a name="Results"></a>Results</h2>
212266 // Set solver configuration
213267 model . setSolverConfig ( "solidHeatTransferScript" ) ;
214268
215- // Set solver method
216- model . setSolverMethod ( "lusolve" ) ;
217-
218269 // Define mesh configuration
219270 model . setMeshConfig ( {
220271 meshDimension : "1D" ,
221272 elementOrder : "linear" ,
222273 numElementsX : 10 ,
223- maxX : 1 ,
274+ maxX : 0.15 ,
224275 } ) ;
225276
226277 // Define boundary conditions
227- model . addBoundaryCondition ( "0" , [ "constantTemp " , 100 ] ) ;
228- model . addBoundaryCondition ( "1" , [ "constantTemp" , 50 ] ) ;
278+ model . addBoundaryCondition ( "0" , [ "convection " , 1 , 25 ] ) ;
279+ model . addBoundaryCondition ( "1" , [ "constantTemp" , 5 ] ) ;
229280
230- // Set solver method (optional) - 'lusolve' uses LU decomposition
281+ // Set solver method
231282 model . setSolverMethod ( "lusolve" ) ;
232283
233284 // Solve the problem and get the solution
0 commit comments