Skip to content

FEAScript/FEAScript-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FEAScript Logo

FEAScript-core

npm version

FEAScript is a lightweight finite element simulation library built in JavaScript. It empowers users to create and execute simulations for physics and engineering applications in both browser-based and server-side environments. This is the core library of the FEAScript project.

🚧 FEAScript is currently under heavy development. Its functionality and interfaces may change rapidly as new features and enhancements are introduced.

Contents

Ways to Use FEAScript

FEAScript offers two main approaches to creating simulations:

  1. JavaScript API (FEAScript Core) – For developers comfortable with coding, providing full programmatic control in browsers, Node.js, or interactive notebooks.
  2. Visual Editor (FEAScript Platform) – For users who prefer a no-code approach, offering a block-based visual interface built with Blockly.

Each approach is explained in detail below.

JavaScript API (FEAScript Core)

The JavaScript API is the core programmatic interface for FEAScript. Written entirely in pure JavaScript, it runs in three environments:

  1. In the browser – Use FEAScript in a simple HTML page, running simulations locally without additional installations or cloud services.
  2. With Node.js – Use FEAScript in server-side JavaScript applications or CLI tools.
  3. With Scribbler – Use FEAScript in the Scribbler interactive JavaScript notebook environment.

Use FEAScript in the Browser

You can use FEAScript in browser environments in two ways:

  • Import from Hosted ESM Build:

    <script type="module">
      import { FEAScriptModel } from "https://core.feascript.com/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 with Node.js

Install FEAScript and its peer dependencies from npm as follows:

npm install feascript mathjs plotly.js

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.

Use FEAScript with Scribbler

FEAScript also works well in interactive JavaScript notebook environments where you can write code, visualize results inline, and share your work with others. Scribbler is one such platform that comes with preloaded scientific libraries, making it an excellent choice for FEAScript simulations.

πŸ‘‰ Explore FEAScript notebook examples on the Scribbler Hub.

Visual Editor (FEAScript Platform)

For users who prefer a visual approach to creating simulations, we offer the FEAScript Platform - a browser-based visual editor built on the Blockly library. This no-code interface allows you to:

  • Build and run finite element simulations directly in your browser by connecting visual blocks together
  • Create complex simulations without writing any JavaScript code
  • Save and load projects in XML format for easy sharing and reuse

While FEAScript's JavaScript API offers full programmatic control for advanced customization, the FEAScript Platform provides an accessible entry point for users without coding experience.

πŸ‘‰ Explore FEAScript Platform examples on our website.

Quick Example

Here is a minimal browser-based example using the JavaScript API. Adapt paths, solver types, and boundary conditions as needed for your specific problem:

<body>
  <!-- ...body region... -->
  <script type="module">
    // Import FEAScript library
    import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";

    window.addEventListener("DOMContentLoaded", () => {
      // Create a new FEAScript model
      const model = new FEAScriptModel();

      // Set the solver type for your problem
      model.setSolverConfig("solverType"); // Example: "solidHeatTransferScript"

      // Configure the mesh
      model.setMeshConfig({
        meshDimension: "1D", // Choose either "1D" or "2D"
        elementOrder: "linear", // Choose either "linear" or "quadratic"
        numElementsX: 10, // Number of elements in x-direction
        numElementsY: 6, // Number of elements in y-direction (for 2D only)
        maxX: 1.0, // Domain length in x-direction
        maxY: 0.5, // Domain length in y-direction (for 2D only)
      });

      // Add boundary conditions with appropriate parameters
      model.addBoundaryCondition("boundaryIndex", ["conditionType" /* parameters */]); // Example boundary condition

      // Solve the problem
      const { solutionVector, nodesCoordinates } = model.solve();
    });
  </script>
  <!-- ...rest of body region... -->
</body>

Note: The code above uses placeholder values that you should replace with appropriate options, e.g.:

  • "solverType" should be replaced with an actual solver type such as "solidHeatTransferScript" for heat conduction problems
  • "conditionType" should be replaced with an actual boundary condition type such as "constantTemp"
  • "boundaryIndex" should be replaced with a string identifying the boundary

Support FEAScript

πŸ’– If you find FEAScript useful, please consider supporting its development through a donation:

Donate using Liberapay

Your support helps ensure the continued development and maintenance of this project.

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-2025 FEAScript.

Sponsor this project

Contributors 5