FEAScript-core

FEAScript is a finite element simulation library developed in JavaScript. It runs engineering simulations in the browser or in Node.js, with no desktop software to install.
🎯 A JavaScript API for FEM: you set up the model, solve it and plot the results in JavaScript, and you can build the simulation into your own web pages and applications. This is the core library of the FEAScript project.
🚧 FEAScript is in development, and each release adds features. Its API may change between minor releases; see the changelog. Donations pay for development time, documentation and tutorials.
Contents
Features
- Physics models: creeping (Stokes) flow, Euler–Bernoulli beam bending, front propagation, heat conduction, general-form PDE (linear and nonlinear)
- Geometry and meshing: a geometry (line, rectangle, or polygon with holes) with named boundaries, meshed with quadrilaterals (mapped grid) or triangles (Delaunay refinement, graded by position, built on Delaunator and Constrainautor), and unstructured mesh import from Gmsh (
.msh) with quadrilateral and triangular elements (linear and quadratic)
- Solvers: frontal, Jacobi (CPU/WebGPU) and LU, Newton–Raphson for nonlinear systems
- Spatially varying coefficients:
thermalConductivity(x, y) and heatSource(x, y) can be scalars or functions, evaluated at each Gauss point
- Performance: web worker support for multi-threaded computation
- Visualization: interactive rendering with vtk.js and Plotly
How to use FEAScript
You can run simulations with FEAScript by calling its functions from JavaScript (the FEAScript API). The API is the core programmatic interface for FEAScript and works across multiple environments, including the browser (simple HTML pages and online JavaScript playgrounds, e.g. CodePen and Scribbler) and server-side runtimes such as Node.js. The most common ways to use FEAScript are outlined below:
- In the browser – Run FEAScript directly in a simple HTML page to perform simulations locally with no additional installations or cloud services required.
- In JavaScript playgrounds – Try FEAScript in interactive JavaScript playgrounds such as CodePen or Scribbler.
- With Node.js – Use FEAScript in server-side JavaScript applications.
The FEAScript documentation covers installation, the physical models and their equations, meshes, boundary conditions, solvers and the full API reference.
Use FEAScript in the browser
You can use FEAScript in browser environments in three ways:
-
Import from CDN (jsDelivr):
<script type="module">
import { FEAScriptModel } from "https://cdn.jsdelivr.net/gh/FEAScript/FEAScript-core/dist/feascript.esm.js";
</script>
-
Import from hosted ESM build:
<script type="module">
import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";
</script>
Note: Both URLs above always serve the latest FEAScript release, so your page updates automatically when a new version is published (new versions may include breaking changes). To freeze your page to a specific version, add a version tag to the jsDelivr URL:
<script type="module">
import { FEAScriptModel } from "https://cdn.jsdelivr.net/gh/FEAScript/[email protected]/dist/feascript.esm.js";
</script>
-
Download and use locally:
You can download the latest stable release from GitHub Releases.
<script type="module">
import { FEAScriptModel } from "./path/to/dist/feascript.esm.js";
</script>
👉 Explore browser-based tutorials on our website.
Use FEAScript in JavaScript playgrounds
FEAScript works well in interactive JavaScript playgrounds where you can write code, visualize results inline, and share your work.
👉 Explore the following examples:
Use FEAScript with Node.js
Install FEAScript and its peer dependencies from npm as follows:
npm install feascript
Then, import it in your JavaScript file:
import { FEAScriptModel } from "feascript";
Important: FEAScript is built as an ES module. If you’re starting a completely new project (outside this repository), make sure to configure it to use ES modules by:
# Create package.json with type=module for ES modules support
echo '{"type":"module"}' > package.json
When running examples from within this repository, this step isn’t needed as the root package.json already has the proper configuration.
👉 Explore Node.js use cases on the examples directory.
FEAScript lite
FEAScript lite is a small build with no dependencies, for pages that embed a model: course pages, interactive explainers, games and offline tools. It is one file of about 144 KB (44 KB gzipped). It has the same API as the full build and covers every model that runs on the frontal solver:
| In lite |
Not in lite (use the full build) |
| Heat conduction, general-form PDE, front propagation |
Creeping flow and the Euler–Bernoulli beam (they need the LU solver) |
| Frontal (the default in lite) and Jacobi solvers |
"lusolve" and "jacobi-gpu" |
| Line, quadrilateral and triangle meshes, Gmsh import |
FEAScriptWorker |
plotSolution, evaluateSolution (Plotly for plots) |
The vtk.js plots |
Anything not in lite stops with a FEAScriptError ("UNSUPPORTED_SOLVER") that says so. Lite runs on pages with a strict Content Security Policy: it makes no network requests and starts no workers. Its files have no http:// or https:// links, so sites that check for links can ship them as they are.
<script src="./path/to/dist/feascript-lite.umd.min.js"></script>
<script>
const { FEAScriptModel } = FEAScript;
</script>
import { FEAScriptModel } from "feascript/lite";
Both files are in dist/ of each release (feascript-lite.umd.min.js and feascript-lite.esm.min.js). To build them from the source, run npm run build:lite.
Examples
Here is a minimal browser-based example using the FEAScript API. Adapt paths, physics model, and boundary conditions as needed for your specific problem:
<body>
<script type="module">
import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";
window.addEventListener("DOMContentLoaded", () => {
const model = new FEAScriptModel();
model.setModelConfig("physicsModel", { solver: { method: "lusolve" } });
model.setGeometry({ rectangle: [1.0, 0.5] });
model.setMeshConfig({
elements: "quadrilaterals",
elementOrder: "linear",
size: 0.1,
});
model.addBoundaryCondition("top", { type: "conditionType" });
const { solutionVector, nodesCoordinates } = model.solve();
});
</script>
</body>
Note: The code above uses placeholder values that you should replace with appropriate options, e.g.:
- “physicsModel” should be replaced with an actual physics model such as “heatConduction” for heat conduction problems
- “conditionType” should be replaced with an actual boundary condition type with its parameters, such as
{ type: "constantTemperature", temperature: 100 } or { type: "convection", h: 1, ambientTemperature: 20 }
solver selects the linear solver: method is “lusolve” (the default), “jacobi” or “frontal”, and the
iterative methods also take maxIterations and tolerance
- “top” is the name of a boundary of the geometry: “left” and “right” for a line, “bottom”, “right”, “top” and “left” for a rectangle, the names you give the edges of a polygon, or the names of the physical groups of a Gmsh mesh
Furthermore, the scripts under examples/ contain Node.js examples. You can run them from the FEAScript-core/ directory as follows:
node examples/heatConduction/heatConduction1DWall/heatConduction1DWall.js
Each script prints its computed solution to the console.
Help FEAScript grow
💖 If you find FEAScript useful, please consider supporting its development through a donation. Your support helps fund new features, performance improvements, documentation and tutorials:

📨 You can also join the FEAScript mailing list to receive project updates and news: Subscribe here
Contributing
We warmly welcome contributors to help expand and refine FEAScript. Please see the CONTRIBUTING.md file for detailed guidance on how to contribute.
License
The core library of FEAScript is released under the MIT license. © 2023-2026 FEAScript.
评论