Skip to content

Commit cee7e58

Browse files
committed
Refine boundary condition descriptions and update solver configuration in HeatConduction1DWall.html and HeatConduction2DFin.html
1 parent 4bdb6e0 commit cee7e58

File tree

2 files changed

+72
-30
lines changed

2 files changed

+72
-30
lines changed

tutorials/HeatConduction1DWall.html

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
&deg;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 &deg;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
&lt;/head&gt;</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+
&lt;body&gt;
132+
. . .
133+
&lt;script type="module"&gt;
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+
&lt;/script&gt;
177+
. . .
178+
&lt;/body&gt;</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

tutorials/HeatConduction2DFin.html

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
140140
// Set solver configuration
141141
model.setSolverConfig("solidHeatTransferScript");
142142

143-
// Set solver method
144-
model.setSolverMethod("lusolve");
145-
146143
// Define mesh configuration
147144
model.setMeshConfig({
148145
meshDimension: "2D",
@@ -159,7 +156,7 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
159156
model.addBoundaryCondition("2", ["convection", 1, 20]);
160157
model.addBoundaryCondition("3", ["constantTemp", 200]);
161158

162-
// Set solver method (optional) - 'lusolve' uses LU decomposition
159+
// Set solver method
163160
model.setSolverMethod("lusolve");
164161

165162
// Solve the problem and get the solution
@@ -256,9 +253,6 @@ <h2 id="results"><a name="Results"></a>Results</h2>
256253
// Set solver configuration
257254
model.setSolverConfig("solidHeatTransferScript");
258255

259-
// Set solver method
260-
model.setSolverMethod("lusolve");
261-
262256
// Define mesh configuration
263257
model.setMeshConfig({
264258
meshDimension: "2D",
@@ -275,7 +269,7 @@ <h2 id="results"><a name="Results"></a>Results</h2>
275269
model.addBoundaryCondition("2", ["convection", 1, 20]);
276270
model.addBoundaryCondition("3", ["constantTemp", 200]);
277271

278-
// Set solver method (optional) - 'lusolve' uses LU decomposition
272+
// Set solver method
279273
model.setSolverMethod("lusolve");
280274

281275
// Solve the problem and get the solution
@@ -310,9 +304,6 @@ <h2 id="results"><a name="Results"></a>Results</h2>
310304
// Set solver configuration
311305
model.setSolverConfig("solidHeatTransferScript");
312306

313-
// Set solver method
314-
model.setSolverMethod("lusolve");
315-
316307
// Define mesh configuration
317308
model.setMeshConfig({
318309
meshDimension: "2D",
@@ -329,7 +320,7 @@ <h2 id="results"><a name="Results"></a>Results</h2>
329320
model.addBoundaryCondition("2", ["convection", 1, 20]);
330321
model.addBoundaryCondition("3", ["constantTemp", 200]);
331322

332-
// Set solver method (optional) - 'lusolve' uses LU decomposition
323+
// Set solver method
333324
model.setSolverMethod("lusolve");
334325

335326
// Solve the problem and get the solution

0 commit comments

Comments
 (0)