@rulecad/fea 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  What changed in each release, for someone upgrading a workspace.
4
4
 
5
+ ## 0.4.0: the stress of each cell is worked out by the one von Mises formula; frame sizing refuses a choice without a strength or section modulus, and frames refuse keys they do not know; needs Node 22.13 or later, the version the kit is tested on; frame sizing can give each design its own end springs; frame sizing names the members its stress limit could not check, and refuses options it does not use
6
+
7
+ ### Changed
8
+
9
+ - `stress()` now calls `vonMises()` rather than writing the same formula out again, so a fix to it is made in one
10
+ place. The figures are the same, except that a stress so small that rounding made the sum under the square root a
11
+ hair below zero now reads 0 rather than not-a-number. Two values the code never read are gone. No printed size
12
+ moves, and nothing a design or a check does changes.
13
+
14
+ - @rulecad/fea now states Node 22.13 or later in its `engines`, the same lowest Node as every rulecad package, and the
15
+ tests run on exactly Node 22.13.0 as well as the newest Node 24. Node 20 reached the end of its support on 30 April
16
+ 2026, and the kit's packages stated five different lowest versions, some of them too low: on Node 20.6 to 20.9 `cad`
17
+ stopped at start-up with "Unexpected token 'with'", and on Node 22.0 to 22.12 every `cad` command that runs a design
18
+ stops, because the sandbox designs run in cannot start there. npm gave no warning at install for either.
19
+
20
+ Upgrading: on a Node older than 22.13, npm now warns at install that this package needs Node 22.13; install Node 22.13
21
+ or later (24 recommended). Nothing else changes, and no printed size moves.
22
+
23
+ ### Fixed
24
+
25
+ - `sizing` with a stress limit passed over, without a word, any member whose material had no strength or whose section had no section modulus, and then called the lightest section good: a 5 mm bar at 96,000 MPa came back as meeting every limit. Now every choice a group may take is asked, before anything is solved, for a strength (its own material's, or the member's where it gives no material) and a section modulus (`cy` and `cz`, or `Wy` and `Wz`). One without is refused by name: `fea.frame.material` or `fea.frame.section`, with `choice` and `group`.
26
+ - `frame()`, `statics()`, `buckling()` and `modes()` took any key and ignored the ones they did not know, so `load:` for `loads:` gave a frame that did not move, which reads as perfectly stiff. A key that the model, an element, a load, `frame()`'s options or a solve's options do not have is now refused as `fea.frame.input`, naming the nearest key it has (`did you mean "loads"?`, and `suggest` on the error). `sizing` also refuses unknown keys in a load case (`cases`) and in a limit (`limits.stress`, `limits.buckling`, `limits.frequency`, each `limits.deflection`).
27
+
28
+ - `sizing(model, o)` with a stress limit passed over, without a word, every member outside the groups whose material
29
+ has no strength or whose section has no section modulus (so no stress is read in it): a join's rigid link, a
30
+ panel. The result read as if the whole frame had been held to the limit. It now returns `unchecked`, each such
31
+ member once (by the member its pieces came from) with why: `{ member: 'join 3', why: 'no strength and no section
32
+ modulus' }`. It is empty where every member was checked, and where there is no stress limit.
33
+ - `sizing` took an option, `bounds`, that nothing read: it is now refused by name, as any other option it does not
34
+ take.
35
+ - A choice's keys were never checked, so a misspelt `mass` (`mas`) was passed over and the choice weighed from its
36
+ density instead. A choice now takes `name`, `section`, `material`, `mass`, `cost` and `roll`, and may carry
37
+ `profile` and `title` for the caller's own use (`profileChoices` in @rulecad/frames gives both); any other key is
38
+ refused by name (`fea.frame.input`), with the nearest key it takes.
39
+
40
+ Upgrading: a call that passed `bounds`, or a choice with a key other than these, is now refused: take it out (it was
41
+ never read). Nothing else changes, and no printed size moves.
42
+
43
+ ### Added
44
+
45
+ - `statics(model, o)`, `buckling(model, o)` and `modes(model, o)` say in their types that they take the solve's own options (`loads`, `gravity`, `masses`, `samples`, `count`) beside `shear`, as they always did.
46
+ - A frame's material says in its types that it takes `strength` (MPa), which sizing's stress limit reads.
47
+
48
+ Upgrading: a call that passes a key a frame does not use, or misspells one, now gets an error where it got a result; take the key out or spell it as the error says. Sizing with a stress limit now refuses a choice without a strength or section modulus: give each one, or leave the stress limit out. Results that were right before do not change, and no printed size moves.
49
+
50
+ - `sizing(model, o)` takes `ends`: a function of a design (each group's choice by name) that gives the element end
51
+ springs that change with it, `{ [element id]: { a, b } }`. Each end given takes the place of the frame's own for
52
+ that design; the ends it leaves out are kept. A join's stiffness follows the size of the beams it joins, so a
53
+ frame of joined beams can now be sized with each section on its own join's spring rather than the drawn one's.
54
+ It is asked once a design, of the frame alone: the other frames in a model list (the same frame joined other
55
+ ways, its joins rigid) keep their ends. Refused by name (`fea.frame.input`): an `ends` that is not a function, or
56
+ that returns anything but `{ [element id]: { a, b } }` naming elements of the frame.
57
+
58
+ Upgrading: nothing changes for a call without `ends`. No printed size moves.
59
+
5
60
  ## 0.3.0: the stress at a part's surface, and a warning where the grid is too coarse to read it
6
61
 
7
62
  ### Added
package/README.md CHANGED
@@ -51,7 +51,8 @@ r.thin; // { share, cells }: how much of the part is in members under
51
51
  the stress concentrates there beyond what any grid settles on, so read it with care (a real part has a fillet).
52
52
  - **Stress at a point:** `centreStress(h, nu, dim)` is the matrix from a cell's movements to the stress at its centre
53
53
  (for Young's modulus 1), and `vonMises(s, dim, grad)` gives von Mises stress and, optionally, its gradient. Stress
54
- limits in @rulecad/topopt use both.
54
+ limits in @rulecad/topopt use both, so they read each cell at its centre, for the gradient (topopt's README says
55
+ why); the kit's strength checks read `surface`.
55
56
  - **Backends:** the few operations `cg` repeats (the stiffness product, its diagonal, dot products) sit behind a small
56
57
  interface. `jsBackend`, plain JavaScript in 64-bit floats, is the reference; a WebGPU or TensorFlow.js backend
57
58
  implements the same and passes `backend-suite.mjs` in this repository. The matrix is assembled in blocks (a node's
@@ -59,10 +60,10 @@ r.thin; // { share, cells }: how much of the part is in members under
59
60
  symmetric Gauss-Seidel through those blocks.
60
61
  - **Threads:** `import { threadsBackend } from '@rulecad/fea/threads'` (Node only) shares each product over the
61
62
  machine's cores (`FEA_THREADS` to say how many), the rest as `jsBackend`. On a 134,000-unknown grid a product takes
62
- 6.8 ms on seven threads against 19 ms on one, and an optimisation step about a third of the time. It needs Node 22
63
- or later: on Node 20 a product now and then came out wrong when the workers let go of an old operator's shared
64
- memory (a few solves in sixty, more with more threads, none on Node 22 or 24), so there it is plain JavaScript
65
- under another name (its `name` says so).
63
+ 6.8 ms on seven threads against 19 ms on one, and an optimisation step about a third of the time. On Node 20, below
64
+ the kit's floor, a product now and then came out wrong when the workers let go of an old operator's shared memory
65
+ (a few solves in sixty, more with more threads, none on Node 22 or 24), so there it is plain JavaScript under
66
+ another name (its `name` says so).
66
67
 
67
68
  Tested against beam theory with shear (Timoshenko's, `F L³ / 3 E I + F L / κ G A`): a cantilever's tip moves within
68
69
  1% of it in 2D at 10 cells through, and within 3% in 3D at 8, never more. The surface stress of a cantilever 4, 8 or
@@ -186,7 +187,13 @@ not above 0 (`fea.frame.section`), a material (`fea.frame.material`), an `up` al
186
187
  (`fea.frame.load`, `fea.frame.mass`), nothing held (`fea.frame.unheld`), a mechanism (`fea.frame.mechanism`, with
187
188
  `loose`: the freedoms nothing resists, by node), and buckling with nothing in compression
188
189
  (`fea.frame.compression`). A node that every element end is pinned to has rotations nothing turns: they are held
189
- still and reported as 0, and a moment put on one is refused.
190
+ still and reported as 0, and a moment put on one is refused. A key that the model, an element, a load, `frame()`'s
191
+ options or a solve's options do not have is refused too (`fea.frame.input`, with the nearest key it has as
192
+ `suggest`): `statics({ load: [...] })` for `loads` would otherwise solve the model's own loads, and a model with
193
+ `load` for `loads` would not move at all, which reads as a perfectly stiff frame. `frame()` takes `shear`;
194
+ `statics` takes `loads`, `gravity`, `masses` and `samples`; `buckling` `count`, `loads`, `gravity` and `masses`;
195
+ `modes` `count` and `masses`; and `statics(model, o)`, `buckling(model, o)` and `modes(model, o)` take `shear` as
196
+ well as their solve's.
190
197
 
191
198
  **Units.** mm, N, MPa, rad, N·mm; springs in N/mm and N·mm/rad; masses in kg, densities in g/cm³, gravity in N/kg;
192
199
  frequencies in Hz. In the modal solve stiffness is N/mm and mass kg. A newton is a kg·m/s² and lengths are mm, so
@@ -250,7 +257,7 @@ A braced box of 50 beams (108 unknowns) solves statically in about 3 ms on a lap
250
257
  posts) from a list, so the frame meets its limits for the least mass, or the least cost where every choice gives
251
258
  one. Each design is the same frame with its groups' sections, materials and rolls changed, solved under every load
252
259
  case. A frame of tubes from a layout optimiser and a frame of extrusions from an assembly go through the same solver
253
- and the same limits.
260
+ and the same limits. Any option it does not take is refused by name (`fea.frame.input`).
254
261
 
255
262
  ```js
256
263
  import { sizing } from '@rulecad/fea/frame';
@@ -272,11 +279,12 @@ r.groups[0]; // { name: 'legs', choice: 'bar 10', lighter: null, governs: null
272
279
  | Part | Shape | Notes |
273
280
  |---|---|---|
274
281
  | `groups` | `{ name: [members] }` | Each member an element's `id`, or the member its pieces came from (`of`). Members in no group keep their sections |
275
- | `choices` | `[{ name, section, material, mass, cost, roll }]` | `material` its own (the member's if left out), with `strength` in MPa for the stress limit; `mass` and `cost` per metre (mass from the area and density if left out); `roll` degrees added to the member's roll, the same section turned (a 20 x 40 on edge) |
282
+ | `choices` | `[{ name, section, material, mass, cost, roll }]` | `material` its own (the member's if left out), with `strength` in MPa for the stress limit; `mass` and `cost` per metre (mass from the area and density if left out); `roll` degrees added to the member's roll, the same section turned (a 20 x 40 on edge). A choice may also carry `profile` and `title` for the caller's own use (`profileChoices` gives both); any other key is refused by name (`fea.frame.input`), so a misspelt `mass` is not passed over |
276
283
  | `only` | `{ group: [choice names] }` | The choices a group may take (all of them if left out) |
277
284
  | `fits` | `(design) => [{ where, why }]` | Whether a design's choices go together, given each group's choice by name: what does not (a join between two groups that one's choice cannot make with the other's), empty where it fits. A design that does not fit is never solved |
285
+ | `ends` | `(design) => { [element id]: { a, b } }` | Each design's own end springs, given each group's choice by name: the element ends that change with it (a join's spring follows the size of the beams it joins), each end given in place of the frame's own, the rest kept. Asked once a design, for the frame alone: the others in a model list keep theirs |
278
286
  | `limits.deflection` | `[{ node, limit, along, cases }]` or `[{ member, limit, from, to, along, cases }]` | mm, along `along` (gravity's direction, else the whole movement); a member between two distances from its start; `cases` the load cases it holds in, by label (every case where left out) |
279
- | `limits.stress` | `{ margin }` | Each member's peak `abs(N)/A + abs(My)/Wy + abs(Mz)/Wz`, times the margin, under its material's strength |
287
+ | `limits.stress` | `{ margin }` | Each member's peak `abs(N)/A + abs(My)/Wy + abs(Mz)/Wz`, times the margin, under its material's strength. Every choice a group may take needs a strength (its own material's, or the member's where it has none) and a section modulus (`cy` and `cz`, or `Wy` and `Wz`): one without is refused by name before anything is solved (`fea.frame.material`, `fea.frame.section`), as its stress could not be read and the lightest section would come back as meeting the limit |
280
288
  | `limits.buckling` | `{ factor, euler }` | The whole frame's first buckling factor at least `factor` (members cut into `pieces`, 4); with `euler` (the effective length factor K) each grouped member in compression also carries `factor` times its force under `π² E I / (K L)²`, I the lesser second moment |
281
289
  | `limits.frequency` | `{ Hz }` | The lowest mode at least this |
282
290
  | `cases` | `[{ label, loads, masses, inertia, gravity, limits }]` | Load cases: `loads` and `masses` as `statics` takes them; `inertia` masses whose weight is already in `loads` and which ring in the modes only; `gravity` the case's own (`[0, 0, 0]` for a side push alone); `limits` the limits it is held to by name (every one where left out) |
@@ -299,11 +307,18 @@ with the others' (`fits` lists something), that set it: `governs` is `{ limit: '
299
307
  margin is its own members' nearest check. Where no design meets the limits, `ok` is
300
308
  false and the result is the design that came nearest, with `worst` saying which limit it breaks and by how much.
301
309
 
310
+ **What the stress limit could not check.** A member outside every group keeps its own section and material, and it
311
+ is held to the stress limit too where it can be. One whose material has no strength, or whose section has no section
312
+ modulus (so no stress is read in it: a join's rigid link, a panel), cannot be; it is not refused, but it is named in
313
+ `unchecked`, once each (by the member its pieces came from), with why: `{ member: 'join 3', why: 'no strength and no
314
+ section modulus' }`. It is empty where every member was checked, and where there is no stress limit.
315
+
302
316
  **Designs that fit.** With `fits`, only designs whose choices go together are solved: the steps start from the
303
317
  lightest design that fits, found lightest first. Where none of the list's designs fits, sizing is refused
304
318
  (`fea.frame.fit`, with the first thing that does not fit).
305
319
 
306
- **Limits of sizing.** The geometry stays as drawn: a deeper section moves no node, so joints that hang off a
320
+ **Limits of sizing.** The geometry stays as drawn: a deeper section moves no node (its end springs change only
321
+ through `ends`), so joints that hang off a
307
322
  member's face by its width keep their drawn offsets. The search is over the list given; it does not invent a section.
308
323
 
309
324
 
package/fea.d.mts CHANGED
@@ -93,7 +93,7 @@ export function surfaceStress(g: Grid, u: Float64Array, modulus: Float64Array, n
93
93
  * (fea.coarse-stress) for each load whose peak surface stress is in a member under 8 cells through. deflection: the
94
94
  * largest movement of any node in solid material, and where.
95
95
  */
96
- export function analyse({ grid: g, density, material, thickness, fixed, loads, penal, method, backend }: {
96
+ export function analyse({ grid: g, density, material, thickness, fixed, loads, penal, method, backend, }: {
97
97
  grid: Grid;
98
98
  density: Float64Array;
99
99
  material: Material;