|
6 | 6 |
|
7 | 7 | > 🚧 **FEAScript is currently under heavy development.** Functionality and interfaces may change rapidly as new features and enhancements are introduced. 🚧
|
8 | 8 |
|
9 |
| -## Getting Started |
| 9 | +## Installation |
10 | 10 |
|
11 |
| -FEAScript is entirely implemented in pure JavaScript and requires only a simple HTML page to operate. All simulations are executed locally in your browser, without the need for any cloud services. |
| 11 | +FEAScript is entirely implemented in pure JavaScript and requires only a simple HTML page to operate. All simulations are executed locally in your browser, without the need for any cloud services. You can use FEAScript in your projects through one of the following methods: |
| 12 | + |
| 13 | +### Option 1: NPM Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +# Install FEAScript and its peer dependencies |
| 17 | +npm install feascript mathjs plotly.js |
| 18 | +``` |
| 19 | + |
| 20 | +Then import it in your JavaScript/TypeScript file: |
| 21 | + |
| 22 | +```javascript |
| 23 | +// ES Modules |
| 24 | +import { FEAScriptModel, plotSolution } from "feascript"; |
| 25 | + |
| 26 | +// CommonJS |
| 27 | +const { FEAScriptModel, plotSolution } = require("feascript"); |
| 28 | +``` |
| 29 | + |
| 30 | +**Important:** FEAScript is built as an ES module. If you're starting a new project, make sure to configure it to use ES modules by running: |
| 31 | + |
| 32 | +```bash |
| 33 | +# Create package.json with type=module for ES modules support |
| 34 | +echo '{"type":"module"}' > package.json |
| 35 | +``` |
| 36 | + |
| 37 | +If you already have a package.json file, manually add `"type": "module"` to enable ES modules in your project. |
| 38 | + |
| 39 | +### Option 2: Direct Import from CDN |
| 40 | + |
| 41 | +Add this line to your HTML or JavaScript module: |
| 42 | + |
| 43 | +```javascript |
| 44 | +import { FEAScriptModel, plotSolution } from "https://core.feascript.com/dist/feascript.umd.js"; |
| 45 | +``` |
| 46 | + |
| 47 | +### Option 3: Download and Use Locally |
| 48 | + |
| 49 | +1. Download the latest release from [GitHub Releases](https://github.com/FEAScript/FEAScript-core/releases) |
| 50 | +2. Include it in your project: |
| 51 | + |
| 52 | +```html |
| 53 | +<script type="module"> |
| 54 | + import { FEAScriptModel, plotSolution } from "./path/to/dist/feascript.esm.js"; |
| 55 | + // Your code here |
| 56 | +</script> |
| 57 | +``` |
12 | 58 |
|
13 | 59 | ### Example Usage
|
14 | 60 |
|
15 | 61 | ```javascript
|
16 | 62 | // Import FEAScript library
|
17 |
| -import { FEAScriptModel, plotSolution } from "https://core.feascript.com/src/index.js"; |
| 63 | +import { FEAScriptModel, plotSolution } from "https://core.feascript.com/dist/feascript.umd.js"; |
18 | 64 |
|
19 | 65 | // Create and configure model
|
20 | 66 | const model = new FEAScriptModel();
|
21 | 67 | model.setSolverConfig("solverType"); // e.g., "solidHeatTransfer" for a stationary solid heat transfer case
|
22 |
| -model.setMeshConfig({ // Define mesh configuration (assuming a rectangular domain for 2D) |
| 68 | +model.setMeshConfig({ |
| 69 | + // Define mesh configuration (assuming a rectangular domain for 2D) |
23 | 70 | meshDimension: "1D" | "2D", // Mesh dimension
|
24 | 71 | elementOrder: "linear" | "quadratic", // Element order
|
25 | 72 | numElementsX: number, // Number of elements in x-direction
|
|
0 commit comments