@rulecad/fea 0.2.8 → 0.2.10
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/README.md +159 -1
- package/frame.d.mts +367 -0
- package/frame.mjs +660 -0
- package/package.json +14 -4
- package/threads.d.mts +9 -9
- package/threads.mjs +6 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ How far a part bends under load. Finite elements on a grid of cells, each with i
|
|
|
4
4
|
in their own plane (2D, plane stress, square cells) and solid parts (3D, cubes). Plain JavaScript in typed arrays, no dependencies: it runs in browsers
|
|
5
5
|
and Node alike. Units are millimetres and newtons, so Young's modulus is in MPa and movement in mm.
|
|
6
6
|
|
|
7
|
+
Frames of beams joined at nodes have their own solver, `@rulecad/fea/frame`: see [Frames of beams](#frames-of-beams).
|
|
8
|
+
|
|
7
9
|
```js
|
|
8
10
|
import { grid, analyse } from '@rulecad/fea';
|
|
9
11
|
|
|
@@ -42,7 +44,10 @@ r.thin; // { share, cells }: how much of the part is in members under
|
|
|
42
44
|
symmetric Gauss-Seidel through those blocks.
|
|
43
45
|
- **Threads:** `import { threadsBackend } from '@rulecad/fea/threads'` (Node only) shares each product over the
|
|
44
46
|
machine's cores (`FEA_THREADS` to say how many), the rest as `jsBackend`. On a 134,000-unknown grid a product takes
|
|
45
|
-
6.8 ms on seven threads against 19 ms on one, and an optimisation step about a third of the time.
|
|
47
|
+
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
|
|
48
|
+
or later: on Node 20 a product now and then came out wrong when the workers let go of an old operator's shared
|
|
49
|
+
memory (a few solves in sixty, more with more threads, none on Node 22 or 24), so there it is plain JavaScript
|
|
50
|
+
under another name (its `name` says so).
|
|
46
51
|
|
|
47
52
|
Tested against beam theory: a cantilever's tip moves within 1% of `F L³ / 3 E I` in 2D, and within 2% in 3D.
|
|
48
53
|
Multigrid is tested against the direct solver with stiffnesses a millionfold apart.
|
|
@@ -61,10 +66,163 @@ So give every member that bends at least four cells, and check a final shape on
|
|
|
61
66
|
stiffness moves by more than a few percent, the grid was too coarse. (Measured on cantilevers and a simply supported
|
|
62
67
|
beam, in 2D and 3D.)
|
|
63
68
|
|
|
69
|
+
## Frames of beams
|
|
70
|
+
|
|
71
|
+
`@rulecad/fea/frame` solves a frame as beams joined at nodes: how far it moves under load, what each beam carries,
|
|
72
|
+
the load at which it buckles and the frequencies it rings at. A frame of aluminium extrusion or tube would need
|
|
73
|
+
millions of cubes, nearly all of them empty; as beams it has a few hundred unknowns and solves in milliseconds, so a
|
|
74
|
+
machine's frame can be checked at every pose. It is its own entry of the package, with no dependencies, and runs in
|
|
75
|
+
browsers and Node alike.
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
import { frame, subdivide } from '@rulecad/fea/frame';
|
|
79
|
+
|
|
80
|
+
const model = {
|
|
81
|
+
nodes: { footA: [0, 0, 0], topA: [0, 0, 400], topB: [600, 0, 400], footB: [600, 0, 0] }, // mm
|
|
82
|
+
sections: { bar2020: { A: 400, Iy: 13333, Iz: 13333, J: 22500, Asy: 333, Asz: 333, cy: 10, cz: 10 } },
|
|
83
|
+
materials: { aluminium: { E: 69000, nu: 0.33, density: 2.7 } },
|
|
84
|
+
elements: [
|
|
85
|
+
{ id: 'legA', a: 'footA', b: 'topA', section: 'bar2020', material: 'aluminium' },
|
|
86
|
+
{ id: 'beam', a: 'topA', b: 'topB', section: 'bar2020', material: 'aluminium', ends: { a: { ry: 2e6, rz: 2e6 }, b: { ry: 2e6, rz: 2e6 } } },
|
|
87
|
+
{ id: 'legB', a: 'footB', b: 'topB', section: 'bar2020', material: 'aluminium' },
|
|
88
|
+
],
|
|
89
|
+
supports: { footA: 'fixed', footB: 'fixed' },
|
|
90
|
+
loads: [{ node: 'topA', force: [50, 0, 0] }, { element: 'beam', spread: [0, 0, -0.2] }],
|
|
91
|
+
gravity: [0, 0, -9.81],
|
|
92
|
+
masses: { topB: 1.5 },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const f = frame(model); // read, checked and factorised once
|
|
96
|
+
const s = f.statics();
|
|
97
|
+
s.displacements.topA; // [x, y, z, rx, ry, rz]: 0.40 mm sideways
|
|
98
|
+
s.reactions.footA; // the force (N) and moment (N·mm) the support gives the frame
|
|
99
|
+
s.elements[1].peak.My; // { value, x }: the beam's largest moment about its own y, and where along it
|
|
100
|
+
s.elements[1].stress.peak; // 5.6 MPa
|
|
101
|
+
const fine = frame(subdivide(model, 4)); // every member in four pieces, for buckling and modes
|
|
102
|
+
fine.buckling().factors[0]; // 181: the loads times this buckle the frame
|
|
103
|
+
fine.modes({ count: 3 }).frequencies; // [26.7, 36.6, 66.9] Hz
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**The model** is plain data, so an assembly can write it and a file can hold it.
|
|
107
|
+
|
|
108
|
+
| Part | Shape | Notes |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `nodes` | `{ name: [x, y, z] }`, or a list of positions named by place | mm |
|
|
111
|
+
| `elements` | `[{ id, a, b, section, material, roll, up, ends }]` | From node `a` to node `b`. `section` and `material` are objects, or names in the model's `sections` and `materials` |
|
|
112
|
+
| a section | `{ A, Iy, Iz, J, Asy, Asz, cy, cz }` | Area (mm²); second moments about the element's own y and z, and the torsion constant (mm⁴); shear areas (mm², leave out for no shear deformation); the distances to the furthest fibre along y and z (mm), or the section moduli `Wy` and `Wz` (mm³), for stress |
|
|
113
|
+
| a material | `{ E, nu, density }` | MPa; Poisson's ratio (or `G` in MPa); g/cm³, as the kit's material rule sets give it |
|
|
114
|
+
| `ends` | `{ a, b }`, each `'rigid'`, `'pinned'`, `'ball'` or `{ rx, ry, rz }` | How each end is joined to its node: each rotation `'rigid'`, `'free'`, or a spring's stiffness in N·mm/rad, about the element's own axes. `'pinned'` frees both bending rotations and still carries twist; `'ball'` frees all three |
|
|
115
|
+
| `supports` | `{ node: 'fixed' }`, `'pinned'`, or `{ x, y, z, rx, ry, rz }` | Each freedom `true` (held), left out (free), or a spring to ground in N/mm or N·mm/rad |
|
|
116
|
+
| `loads` | `{ node, force, moment }` or `{ element, spread, axes }` | N and N·mm in global axes; a spread load is N per mm of the element's length, in `'global'` axes or the element's `'local'` ones |
|
|
117
|
+
| `gravity` | `[0, 0, -9.81]` | N/kg, the same number as m/s². It acts on every element's mass and every lumped mass |
|
|
118
|
+
| `masses` | `{ node: kg }` | Lumped masses: weight under gravity, inertia in modes |
|
|
119
|
+
|
|
120
|
+
**An element's own axes.** x runs from `a` to `b`. z is the part of `up` square to the element, and `up` is global
|
|
121
|
+
+Z unless the element gives another (for an element along Z it is global +X). y = z × x. `roll`, in degrees, then
|
|
122
|
+
turns y and z about x. `Iy` resists bending that moves the beam along its z, `Iz` along its y. Every element's
|
|
123
|
+
result carries its `axes`, so nothing has to be guessed.
|
|
124
|
+
|
|
125
|
+
**What each solve returns.**
|
|
126
|
+
|
|
127
|
+
- `frame(model, { shear })` reads and checks the model, assembles and factorises it, and returns `{ statics,
|
|
128
|
+
buckling, modes, freedoms, nodes }`. `shear: false` ignores the shear areas. `statics(model)`, `buckling(model)`
|
|
129
|
+
and `modes(model)` do it in one call.
|
|
130
|
+
- `statics({ loads, gravity, masses, samples })`: `displacements` and `reactions` by node, each `[x, y, z, rx, ry,
|
|
131
|
+
rz]` in global axes; `deflection: { most, node }`; and `elements`, each with its `length`, `axes`, the `ends`
|
|
132
|
+
forces its nodes put on it (local axes), `axial` (its mean axial force, tension positive), and `along`: at each
|
|
133
|
+
station `x`, the axial force `N`, shears `Vy` and `Vz`, torque `T`, moments `My` and `Mz`, and the movement `d`
|
|
134
|
+
in global axes. The stations are `samples` evenly spaced (11) plus the points where each moment peaks, so `peak`
|
|
135
|
+
(each quantity's largest value and where) is exact for the loads supported. `stress` is the largest
|
|
136
|
+
`|N|/A + |My|/Wy + |Mz|/Wz` along the element, in MPa, where it is, and the bending part alone. Given other
|
|
137
|
+
loads, it solves another load case on the same factorisation.
|
|
138
|
+
- `buckling({ count })`: `factors`, lowest first, and `modes`, each `{ factor, shape }`: the loads times the factor
|
|
139
|
+
buckle the frame into the shape (by node, largest movement 1). `statics` is the solve it came from. The first
|
|
140
|
+
factor is always quick; more of them cost more when slender members are in tension.
|
|
141
|
+
- `modes({ count })`: `frequencies` in Hz, lowest first, and `modes`, each `{ frequency, shape }`.
|
|
142
|
+
- `subdivide(model, pieces)` cuts every element into equal pieces. One element cannot bow between its own ends, so
|
|
143
|
+
buckling and modes want members in pieces: a pinned column's Euler load is 22% out with one element, 0.8% with
|
|
144
|
+
two and 0.05% with four. Statics is exact with one.
|
|
145
|
+
|
|
146
|
+
**Refusals.** What is wrong with a model is said by name before any solve, as an `Error` with a `code`: a node
|
|
147
|
+
that does not exist (`fea.frame.node`), an element of no length (`fea.frame.length`), a section property that is
|
|
148
|
+
not above 0 (`fea.frame.section`), a material (`fea.frame.material`), an `up` along the element
|
|
149
|
+
(`fea.frame.axes`), a joint or support it cannot read (`fea.frame.join`, `fea.frame.support`), a load or mass
|
|
150
|
+
(`fea.frame.load`, `fea.frame.mass`), nothing held (`fea.frame.unheld`), a mechanism (`fea.frame.mechanism`, with
|
|
151
|
+
`loose`: the freedoms nothing resists, by node), and buckling with nothing in compression
|
|
152
|
+
(`fea.frame.compression`). A node that every element end is pinned to has rotations nothing turns: they are held
|
|
153
|
+
still and reported as 0, and a moment put on one is refused.
|
|
154
|
+
|
|
155
|
+
**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;
|
|
156
|
+
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
|
|
157
|
+
N/mm ÷ kg = 1000 s⁻²: the frequency is `√(1000 λ) / 2π`, with λ the eigenvalue of the stiffness against the mass
|
|
158
|
+
in kg. A test holds this against the textbook formula worked in SI units.
|
|
159
|
+
|
|
160
|
+
**Formulas.** Each bending plane of an element has the freedoms `[v1, θ1, v2, θ2]`, with L its length and ξ = x/L.
|
|
161
|
+
|
|
162
|
+
| What | Formula | Source |
|
|
163
|
+
|---|---|---|
|
|
164
|
+
| Shear parameter | `Φ = 12 E I / (G As L²)`, one for each bending plane; 0 with no shear area, which is Euler-Bernoulli's beam | Przemieniecki, eq. 5.116 |
|
|
165
|
+
| Bending stiffness | `E I / ((1 + Φ) L³) × [[12, 6L, −12, 6L], [6L, (4 + Φ) L², −6L, (2 − Φ) L²], [−12, −6L, 12, −6L], [6L, (2 − Φ) L², −6L, (4 + Φ) L²]]` | Przemieniecki, eq. 5.116 |
|
|
166
|
+
| Stretch and twist | `(E A / L) × [[1, −1], [−1, 1]]` and `(G J / L) × [[1, −1], [−1, 1]]` | Przemieniecki, chapter 5 |
|
|
167
|
+
| Shape functions | Deflection `N = [2ξ³ − 3ξ² − Φξ + 1 + Φ, L (ξ³ − (2 + Φ/2) ξ² + (1 + Φ/2) ξ), −(2ξ³ − 3ξ² − Φξ), L (ξ³ − (1 − Φ/2) ξ² − (Φ/2) ξ)] / (1 + Φ)`; the section's rotation `R = [6 (ξ² − ξ) / L, 3ξ² − (4 + Φ) ξ + 1 + Φ, −6 (ξ² − ξ) / L, 3ξ² − (2 − Φ) ξ] / (1 + Φ)` | Friedman and Kosmatka |
|
|
168
|
+
| Geometric stiffness | `P ∫ N′ᵀ N′ dx` for an axial force P, tension positive. With Φ = 0: `(P / 30 L) × [[36, 3L, −36, 3L], [3L, 4L², −3L, −L²], [−36, −3L, 36, −3L], [3L, −L², −3L, 4L²]]` | McGuire, Gallagher and Ziemian, chapter 9; Cook et al. |
|
|
169
|
+
| Consistent mass | `ρ A ∫ Nᵀ N dx + ρ I ∫ Rᵀ R dx` (the second term is rotary inertia). With Φ = 0 the first is `(ρ A L / 420) × [[156, 22L, 54, −13L], [22L, 4L², 13L, −3L²], [54, 13L, 156, −22L], [−13L, −3L², −22L, 4L²]]`; stretch and twist are `(ρ A L / 6) × [[2, 1], [1, 2]]` and the same with `Iy + Iz` for A | Przemieniecki, chapter 11; Cook et al. |
|
|
170
|
+
| A spread load w | End forces `w L / 2` and end moments `± w L² / 12`; the deflection between the ends adds `w x² (L − x)² / 24 E I + w x (L − x) / 2 G As` | Roark's, table 8.1 |
|
|
171
|
+
| A spring k or a release (k = 0) at an end | With s the sprung rotations: `K − K_s (K_ss + k)⁻¹ K_sᵀ`, and loads `f − K_s (K_ss + k)⁻¹ f_s`. Exact, and nothing is subtracted from a large number however stiff the spring | Static condensation: Cook et al.; member releases and semi-rigid joints: McGuire, Gallagher and Ziemian |
|
|
172
|
+
| Mass and geometric stiffness behind a spring or release | `Tᵀ M T` with `T = I − E_s (K_ss + k)⁻¹ K_sᵀ`: the beam's end follows its nodes as it would at rest | Guyan |
|
|
173
|
+
| Buckling | `(K + λ Kg) φ = 0`, Kg from each element's mean axial force in the static solve | McGuire, Gallagher and Ziemian, chapter 9 |
|
|
174
|
+
| Modes | `K φ = ω² M φ`, frequency `ω / 2π` | Przemieniecki, chapter 12; Bathe, chapter 11 (subspace iteration) |
|
|
175
|
+
| Forces along an element | From the forces F on end a and the spread load w: `N = −(Fx + wx x)`, `Vy = −(Fy + wy x)`, `My = −(My_a + Fz x + wz x² / 2)`, `Mz = −Mz_a + Fy x + wy x² / 2`: the part of the beam beyond x acting on the part before it | Statics |
|
|
176
|
+
| Stress | `abs(N) / A + abs(My) / Wy + abs(Mz) / Wz`, with `Wy = Iy / cz` and `Wz = Iz / cy` | Roark's, chapter 8 |
|
|
177
|
+
|
|
178
|
+
The matrix is stored row by row from each row's first non-zero to its diagonal, with the nodes ordered to keep
|
|
179
|
+
rows short (reverse Cuthill-McKee), and factorised by Cholesky. Buckling and modes use subspace iteration with the
|
|
180
|
+
small problems solved by Jacobi rotations; buckling first brackets its lowest factor between a shift that
|
|
181
|
+
factorises and one that does not, so factors of the loads reversed are never taken for it.
|
|
182
|
+
|
|
183
|
+
**Tested** against closed forms, each within 1%, most to rounding: a cantilever's tip deflection and rotation
|
|
184
|
+
with and without shear; a simply supported and a fixed-fixed beam under a spread load; a portal frame's sway and
|
|
185
|
+
foot moments by slope-deflection; a bar's twist; Euler's load for pinned-pinned and fixed-free columns (0.003% with
|
|
186
|
+
eight elements), and Engesser's with shear; the first frequencies of a cantilever and a simply supported beam
|
|
187
|
+
(0.02% and 0.04%); a heavy tip mass as one mass on a spring; a cantilever on a sprung joint, `P L³ / 3 E I + P L²
|
|
188
|
+
/ k`, a stiff spring against rigid and a soft one against pinned; the same cantilever along every axis and rolled;
|
|
189
|
+
a two-bar truss. Against this package's voxel solver on a cantilever three times as long as deep, the tip agrees
|
|
190
|
+
within 2.7% (the voxels are the stiffer: eight cubes through the depth, and a root clamped over its whole face).
|
|
191
|
+
A braced box of 50 beams (108 unknowns) solves statically in about 3 ms on a laptop.
|
|
192
|
+
|
|
193
|
+
**Limits.**
|
|
194
|
+
|
|
195
|
+
- Linear and small-displacement: stiffness does not change as the frame moves, and buckling is the linear
|
|
196
|
+
(eigenvalue) kind, an upper bound on what a real, imperfect frame carries.
|
|
197
|
+
- Prismatic, straight members joined at their centroids: no tapers, no curved members, no offsets or rigid ends at
|
|
198
|
+
joints.
|
|
199
|
+
- Torsion is St Venant's only: no warping stiffness, so an open thin-walled section twists more here than it
|
|
200
|
+
would. No shear lag.
|
|
201
|
+
- Buckling is by bending under axial force: no torsional or lateral-torsional buckling, and bending moments do not
|
|
202
|
+
enter the geometric stiffness.
|
|
203
|
+
- Joint springs are rotational and linear, at element ends; a joint's play, slip and preload are outside it.
|
|
204
|
+
- Stress is axial plus bending at the extreme corner, right for rectangular sections and extrusions and on the
|
|
205
|
+
safe side for round ones; shear and torsion stresses are left out, as is anything local to a joint or a hole.
|
|
206
|
+
- Loads spread along an element are even along it; a load part-way along needs a node there. No temperature loads
|
|
207
|
+
and no moved supports.
|
|
208
|
+
- Behind a spring or a release, mass and geometric stiffness are reduced as at rest (Guyan's reduction), which
|
|
209
|
+
is why buckling and modes want members cut into pieces.
|
|
210
|
+
|
|
64
211
|
## Sources
|
|
65
212
|
|
|
66
213
|
- Amir, Aage, Lazarov (2014). On multigrid-CG for efficient topology optimization. *Structural and Multidisciplinary
|
|
67
214
|
Optimization* 49, 815–829.
|
|
68
215
|
- Andreassen, Clausen, Schevenels, Lazarov, Sigmund (2011). Efficient topology optimization in MATLAB using 88 lines
|
|
69
216
|
of code. *Structural and Multidisciplinary Optimization* 43, 1–16.
|
|
217
|
+
- Bathe (2014). *Finite Element Procedures*, 2nd ed. K. J. Bathe, Watertown.
|
|
218
|
+
- Blevins (1979). *Formulas for Natural Frequency and Mode Shape*. Van Nostrand Reinhold.
|
|
70
219
|
- Cook, Malkus, Plesha, Witt (2002). *Concepts and Applications of Finite Element Analysis*, 4th ed. Wiley.
|
|
220
|
+
- Cuthill, McKee (1969). Reducing the bandwidth of sparse symmetric matrices. *Proceedings of the 24th National
|
|
221
|
+
Conference of the ACM*, 157–172.
|
|
222
|
+
- Friedman, Kosmatka (1993). An improved two-node Timoshenko beam finite element. *Computers and Structures* 47,
|
|
223
|
+
473–481.
|
|
224
|
+
- Guyan (1965). Reduction of stiffness and mass matrices. *AIAA Journal* 3, 380.
|
|
225
|
+
- McGuire, Gallagher, Ziemian (2000). *Matrix Structural Analysis*, 2nd ed. Wiley.
|
|
226
|
+
- Przemieniecki (1968). *Theory of Matrix Structural Analysis*. McGraw-Hill.
|
|
227
|
+
- Timoshenko, Gere (1961). *Theory of Elastic Stability*, 2nd ed. McGraw-Hill.
|
|
228
|
+
- Young, Budynas (2002). *Roark's Formulas for Stress and Strain*, 7th ed. McGraw-Hill.
|
package/frame.d.mts
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One beam element's matrices in its own axes, both ends rigid: 12 × 12, row by row, for [u, v, w, θx, θy, θz] at its
|
|
3
|
+
* start then its end. `k` is its stiffness (N/mm, N, N·mm), `kg` its geometric stiffness for a tension of 1 N, and
|
|
4
|
+
* `m` its consistent mass in kg (kg·mm for the cross terms, kg·mm² for rotations), with rotary inertia.
|
|
5
|
+
* @param {FrameSection} section @param {FrameMaterial} material @param {number} L length, mm
|
|
6
|
+
* @param {{ shear?: boolean }} [o] shear: false ignores the shear areas (Euler-Bernoulli)
|
|
7
|
+
* @returns {{ k: Float64Array, kg: Float64Array, m: Float64Array, phi: [number, number] }} phi: the shear parameters
|
|
8
|
+
* 12 E Iz / (G Asy L²) and 12 E Iy / (G Asz L²)
|
|
9
|
+
*/
|
|
10
|
+
export function elementMatrices(section: FrameSection, material: FrameMaterial, L: number, { shear }?: {
|
|
11
|
+
shear?: boolean;
|
|
12
|
+
}): {
|
|
13
|
+
k: Float64Array;
|
|
14
|
+
kg: Float64Array;
|
|
15
|
+
m: Float64Array;
|
|
16
|
+
phi: [number, number];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A frame, read, checked and factorised once, ready for its solves. What is wrong with the model is said here, by
|
|
20
|
+
* name, before any solve: each refusal is an Error with a `code` ("fea.frame." then node, length, section, material,
|
|
21
|
+
* axes, join, support, load, mass, input, unheld or mechanism; buckling adds compression).
|
|
22
|
+
* @param {FrameModel} model
|
|
23
|
+
* @param {{ shear?: boolean }} [o] shear: false ignores the sections' shear areas (Euler-Bernoulli beams)
|
|
24
|
+
* @returns {{
|
|
25
|
+
* statics: (o?: { loads?: FrameLoad[], gravity?: Vec3, masses?: Record<string, number>, samples?: number }) => StaticResult,
|
|
26
|
+
* buckling: (o?: { count?: number, loads?: FrameLoad[], gravity?: Vec3, masses?: Record<string, number> }) => { factors: number[], modes: BucklingMode[], statics: StaticResult },
|
|
27
|
+
* modes: (o?: { count?: number, masses?: Record<string, number> }) => { frequencies: number[], modes: VibrationMode[] },
|
|
28
|
+
* freedoms: number, nodes: string[] }}
|
|
29
|
+
* statics, buckling and modes use the model's own loads, gravity and masses unless given others (another load case
|
|
30
|
+
* on the same factorisation). samples: stations along each element (11). count: how many modes (1 for buckling, 6
|
|
31
|
+
* for vibration; fewer come back if the frame has fewer). freedoms: how many unknowns were solved for.
|
|
32
|
+
*/
|
|
33
|
+
export function frame(model: FrameModel, o?: {
|
|
34
|
+
shear?: boolean;
|
|
35
|
+
}): {
|
|
36
|
+
statics: (o?: {
|
|
37
|
+
loads?: FrameLoad[];
|
|
38
|
+
gravity?: Vec3;
|
|
39
|
+
masses?: Record<string, number>;
|
|
40
|
+
samples?: number;
|
|
41
|
+
}) => StaticResult;
|
|
42
|
+
buckling: (o?: {
|
|
43
|
+
count?: number;
|
|
44
|
+
loads?: FrameLoad[];
|
|
45
|
+
gravity?: Vec3;
|
|
46
|
+
masses?: Record<string, number>;
|
|
47
|
+
}) => {
|
|
48
|
+
factors: number[];
|
|
49
|
+
modes: BucklingMode[];
|
|
50
|
+
statics: StaticResult;
|
|
51
|
+
};
|
|
52
|
+
modes: (o?: {
|
|
53
|
+
count?: number;
|
|
54
|
+
masses?: Record<string, number>;
|
|
55
|
+
}) => {
|
|
56
|
+
frequencies: number[];
|
|
57
|
+
modes: VibrationMode[];
|
|
58
|
+
};
|
|
59
|
+
freedoms: number;
|
|
60
|
+
nodes: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The same frame with every element cut into `pieces` equal lengths, for buckling and modes: one element cannot bow
|
|
64
|
+
* between its own ends, so a column's Euler load is 22% out with one element, 0.8% with two and 0.05% with four. New
|
|
65
|
+
* nodes are named "<element>/<k>" (or added to the end of a list of nodes), new elements "<element>/<k>" with `of`
|
|
66
|
+
* naming the element they came from; end joints stay at the member's own ends, and spread loads follow their pieces.
|
|
67
|
+
* @param {FrameModel} model @param {number} [pieces] 4
|
|
68
|
+
* @returns {FrameModel}
|
|
69
|
+
*/
|
|
70
|
+
export function subdivide(model: FrameModel, pieces?: number): FrameModel;
|
|
71
|
+
export function statics(model: FrameModel, o?: {
|
|
72
|
+
shear?: boolean;
|
|
73
|
+
samples?: number;
|
|
74
|
+
}): StaticResult;
|
|
75
|
+
export function buckling(model: FrameModel, o?: {
|
|
76
|
+
shear?: boolean;
|
|
77
|
+
count?: number;
|
|
78
|
+
}): {
|
|
79
|
+
factors: number[];
|
|
80
|
+
modes: BucklingMode[];
|
|
81
|
+
statics: StaticResult;
|
|
82
|
+
};
|
|
83
|
+
export function modes(model: FrameModel, o?: {
|
|
84
|
+
shear?: boolean;
|
|
85
|
+
count?: number;
|
|
86
|
+
}): {
|
|
87
|
+
frequencies: number[];
|
|
88
|
+
modes: VibrationMode[];
|
|
89
|
+
};
|
|
90
|
+
export type Vec3 = [number, number, number];
|
|
91
|
+
/**
|
|
92
|
+
* A beam's cross-section, in its local axes
|
|
93
|
+
*/
|
|
94
|
+
export type FrameSection = {
|
|
95
|
+
/**
|
|
96
|
+
* area, mm²
|
|
97
|
+
*/
|
|
98
|
+
A: number;
|
|
99
|
+
/**
|
|
100
|
+
* second moment about local y, mm⁴ (bending that moves the beam along local z)
|
|
101
|
+
*/
|
|
102
|
+
Iy: number;
|
|
103
|
+
/**
|
|
104
|
+
* second moment about local z, mm⁴ (bending that moves the beam along local y)
|
|
105
|
+
*/
|
|
106
|
+
Iz: number;
|
|
107
|
+
/**
|
|
108
|
+
* torsion constant, mm⁴
|
|
109
|
+
*/
|
|
110
|
+
J: number;
|
|
111
|
+
/**
|
|
112
|
+
* shear area for shear along local y, mm² (left out: no shear deformation that way)
|
|
113
|
+
*/
|
|
114
|
+
Asy?: number;
|
|
115
|
+
/**
|
|
116
|
+
* shear area for shear along local z, mm²
|
|
117
|
+
*/
|
|
118
|
+
Asz?: number;
|
|
119
|
+
/**
|
|
120
|
+
* distance from the centroid to the furthest fibre along local y, mm (for stress)
|
|
121
|
+
*/
|
|
122
|
+
cy?: number;
|
|
123
|
+
/**
|
|
124
|
+
* distance to the furthest fibre along local z, mm
|
|
125
|
+
*/
|
|
126
|
+
cz?: number;
|
|
127
|
+
/**
|
|
128
|
+
* section modulus for bending about y, mm³ (Iy / cz, if cz is not given)
|
|
129
|
+
*/
|
|
130
|
+
Wy?: number;
|
|
131
|
+
/**
|
|
132
|
+
* section modulus for bending about z, mm³ (Iz / cy)
|
|
133
|
+
*/
|
|
134
|
+
Wz?: number;
|
|
135
|
+
};
|
|
136
|
+
export type FrameMaterial = {
|
|
137
|
+
/**
|
|
138
|
+
* Young's modulus, MPa
|
|
139
|
+
*/
|
|
140
|
+
E: number;
|
|
141
|
+
/**
|
|
142
|
+
* shear modulus, MPa (or give nu)
|
|
143
|
+
*/
|
|
144
|
+
G?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Poisson's ratio, for G = E / 2(1 + nu)
|
|
147
|
+
*/
|
|
148
|
+
nu?: number;
|
|
149
|
+
/**
|
|
150
|
+
* g/cm³ (for gravity and modes; left out: weightless)
|
|
151
|
+
*/
|
|
152
|
+
density?: number;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* how one rotation at an element's end is joined to its node: rigidly, not at all (a hinge), or through a spring of that many N·mm/rad
|
|
156
|
+
*/
|
|
157
|
+
export type Fixity = "rigid" | "free" | number;
|
|
158
|
+
/**
|
|
159
|
+
* 'pinned' frees both bending rotations (ry, rz) and carries twist; 'ball' frees all three; or say each, about the element's local axes
|
|
160
|
+
*/
|
|
161
|
+
export type EndJoin = "rigid" | "pinned" | "ball" | {
|
|
162
|
+
rx?: Fixity;
|
|
163
|
+
ry?: Fixity;
|
|
164
|
+
rz?: Fixity;
|
|
165
|
+
};
|
|
166
|
+
export type FrameElement = {
|
|
167
|
+
/**
|
|
168
|
+
* its name in the results (its place in the list if left out)
|
|
169
|
+
*/
|
|
170
|
+
id?: string | number;
|
|
171
|
+
/**
|
|
172
|
+
* the node it starts at
|
|
173
|
+
*/
|
|
174
|
+
a: string | number;
|
|
175
|
+
/**
|
|
176
|
+
* the node it ends at
|
|
177
|
+
*/
|
|
178
|
+
b: string | number;
|
|
179
|
+
/**
|
|
180
|
+
* the section, or its name in the model's `sections`
|
|
181
|
+
*/
|
|
182
|
+
section: FrameSection | string;
|
|
183
|
+
/**
|
|
184
|
+
* the material, or its name in the model's `materials`
|
|
185
|
+
*/
|
|
186
|
+
material: FrameMaterial | string;
|
|
187
|
+
/**
|
|
188
|
+
* degrees about its own axis, turning local y towards local z
|
|
189
|
+
*/
|
|
190
|
+
roll?: number;
|
|
191
|
+
/**
|
|
192
|
+
* the direction local z leans towards (global +Z, or +X for an element along Z)
|
|
193
|
+
*/
|
|
194
|
+
up?: Vec3;
|
|
195
|
+
/**
|
|
196
|
+
* how each end is joined to its node ('rigid' if left out)
|
|
197
|
+
*/
|
|
198
|
+
ends?: {
|
|
199
|
+
a?: EndJoin;
|
|
200
|
+
b?: EndJoin;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* the member this is a piece of (set by `subdivide`, handed back in the results)
|
|
204
|
+
*/
|
|
205
|
+
of?: string | number;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* one freedom of a support: held (true), free, or a spring to ground of that many N/mm (movements) or N·mm/rad (rotations)
|
|
209
|
+
*/
|
|
210
|
+
export type Hold = boolean | number | "fixed" | "free";
|
|
211
|
+
/**
|
|
212
|
+
* 'fixed' holds all six freedoms, 'pinned' the three movements
|
|
213
|
+
*/
|
|
214
|
+
export type FrameSupport = "fixed" | "pinned" | {
|
|
215
|
+
x?: Hold;
|
|
216
|
+
y?: Hold;
|
|
217
|
+
z?: Hold;
|
|
218
|
+
rx?: Hold;
|
|
219
|
+
ry?: Hold;
|
|
220
|
+
rz?: Hold;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* a force (N) and moment (N·mm) at a node, in global axes; or a load spread evenly along an element, N per mm of its length, in global axes or its own
|
|
224
|
+
*/
|
|
225
|
+
export type FrameLoad = {
|
|
226
|
+
node: string | number;
|
|
227
|
+
force?: Vec3;
|
|
228
|
+
moment?: Vec3;
|
|
229
|
+
} | {
|
|
230
|
+
element: string | number;
|
|
231
|
+
spread: Vec3;
|
|
232
|
+
axes?: "global" | "local";
|
|
233
|
+
};
|
|
234
|
+
export type FrameModel = {
|
|
235
|
+
/**
|
|
236
|
+
* each node's position in mm, by name (or a list, named by place: 0, 1, ...)
|
|
237
|
+
*/
|
|
238
|
+
nodes: Record<string, Vec3> | Vec3[];
|
|
239
|
+
elements: FrameElement[];
|
|
240
|
+
/**
|
|
241
|
+
* sections by name
|
|
242
|
+
*/
|
|
243
|
+
sections?: Record<string, FrameSection>;
|
|
244
|
+
/**
|
|
245
|
+
* materials by name
|
|
246
|
+
*/
|
|
247
|
+
materials?: Record<string, FrameMaterial>;
|
|
248
|
+
/**
|
|
249
|
+
* by node
|
|
250
|
+
*/
|
|
251
|
+
supports: Record<string, FrameSupport>;
|
|
252
|
+
loads?: FrameLoad[];
|
|
253
|
+
/**
|
|
254
|
+
* N/kg (m/s²), acting on every element's mass and every lumped mass: [0, 0, -9.81]
|
|
255
|
+
*/
|
|
256
|
+
gravity?: Vec3;
|
|
257
|
+
/**
|
|
258
|
+
* lumped masses by node, kg (weight under gravity, and inertia in modes)
|
|
259
|
+
*/
|
|
260
|
+
masses?: Record<string, number>;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* x, y, z, then about x, y, z
|
|
264
|
+
*/
|
|
265
|
+
export type Six = [number, number, number, number, number, number];
|
|
266
|
+
export type ElementResult = {
|
|
267
|
+
id: string | number;
|
|
268
|
+
/**
|
|
269
|
+
* the member it is a piece of, when the model came from `subdivide`
|
|
270
|
+
*/
|
|
271
|
+
of?: string | number;
|
|
272
|
+
/**
|
|
273
|
+
* mm
|
|
274
|
+
*/
|
|
275
|
+
length: number;
|
|
276
|
+
/**
|
|
277
|
+
* its local x, y and z in global axes
|
|
278
|
+
*/
|
|
279
|
+
axes: [Vec3, Vec3, Vec3];
|
|
280
|
+
/**
|
|
281
|
+
* the forces (N) and moments (N·mm) its nodes put on each end, in local axes
|
|
282
|
+
*/
|
|
283
|
+
ends: {
|
|
284
|
+
a: Six;
|
|
285
|
+
b: Six;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* at each station x (mm from a): axial force (tension positive), shear along local y and z, torque, bending moments
|
|
289
|
+
* about local y and z (each as the part of the beam beyond x acts on the part before it, so at b they are the end
|
|
290
|
+
* forces), and the movement there in global axes (mm). The stations are evenly spaced, plus where each moment peaks.
|
|
291
|
+
*/
|
|
292
|
+
along: {
|
|
293
|
+
x: number[];
|
|
294
|
+
N: number[];
|
|
295
|
+
Vy: number[];
|
|
296
|
+
Vz: number[];
|
|
297
|
+
T: number[];
|
|
298
|
+
My: number[];
|
|
299
|
+
Mz: number[];
|
|
300
|
+
d: Vec3[];
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* each one's largest value by size, signed, and where
|
|
304
|
+
*/
|
|
305
|
+
peak: {
|
|
306
|
+
N: Peak;
|
|
307
|
+
Vy: Peak;
|
|
308
|
+
Vz: Peak;
|
|
309
|
+
T: Peak;
|
|
310
|
+
My: Peak;
|
|
311
|
+
Mz: Peak;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* the mean axial force, N (tension positive): what buckling reads
|
|
315
|
+
*/
|
|
316
|
+
axial: number;
|
|
317
|
+
/**
|
|
318
|
+
* MPa, when the section has cy and cz (or
|
|
319
|
+
* Wy and Wz): the largest |N|/A + |My|/Wy + |Mz|/Wz along the element and where; the largest bending part alone;
|
|
320
|
+
* and N/A at the peak
|
|
321
|
+
*/
|
|
322
|
+
stress?: {
|
|
323
|
+
peak: number;
|
|
324
|
+
bending: number;
|
|
325
|
+
axial: number;
|
|
326
|
+
x: number;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
export type Peak = {
|
|
330
|
+
value: number;
|
|
331
|
+
x: number;
|
|
332
|
+
};
|
|
333
|
+
export type StaticResult = {
|
|
334
|
+
/**
|
|
335
|
+
* each node's movement (mm) and rotation (rad), in global axes
|
|
336
|
+
*/
|
|
337
|
+
displacements: Record<string, Six>;
|
|
338
|
+
/**
|
|
339
|
+
* at each supported node: the force (N) and moment (N·mm) its support gives the frame
|
|
340
|
+
*/
|
|
341
|
+
reactions: Record<string, Six>;
|
|
342
|
+
/**
|
|
343
|
+
* in the model's order
|
|
344
|
+
*/
|
|
345
|
+
elements: ElementResult[];
|
|
346
|
+
/**
|
|
347
|
+
* the largest movement of any node, and which
|
|
348
|
+
*/
|
|
349
|
+
deflection: {
|
|
350
|
+
most: number;
|
|
351
|
+
node: string;
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* the loads times `factor` buckle the frame into `shape` (largest movement 1)
|
|
356
|
+
*/
|
|
357
|
+
export type BucklingMode = {
|
|
358
|
+
factor: number;
|
|
359
|
+
shape: Record<string, Six>;
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* Hz, and the shape (largest movement 1)
|
|
363
|
+
*/
|
|
364
|
+
export type VibrationMode = {
|
|
365
|
+
frequency: number;
|
|
366
|
+
shape: Record<string, Six>;
|
|
367
|
+
};
|