Run Structural FEA
run_feaUse this when you need to know whether a part will hold a load. Runs a linear-static structural study and returns evidence — peak von Mises stress (MPa), peak displacement (mm), the minimum safety factor against the material yield (taken away from the clamp-singular edges of the fixed faces; the raw clamp-edge peak is reported separately as peakAtSupportMPa), per-region hot spots named by @kc[...] face ref, mesh trust flags, an equilibrium residual, and (CalculiX only) stress-heatmap PNG paths.
The study is EITHER declared in the script with shape.feaStudy({ material, fixed, loads, meshSize?, minSafetyFactor? }) OR passed on the call against the shape the script returns: { code: 'return box(100, 20, 10);', material: 'aluminum-6061', fixed: { atX: 0 }, loads: [{ faces: { atX: 100 }, force: [0, 0, -200] }] }. Faces are a FaceQuery ({ atX | atY | atZ, byNormal: 'Z', ofSurfaceType, near: [x,y,z], ... }; with near it names the ONE matching face nearest the point), a face label ('top', 'bottom', 'left', 'right', 'front', 'back'; it must name ONE face — after a boolean 'top' can be several, which is an error listing them) or an @kc[...] ref. Force is the TOTAL [Fx, Fy, Fz] in N on those faces (a scalar force + direction is accepted). Materials: mild-steel, aluminum-6061, pla, petg, abs, nylon (aliases steel, aluminum), or { E, nu, yield } in MPa.
Solver (solver, default 'auto'): CalculiX + gmsh quadratic tets when that toolchain is installed; otherwise the built-in in-process voxel solver (8-node incompatible-mode bricks), which needs nothing installed and is marked summary.solver 'in-process-voxel' with trust.meshTrusted false — an estimate (accurate for prismatic bending, approximate at curved faces and notches), never a verified pass. solver: 'calculix' fails up front with fea.solver.unavailable and the install command when the toolchain is absent.
Also: study (a declared study name; default the last), output_dir (keeps the deck / summary JSON), mesh_size (mm, overrides the study for this run), heatmaps: false for a numbers-only run. CalculiX mesh refinement is automatic: when the stress is untrusted only because the solver's error estimate is high, it re-solves once at 0.75x the element size (inside the element budget), with summary.refinement listing each pass. refine: false solves once.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Inline kernelCAD script source (mutually exclusive with file). | |
| file | No | Path to a .kcad.ts script declaring at least one feaStudy. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. | |
| fixed | No | Inline study: faces held fixed — a FaceQuery like { atX: 0 }, a face label like 'bottom', or an @kc[...] ref. | |
| loads | No | Inline study: loads, each { faces, force: [Fx, Fy, Fz] } — total force in N on those faces. | |
| study | No | Name of the declared study to run; defaults to the last declared one. | |
| refine | No | One automatic finer pass (0.75x element size) when the stress is untrusted, inside the element budget (default true). false: one solve at mesh_size. | |
| solver | No | 'auto' (default): CalculiX when installed, else in-process. 'calculix': require it. 'in-process': always the built-in voxel solver. | |
| heatmaps | No | Render stress heatmap PNGs (default true). | |
| material | No | Inline study: material grade name (e.g. 'aluminum-6061') or { E, nu, yield } in MPa. | |
| mesh_size | No | Target element size in mm, overriding the study for this run. | |
| output_dir | No | Directory for the solver deck, results, summary JSON and heatmap PNGs. | |
| mesh_timeout_ms | No | Wall-clock budget for meshing (default 120000). | |
| solve_timeout_ms | No | Wall-clock budget for the solve (default 300000). | |
| min_safety_factor | No | Inline study: required minimum safety factor; below it the call fails with fea.safety-factor.below-min. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||