@rulecad/fea 0.2.10 → 0.2.13
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 +40 -0
- package/README.md +185 -3
- package/frame.d.mts +206 -4
- package/frame.mjs +380 -17
- package/layout.d.mts +258 -0
- package/layout.mjs +536 -0
- package/package.json +12 -3
package/layout.d.mts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate nodes every `pitch` mm across a box, both ends included, by name "i,j" (or "i,j,k"): their places along
|
|
3
|
+
* x, y and z.
|
|
4
|
+
* @param {{ from: number[], to: number[], pitch: number }} g
|
|
5
|
+
* @returns {Record<string, Vec3>}
|
|
6
|
+
*/
|
|
7
|
+
export function nodeGrid(g: {
|
|
8
|
+
from: number[];
|
|
9
|
+
to: number[];
|
|
10
|
+
pitch: number;
|
|
11
|
+
}): Record<string, Vec3>;
|
|
12
|
+
/**
|
|
13
|
+
* The candidate members between nodes: every pair, less those that pass through a third node (the same as two
|
|
14
|
+
* shorter ones there, and so never needed: Gilbert and Tyas 2003), those longer than `reach` and those that enter
|
|
15
|
+
* an `avoid` ball (but for one members may pass `through`).
|
|
16
|
+
* @param {Record<string, number[]> | number[][]} nodes mm
|
|
17
|
+
* @param {{ reach?: number, avoid?: LayoutAvoid[] }} [o]
|
|
18
|
+
* @returns {{ ids: string[], at: Float64Array, members: { a: number, b: number, length: number }[] }} at: x, y, z of
|
|
19
|
+
* each node in turn; members by node index
|
|
20
|
+
*/
|
|
21
|
+
export function groundStructure(nodes: Record<string, number[]> | number[][], o?: {
|
|
22
|
+
reach?: number;
|
|
23
|
+
avoid?: LayoutAvoid[];
|
|
24
|
+
}): {
|
|
25
|
+
ids: string[];
|
|
26
|
+
at: Float64Array;
|
|
27
|
+
members: {
|
|
28
|
+
a: number;
|
|
29
|
+
b: number;
|
|
30
|
+
length: number;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The least-volume pin-jointed frame that carries the loads to the supports, chosen from every member between the
|
|
35
|
+
* candidate nodes (the ground structure), with each member's area. Proven least over every candidate: members are
|
|
36
|
+
* added to the programme until no left-out one would lower the volume. Refused by name before any maths: unknown
|
|
37
|
+
* keys, a node out of place or twice at one spot, a support or load at no node, no strength above 0, a load where
|
|
38
|
+
* nothing can carry it; and after, a frame the candidates cannot make stand (`fea.layout.unstable`).
|
|
39
|
+
* @param {LayoutProblem} problem
|
|
40
|
+
* @param {{ keep?: number, start?: number, add?: number, tolerance?: number, adding?: boolean }} [o] keep: members
|
|
41
|
+
* thinner than this share of the thickest are left out of `members` (1e-4; the volume counts them); start: each
|
|
42
|
+
* node's nearest candidates in the first programme (8 flat, 18 in space); add: most members added a round (a tenth
|
|
43
|
+
* of the programme's, at least 100); adding: false puts every candidate in the one programme
|
|
44
|
+
* @returns {{ volume: number, mass: number | null, members: LayoutMember[], nodes: Record<string, Vec3>,
|
|
45
|
+
* cases: string[], plane: boolean, candidates: number, programme: number, rounds: number, strain: number, left: number,
|
|
46
|
+
* virtual: Record<string, number[]>[], strength: { tension: number, compression: number }, joint: number,
|
|
47
|
+
* supports: Record<string, string>, loads: { label: string, loads: LayoutLoad[] }[] }}
|
|
48
|
+
* volume mm³ (the members' l a, every member counted); mass kg with a density; members the kept ones, thickest
|
|
49
|
+
* first; nodes the ones they meet at, with the loaded and supported ones; candidates how many members the ground
|
|
50
|
+
* structure has, programme how many the last programme held, rounds how many programmes were solved; strain the
|
|
51
|
+
* largest virtual strain of any candidate over its limit, 1 at most (to the tolerance) when the layout is the least
|
|
52
|
+
* over every candidate; left the volume share of the members under `keep`; virtual each case's virtual
|
|
53
|
+
* displacements by node, mm (the programme's dual), scaled so a member at its tension limit in one case stretches
|
|
54
|
+
* by its own length
|
|
55
|
+
*/
|
|
56
|
+
export function layout(problem: LayoutProblem, o?: {
|
|
57
|
+
keep?: number;
|
|
58
|
+
start?: number;
|
|
59
|
+
add?: number;
|
|
60
|
+
tolerance?: number;
|
|
61
|
+
adding?: boolean;
|
|
62
|
+
}): {
|
|
63
|
+
volume: number;
|
|
64
|
+
mass: number | null;
|
|
65
|
+
members: LayoutMember[];
|
|
66
|
+
nodes: Record<string, Vec3>;
|
|
67
|
+
cases: string[];
|
|
68
|
+
plane: boolean;
|
|
69
|
+
candidates: number;
|
|
70
|
+
programme: number;
|
|
71
|
+
rounds: number;
|
|
72
|
+
strain: number;
|
|
73
|
+
left: number;
|
|
74
|
+
virtual: Record<string, number[]>[];
|
|
75
|
+
strength: {
|
|
76
|
+
tension: number;
|
|
77
|
+
compression: number;
|
|
78
|
+
};
|
|
79
|
+
joint: number;
|
|
80
|
+
supports: Record<string, string>;
|
|
81
|
+
loads: {
|
|
82
|
+
label: string;
|
|
83
|
+
loads: LayoutLoad[];
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A layout as a frame of beams (@rulecad/fea/frame's model), with its load cases, ready for `sizing` to pick a tube
|
|
88
|
+
* for each member that can be bought (stress and buckling checked, with bending at stiff joints). Each member is a
|
|
89
|
+
* solid round bar of its layout area until sized (or the `section` given). A flat layout is held out of its plane at
|
|
90
|
+
* its supports (z and the two rotations out of plane) and any other way nothing resists is held while its loads do
|
|
91
|
+
* not push it (`loose: 'hold'`).
|
|
92
|
+
* @param {ReturnType<typeof layout>} result
|
|
93
|
+
* @param {{ material: { E: number, nu?: number, G?: number, density?: number, strength?: number }, section?: object, ends?: 'rigid' | 'pinned' }} o
|
|
94
|
+
* material: the members' (E in MPa); section: one section for every member in place of the round bars; ends:
|
|
95
|
+
* 'rigid' (welded, brazed or bonded: the default) or 'pinned' (each member's ends free to turn: one 'ball', one 'pinned')
|
|
96
|
+
* @returns {{ model: object, cases: { label: string, loads: { node: string, force: Vec3 }[] }[], members: string[] }}
|
|
97
|
+
* model: nodes, elements (ids as the layout's members), supports, the first case's loads and loose: 'hold';
|
|
98
|
+
* cases: every case as sizing takes it; members: the element ids
|
|
99
|
+
*/
|
|
100
|
+
export function layoutFrame(result: ReturnType<typeof layout>, o?: {
|
|
101
|
+
material: {
|
|
102
|
+
E: number;
|
|
103
|
+
nu?: number;
|
|
104
|
+
G?: number;
|
|
105
|
+
density?: number;
|
|
106
|
+
strength?: number;
|
|
107
|
+
};
|
|
108
|
+
section?: object;
|
|
109
|
+
ends?: "rigid" | "pinned";
|
|
110
|
+
}): {
|
|
111
|
+
model: object;
|
|
112
|
+
cases: {
|
|
113
|
+
label: string;
|
|
114
|
+
loads: {
|
|
115
|
+
node: string;
|
|
116
|
+
force: Vec3;
|
|
117
|
+
}[];
|
|
118
|
+
}[];
|
|
119
|
+
members: string[];
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Each joint of a layout as a problem of its own for the voxel optimiser (cad optimise, @rulecad/topopt), in the
|
|
123
|
+
* problem file's form: the members meeting there as stubs, each member's force in every case as a load on its stub's
|
|
124
|
+
* end, the outside load at the node, and the stub carrying the most held (the frame beyond it). A lug, a dropout or
|
|
125
|
+
* a bracket is then shaped for the forces the layout found. Flat layouts give flat problems, `thickness` the widest
|
|
126
|
+
* member's diameter; the rest give 3D ones. Each problem is centred on its node; `at` says where that is.
|
|
127
|
+
* @param {ReturnType<typeof layout>} result
|
|
128
|
+
* @param {{ material: string, diameters?: Record<string, number>, forces?: Record<string, number[]>, stub?: number, cell?: number, volume?: number, nodes?: string[] }} o
|
|
129
|
+
* material: the rule set the joint is made of (pla, al6061, ...); diameters: each member's outside diameter by id
|
|
130
|
+
* (a solid bar of its area if left out: give the sized tubes'); forces: each member's force in each case, N,
|
|
131
|
+
* tension positive (the layout's own if left out: one set the strengths allow, where a frame with several cases may
|
|
132
|
+
* have many; give the sized frame's, solved, for the forces it will carry); stub: how far each stub reaches from the node, mm
|
|
133
|
+
* (twice the widest diameter); cell: the grid's cell (a quarter of the narrowest diameter); volume: share of the
|
|
134
|
+
* space to fill (0.3); nodes: which joints (every node where two members or more meet)
|
|
135
|
+
* @returns {{ node: string, at: Vec3, members: { id: string, to: string, direction: number[], forces: number[], diameter: number }[], problem: object }[]}
|
|
136
|
+
*/
|
|
137
|
+
export function layoutJoints(result: ReturnType<typeof layout>, o?: {
|
|
138
|
+
material: string;
|
|
139
|
+
diameters?: Record<string, number>;
|
|
140
|
+
forces?: Record<string, number[]>;
|
|
141
|
+
stub?: number;
|
|
142
|
+
cell?: number;
|
|
143
|
+
volume?: number;
|
|
144
|
+
nodes?: string[];
|
|
145
|
+
}): {
|
|
146
|
+
node: string;
|
|
147
|
+
at: Vec3;
|
|
148
|
+
members: {
|
|
149
|
+
id: string;
|
|
150
|
+
to: string;
|
|
151
|
+
direction: number[];
|
|
152
|
+
forces: number[];
|
|
153
|
+
diameter: number;
|
|
154
|
+
}[];
|
|
155
|
+
problem: object;
|
|
156
|
+
}[];
|
|
157
|
+
export type Vec3 = [number, number, number];
|
|
158
|
+
/**
|
|
159
|
+
* a ball (a circle in a flat layout) no node or member may enter: centre, mm, and radius; through: members may pass through it and only nodes are kept out (a wheel that stays straddle)
|
|
160
|
+
*/
|
|
161
|
+
export type LayoutAvoid = {
|
|
162
|
+
at: number[];
|
|
163
|
+
r: number;
|
|
164
|
+
through?: boolean;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* a force, N, at a node: [x, y, z] (or [x, y] in a flat layout)
|
|
168
|
+
*/
|
|
169
|
+
export type LayoutLoad = {
|
|
170
|
+
node: string | number;
|
|
171
|
+
force: number[];
|
|
172
|
+
};
|
|
173
|
+
export type LayoutProblem = {
|
|
174
|
+
/**
|
|
175
|
+
* the candidate nodes, mm, by name (or a list, named by place)
|
|
176
|
+
*/
|
|
177
|
+
nodes?: Record<string, number[]> | number[][];
|
|
178
|
+
/**
|
|
179
|
+
* more candidate nodes, every `pitch` mm across a
|
|
180
|
+
* box, named "x,y" or "x,y,z" by their place in it; one within a hundredth of the pitch of a named node gives way to it
|
|
181
|
+
*/
|
|
182
|
+
grid?: {
|
|
183
|
+
from: number[];
|
|
184
|
+
to: number[];
|
|
185
|
+
pitch: number;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* by node: 'pinned' holds
|
|
189
|
+
* every movement, or say which
|
|
190
|
+
*/
|
|
191
|
+
supports: Record<string, "pinned" | {
|
|
192
|
+
x?: boolean;
|
|
193
|
+
y?: boolean;
|
|
194
|
+
z?: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* the one load case
|
|
198
|
+
*/
|
|
199
|
+
loads?: LayoutLoad[];
|
|
200
|
+
/**
|
|
201
|
+
* several load cases, each carried alone, sharing the areas
|
|
202
|
+
*/
|
|
203
|
+
cases?: {
|
|
204
|
+
label?: string;
|
|
205
|
+
loads: LayoutLoad[];
|
|
206
|
+
}[];
|
|
207
|
+
/**
|
|
208
|
+
* MPa: one for both, or each
|
|
209
|
+
*/
|
|
210
|
+
strength: number | {
|
|
211
|
+
tension: number;
|
|
212
|
+
compression: number;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* g/cm³, for the mass
|
|
216
|
+
*/
|
|
217
|
+
density?: number;
|
|
218
|
+
/**
|
|
219
|
+
* a joint's cost as a length of member, mm (0): above 0, fewer and longer members
|
|
220
|
+
*/
|
|
221
|
+
joint?: number;
|
|
222
|
+
/**
|
|
223
|
+
* the longest candidate member, mm (no limit)
|
|
224
|
+
*/
|
|
225
|
+
reach?: number;
|
|
226
|
+
/**
|
|
227
|
+
* balls no node or member may enter
|
|
228
|
+
*/
|
|
229
|
+
avoid?: LayoutAvoid[];
|
|
230
|
+
/**
|
|
231
|
+
* a flat layout in x and y (left out: flat when every node and load is at z = 0)
|
|
232
|
+
*/
|
|
233
|
+
plane?: boolean;
|
|
234
|
+
};
|
|
235
|
+
export type LayoutMember = {
|
|
236
|
+
/**
|
|
237
|
+
* "a-b"
|
|
238
|
+
*/
|
|
239
|
+
id: string;
|
|
240
|
+
a: string;
|
|
241
|
+
/**
|
|
242
|
+
* its nodes
|
|
243
|
+
*/
|
|
244
|
+
b: string;
|
|
245
|
+
/**
|
|
246
|
+
* mm
|
|
247
|
+
*/
|
|
248
|
+
length: number;
|
|
249
|
+
/**
|
|
250
|
+
* mm²: its worst case's force over the strength
|
|
251
|
+
*/
|
|
252
|
+
area: number;
|
|
253
|
+
/**
|
|
254
|
+
* N in each case, tension positive
|
|
255
|
+
*/
|
|
256
|
+
forces: number[];
|
|
257
|
+
kind: "tension" | "compression" | "both";
|
|
258
|
+
};
|