Skip to content

Commit 1560d41

Browse files
Add Solidification Front 2D example (#30)
* Added initial file for frontPropagationScript * Refactor Heat Conduction example: add JavaScript implementation, update README instructions, and enhance .gitignore * - Enhanced frontPropagationScript.js with a new function to assemble the front propagation matrix, including detailed JSDoc comments. - Updated version number in package.json and src/index.js to 0.1.2. - Added logging for FEAScript version in HeatConduction1DWall.js. - Updated peer dependency for plotly.js to version 2.35.3. - Removed unnecessary dependencies from package-lock.json and package.json. * Reorganize README sections for clarity: update installation options and example usage * Update README for improved clarity: reorganize installation options and example usage sections * Remove HTML examples and add Node.js implementations for heat conduction simulations * Add front propagation matrix assembly to FEAScriptModel * Enhance front propagation matrix assembly and initiate Newton-Raphson method * Update parameters names and improve convergence logic in Newton-Raphson method * Add Euclidean norm function and update Newton-Raphson method to use it for error calculation * Update README files to clarify Node.js environment suitability for heat conduction examples * Integrate Newton-Raphson method into front propagation solver * Refactor Newton-Raphson method to accept matrix assembly function and context, enhancing front propagation solver with eikonal viscous term parameterization * Add a seperate linear system solver function (linearSystemScript.js). Refactor linearSystemScript.js and FEAScript.js to utilize it * Include error logging for unknown linear solver * Refactor Jacobi and Newton-Raphson methods to standardize solution vector naming * Fix import path for logging utilities in Newton-Raphson script * Add todo statements in frontPropagationScript.js * Improve Readability and Maintainability of meshGenerationScript.js (#28) * Redefining the mesh script as a Class * Deleting meshGeneration class and replacing it to the Mesh1D and Mesh2D classes * Replace meshGeneration class with the Mesh1D and Mesh2D classes * Fix non-capitalized class names * Rename variables for consistency * Create a new file for generic boundary condutions (genericBoundaryConditionsScript.js). Possible need to consolidate with thermalBoundaryConditionsScript.js in the future * Add residual and Jacobian terms for the eikonal equation * Refactor Jacobian determinant calculation * Update boundary condition handling to use 'constantValue' instead of 'constantTemp' * Refactor Newton-Raphson implementation and improve debug logging in boundary conditions * Enhance eikonal equation solver with initial solution handling and improve logging in boundary condition applications * Refactor eikonal equation parameters and update Newton-Raphson convergence tolerance; add helper function for system size calculation * - Reduce the number of incremental steps for the eikonal term activation in FEAScript.js from 10 to 5 - Reorganize the return statement in meshGenerationScript.js since it was causing an error in the case of linear elements - Update logging messages in newtonRaphsonScript.js - Increase the base viscous term in frontPropagationScript.js from 1e-3 to 1e-2 to prevent stability issues * Add Solidification Front 2D example * Fix markdown link formatting in SolidificationFront2D README --------- Co-authored-by: ferrari212 <felipe.ferrari.212@gmail.com>
1 parent 0f188d7 commit 1560d41

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptFrontPropagation.png" width="80" alt="FEAScript Logo">
2+
3+
## Solidification Front Propagation in a Two-Dimensional Domain
4+
5+
This example demonstrates solving an eikonal equation in a two-dimensional domain using the FEAScript library. The problem represents a typical solidification front propagation scenario, where the objective is to track the movement of an interface, such as in metal cooling or crystal growth processes.
6+
7+
### Instructions
8+
9+
This example requires the `feascript` npm package and its peer dependencies (`mathjs`). It imports FEAScript directly from the npm package and runs the simulation in a Node.js environment. To run the example, follow these instructions:
10+
11+
1. **Create package.json with ES module support:**
12+
13+
```bash
14+
echo '{"type":"module"}' > package.json
15+
```
16+
17+
2. **Install dependencies:**
18+
19+
```bash
20+
npm install feascript mathjs
21+
```
22+
23+
3. **Run the example:**
24+
25+
```bash
26+
node SolidificationFront2D.js
27+
```
28+
29+
**Note:** For detailed information on the model setup, boundary conditions, and simulation results, refer to the comments in the JavaScript files and the corresponding standard [tutorial](https://feascript.com/tutorials/SolidificationFront2D.html).
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ______ ______ _____ _ _ //
2+
// | ____| ____| /\ / ____| (_) | | //
3+
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
4+
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
5+
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
6+
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
7+
// | | | | //
8+
// |_| | |_ //
9+
// Website: https://feascript.com/ \__| //
10+
11+
// Import Math.js
12+
import * as math from "mathjs";
13+
global.math = math;
14+
15+
// Import FEAScript library
16+
import { FEAScriptModel, logSystem, VERSION } from "feascript";
17+
18+
console.log("FEAScript Version:", VERSION);
19+
20+
// Create a new FEAScript model
21+
const model = new FEAScriptModel();
22+
23+
// Set solver configuration for front propagation
24+
model.setSolverConfig("frontPropagationScript");
25+
26+
// Define mesh configuration
27+
model.setMeshConfig({
28+
meshDimension: "2D",
29+
elementOrder: "quadratic",
30+
numElementsX: 12,
31+
numElementsY: 8,
32+
maxX: 4,
33+
maxY: 2,
34+
});
35+
36+
// Define boundary conditions
37+
model.addBoundaryCondition("0", ["constantValue", 0]); // Bottom
38+
model.addBoundaryCondition("1", ["constantValue", 0]); // Left
39+
model.addBoundaryCondition("2", ["zeroGradient"]); // Top
40+
model.addBoundaryCondition("3", ["constantValue", 0]); // Right
41+
42+
// Set solver method (optional)
43+
model.setSolverMethod("lusolve");
44+
45+
// Solve the problem and get the solution
46+
const { solutionVector, nodesCoordinates } = model.solve();
47+
48+
// Print results to console
49+
console.log("Solution vector:", solutionVector);
50+
console.log("Node coordinates:", nodesCoordinates);
51+
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);

0 commit comments

Comments
 (0)