Heat conduction
heatConductionScript solves steady-state heat conduction in 1D and 2D, with spatially varying thermal
conductivity and heat source.
Governing equation
where is the temperature, the thermal conductivity and the volumetric heat source. In 1D the equation reduces to .
The boundary is split into parts with prescribed temperature (Dirichlet), convective heat exchange (Robin), and zero heat flux (Neumann):
where is the convective heat transfer coefficient, the temperature of the surrounding fluid and the derivative along the outward normal.
Weak form
After integration by parts, the Galerkin residuals are
where is the part of the boundary with convection. On the rest of the boundary, the boundary integral vanishes (zero heat flux) or the residual is replaced by the Dirichlet condition. In 1D the boundary integral reduces to the value at the boundary node.
The model is linear, so the system is solved once.
Usage
import { FEAScriptModel } from "feascript";
// 1. Create the model and select the physics
const model = new FEAScriptModel();
model.setModelConfig("heatConductionScript", {
coefficientFunctions: {
thermalConductivity: 1, // k
heatSource: 0, // Q
},
});
// 2. Define the mesh
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsX: 8,
numElementsY: 4,
maxX: 4,
maxY: 2,
});
// 3. Apply the boundary conditions
model.addBoundaryCondition("0", ["constantTemperature", 200]); // Bottom
model.addBoundaryCondition("1", ["symmetry"]); // Left
model.addBoundaryCondition("2", ["convection", 1, 20]); // Top
model.addBoundaryCondition("3", ["constantTemperature", 200]); // Right
// 4. Solve
model.setSolverMethod("lusolve");
const { solutionVector, nodesCoordinates } = model.solve();
Coefficient functions
| Property | Symbol | Default | Type |
|---|---|---|---|
thermalConductivity | 1 | number or function of position | |
heatSource | 0 | number or function of position |
Each coefficient can be a constant or a function of the physical coordinates: (x) => ... in 1D and
(x, y) => ... in 2D. Functions are evaluated at every integration point, so piecewise (for example
multi-material) and smooth variations are both supported. coefficientFunctions can be omitted entirely to use
the defaults.
model.setModelConfig("heatConductionScript", {
coefficientFunctions: {
// High-conductivity metal on the left half, low-conductivity ceramic on the right half
thermalConductivity: (x, y) => (x < 2 ? 10 : 1),
// Heat source in the upper strip only
heatSource: (x, y) => (y > 1.5 ? 500 : 0),
},
});
FEAScript does not enforce a unit system: use any consistent set of units, for example SI units (W/(m·K) for , W/m³ for , W/(m²·K) for , and °C or K for temperatures).
Boundary conditions
| Condition | Parameters | Kind |
|---|---|---|
["constantTemperature", T] | Temperature | Dirichlet |
["convection", h, Tinf] | Heat transfer coefficient , fluid temperature | Robin |
["symmetry"] | – | Neumann (zero flux) |
h and Tinf are constants. A boundary without a condition is insulated (zero heat flux), exactly like
"symmetry". The deprecated name "constantTemp" is still accepted, with a warning.
Solvers
All solver methods are supported: "lusolve" (default), "jacobi", "frontal", and "jacobi-gpu" with
solveAsync(). Coefficient functions are supported by all of them. See Solvers.
Results
solutionVector holds the nodal temperatures, in the order of the nodes in nodesCoordinates (see
Node numbering). Plot them with
plotSolution or post-process them directly:
const { nodesXCoordinates, nodesYCoordinates } = nodesCoordinates;
const maxTemperature = Math.max(...solutionVector);
Examples
- Heat conduction in a 1D wall
- Heat conduction in a 2D fin (structured mesh)
- Heat conduction in a 2D fin with a Gmsh mesh
- Heat conduction in a 2D rhomboid fin with a Gmsh mesh
- Node.js scripts in
examples/heatConductionScript, including spatially varying and ,