@rulecad/cad 0.7.77 → 0.7.80
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/AGENTS.md +3 -2
- package/CHANGELOG.md +84 -0
- package/README.md +69 -17
- package/bin/cad.mjs +32 -5
- package/lib/explain.mjs +18 -0
- package/lib/fittings.mjs +20 -2
- package/lib/framecheck.mjs +111 -37
- package/lib/frameprint.mjs +3 -3
- package/lib/framesize.mjs +105 -13
- package/lib/live.mjs +52 -2
- package/lib/optimise.mjs +80 -12
- package/package.json +6 -6
- package/schemas/assembly.schema.json +1 -1
- package/schemas/problem.schema.json +51 -7
- package/schemas/rules.schema.json +2 -0
package/lib/framecheck.mjs
CHANGED
|
@@ -53,6 +53,7 @@ export const FRAME_CHECK = {
|
|
|
53
53
|
order: { value: ['gusset', 'brace', 'panel'], unit: '', rule: 'The changes that stiffen a bay against racking, cheapest first: gussets at its corners (four printed or bought plates), one diagonal brace (a length of the bay\'s own profile and two fittings), a panel (a sheet and its clips). The first in this order that brings the sway under the limit is advised, in one bay before every bay that way', kind: 'default', source: 'A working order of @rulecad/cad, by the parts each needs; cad list prices them', checked: '2026-11-17' },
|
|
54
54
|
clip: { value: 200, unit: 'N/mm', rule: 'How stiffly one panel clip holds the sheet\'s edge from sliding along the beam: the clip grips the sheet by friction and its edge sits half a millimetre off the step, so this is a guess at the friction\'s stiffness, the weak link of a panel as a shear web', kind: 'estimate', source: 'A working guess of @rulecad/cad, with no measurement behind it: a panel on the joint rig would measure it', checked: '2026-11-17' },
|
|
55
55
|
band: { value: 0.2, unit: '', rule: 'A mode within this share of a frequency the machine dwells at (a stepper\'s full-step rate at its working speed) is near enough to ring', kind: 'estimate', source: 'A working figure of @rulecad/cad: a lightly damped mode amplifies a forcing within about ±20% of it several times over', checked: '2026-11-17' },
|
|
56
|
+
sweep: { value: 4, unit: 'steps', rule: 'A moving joint mounted on a beam is solved at each end of its travel and at this many equal steps of it between (its quarters), so a worst place between the ends is found: a carriage between two supports at its middle, an arm on a hinge where it lies level', kind: 'default', source: 'A working figure of @rulecad/cad: quarters hold a middle and the quarter points, each step one more solve of every check', checked: '2026-11-24' },
|
|
56
57
|
ramp: { value: 500, unit: 'mm/s²', rule: 'Where the task gives no accel, the acceleration a move ramps at: a move at the task\'s speed ramps for speed over this many seconds, and shakes the frame at about one over that time', kind: 'default', source: 'The same default as cad machine\'s task.accel (lib/machine.mjs)', checked: '2026-11-17' },
|
|
57
58
|
};
|
|
58
59
|
|
|
@@ -123,6 +124,36 @@ function webOf(bay, sheet, t, clips, id) {
|
|
|
123
124
|
element: { id: `panel ${id}`, a: bay.corners[0], b: bay.corners[2], section: { A, Iy: A * (d / 10) ** 2, Iz: A * (d / 10) ** 2, J: A * (d / 10) ** 2 }, material: { E: WEB_E, G: WEB_E / 2.6, density: 0 }, ends: { a: 'ball', b: 'pinned' } } };
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
// How a frame moves where nothing holds it, in words, from each way @rulecad/fea finds it moves (frame().mechanisms,
|
|
128
|
+
// each node's six, its largest movement 1): its top moving across "down" with its feet still is the frame tipping over
|
|
129
|
+
// that way (named by the world axis nearest), a movement mostly along "down" a beam dropping, and a way that only
|
|
130
|
+
// turns a beam spinning on its own axis (or turning about the axis nearest, where that is not its own). Each said once,
|
|
131
|
+
// with the freedoms that showed it.
|
|
132
|
+
const beamOfNode = (n) => String(n).split(/[.@#/]/)[0];
|
|
133
|
+
function howFree(fm, ways) {
|
|
134
|
+
const out = new Map();
|
|
135
|
+
for (const w of ways ?? []) {
|
|
136
|
+
const sh = w.shape ?? {};
|
|
137
|
+
let lead = null, most = 0, spin = null, turn = 0;
|
|
138
|
+
for (const [n, v] of Object.entries(sh)) { const t = Math.hypot(v[0], v[1], v[2]), r = Math.hypot(v[3], v[4], v[5]); if (t > most) { most = t; lead = n; } if (r > turn) { turn = r; spin = n; } }
|
|
139
|
+
const nearest = (v) => 'xyz'[[0, 1, 2].reduce((p, q) => (Math.abs(v[q]) > Math.abs(v[p]) ? q : p), 0)];
|
|
140
|
+
let says;
|
|
141
|
+
if (lead && most > 1e-6) {
|
|
142
|
+
const d = sh[lead].slice(0, 3), v = dot(d, fm.down), h = sub(d, scale(fm.down, v));
|
|
143
|
+
says = Math.hypot(...h) >= Math.abs(v) ? `the frame tips over along ${nearest(h)}` : `${beamOfNode(lead)} drops at ${lead}`;
|
|
144
|
+
} else if (spin) {
|
|
145
|
+
const r = sh[spin].slice(3), b = fm.beams.get(beamOfNode(spin));
|
|
146
|
+
says = b && Math.abs(Math.abs(dot(unitv(r), b.u)) - 1) < 1e-3 ? `${b.id} spins on its own axis` : `it turns about ${nearest(r)} at ${spin}`;
|
|
147
|
+
} else says = `it moves at ${w.node} (${w.freedom})`;
|
|
148
|
+
out.set(says, [...(out.get(says) ?? []), { node: w.node, freedom: w.freedom }]);
|
|
149
|
+
}
|
|
150
|
+
return [...out].map(([says, at]) => ({ says, at }));
|
|
151
|
+
}
|
|
152
|
+
// the ways in one clause each, and where each is free: "the frame tips over along y (free at z2.b: rx)"
|
|
153
|
+
const howSaid = (hs) => hs.map((h) => `${h.says} (free at ${[...h.at.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n}: ${fr.join(', ')}`).join('; ')})`).join(', and ');
|
|
154
|
+
// the mechanisms of a solved frame that match freedoms named (a refusal's or buckling's), by node and freedom
|
|
155
|
+
const waysAt = (solved, ls) => (solved?.mechanisms ?? []).filter((m) => ls.some((l) => l.node === m.node && l.freedom === m.freedom));
|
|
156
|
+
|
|
126
157
|
// what a join's spring rests on, in a few words
|
|
127
158
|
const restsWord = (k) => (k.measured?.bending && k.measured?.twist ? 'measured' : k.fitting ? 'a printed fitting by finite elements' : k.bought?.own ? `${k.bought.set}'s own figures, ${k.kind}` : 'an estimate');
|
|
128
159
|
|
|
@@ -152,7 +183,7 @@ export function frameModelOf(s, helpers) {
|
|
|
152
183
|
const movesWith = (k) => { for (let i = k, n = 0; n < 99; n++) { const j = byChild.get(i); if (!j) return false; if (moving(j)) return true; i = j.parent; } return false; };
|
|
153
184
|
const down = (() => { const g = motion.gravity || [0, 0, -1], l = Math.hypot(...g) || 1; return g.map((c) => c / l); })();
|
|
154
185
|
// the beams: still ones only (a beam on a carriage is a load, not the frame: its weight is carried below)
|
|
155
|
-
const beams = new Map(), left = [], riding = [];
|
|
186
|
+
const beams = new Map(), left = [], riding = [], loose = [];
|
|
156
187
|
for (const o of s.objects) {
|
|
157
188
|
if (!o.beam || o.unplaced) continue;
|
|
158
189
|
const k = ids.indexOf(o.id);
|
|
@@ -196,19 +227,31 @@ export function frameModelOf(s, helpers) {
|
|
|
196
227
|
return [{ mount: mt, part: p1, s: s1 }, { mount: { ...mt, beam: b, sign, shift }, part: 1 - p1, s: s2 }];
|
|
197
228
|
};
|
|
198
229
|
|
|
199
|
-
// the poses: as drawn, each named pose, and each moving joint mounted on a beam
|
|
200
|
-
//
|
|
201
|
-
const
|
|
202
|
-
for (const p of Object.keys(motion.poses || {}))
|
|
203
|
-
const movers = motion.joints.filter((j) => moving(j) && beams.has(ids[j.parent]) && j.dofs?.length === 1);
|
|
204
|
-
// (a slide also at the middle of its travel, where a carriage between two supports bends its beam most, unless drawn there)
|
|
230
|
+
// the poses: as drawn, each named pose, and each moving joint mounted on a beam swept through its travel: each end and
|
|
231
|
+
// frame.sweep steps between (a step where it is drawn is the drawn pose)
|
|
232
|
+
const poses = [{ label: 'as drawn', values: base }];
|
|
233
|
+
for (const p of Object.keys(motion.poses || {})) poses.push({ label: `pose ${p}`, values: jointValues(motion, p) });
|
|
234
|
+
const movers = motion.joints.filter((j) => moving(j) && beams.has(ids[j.parent]) && j.dofs?.length === 1), steps = FRAME_CHECK.sweep.value;
|
|
205
235
|
for (const j of movers) {
|
|
206
|
-
const [lo, hi] = j.dofs[0],
|
|
207
|
-
for (const v of [lo, hi, ...
|
|
236
|
+
const [lo, hi] = j.dofs[0], drawn = base[j.id]?.[0], between = Array.from({ length: steps - 1 }, (_, k) => lo + ((hi - lo) * (k + 1)) / steps).filter((v) => !(drawn != null && Math.abs(drawn - v) < 1e-6));
|
|
237
|
+
for (const v of [lo, hi, ...between]) poses.push({ label: `${j.id} at ${n3(v, 1)}`, values: { ...base, [j.id]: [v] } });
|
|
208
238
|
}
|
|
239
|
+
// what a joint must push or turn against ("loads" on joints: a force on a slide, a torque on a hinge, and a belt's
|
|
240
|
+
// push at its carriage's acceleration), carried through the joint, held by its motor, into the beam its chain is
|
|
241
|
+
// mounted on: each in every pose, one way and then the other (none says which way it acts). A belt's share of its
|
|
242
|
+
// carriage's own weight along the travel is that weight, already on the frame, so it is not counted again
|
|
243
|
+
const onJoints = [];
|
|
244
|
+
for (const l of motion.loads || []) {
|
|
245
|
+
if (l.joint == null || l.beltWeight || !(Math.abs(l.value) > 0)) continue;
|
|
246
|
+
const j = motion.joints.find((x) => x.id === l.joint), mt = j ? mountOf(j.child) : null;
|
|
247
|
+
if (!j) continue;
|
|
248
|
+
if (!mt) { loose.push(`the load on ${j.id}`); continue; }
|
|
249
|
+
onJoints.push({ joint: j, value: Math.abs(l.value), unit: j.type === 'prismatic' ? 'N' : 'N m', note: l.note ?? null, belt: l.belt ?? null, mount: mt });
|
|
250
|
+
}
|
|
251
|
+
const cases = onJoints.length ? poses.flatMap((c) => [{ ...c, label: `${c.label}, joint loads +`, push: 1 }, { ...c, label: `${c.label}, joint loads -`, push: -1 }]) : poses;
|
|
209
252
|
|
|
210
253
|
// what weighs on the frame: items (beams' own weight is the elements'), and the masses of "loads"
|
|
211
|
-
const masses = massesOf(s, { placeItems, jointValues }), carried = [],
|
|
254
|
+
const masses = massesOf(s, { placeItems, jointValues }), carried = [], unknown = [];
|
|
212
255
|
// a panel (not a door) on a bay of frame beams is a shear web of the frame: its weight goes to its bay's corners; on
|
|
213
256
|
// beams that make no bay, its weight is spread along those of the frame
|
|
214
257
|
const sheets = (s.panels ?? []).filter((p) => !p.door && p.bay?.some((id) => beams.has(id))).map((p) => ({ ...p, kg: (p.model?.grams ?? 0) / 1000 }));
|
|
@@ -243,7 +286,7 @@ export function frameModelOf(s, helpers) {
|
|
|
243
286
|
if (!mt) { loose.push(`load ${i + 1} (${where})`); return; }
|
|
244
287
|
loads.push({ index: i, kg: l.mass, where, item: l.item, point, mount: mt, note: l.note });
|
|
245
288
|
});
|
|
246
|
-
for (const c of [...carried, ...loads.filter((l) => l.mount)]) for (const cs of
|
|
289
|
+
for (const c of [...carried, ...loads.filter((l) => l.mount), ...onJoints]) for (const cs of poses) snap(c.mount.beam, mountStation(c.mount, cs.values));
|
|
247
290
|
// named points, and every guide's travel
|
|
248
291
|
const points = (opts.points ?? []).map((p, i) => {
|
|
249
292
|
const t = String(p), id = t.split('.')[0], b = beams.get(id);
|
|
@@ -261,6 +304,7 @@ export function frameModelOf(s, helpers) {
|
|
|
261
304
|
const supports = [];
|
|
262
305
|
if (opts.supports != null) {
|
|
263
306
|
if (typeof opts.supports !== 'object' || Array.isArray(opts.supports)) throw new Error(`frame.supports is { "z1.a": "pinned", "z2.a": "fixed" } (got ${shown(opts.supports)})`);
|
|
307
|
+
if (!Object.keys(opts.supports).length) throw new Error('frame.supports names no support: give at least one place the frame is held, as { "z1.a": "pinned" }, or leave supports out to stand the frame on its feet or its lowest ends');
|
|
264
308
|
for (const [addr, how] of Object.entries(opts.supports)) {
|
|
265
309
|
const id = addr.split('.')[0], b = beams.get(id);
|
|
266
310
|
if (!b) throw new Error(`frame.supports: "${addr}" is on a beam of the frame, as z1.a or x1.bottom@50% (beams: ${[...beams.keys()].join(', ')})`);
|
|
@@ -358,7 +402,7 @@ export function frameModelOf(s, helpers) {
|
|
|
358
402
|
let free = [];
|
|
359
403
|
// (in the model as solved and in the pieces modes and buckling are solved in, where a freedom can show that
|
|
360
404
|
// rounding hid in the whole: either says the frame is free)
|
|
361
|
-
for (const rigid of [false, true]) for (const m of [withSprings(rigid), subdivide(withSprings(rigid), 4)]) try { free.push(...solveFrame(m).
|
|
405
|
+
for (const rigid of [false, true]) for (const m of [withSprings(rigid), subdivide(withSprings(rigid), 4)]) try { free.push(...solveFrame(m).mechanisms); } catch { /* refused: said by the solve itself */ }
|
|
362
406
|
if (free.length) {
|
|
363
407
|
for (const x of guessed) {
|
|
364
408
|
const lies = supports.some((y) => y !== x && y.beam === x.beam) && axisOfBeam(x.beam) >= 0, stands = Math.abs(dot(x.beam.u, down)) > 1 - 1e-6;
|
|
@@ -367,19 +411,28 @@ export function frameModelOf(s, helpers) {
|
|
|
367
411
|
}
|
|
368
412
|
mapSupports();
|
|
369
413
|
const seen = new Set();
|
|
370
|
-
|
|
414
|
+
const ways = free.filter((l) => { const k = `${l.node} ${l.freedom}`; return !seen.has(k) && seen.add(k); });
|
|
415
|
+
guess = { free: ways.map(({ node, freedom }) => ({ node, freedom })), ways,
|
|
371
416
|
supports: guessed.filter((x) => x.why !== 'a lowest end').map((x) => ({ where: x.where, how: x.how, why: x.why })) };
|
|
372
417
|
if (!guess.supports.length) guess = null; // (nothing changed: the guess stays pinned, and the solve says what is free)
|
|
373
418
|
}
|
|
374
419
|
}
|
|
375
420
|
// the loads at each pose: every carried item's and load's weight as a force and a moment at its node
|
|
376
|
-
const nodeLoads = (values, only) => {
|
|
421
|
+
const nodeLoads = (values, only, push) => {
|
|
377
422
|
const W = placeItems(motion, values), out = [];
|
|
378
423
|
const put = (b, z, C, kg) => { const n = nodeAt(b, z); if (!n) throw new Error(`frame: no node on ${b.id} at ${n3(z)} mm for a load (a pose this check did not foresee)`); const F = scale(down, kg * G); out.push({ node: n, force: F, moment: cross(sub(C, nodes[n]), F) }); };
|
|
379
424
|
for (const c of only ? [] : carried.filter(keep)) put(c.mount.beam, mountStation(c.mount, values), rowsAt(W[c.item], c.centre), c.kg);
|
|
380
425
|
for (const l of loads.filter(keep)) { if (only && only !== l) continue; const C = rowsAt(W[l.item], l.point); if (l.beam) put(l.beam, l.z, C, l.kg); else put(l.mount.beam, mountStation(l.mount, values), C, l.kg); }
|
|
381
426
|
for (const p of only ? [] : heldSheets) for (const n of bays[p.bay].corners) out.push({ node: n, force: scale(down, (p.kg / 4) * G), moment: [0, 0, 0] });
|
|
382
427
|
for (const p of only ? [] : laid) for (const id of p.beams) { const b = beams.get(id), w = scale(down, ((p.kg / p.beams.length) * G) / b.L); for (const q of elements) if (q.of === id) out.push({ element: q.id, spread: w }); }
|
|
428
|
+
// a joint's load, one way (push 1) or the other (-1): a slide's force along its axis through the joint's place, a
|
|
429
|
+
// hinge's torque about its axis, each at the node where its chain meets the beam
|
|
430
|
+
for (const x of only || !push ? [] : onJoints.filter(keep)) {
|
|
431
|
+
const n = nodeAt(x.mount.beam, mountStation(x.mount, values));
|
|
432
|
+
if (!n) throw new Error(`frame: no node on ${x.mount.beam.id} for the load on ${x.joint.id} (a pose this check did not foresee)`);
|
|
433
|
+
const { O, Z } = axisOf(motion, W, x.joint, mul), F = x.unit === 'N' ? scale(Z, push * x.value) : [0, 0, 0];
|
|
434
|
+
out.push({ node: n, force: F, moment: x.unit === 'N' ? cross(sub(O, nodes[n]), F) : scale(Z, push * x.value * 1000) });
|
|
435
|
+
}
|
|
383
436
|
return out;
|
|
384
437
|
};
|
|
385
438
|
// the same masses for a modal solve: each at the node it is carried at, in kg (its offset's rotary inertia left out)
|
|
@@ -396,7 +449,7 @@ export function frameModelOf(s, helpers) {
|
|
|
396
449
|
// what is mounted only on beams left out (not held by a support through joins): not weighed, and named
|
|
397
450
|
const off = [...new Map([...carried, ...loads].filter((c) => !keep(c) && !kept.has(c.id)).map((c) => [c.id ?? `load ${c.index + 1} at ${c.where}`, (c.mount?.beam ?? c.beam).id]))].map(([id, on]) => ({ id, on }));
|
|
398
451
|
return { beams, left, missing, loose, unknown, off, riding: rides.filter((x) => kept.has(x.id)), carried: carried.filter(keep), loads: loads.filter(keep), points, guides: guides.filter(keep), supports: supports.filter(keep), joins: joins.filter((x) => beams.has(x.A.id)),
|
|
399
|
-
cases, down, nodes, nodeAt, guess, model: withSprings(false), rigid: withSprings(true), nodeLoads, nodeMasses, bays, webs, sheets: heldSheets, laid, elements, mountStation, worlds, axisOf: (j) => axisOf(motion, worlds, j, mul) };
|
|
452
|
+
cases, poses, onJoints: onJoints.filter(keep), down, nodes, nodeAt, guess, model: withSprings(false), rigid: withSprings(true), nodeLoads, nodeMasses, bays, webs, sheets: heldSheets, laid, elements, mountStation, worlds, axisOf: (j) => axisOf(motion, worlds, j, mul) };
|
|
400
453
|
}
|
|
401
454
|
|
|
402
455
|
// the downward movement of a node, and along a beam between two stations (the worst of the element stations there)
|
|
@@ -421,6 +474,8 @@ export function frameChecks(s, f, helpers) {
|
|
|
421
474
|
if (solved.error) { const guessed = fm.supports.every((x) => x.why.startsWith('a lowest end')); f(guessed ? 'info' : 'warn', `the frame is not solved: ${solved.error}. Its supports: ${fm.supports.map((x) => `${x.where} (${x.why})`).join(', ') || 'none'}${guessed ? '. Say where it is held: "frame": { "supports": { "z1.a": "pinned" } }, or fit its feet' : ''}`, guessed ? null : 'frame: not solved', { code: 'frame.solve', refs: { supports: fm.supports.map((x) => x.where), code: solved.code } }); return null; }
|
|
422
475
|
const { results } = solved, down = fm.down, margin = FRAME_CHECK.margin.value, held = solved.loose ?? [];
|
|
423
476
|
const heldList = [...held.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n} (${fr.join(', ')})`).join(', ');
|
|
477
|
+
// how it moves there, in words: the frame tipping over along y, a beam spinning on its axis
|
|
478
|
+
const heldHow = howFree(fm, solved.mechanisms), heldSaid = howSaid(heldHow);
|
|
424
479
|
// what the joins rest on, counted by kind
|
|
425
480
|
const kinds = new Map();
|
|
426
481
|
for (const x of fm.joins) { const key = `${x.j.kind}${x.j.fitting ? ` (${x.j.fitting})` : ''}: ${restsWord(x.k)}`; kinds.set(key, (kinds.get(key) ?? 0) + 1); }
|
|
@@ -434,15 +489,17 @@ export function frameChecks(s, f, helpers) {
|
|
|
434
489
|
const and = (xs) => (xs.length > 1 ? `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}` : xs[0] ?? '');
|
|
435
490
|
const posts = guess ? guess.supports.filter((x) => x.how === 'fixed').map((x) => x.where) : [], lying = guess ? guess.supports.filter((x) => x.how !== 'fixed').map((x) => x.where) : [];
|
|
436
491
|
const guessHeld = [posts.length ? `${and(posts)} fixed, standing on ${posts.length > 1 ? 'their end faces' : 'its end face'}` : null, lying.length ? `${and(lying)} resting, held from twisting as ${lying.length > 1 ? 'ends of beams' : 'an end of a beam'} lying on its face` : null].filter(Boolean).join(', and ');
|
|
437
|
-
const guessFree = guess ? listFree(guess.free) : '';
|
|
492
|
+
const guessFree = guess ? listFree(guess.free) : '', guessHow = guess ? howFree(fm, guess.ways) : [], guessSaid = howSaid(guessHow);
|
|
493
|
+
// supports guessed at the lowest ends and left pinned: nothing in the assembly says the frame stands there
|
|
494
|
+
const pinnedGuess = fm.supports.filter((x) => x.why === 'a lowest end').map((x) => x.where), guessedOnly = fm.supports.length > 0 && fm.supports.every((x) => x.why.startsWith('a lowest end'));
|
|
438
495
|
if (guess) {
|
|
439
496
|
const said = f;
|
|
440
497
|
f = (level, text, card, extra = {}) => (['frame.rack', 'frame.buckling', 'frame.frequency'].includes(extra.code)
|
|
441
|
-
? said(level, `${text}. This rests on supports guessed, not given: ${guessHeld}, where pinned feet would
|
|
498
|
+
? said(level, `${text}. This rests on supports guessed, not given: ${guessHeld}, where on pinned feet nothing would hold it: ${guessSaid}`, card, { ...extra, refs: { ...extra.refs, guessed: guess.supports.map((x) => x.where) } })
|
|
442
499
|
: said(level, text, card, extra));
|
|
443
500
|
}
|
|
444
|
-
f(
|
|
445
|
-
{ code: 'frame.solve', values: { beams: fm.beams.size, nodes: Object.keys(fm.nodes).length, cases: fm.cases.length, joins: fm.joins.length, estimates }, refs: { supports: fm.supports.map((x) => x.where), ...(guess ? { guessed: guess.supports.map((x) => x.where), free: guess.free } : {}), left: fm.left, off: fm.off, held, laid: fm.laid.map((p) => ({ id: p.id, kg: r3(p.kg), beams: p.beams })), riding: fm.riding.map((x) => ({ ...x, kg: r3(x.kg) })), loose: fm.loose, rests } });
|
|
501
|
+
f(guessedOnly ? 'warn' : 'info', `the frame is solved as ${fm.beams.size} beam${fm.beams.size > 1 ? 's' : ''} on ${Object.keys(fm.nodes).length} nodes, held at ${fm.supports.map((x) => `${x.where} (${x.how}, ${x.why})`).join(', ')}, under its own weight${fm.carried.length ? `, ${new Set(fm.carried.map((c) => c.id)).size} item${new Set(fm.carried.map((c) => c.id)).size > 1 ? 's' : ''} mounted on it` : ''}${fm.loads.length ? ` and ${fm.loads.length} load${fm.loads.length > 1 ? 's' : ''}` : ''}${fm.onJoints.length ? `, with ${fm.onJoints.map((x) => `${n3(x.value, 3)} ${x.unit} on ${x.joint.id}${x.belt ? ` (${x.note})` : ''}`).join(', ')} carried into ${[...new Set(fm.onJoints.map((x) => x.mount.beam.id))].join(', ')} through ${fm.onJoints.length > 1 ? 'their joints, each' : 'its joint,'} one way and then the other` : ''}, in ${fm.poses.length} pose${fm.poses.length > 1 ? 's' : ''}${fm.onJoints.length ? ` (${fm.cases.length} cases)` : ''}; ${restsJoins}${estimates ? `, ${estimates} of them an estimate until the joint rig (issue 264) measures it, so each figure is given with the joins rigid too` : ''}${fm.riding.length ? `. ${fm.riding.map((x) => `${x.id} rides on ${x.joint}, its ${n3(x.kg, 3)} kg weighed on the frame${x.on.length > 1 ? `, shared as it lies: ${x.on.map((q) => `${n3(q.share * 100, 0)}% on ${q.beam}`).join(', ')}` : `, all of it on ${x.on[0].beam}, the beam its joint is on`}`).join('; ')}` : ''}${fm.webs.length ? `. ${fm.webs.map((w) => `${w.id} is a shear web on its bay, ${n3(w.k, 0)} N/mm along its diagonal (${w.clips} clips, their grip an estimate)`).join('; ')}` : ''}${fm.laid.length ? `. ${fm.laid.map((p) => `${p.id} lies on ${p.beams.join(', ')}, which are not joined round it as a bay: its ${n3(p.kg, 3)} kg is spread along them, and it is no shear web`).join('; ')}` : ''}${held.length ? `. Nothing holds it one way: ${heldSaid}, with nothing resisting. Its loads do not move it that way, so it is held there for the sag and the stresses; its modes and buckling count it free (frame.frequency, frame.buckling), and a push that way finds it free (frame.rack). Hold it with "frame": { "supports" } fixed or resting, or join it into a box` : ''}${fm.left.length ? `. Left out: ${fm.left.join(', ')} (not held by a support through joins)` : ''}${fm.off.length ? `. Not weighed on the frame, as the beam carrying it is left out: ${fm.off.map((x) => `${x.id} (on ${x.on})`).join(', ')}` : ''}${fm.loose.length ? `. Not on a beam, so not weighed on the frame: ${fm.loose.join(', ')}` : ''}${fm.unknown.length ? `. No mass known for ${fm.unknown.join(', ')}` : ''}${guess ? `. Its supports are guessed: nothing says where it is held (no feet, no "frame": { "supports" }), and on its lowest ends pinned, as a foot stands on a floor, nothing would hold it: ${guessSaid}. So it is solved with ${guessHeld}${pinnedGuess.length ? ` (${and(pinnedGuess)} pinned, a guess too)` : ''}, and every sag, rack, buckling and frequency figure rests on those ends held from turning, which nothing in the assembly gives. Give it feet, or say how it is held in "frame": { "supports" }` : guessedOnly ? `. Its supports are guessed: nothing says where it is held (no feet, no "frame": { "supports" }), so it stands on its lowest ends, ${and(pinnedGuess)}, pinned, as feet stand on a floor, and every figure rests on that. Give it feet, or say how it is held in "frame": { "supports" }` : ''}`, guessedOnly ? 'frame: supports guessed' : null,
|
|
502
|
+
{ code: 'frame.solve', values: { beams: fm.beams.size, nodes: Object.keys(fm.nodes).length, cases: fm.cases.length, poses: fm.poses.length, joins: fm.joins.length, estimates }, refs: { supports: fm.supports.map((x) => x.where), ...(guess ? { guessed: [...guess.supports.map((x) => x.where), ...pinnedGuess], free: guess.free, how: guessHow.map((h) => h.says) } : guessedOnly ? { guessed: pinnedGuess } : {}), left: fm.left, off: fm.off, onJoints: fm.onJoints.map((x) => ({ joint: x.joint.id, value: r3(x.value), unit: x.unit, beam: x.mount.beam.id, note: x.note })), held, ...(held.length ? { how: heldHow.map((h) => h.says) } : {}), laid: fm.laid.map((p) => ({ id: p.id, kg: r3(p.kg), beams: p.beams })), riding: fm.riding.map((x) => ({ ...x, kg: r3(x.kg) })), loose: fm.loose, rests } });
|
|
446
503
|
|
|
447
504
|
// ---- frame.deflection: each load's point, each named point, every guide ----
|
|
448
505
|
const worst = (fn) => { let w = null; for (const r of results) { const v = fn(r.spring, r), v0 = fn(r.rigid, r); if (!w || v.sag > w.sag) w = { ...v, rigid: v0.sag, case: { ...r.case, alone: r.alone } }; } return w; };
|
|
@@ -545,13 +602,14 @@ export function frameChecks(s, f, helpers) {
|
|
|
545
602
|
{ code: 'frame.buckling', at: r4(add(low.b.A, scale(low.b.u, low.b.L / 2))), values: { compression: r3(low.N), euler: r3(low.Pcr), margin: r3(low.margin), beams: okSq.length }, refs: { beam: low.b.id } });
|
|
546
603
|
}
|
|
547
604
|
try {
|
|
548
|
-
const drawn = results[0],
|
|
605
|
+
const drawn = results[0], fine = solveFrame(subdivide(fm.model, 4)), bk = fine.buckling({ loads: drawn.loads, count: 1 }), factor = bk.factors[0];
|
|
549
606
|
const shape = bk.modes[0].shape, lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
|
|
550
607
|
const listed = (ls) => [...ls.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n} (${fr.join(', ')})`).join(', ');
|
|
551
608
|
if (bk.tipped) {
|
|
552
609
|
// nothing holds the frame where it is free, and its loads as drawn lean it further that way: it tips over before anything buckles
|
|
553
|
-
|
|
554
|
-
|
|
610
|
+
const how = howFree(fm, waysAt(fine, bk.tipped));
|
|
611
|
+
f('fail', `the whole frame tips over under its load as drawn before anything buckles: nothing holds it one way, ${how.length ? howSaid(how) : `free at ${listed(bk.tipped)}`}, and its squeezed beams lean it further that way, ${beam} moving most. Its buckling factor is 0. Hold it with "frame": { "supports" } fixed, brace it out of its plane, or join it into a box`, 'frame tips over',
|
|
612
|
+
{ code: 'frame.buckling', at: r4(fm.nodes[lead[0]] ?? fm.nodes[Object.keys(fm.nodes)[0]]), values: { factor: 0 }, refs: { beam, restsOn, tipped: bk.tipped, how: how.map((h) => h.says) } });
|
|
555
613
|
} else {
|
|
556
614
|
const level = factor < 1 ? 'fail' : factor < margin ? 'warn' : 'pass', rests = bk.rests ?? [];
|
|
557
615
|
f(level, `the whole frame, with the joins' springs, buckles first at ${rests.length ? 'no more than ' : ''}${n3(factor, 1)} times its load as drawn, ${beam} moving most: ${level === 'pass' ? 'far from it' : 'too near it: brace it, or a stiffer profile'} (rests on ${restsJoins})${rests.length ? `. Nothing holds it at ${listed(rests)}, where its loads pull it back as a hanging frame's do: the figure is with it held there, so the true one may be lower` : ''}`, level === 'pass' ? null : `frame buckles at ${n3(factor, 1)}×`,
|
|
@@ -559,7 +617,7 @@ export function frameChecks(s, f, helpers) {
|
|
|
559
617
|
}
|
|
560
618
|
} catch (e) { if (e.code !== 'fea.frame.compression') f('info', `the frame's own buckling factor is not found: ${e.message}`, null, { code: 'frame.buckling' }); }
|
|
561
619
|
try { rackCheck(s, fm, f, { restsJoins, restsOn }); } catch (e) { f('info', `the frame's racking is not found: ${e.message}`, null, { code: 'frame.rack' }); }
|
|
562
|
-
try { frequencyCheck(s, fm, f, { restsJoins, restsOn,
|
|
620
|
+
try { frequencyCheck(s, fm, f, { restsJoins, restsOn, heldSaid }); } catch (e) { f('info', `the frame's modes are not found: ${e.message}`, null, { code: 'frame.frequency' }); }
|
|
563
621
|
const ctx = { results, limitFor, sagAt, sagAlong, excitesOf, restsJoins, restsOn, margin };
|
|
564
622
|
try { couponChecks(s, fm, f, ctx); } catch (e) { f('info', `the beam coupon's figures are not predicted: ${e.message}`, null, { code: 'beam.coupon' }); }
|
|
565
623
|
if (s.a.frame?.printed != null) try { printableCheck(s, fm, f, ctx); } catch (e) { f('info', `which beams can be printed is not found: ${e.message}`, null, { code: 'beam.printable' }); }
|
|
@@ -567,7 +625,7 @@ export function frameChecks(s, f, helpers) {
|
|
|
567
625
|
}
|
|
568
626
|
|
|
569
627
|
// the two directions across "down" a frame is racked in, each named by the world axis it is nearest
|
|
570
|
-
function sideways(down) {
|
|
628
|
+
export function sideways(down) {
|
|
571
629
|
const flat = (v) => sub(v, scale(down, dot(v, down))), x = flat([1, 0, 0]), e1 = Math.hypot(...x) > 0.5 ? unitv(x) : unitv(flat([0, 1, 0])), e2 = unitv(cross(down, e1));
|
|
572
630
|
const name = (v) => { const k = [0, 1, 2].reduce((p, q) => (Math.abs(v[q]) > Math.abs(v[p]) ? q : p), 0); return `along ${'xyz'[k]}`; };
|
|
573
631
|
return [e1, e2].map((v) => ({ dir: v, name: name(v) }));
|
|
@@ -582,14 +640,30 @@ const RACK_PANEL = { sheet: 'acrylic', thickness: 3 };
|
|
|
582
640
|
* best bay that way alone and in every open bay that way, each solved, with its gain; the cheapest that brings the sway
|
|
583
641
|
* under the limit advised.
|
|
584
642
|
*/
|
|
585
|
-
|
|
643
|
+
/**
|
|
644
|
+
* How a frame is racked: the side push (frame.rack.load, else frame.push), the nodes at its top it is shared among (its
|
|
645
|
+
* bays' top corners, else its highest nodes), its height above its supports, and the sway allowed (frame.rack.limit,
|
|
646
|
+
* the task's accuracy, else its height over frame.sway). Null where it has no height to rack. frame.rack and the
|
|
647
|
+
* sizing's racking limit both read it. @param {object} s a built assembly @param {object} fm frameModelOf's
|
|
648
|
+
* @returns {{ F: number, loadFrom: string, top: string[], H: number, lim: { value: number, from: string } } | null}
|
|
649
|
+
*/
|
|
650
|
+
export function rackOf(s, fm) {
|
|
586
651
|
const opts = s.a.frame?.rack ?? {}, F = opts.load != null ? s.num(opts.load) : FRAME_CHECK.push.value, down = fm.down, height = (n) => -dot(fm.nodes[n], down);
|
|
587
652
|
const feet = fm.supports.map((sp) => fm.nodeAt(sp.beam, sp.z)).filter(Boolean);
|
|
588
653
|
const pool = fm.bays.length ? [...new Set(fm.bays.flatMap((b) => b.corners))] : Object.keys(fm.nodes), topH = Math.max(...pool.map(height)), top = pool.filter((n) => height(n) > topH - 1);
|
|
589
654
|
const H = topH - Math.min(...feet.map(height));
|
|
590
|
-
if (!(H > 1) || !top.length) return;
|
|
655
|
+
if (!(H > 1) || !top.length) return null;
|
|
591
656
|
const lim = opts.limit != null ? { value: s.num(opts.limit), from: 'the assembly\'s frame.rack.limit' } : s.task?.accuracy != null ? { value: s.task.accuracy, from: 'the task\'s accuracy' } : { value: H / FRAME_CHECK.sway.value, from: `its height, ${n3(H, 1)} mm, over ${FRAME_CHECK.sway.value} (frame.sway)` };
|
|
592
|
-
|
|
657
|
+
return { F, loadFrom: opts.load != null ? 'frame.rack.load' : `frame.push, an estimate`, top, H, lim };
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/** How a frame moves where nothing holds it, in words (see howFree): for the sizing's racking limit. @param {object} fm @param {object[]} ways frame().mechanisms */
|
|
661
|
+
export const freeSaid = (fm, ways) => howSaid(howFree(fm, ways));
|
|
662
|
+
|
|
663
|
+
function rackCheck(s, fm, f, { restsJoins, restsOn }) {
|
|
664
|
+
const rk = rackOf(s, fm);
|
|
665
|
+
if (!rk) return;
|
|
666
|
+
const { F, top, H, lim, loadFrom } = rk, down = fm.down;
|
|
593
667
|
const swayOf = (model, dir) => { const r = solveFrame(model).statics({ loads: top.map((n) => ({ node: n, force: scale(dir, F / top.length) })), gravity: [0, 0, 0] }); return top.reduce((t, n) => t + dot(r.displacements[n].slice(0, 3), dir), 0) / top.length; };
|
|
594
668
|
const base = fm.model, els = base.elements;
|
|
595
669
|
// the changes, each as the model's elements with it made
|
|
@@ -615,9 +689,9 @@ function rackCheck(s, fm, f, { restsJoins, restsOn }) {
|
|
|
615
689
|
try { sway = swayOf(base, dir); rigid = swayOf(fm.rigid, dir); } catch (e) {
|
|
616
690
|
if (e.code !== 'fea.frame.mechanism' || !e.driven) throw e;
|
|
617
691
|
// a frame free to move this way (one plane on pinned feet, pushed across it): the push finds nothing to hold it
|
|
618
|
-
const at = e.loose.map((l) => `${l.node} (${l.freedom})`).join(', ');
|
|
619
|
-
f('warn', `racked ${name}: nothing holds the frame that way, so ${n3(F, 1)} N pushed at the top (${loadFrom}) moves it with nothing resisting
|
|
620
|
-
{ code: 'frame.rack', at: r4(fm.nodes[top[0]]), values: { load: r3(F), limit: r3(lim.value), height: r3(H) }, refs: { direction: name, dir: r4(dir), top, free: e.loose, limit: lim.from, load: loadFrom, restsOn, advise: null } });
|
|
692
|
+
const at = e.loose.map((l) => `${l.node} (${l.freedom})`).join(', '), how = howFree(fm, waysAt(solveFrame(base), e.loose));
|
|
693
|
+
f('warn', `racked ${name}: nothing holds the frame that way, ${how.length ? howSaid(how) : `free at ${at}`}, so ${n3(F, 1)} N pushed at the top (${loadFrom}) moves it with nothing resisting. Fix its feet ("frame": { "supports" } fixed), or join beams across it to make a bay that way and brace it`, `racks ${name}: nothing holds it`,
|
|
694
|
+
{ code: 'frame.rack', at: r4(fm.nodes[top[0]]), values: { load: r3(F), limit: r3(lim.value), height: r3(H) }, refs: { direction: name, dir: r4(dir), top, free: e.loose, how: how.map((h) => h.says), limit: lim.from, load: loadFrom, restsOn, advise: null } });
|
|
621
695
|
continue;
|
|
622
696
|
}
|
|
623
697
|
const k = F / sway, k0 = F / rigid;
|
|
@@ -662,10 +736,10 @@ export function excitesOf(s) {
|
|
|
662
736
|
* speed (a mode near it rings while the motor runs at that speed), and the task's moves (a move ramping in t seconds
|
|
663
737
|
* shakes the frame at about 1/t, and the lowest mode should stand twice that clear).
|
|
664
738
|
*/
|
|
665
|
-
function frequencyCheck(s, fm, f, { restsJoins, restsOn,
|
|
739
|
+
function frequencyCheck(s, fm, f, { restsJoins, restsOn, heldSaid }) {
|
|
666
740
|
const solveIn = (model, values, count) => solveFrame(subdivide({ ...model, masses: fm.nodeMasses(values) }, 4)).modes({ count });
|
|
667
741
|
let worst = null;
|
|
668
|
-
for (const c of fm.
|
|
742
|
+
for (const c of fm.poses) { const r = solveIn(fm.model, c.values, 3); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r }; }
|
|
669
743
|
const hz = worst.r.frequencies, low = hz[0], rigid = solveIn(fm.rigid, worst.c.values, 1).frequencies[0];
|
|
670
744
|
const shape = worst.r.modes[0].shape, lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
|
|
671
745
|
const carried = Object.values(fm.nodeMasses(worst.c.values)).reduce((t, x) => t + x, 0), own = [...fm.beams.values()].reduce((t, b) => t + b.grams / 1000, 0);
|
|
@@ -678,7 +752,7 @@ function frequencyCheck(s, fm, f, { restsJoins, restsOn, heldList }) {
|
|
|
678
752
|
const level0 = !excites.length ? 'info' : (moves.length && low < need / margin) ? 'fail' : (low < need || near.length) ? 'warn' : 'pass', level = free && (level0 === 'info' || level0 === 'pass') ? 'warn' : level0;
|
|
679
753
|
const target = Math.max(need, ...near.map((x) => x.Hz * (1 + band)));
|
|
680
754
|
const advice = free ? `. Hold it there with "frame": { "supports" } fixed, brace it, or join it into a box: then it has a mode to lift` : level === 'warn' || level === 'fail' ? `. To lift it to ${n3(target, 1)} Hz takes about ${n3((target / low) ** 2, 2)} times the stiffness where ${beam} moves (a deeper profile, a shorter span, stiffer joins or a brace), or as many times less mass moving with it` : '';
|
|
681
|
-
const text = `the lowest mode is ${n3(low, 1)} Hz${free ? `: nothing holds the frame${
|
|
755
|
+
const text = `the lowest mode is ${n3(low, 1)} Hz${free ? `: nothing holds the frame one way${heldSaid ? `, ${heldSaid}` : ''}, so it moves that way with nothing resisting${free > 1 ? ` (${free} such modes)` : ''}` : ''}${fm.poses.length > 1 ? `, worst ${worst.c.label}` : ''}, ${beam} moving most${fm.joins.length ? `, with the joins' springs; ${n3(rigid, 1)} Hz with the joins rigid` : ''}. Its next: ${hz.slice(1).map((h) => `${n3(h, 1)} Hz`).join(', ')}. With ${n3(own, 3)} kg of beams and ${n3(carried, 3)} kg carried, each item's mass at the node it is carried at (its rotary inertia left out); it rests on ${restsJoins}. ${excites.length
|
|
682
756
|
? `The machine excites: ${excites.map((x) => `${x.what}, ${n3(x.Hz, 1)} Hz`).join('; ')}. ${near.length ? `A mode within ${band * 100}% of ${near.map((x) => `${x.what} (the mode${x.modes.length > 1 ? 's' : ''} at ${x.modes.join(' and ')} Hz)`).join(', ')}: it rings while the motor runs at that speed` : ''}${near.length && moves.length ? '; ' : ''}${moves.length ? (low < need ? `under ${margin} times the moves' ${n3(need / margin, 1)} Hz` : `${n3(low / (need / margin), 1)} times over the moves' ${n3(need / margin, 1)} Hz, where ${margin} is wanted`) : ''}`
|
|
683
757
|
: 'Nothing named excites it: no stepper drives a joint and the assembly has no task'}${advice}`;
|
|
684
758
|
f(level, text.replace(/\. $/, ''), level === 'warn' || level === 'fail' ? `frame mode ${n3(low, 1)} Hz` : null, { code: 'frame.frequency', at: r4(fm.nodes[lead[0]] ?? fm.nodes[Object.keys(fm.nodes)[0]]),
|
|
@@ -698,13 +772,13 @@ export function frameMode(s, helpers) {
|
|
|
698
772
|
if (!fm || fm.empty) return null;
|
|
699
773
|
try {
|
|
700
774
|
let worst = null;
|
|
701
|
-
for (const c of fm.
|
|
775
|
+
for (const c of fm.poses) { const m = subdivide({ ...fm.model, masses: fm.nodeMasses(c.values) }, 4), r = solveFrame(m).modes({ count: 1 }); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r, m }; }
|
|
702
776
|
const shape = worst.r.modes[0].shape, pts = Object.values(worst.m.nodes), size = Math.max(...[0, 1, 2].map((k) => Math.max(...pts.map((p) => p[k])) - Math.min(...pts.map((p) => p[k])))), k = size / 10;
|
|
703
777
|
const move = (n) => scale((shape[n] ?? [0, 0, 0]).slice(0, 3), k);
|
|
704
778
|
const lines = worst.m.elements.map((e) => ({ id: String(e.id), a: worst.m.nodes[e.a], b: worst.m.nodes[e.b], da: move(e.a), db: move(e.b) }));
|
|
705
779
|
const lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
|
|
706
780
|
const Hz = worst.r.frequencies[0];
|
|
707
|
-
return { Hz, pose: worst.c.label, beam, lines, scale: k, label: `lowest mode ${n3(Hz, 1)} Hz${fm.
|
|
781
|
+
return { Hz, pose: worst.c.label, beam, lines, scale: k, label: `lowest mode ${n3(Hz, 1)} Hz${fm.poses.length > 1 ? `, ${worst.c.label}` : ''}, ${beam} moving most; its movement drawn as a tenth of the frame's size (scaled)` };
|
|
708
782
|
} catch { return null; }
|
|
709
783
|
}
|
|
710
784
|
|
|
@@ -758,11 +832,11 @@ function solveAll(fm) {
|
|
|
758
832
|
try { results = solveCases(fm, fs, fr); } catch (e) { if (e.code !== 'fea.frame.mechanism') throw e; return { error: e.message, code: e.code }; }
|
|
759
833
|
// each element's start along its beam, for sagAlong
|
|
760
834
|
for (const r of results) for (const res of [r.spring, r.rigid]) for (const e of res.elements) if (e.of != null) { const b = fm.beams.get(e.of), el = fm.model.elements.find((q) => q.id === e.id); e._from = dot(sub(fm.nodes[el.a], b.A), b.u); }
|
|
761
|
-
return { results, loose: fs.loose };
|
|
835
|
+
return { results, loose: fs.loose, mechanisms: fs.mechanisms };
|
|
762
836
|
}
|
|
763
837
|
function solveCases(fm, fs, fr) {
|
|
764
838
|
const results = fm.cases.map((c) => {
|
|
765
|
-
const loads = fm.nodeLoads(c.values), spring = fs.statics({ loads }), rigid = fr.statics({ loads }), out = { case: c, loads, spring, rigid, values: c.values };
|
|
839
|
+
const loads = fm.nodeLoads(c.values, null, c.push), spring = fs.statics({ loads }), rigid = fr.statics({ loads }), out = { case: c, loads, spring, rigid, values: c.values };
|
|
766
840
|
{ out.alone = new Map(); for (const l of fm.loads) { const ll = fm.nodeLoads(c.values, l), n = ll[0]?.node; if (!n) continue; out.alone.set(l, { sag: sagAt(fs.statics({ loads: ll, gravity: [0, 0, 0] }), n, fm.down), rigid: sagAt(fr.statics({ loads: ll, gravity: [0, 0, 0] }), n, fm.down) }); } }
|
|
767
841
|
return out;
|
|
768
842
|
});
|
package/lib/frameprint.mjs
CHANGED
|
@@ -94,7 +94,7 @@ const alongOf = (b, ctx) => ({ what: `${b.id} along its length`, beam: b, from:
|
|
|
94
94
|
function drawnSags(fm, ctx, targets) {
|
|
95
95
|
const solver = solveFrame(fm.model), out = new Map(), all = [...targets, ...[...fm.beams.values()].map((b) => alongOf(b, ctx))];
|
|
96
96
|
for (const cs of fm.cases) {
|
|
97
|
-
const res = stamp(fm, fm.model, solver.statics({ loads: fm.nodeLoads(cs.values) }));
|
|
97
|
+
const res = stamp(fm, fm.model, solver.statics({ loads: fm.nodeLoads(cs.values, null, cs.push) }));
|
|
98
98
|
for (const t of all) out.set(`${t.what}|${cs.label}`, t.node ? ctx.sagAt(res, t.node(cs.values), fm.down) : ctx.sagAlong(res, t.beam, t.from, t.to, fm.down).sag);
|
|
99
99
|
}
|
|
100
100
|
const missed = [];
|
|
@@ -115,7 +115,7 @@ function evaluate(s, fm, ctx, cands, targets, drawn) {
|
|
|
115
115
|
let def = null, creepSag = null;
|
|
116
116
|
const per = new Map(cands.map((c) => [c.b.id, { stress: 0, compression: 0, case: null }]));
|
|
117
117
|
for (const cs of fm.cases) {
|
|
118
|
-
const loads = fm.nodeLoads(cs.values), res = stamp(fm, model, solver.statics({ loads })), cr = stamp(fm, creep, creeper.statics({ loads }));
|
|
118
|
+
const loads = fm.nodeLoads(cs.values, null, cs.push), res = stamp(fm, model, solver.statics({ loads })), cr = stamp(fm, creep, creeper.statics({ loads }));
|
|
119
119
|
for (const t of all) {
|
|
120
120
|
// where the frame as drawn already misses this sag, the printed beam is held to the drawn frame's own figure
|
|
121
121
|
const base = drawn.get(`${t.what}|${cs.label}`) ?? 0, missed = base > t.limit.value + 1e-12, lim = missed ? base * (1 + DRAWN_SLACK) : t.limit.value;
|
|
@@ -129,7 +129,7 @@ function evaluate(s, fm, ctx, cands, targets, drawn) {
|
|
|
129
129
|
const moves = ctx.excitesOf(s).filter((x) => x.kind === 'move');
|
|
130
130
|
if (moves.length) {
|
|
131
131
|
const need = Math.max(...moves.map((x) => x.Hz)) * margin;
|
|
132
|
-
for (const cs of fm.
|
|
132
|
+
for (const cs of fm.poses) { const low = solveFrame(subdivide({ ...model, masses: fm.nodeMasses(cs.values) }, 4)).modes({ count: 1 }).frequencies[0]; if (!freq || low < freq.low) freq = { low, need, margin: low / need, case: cs.label }; }
|
|
133
133
|
}
|
|
134
134
|
const out = new Map();
|
|
135
135
|
for (const c of cands) {
|
package/lib/framesize.mjs
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
// change. The result is a table: each group's profile, the limit that set it (the one its next lighter profile breaks)
|
|
9
9
|
// and the margin, written into the assembly by cad frame --size --write.
|
|
10
10
|
// Units: mm, N, MPa, kg, Hz.
|
|
11
|
-
import { sizing } from '@rulecad/fea/frame';
|
|
12
|
-
import { profileModel, profileChoices } from '@rulecad/frames';
|
|
13
|
-
import {
|
|
11
|
+
import { sizing, frame as solveFrame } from '@rulecad/fea/frame';
|
|
12
|
+
import { profileModel, profileChoices, beamModel, boughtFittingModel, JOINS } from '@rulecad/frames';
|
|
13
|
+
import { fixingModel } from '@rulecad/fixings';
|
|
14
|
+
import { frameModelOf, FRAME_CHECK, excitesOf, rackOf, sideways, freeSaid } from './framecheck.mjs';
|
|
14
15
|
import { framesContext } from './beams.mjs';
|
|
15
16
|
import { givenFor } from './frames.mjs';
|
|
16
17
|
|
|
@@ -24,7 +25,7 @@ export const FRAME_SIZING = {
|
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const SIZE_KEYS = ['profiles', 'groups', 'limits', 'by'];
|
|
27
|
-
const LIMIT_KEYS = ['deflection', 'stress', 'buckling', 'frequency'];
|
|
28
|
+
const LIMIT_KEYS = ['deflection', 'stress', 'buckling', 'frequency', 'rack'];
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* frame.size read and refused by name: { profiles, groups, limits, by }.
|
|
@@ -41,8 +42,8 @@ export function sizeOption(s) {
|
|
|
41
42
|
if (typeof groups !== 'object' || Array.isArray(groups)) throw new Error(`frame.size.groups is { "legs": ["z1", "z2", "z3", "z4"] }: beams that must take one profile, by name (got ${shown(o.groups)})`);
|
|
42
43
|
for (const [g, list] of Object.entries(groups)) if (!Array.isArray(list) || !list.length || !list.every((x) => typeof x === 'string')) throw new Error(`frame.size.groups.${g} is a list of beams by name (got ${shown(list)})`);
|
|
43
44
|
const limits = o.limits ?? {};
|
|
44
|
-
if (typeof limits !== 'object' || Array.isArray(limits)) throw new Error(`frame.size.limits is { "deflection": mm, "stress": margin, "buckling": factor, "frequency": Hz } (got ${shown(o.limits)})`);
|
|
45
|
-
for (const k of Object.keys(limits)) if (!LIMIT_KEYS.includes(k)) throw new Error(`frame.size.limits has no "${k}": it takes deflection (mm), stress (a margin), buckling (a factor)
|
|
45
|
+
if (typeof limits !== 'object' || Array.isArray(limits)) throw new Error(`frame.size.limits is { "deflection": mm, "stress": margin, "buckling": factor, "frequency": Hz, "rack": mm } (got ${shown(o.limits)})`);
|
|
46
|
+
for (const k of Object.keys(limits)) if (!LIMIT_KEYS.includes(k)) throw new Error(`frame.size.limits has no "${k}": it takes deflection (mm), stress (a margin), buckling (a factor), frequency (Hz) and rack (the sway allowed at the top, mm)`);
|
|
46
47
|
const out = {};
|
|
47
48
|
for (const [k, v] of Object.entries(limits)) { const x = s.num(v); if (!(x > 0)) throw new Error(`frame.size.limits.${k} is above 0 (got ${shown(v)})`); out[k] = x; }
|
|
48
49
|
if (o.by != null && !['mass', 'cost'].includes(o.by)) throw new Error(`frame.size.by is mass or cost (got ${shown(o.by)})`);
|
|
@@ -50,6 +51,56 @@ export function sizeOption(s) {
|
|
|
50
51
|
return { profiles, groups, limits: out, by: o.by ?? 'mass' };
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
// The world direction a beam's face looks, from its section's normal: x across its width, y up its height, turned by roll
|
|
55
|
+
const faceAxes = (b, roll) => { const X = [b.W[0], b.W[4], b.W[8]], Y = [b.W[1], b.W[5], b.W[9]], c = Math.cos((roll * Math.PI) / 180), sn = Math.sin((roll * Math.PI) / 180); return { X: X.map((v, k) => c * v + sn * Y[k]), Y: Y.map((v, k) => c * v - sn * X[k]) }; };
|
|
56
|
+
const looks = (ax, n) => ax.X.map((v, k) => v * n[0] + ax.Y[k] * n[1]);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether a join still goes together when its beams take other profiles: a's end on b's face where the drawn join
|
|
60
|
+
* meets it (the face of b's new profile that looks the same way in the world). A blind join needs a bore in a's end and
|
|
61
|
+
* a slot in b's face whose opening passes the screw (the bore's thread) and holds its button head under the lips, the
|
|
62
|
+
* head no wider than the slot's cavity; an end-tap join a bore in a's end and, where b's far face has a slot, a cap
|
|
63
|
+
* head wider than its opening. A bought fitting must fit both profiles (its set's fitting.fit). A printed fitting is
|
|
64
|
+
* drawn for the profiles it joins, so it goes with any; a join whose fitting comes later is not held to one. Null where
|
|
65
|
+
* it fits, else why not. @param {object} x a frame join (frameModelOf's joins) @param {{ model: object, roll: number }} pa a's profile as sized
|
|
66
|
+
* @param {{ model: object, roll: number }} pb b's @param {object} given the workspace's sets
|
|
67
|
+
* @returns {string | null}
|
|
68
|
+
*/
|
|
69
|
+
export function joinFit(x, pa, pb, given) {
|
|
70
|
+
const kind = x.j.kind, A = pa.model, Bm = pb.model, name = (m) => m.name.replace(/^profile-/, '');
|
|
71
|
+
if (x.j.fitting && x.j.fitting !== 'printed' && JOINS[kind]?.bought) {
|
|
72
|
+
let fm;
|
|
73
|
+
try { fm = boughtFittingModel(x.j.fitting, { given, profile: Bm, other: A, join: kind }); } catch (e) { return String(e.message).replace(/^\w+: /, ''); }
|
|
74
|
+
const bad = fm.findings.find((f) => f.code === 'fitting.fit' && f.level === 'fail');
|
|
75
|
+
return bad ? `${x.j.fitting} does not fit ${name(A)} to ${name(Bm)}: ${bad.text}` : null;
|
|
76
|
+
}
|
|
77
|
+
if (!['blind', 'end-tap'].includes(kind)) return null;
|
|
78
|
+
const e = String(x.j.end ?? 'a')[0], bores = A.bores ?? [];
|
|
79
|
+
if (!bores.length) return `${name(A)} has no bore in its ends to tap, and a ${kind} join screws into one`;
|
|
80
|
+
// b's face where the join meets it, in the world, and the place of the new profile that looks that way
|
|
81
|
+
const drawn = x.B.m.places.find((q) => q.name === x.j.model.b.place);
|
|
82
|
+
if (!drawn) return null;
|
|
83
|
+
const n = looks(faceAxes(x.B, 0), drawn.normal), B = beamModel(Bm, { length: x.B.L }), ax = faceAxes(x.B, pb.roll);
|
|
84
|
+
const place = B.places.filter((q) => { const w = looks(ax, q.normal); return w[0] * n[0] + w[1] * n[1] + w[2] * n[2] > 0.99; })[0];
|
|
85
|
+
const thread = bores[0].thread;
|
|
86
|
+
if (!thread) return `${name(A)}'s bores name no thread`;
|
|
87
|
+
const head = (form) => { try { return fixingModel(`${thread} ${form}`); } catch { return null; } };
|
|
88
|
+
if (kind === 'blind') {
|
|
89
|
+
if (!place?.slot) return `${name(Bm)}'s face there is closed, and a blind join's head sits in a slot`;
|
|
90
|
+
const sl = Bm.slots[place.slot], fx = head('button');
|
|
91
|
+
if (!sl || !fx) return null;
|
|
92
|
+
if (fx.major > sl.opening) return `${a(thread)} ${thread} screw (${name(A)}'s bore) does not pass ${name(Bm)}'s ${sl.opening} mm slot opening`;
|
|
93
|
+
if (fx.head.across <= sl.opening) return `${a(thread)} ${thread} button head, ${fx.head.across} mm across, pulls through ${name(Bm)}'s ${sl.opening} mm slot opening`;
|
|
94
|
+
if (fx.head.across > sl.cavityWidth) return `${a(thread)} ${thread} button head, ${fx.head.across} mm across, does not go into ${name(Bm)}'s slot, ${sl.cavityWidth} mm wide under its lips`;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
// end-tap: the screw through b, its cap head on b's far face
|
|
98
|
+
const far = place ? B.places.find((q) => Math.abs(q.normal[0] + place.normal[0]) < 1e-9 && Math.abs(q.normal[1] + place.normal[1]) < 1e-9) : null, fx = head('cap');
|
|
99
|
+
if (far?.slot && fx && Bm.slots[far.slot] && fx.head.across <= Bm.slots[far.slot].opening) return `${a(thread)} ${thread} cap head, ${fx.head.across} mm across, falls through ${name(Bm)}'s ${Bm.slots[far.slot].opening} mm slot opening on its far face`;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const a = () => 'an'; // (a metric thread's name is said em: an M5, an M3)
|
|
103
|
+
|
|
53
104
|
/**
|
|
54
105
|
* The frame's sizing: frameModelOf's frame, its beams grouped, each group given the lightest profile from the list that
|
|
55
106
|
* meets the frame's limits. Null where the assembly has no frame to solve. Refused by name: frame.size as sizeOption
|
|
@@ -80,7 +131,7 @@ export function frameSizing(s, helpers, given) {
|
|
|
80
131
|
}
|
|
81
132
|
for (const x of auto) groups[x.ids.join(', ')] = x.ids;
|
|
82
133
|
// the choices, from the workspace's sets before the kit's
|
|
83
|
-
const context = framesContext(), choices = [];
|
|
134
|
+
const context = framesContext(), choices = [], models = new Map(), modelOf = (name) => { if (!models.has(name)) models.set(name, profileModel(name, {}, givenFor(context, name))); return models.get(name); };
|
|
84
135
|
for (const name of opt.profiles) {
|
|
85
136
|
let m;
|
|
86
137
|
try { m = profileModel(name, {}, givenFor(context, name)); } catch (e) { throw new Error(`frame.size.profiles: ${String(e.message).replace(/^profileModel: /, '')}`); }
|
|
@@ -108,17 +159,55 @@ export function frameSizing(s, helpers, given) {
|
|
|
108
159
|
limitRows.push({ limit: 'buckling', where: 'the frame and each grouped beam (Euler, K 1)', value: factor, from: opt.limits.buckling != null ? 'frame.size.limits.buckling' : 'frame.margin' });
|
|
109
160
|
const moves = excitesOf(s).filter((x) => x.kind === 'move'), Hz = opt.limits.frequency ?? (moves.length ? Math.max(...moves.map((x) => x.Hz)) * margin : null);
|
|
110
161
|
if (Hz != null) limitRows.push({ limit: 'frequency', where: 'the frame', value: Hz, from: opt.limits.frequency != null ? 'frame.size.limits.frequency' : `twice the task's moves (frame.frequency)` });
|
|
162
|
+
// racking, where the assembly asks it of the frame (frame.rack) or of its sizing (limits.rack): each way across, the
|
|
163
|
+
// side push alone at the top, with no weight, held to the sway allowed at each top node; a way nothing holds the
|
|
164
|
+
// frame (one plane on pinned feet) cannot be sized against, and is said
|
|
165
|
+
const rackCases = [];
|
|
166
|
+
const rk = s.a.frame?.rack != null || opt.limits.rack != null ? rackOf(s, fm) : null;
|
|
167
|
+
if (rk) {
|
|
168
|
+
const lim = opt.limits.rack != null ? { value: opt.limits.rack, from: 'frame.size.limits.rack' } : rk.lim, drawnFrame = solveFrame(fm.model);
|
|
169
|
+
for (const { dir, name } of sideways(fm.down)) {
|
|
170
|
+
const label = `racked ${name}`, loads = rk.top.map((n) => ({ node: n, force: dir.map((v) => (v * rk.F) / rk.top.length) }));
|
|
171
|
+
try { drawnFrame.statics({ loads, gravity: [0, 0, 0] }); } catch (e) {
|
|
172
|
+
if (e.code !== 'fea.frame.mechanism' || !e.driven) throw e;
|
|
173
|
+
limitRows.push({ limit: 'rack', where: name, what: `not sized: nothing holds the frame ${name}, ${freeSaid(fm, (drawnFrame.mechanisms ?? []).filter((m) => e.loose.some((l) => l.node === m.node && l.freedom === m.freedom)))}; a brace or fixed feet, not a profile, holds it`, value: null, from: rk.loadFrom });
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
rackCases.push({ label, loads, gravity: [0, 0, 0], limits: ['deflection'] });
|
|
177
|
+
for (const n of rk.top) deflection.push({ node: n, limit: lim.value, along: dir, cases: [label] });
|
|
178
|
+
limitRows.push({ limit: 'deflection', where: rk.top.join(', '), what: `the top, ${label} by ${n3(rk.F, 1)} N (${rk.loadFrom})`, value: lim.value, from: lim.from });
|
|
179
|
+
}
|
|
180
|
+
// the sag limits hold in the poses, not under the push
|
|
181
|
+
if (rackCases.length) for (const d of deflection) if (!d.cases) d.cases = fm.cases.map((c) => c.label);
|
|
182
|
+
}
|
|
111
183
|
const limits = { ...(deflection.length ? { deflection } : {}), stress: { margin: stress }, buckling: { factor, euler: FRAME_CHECK.euler.value }, ...(Hz != null ? { frequency: { Hz } } : {}) };
|
|
112
184
|
// every beam's alloy carries its strength, so the beams outside the groups are held to it too
|
|
113
185
|
const withStrength = (model) => ({ ...model, materials: Object.fromEntries(Object.entries(model.materials).map(([k, v]) => [k, fm.beams.get(k)?.strength ? { ...v, strength: fm.beams.get(k).strength } : v])) });
|
|
114
|
-
const cases = fm.cases.map((c) => ({ label: c.label, loads: fm.nodeLoads(c.values), inertia: fm.nodeMasses(c.values) }));
|
|
115
|
-
const sized = sizing([withStrength(fm.model), withStrength(fm.rigid)], { groups, choices, limits, cases, by: opt.by });
|
|
186
|
+
const cases = [...fm.cases.map((c) => ({ label: c.label, loads: fm.nodeLoads(c.values, null, c.push), inertia: fm.nodeMasses(c.values) })), ...rackCases];
|
|
116
187
|
const byName = new Map(choices.map((c) => [c.name, c]));
|
|
188
|
+
// every join a group's beam makes must go together with the profiles chosen (joinFit): a design where one does not is
|
|
189
|
+
// never solved, and a lighter choice that breaks one is what set the group. A join as drawn is not asked again
|
|
190
|
+
const groupOf = new Map(Object.entries(groups).flatMap(([g, ids]) => ids.map((id) => [id, g]))), sets = { sets: context?.sets ?? {} }, fitMemo = new Map();
|
|
191
|
+
const asSized = (b, design) => { const g = groupOf.get(b.id), c = g ? byName.get(design[g]) : null; return c ? { name: c.profile, roll: c.roll ?? 0 } : { name: b.m.profile.name, roll: 0, drawn: true }; };
|
|
192
|
+
const pairs = fm.joins.filter((x) => fm.beams.has(x.A.id) && fm.beams.has(x.B.id) && (groupOf.has(x.A.id) || groupOf.has(x.B.id)));
|
|
193
|
+
const fits = (design) => {
|
|
194
|
+
const out = [];
|
|
195
|
+
for (const x of pairs) {
|
|
196
|
+
const pa = asSized(x.A, design), pb = asSized(x.B, design);
|
|
197
|
+
if (pa.drawn && pb.drawn) continue;
|
|
198
|
+
const key = `${x.j.index}|${pa.name}|${pa.roll}|${pb.name}|${pb.roll}`;
|
|
199
|
+
if (!fitMemo.has(key)) fitMemo.set(key, joinFit(x, { model: modelOf(pa.name), roll: pa.roll }, { model: modelOf(pb.name), roll: pb.roll }, sets));
|
|
200
|
+
const why = fitMemo.get(key);
|
|
201
|
+
if (why) out.push({ where: x.j.label, why });
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
};
|
|
205
|
+
const sized = sizing([withStrength(fm.model), withStrength(fm.rigid)], { groups, choices, limits, cases, by: opt.by, ...(pairs.length ? { fits } : {}) });
|
|
117
206
|
const rows = sized.groups.map((g) => {
|
|
118
207
|
const c = byName.get(g.choice), drawn = [...new Set(g.members.map((id) => fm.beams.get(id).m.profile.name.replace(/^profile-/, '')))];
|
|
119
208
|
const drawnKg = g.members.reduce((t, id) => t + fm.beams.get(id).grams / 1000, 0);
|
|
120
209
|
return { group: g.name, beams: g.members, profile: c.profile, roll: c.roll, choice: g.choice, drawn, length: r3(g.length), kg: r3(g.mass), drawnKg: r3(drawnKg), lighter: g.lighter,
|
|
121
|
-
governs: g.governs ? { limit: g.governs.limit, where: g.governs.where, value: r3(g.governs.value), allowed: r3(g.governs.allowed), case: g.governs.case, lighter: g.governs.lighter, broken: r3(g.governs.broken) } : null, margin: g.margin == null ? null : r3(g.margin) };
|
|
210
|
+
governs: g.governs ? (g.governs.limit === 'fit' ? { limit: 'fit', where: g.governs.where, why: g.governs.why, lighter: g.governs.lighter, broken: null } : { limit: g.governs.limit, where: g.governs.where, value: r3(g.governs.value), allowed: r3(g.governs.allowed), case: g.governs.case, lighter: g.governs.lighter, broken: r3(g.governs.broken) }) : null, margin: g.margin == null ? null : r3(g.margin) };
|
|
122
211
|
});
|
|
123
212
|
const drawn = [...fm.beams.values()].filter((b) => sized.groups.some((g) => g.members.includes(b.id))).reduce((t, b) => t + b.grams / 1000, 0);
|
|
124
213
|
return { ok: sized.ok, rows, limits: limitRows, total: r3(sized.total), drawn: r3(drawn), tried: sized.tried, search: sized.search, worst: sized.worst, sized, fm };
|
|
@@ -128,6 +217,8 @@ export function frameSizing(s, helpers, given) {
|
|
|
128
217
|
const unitOf = { deflection: 'mm', stress: 'MPa', buckling: 'x', frequency: 'Hz' };
|
|
129
218
|
const sayLimit = (g) => {
|
|
130
219
|
if (!g) return 'the lightest in the list';
|
|
220
|
+
if (g.limit === 'fit') return `a join: with ${g.lighter}, ${g.where} does not go together (${g.why})`;
|
|
221
|
+
if (g.limit === 'deflection' && /^racked /.test(g.case ?? '')) return `racking: with ${g.lighter}, the sway at ${g.where} ${g.case.replace(/^racked /, '')} breaks its limit ${n3(g.broken, 2)} times over`;
|
|
131
222
|
const u = unitOf[g.limit], what = g.limit === 'deflection' ? `the sag at ${g.where}` : g.limit === 'stress' ? `the stress in ${g.where}` : g.limit === 'buckling' ? (g.where === 'frame' ? 'the frame\'s buckling factor' : `${g.where.replace(' (Euler)', '')}'s Euler margin`) : 'the lowest mode';
|
|
132
223
|
return `${g.limit}: with ${g.lighter}, ${what} breaks its limit ${n3(g.broken, 2)} times over`;
|
|
133
224
|
};
|
|
@@ -139,7 +230,7 @@ export function sizingText(r) {
|
|
|
139
230
|
const lines = [`${r.ok ? 'sized' : 'no profile in the list meets every limit; nearest'}: ${n3(r.total, 3)} kg of grouped beams (drawn ${n3(r.drawn, 3)} kg), ${r.tried} designs solved (${r.search === 'every' ? 'every design ranked by mass' : 'by steps'})`];
|
|
140
231
|
lines.push('group | profile | kg | set by | margin');
|
|
141
232
|
for (const x of r.rows) lines.push(`${x.group} | ${x.choice}${x.drawn.length === 1 && x.drawn[0] === x.choice ? '' : ` (drawn ${x.drawn.join(', ')})`} | ${n3(x.kg, 3)} | ${sayLimit(x.governs)} | ${x.margin == null ? '-' : `${n3(x.margin, 2)}x`}`);
|
|
142
|
-
lines.push(`limits: ${r.limits.map((l) => `${l.limit} ${l.limit === 'deflection' ? `${n3(l.value, 3)} mm at ${l.what ?? l.where}` : l.limit === 'frequency' ? `${n3(l.value, 1)} Hz` : `${n3(l.value, 2)}x`} (${l.from})`).join('; ')}`);
|
|
233
|
+
lines.push(`limits: ${r.limits.map((l) => `${l.limit} ${l.limit === 'rack' ? `${l.where}: ${l.what}` : l.limit === 'deflection' ? `${n3(l.value, 3)} mm at ${l.what ?? l.where}` : l.limit === 'frequency' ? `${n3(l.value, 1)} Hz` : `${n3(l.value, 2)}x`} (${l.from})`).join('; ')}`);
|
|
143
234
|
return lines;
|
|
144
235
|
}
|
|
145
236
|
|
|
@@ -152,8 +243,9 @@ export function sizeChecks(s, f, helpers) {
|
|
|
152
243
|
let r;
|
|
153
244
|
try { r = frameSizing(s, helpers); } catch (e) { f('fail', `frame.size: ${e.message}`, 'frame.size: refused', { code: 'frame.size' }); return; }
|
|
154
245
|
if (!r) return;
|
|
155
|
-
const text = r.rows.map((x) => `${x.group}: ${x.choice}, ${n3(x.kg, 3)} kg, ${x.governs ? `set by ${sayLimit(x.governs)}, ${n3(x.margin, 2)} times inside it as chosen` : 'the lightest in the list'}`).join('; ');
|
|
156
|
-
|
|
246
|
+
const text = r.rows.map((x) => `${x.group}: ${x.choice}, ${n3(x.kg, 3)} kg, ${x.governs ? `set by ${sayLimit(x.governs)}, ${n3(x.margin, 2)} times inside ${x.governs.limit === 'fit' ? 'its nearest limit' : 'it'} as chosen` : 'the lightest in the list'}`).join('; ');
|
|
247
|
+
const broke = r.worst && /^racked /.test(r.worst.case ?? '') ? `racking (${r.worst.case}) at ${r.worst.where}` : `${r.worst?.limit} at ${r.worst?.where}`;
|
|
248
|
+
f(r.ok ? 'info' : 'warn', `${r.ok ? 'sized' : `no profile in the list meets every limit: the nearest breaks ${broke} ${n3(r.worst.ratio, 2)} times over`}: ${text}. ${n3(r.total, 3)} kg of grouped beams against ${n3(r.drawn, 3)} kg drawn (cad frame --size --write writes the profiles in)`, r.ok ? null : 'frame.size: not met',
|
|
157
249
|
{ code: 'frame.size', values: { kg: r.total, drawn: r.drawn, tried: r.tried }, refs: { groups: r.rows, limits: r.limits, search: r.search } });
|
|
158
250
|
}
|
|
159
251
|
|