@rulecad/cad 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -10
- package/CHANGELOG.md +404 -0
- package/EXAMPLES.md +40 -38
- package/README.md +193 -67
- package/TUTORIAL.md +2 -2
- package/bin/cad.mjs +2250 -512
- package/lib/animate.mjs +173 -49
- package/lib/assembly.mjs +1847 -434
- package/lib/beams.mjs +256 -52
- package/lib/belts.mjs +66 -15
- package/lib/board-work.mjs +12 -0
- package/lib/bought.mjs +309 -53
- package/lib/buildpage.mjs +179 -29
- package/lib/carried.mjs +201 -0
- package/lib/clone.mjs +194 -42
- package/lib/design.mjs +649 -121
- package/lib/drive.mjs +187 -63
- package/lib/edit.mjs +899 -191
- package/lib/errors.mjs +16 -3
- package/lib/explain.mjs +62 -13
- package/lib/fasten.mjs +2702 -507
- package/lib/fittings.mjs +715 -121
- package/lib/fixings.mjs +21 -9
- package/lib/framebuild.mjs +790 -175
- package/lib/framecheck.mjs +1901 -368
- package/lib/framegen.mjs +100 -22
- package/lib/frameheat.mjs +225 -42
- package/lib/frameprint.mjs +513 -108
- package/lib/frames.mjs +81 -17
- package/lib/framesize.mjs +792 -120
- package/lib/frametip.mjs +235 -0
- package/lib/gait.mjs +135 -23
- package/lib/grip.mjs +62 -13
- package/lib/guides.mjs +1403 -230
- package/lib/host.mjs +123 -21
- package/lib/inplace.mjs +171 -36
- package/lib/jigs.mjs +360 -78
- package/lib/joins.mjs +697 -118
- package/lib/jsonedit.mjs +88 -26
- package/lib/kept.mjs +84 -0
- package/lib/kit.mjs +438 -68
- package/lib/layout.mjs +2 -1
- package/lib/links.mjs +149 -42
- package/lib/list.mjs +326 -64
- package/lib/live-guard.mjs +68 -0
- package/lib/live-shape.mjs +96 -24
- package/lib/live.mjs +189 -59
- package/lib/loads.mjs +579 -130
- package/lib/machine.mjs +372 -74
- package/lib/magnets.mjs +162 -44
- package/lib/measured.mjs +417 -94
- package/lib/mesh.mjs +526 -119
- package/lib/meshcmd.mjs +215 -60
- package/lib/motors.mjs +1021 -213
- package/lib/motorsvg.mjs +114 -32
- package/lib/names.mjs +3 -1
- package/lib/optimise.mjs +978 -283
- package/lib/order.mjs +519 -112
- package/lib/panels.mjs +482 -94
- package/lib/parts.mjs +78 -23
- package/lib/pins.mjs +163 -44
- package/lib/plates.mjs +223 -35
- package/lib/player.mjs +37 -9
- package/lib/power.mjs +64 -13
- package/lib/preview.mjs +83 -16
- package/lib/profilemeasure.mjs +572 -129
- package/lib/rules.mjs +15 -5
- package/lib/sandbox-hooks.mjs +77 -19
- package/lib/sandbox-run.mjs +117 -18
- package/lib/sandbox.mjs +509 -60
- package/lib/schema.mjs +42 -11
- package/lib/seats.mjs +227 -49
- package/lib/services.mjs +261 -52
- package/lib/sheet.mjs +851 -178
- package/lib/slotnuts.mjs +213 -34
- package/lib/targets/gist.mjs +4 -1
- package/lib/targets.mjs +22 -4
- package/lib/task.mjs +376 -79
- package/lib/versions.mjs +111 -28
- package/lib/wires.mjs +228 -45
- package/lib/workspace.mjs +197 -12
- package/package.json +19 -19
- package/schemas/assembly.schema.json +2 -2
package/lib/frameprint.mjs
CHANGED
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
// (@rulecad/frames printedOf: walls and infill, the plastic's figures for its pose, or the beam coupon's where
|
|
8
8
|
// measured). The frame is solved again with that one beam printed, every other beam as it is, and the printed beam is
|
|
9
9
|
// held to the limits the frame's own checks use: every sag (each load's point, each named point, each guide and the
|
|
10
|
-
// beam along its length) against its limit; its stress against its plastic's strength with twice the margin;
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
10
|
+
// beam along its length) against its limit; its stress against its plastic's strength with twice the margin; the whole
|
|
11
|
+
// frame's buckling with it printed (the frame's own buckling solve, so a post fixed at its foot and free at its top
|
|
12
|
+
// buckles at a quarter of Euler's load with both ends pinned, which is given only as words) with twice the margin, or
|
|
13
|
+
// with the frame as drawn where that already buckles sooner, within DRAWN_SLACK of it; its sustained stress against
|
|
14
|
+
// the creep limit (beam.creep); its sag as it creeps (the frame solved again with the beam's modulus at
|
|
15
|
+
// PRINTED_DEFAULTS.creep_modulus of it) against the same limits; and where the task's moves excite the frame, its
|
|
16
|
+
// lowest mode at twice their rate. A sag the frame as drawn already misses
|
|
14
17
|
// (frame.deflection fails there in the beams' own material) is no fault of printing: there the printed beam is held to
|
|
15
18
|
// the drawn frame's own sag, within DRAWN_SLACK of it (the kit's choice), so it fails only where printing it makes that
|
|
16
19
|
// sag worse, and the findings name each such point. Each is a margin, 1 where it just
|
|
@@ -28,15 +31,25 @@ import { frame as solveFrame, subdivide } from '@rulecad/fea/frame';
|
|
|
28
31
|
import { PRINTED_SERIES, PRINTED_DEFAULTS, JOINS, beamCreep, printerFigures } from '@rulecad/frames';
|
|
29
32
|
import { beamOf } from './beams.mjs';
|
|
30
33
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const add = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]],
|
|
34
|
-
|
|
34
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2],
|
|
35
|
+
sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
36
|
+
const add = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]],
|
|
37
|
+
scale = (a, k) => [a[0] * k, a[1] * k, a[2] * k];
|
|
38
|
+
const n3 = (x, d = 3) => String(+Number(x).toFixed(d)),
|
|
39
|
+
r3 = (x) => (x == null || !Number.isFinite(x) ? null : +Number(x).toFixed(3)),
|
|
40
|
+
r4 = (p) => p.map((x) => +Number(x).toFixed(3));
|
|
35
41
|
const fig = (x) => String(+Number(x).toPrecision(3));
|
|
36
42
|
const shown = (v) => (v === undefined ? 'nothing' : JSON.stringify(v));
|
|
37
43
|
const PRINT_KEYS = ['material', 'walls', 'infill', 'pose'];
|
|
38
44
|
const DRAWN_SLACK = 0.02; // a printed beam may add 2% to a sag the frame as drawn already misses (the kit's choice, so that a beam far from it is not blamed for it)
|
|
39
|
-
const said = {
|
|
45
|
+
const said = {
|
|
46
|
+
deflection: 'its sag',
|
|
47
|
+
stress: 'its stress',
|
|
48
|
+
buckling: 'buckling',
|
|
49
|
+
creep: 'its sustained stress (creep)',
|
|
50
|
+
creepSag: 'its sag as it creeps',
|
|
51
|
+
frequency: 'its lowest mode',
|
|
52
|
+
};
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
* The frame's "printed" option held to its shape: the plastic every beam is tried in, by name ("petg"), or
|
|
@@ -46,16 +59,27 @@ const said = { deflection: 'its sag', stress: 'its stress', buckling: 'buckling'
|
|
|
46
59
|
export function printedOption(x) {
|
|
47
60
|
if (x == null) return null;
|
|
48
61
|
const o = typeof x === 'string' ? { material: x } : x;
|
|
49
|
-
if (!o || typeof o !== 'object' || Array.isArray(o))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
if (!o || typeof o !== 'object' || Array.isArray(o))
|
|
63
|
+
throw new Error(
|
|
64
|
+
`frame.printed is the plastic each beam is tried printed in, "petg", or { "material": "petg", "walls": 3, "infill": 0.4, "pose": "lying" } (got ${shown(x)})`,
|
|
65
|
+
);
|
|
66
|
+
for (const k of Object.keys(o))
|
|
67
|
+
if (!PRINT_KEYS.includes(k)) throw new Error(`frame.printed has no "${k}": it takes ${PRINT_KEYS.join(', ')}`);
|
|
68
|
+
if (typeof o.material !== 'string' || !o.material)
|
|
69
|
+
throw new Error(`frame.printed.material names a plastic's set, such as pla or petg (got ${shown(o.material)})`);
|
|
70
|
+
if (o.pose != null && !['lying', 'standing'].includes(o.pose))
|
|
71
|
+
throw new Error(`frame.printed.pose is lying or standing, or left out to try both (got ${shown(o.pose)})`);
|
|
53
72
|
return o;
|
|
54
73
|
}
|
|
55
74
|
|
|
56
75
|
// each element's start along its beam, as sagAlong reads it
|
|
57
76
|
function stamp(fm, model, res) {
|
|
58
|
-
for (const e of res.elements)
|
|
77
|
+
for (const e of res.elements)
|
|
78
|
+
if (e.of != null) {
|
|
79
|
+
const b = fm.beams.get(e.of),
|
|
80
|
+
el = model.elements.find((q) => q.id === e.id);
|
|
81
|
+
e._from = dot(sub(fm.nodes[el.a], b.A), b.u);
|
|
82
|
+
}
|
|
59
83
|
return res;
|
|
60
84
|
}
|
|
61
85
|
|
|
@@ -63,81 +87,246 @@ function stamp(fm, model, res) {
|
|
|
63
87
|
// it is printed already), and the figures the solve takes. Null with why where it cannot be.
|
|
64
88
|
function candidate(b, opts, pose, cache) {
|
|
65
89
|
let pm, profile;
|
|
66
|
-
if (b.m.printed) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
if (b.m.printed) {
|
|
91
|
+
if (pose !== b.m.printed.pose) return null;
|
|
92
|
+
pm = b.m;
|
|
93
|
+
profile = b.m.profile.name;
|
|
94
|
+
} else {
|
|
95
|
+
const w = b.m.profile.width,
|
|
96
|
+
h = b.m.profile.height;
|
|
97
|
+
if (!(Math.abs(w - h) < 1e-6 && PRINTED_SERIES[w]))
|
|
98
|
+
return {
|
|
99
|
+
why: `${b.id} is a ${fig(w)} x ${fig(h)} mm section, and the kit prints square ones of ${Object.keys(PRINTED_SERIES).join(', ')} mm (profile-2020-printed and its like)`,
|
|
100
|
+
};
|
|
70
101
|
profile = `profile-${w}${w}-printed`;
|
|
71
|
-
const printed = {
|
|
102
|
+
const printed = {
|
|
103
|
+
pose,
|
|
104
|
+
...(opts.walls != null ? { walls: opts.walls } : {}),
|
|
105
|
+
...(opts.infill != null ? { infill: opts.infill } : {}),
|
|
106
|
+
};
|
|
72
107
|
const key = `${profile}|${n3(b.L)}|${pose}`;
|
|
73
|
-
if (!cache.has(key))
|
|
108
|
+
if (!cache.has(key))
|
|
109
|
+
cache.set(
|
|
110
|
+
key,
|
|
111
|
+
beamOf({ id: b.id, beam: { profile, length: b.L, material: opts.material, printed } }, (x) => x).model,
|
|
112
|
+
);
|
|
74
113
|
pm = cache.get(key);
|
|
75
114
|
}
|
|
76
|
-
const P = printerFigures('frame.printed', null),
|
|
115
|
+
const P = printerFigures('frame.printed', null),
|
|
116
|
+
bed = pm.printed.bed,
|
|
117
|
+
height = P.n('bed');
|
|
77
118
|
if (pose === 'standing' && b.L > height + 1e-9) return null;
|
|
78
|
-
const spliced = pose === 'lying' && b.L > bed + 1e-9,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
const spliced = pose === 'lying' && b.L > bed + 1e-9,
|
|
120
|
+
F = pm.figures,
|
|
121
|
+
E = pm.material.modulus,
|
|
122
|
+
nu = pm.profile.material?.poisson ?? 0.36;
|
|
123
|
+
const share = spliced ? PRINTED_DEFAULTS.splice_share.value : 1,
|
|
124
|
+
A = F.area.value;
|
|
125
|
+
return {
|
|
126
|
+
b,
|
|
127
|
+
pm,
|
|
128
|
+
pose,
|
|
129
|
+
spliced,
|
|
130
|
+
profile,
|
|
131
|
+
E,
|
|
132
|
+
strength: pm.printed.strength * share,
|
|
133
|
+
creepLimit: pm.printed.creep.limit * share,
|
|
134
|
+
grams: pm.mass,
|
|
135
|
+
section: {
|
|
136
|
+
A,
|
|
137
|
+
Iy: F.inertiaX.value,
|
|
138
|
+
Iz: F.inertiaY.value,
|
|
139
|
+
J: F.torsion.value,
|
|
140
|
+
Wy: F.modulusX.value,
|
|
141
|
+
Wz: F.modulusY.value,
|
|
142
|
+
},
|
|
143
|
+
material: { E, G: E / (2 * (1 + nu)), density: pm.mass > 0 ? pm.mass / 1000 / b.L / (A * 1e-6) : 0 },
|
|
144
|
+
};
|
|
83
145
|
}
|
|
84
146
|
|
|
85
147
|
// The frame's model with these beams printed (and their modulus times k, for creep)
|
|
86
|
-
const swapped = (base, cands, k = 1) => ({
|
|
87
|
-
|
|
148
|
+
const swapped = (base, cands, k = 1) => ({
|
|
149
|
+
...base,
|
|
150
|
+
sections: { ...base.sections, ...Object.fromEntries(cands.map((c) => [c.b.id, c.section])) },
|
|
151
|
+
materials: {
|
|
152
|
+
...base.materials,
|
|
153
|
+
...Object.fromEntries(cands.map((c) => [c.b.id, { ...c.material, E: c.material.E * k, G: c.material.G * k }])),
|
|
154
|
+
},
|
|
155
|
+
});
|
|
88
156
|
|
|
89
157
|
// a beam's own sag along its length, as a target
|
|
90
|
-
const alongOf = (b, ctx) => ({
|
|
158
|
+
const alongOf = (b, ctx) => ({
|
|
159
|
+
what: `${b.id} along its length`,
|
|
160
|
+
along: true,
|
|
161
|
+
beam: b,
|
|
162
|
+
from: 0,
|
|
163
|
+
to: b.L,
|
|
164
|
+
limit: ctx.limitFor(b, null),
|
|
165
|
+
});
|
|
91
166
|
|
|
92
167
|
// The frame as drawn (no beam printed): its sag at every target, and each beam along its length, in every case, keyed
|
|
93
168
|
// "what|case". Where one is past its limit the frame already misses it, printed or not.
|
|
94
169
|
function drawnSags(fm, ctx, targets) {
|
|
95
|
-
const solver = solveFrame(fm.model),
|
|
170
|
+
const solver = solveFrame(fm.model),
|
|
171
|
+
out = new Map(),
|
|
172
|
+
all = [...targets, ...[...fm.beams.values()].map((b) => alongOf(b, ctx))];
|
|
96
173
|
for (const cs of fm.cases) {
|
|
97
174
|
const res = stamp(fm, fm.model, solver.statics({ loads: fm.nodeLoads(cs.values, null, cs.push, cs.stall) }));
|
|
98
|
-
for (const t of all)
|
|
175
|
+
for (const t of all)
|
|
176
|
+
out.set(
|
|
177
|
+
`${t.what}|${cs.label}`,
|
|
178
|
+
t.node ? ctx.sagAt(res, t.node(cs.values), fm.down) : ctx.sagAlong(res, t.beam, t.from, t.to, fm.down).sag,
|
|
179
|
+
);
|
|
99
180
|
}
|
|
100
181
|
const missed = [];
|
|
101
|
-
for (const t of all) {
|
|
182
|
+
for (const t of all) {
|
|
183
|
+
let worst = 0;
|
|
184
|
+
for (const cs of fm.cases) worst = Math.max(worst, out.get(`${t.what}|${cs.label}`));
|
|
185
|
+
if (worst > t.limit.value + 1e-12) missed.push({ what: t.what, sag: worst, limit: t.limit, along: !!t.along });
|
|
186
|
+
}
|
|
102
187
|
return { sags: out, missed };
|
|
103
188
|
}
|
|
104
189
|
|
|
190
|
+
// The whole frame's first buckling factor under these loads, and the beam that moves most in its shape, as
|
|
191
|
+
// frame.buckling's second finding solves it (each element in four, for the bow); null where it is not found (no
|
|
192
|
+
// compression, a frame that tips over before it buckles, or a solve that fails)
|
|
193
|
+
function frameBuckling(model, loads) {
|
|
194
|
+
try {
|
|
195
|
+
const bk = solveFrame(subdivide(model, 4)).buckling({ loads, count: 1 });
|
|
196
|
+
if (bk.tipped || !(bk.factors[0] > 0)) return null;
|
|
197
|
+
const shape = bk.modes[0].shape,
|
|
198
|
+
lead = Object.entries(shape).reduce((p, q) =>
|
|
199
|
+
Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p,
|
|
200
|
+
);
|
|
201
|
+
return { factor: bk.factors[0], lead: lead[0].split(/[.@#/]/)[0] };
|
|
202
|
+
} catch (e) {
|
|
203
|
+
// (a fault in the kit is thrown on, not taken for a frame it cannot solve)
|
|
204
|
+
if (e instanceof TypeError || e instanceof ReferenceError) throw e;
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
105
209
|
/**
|
|
106
210
|
* Every margin of a frame with these beams printed, each 1 where it just holds: the sags against their limits (and
|
|
107
|
-
* each printed beam along its length), as it creeps too; per printed beam its stress,
|
|
108
|
-
* stress; and the lowest mode against the task's moves.
|
|
211
|
+
* each printed beam along its length), as it creeps too; per printed beam its stress, the whole frame's buckling factor
|
|
212
|
+
* in the case that squeezes it most, and its sustained stress; and the lowest mode against the task's moves.
|
|
109
213
|
*/
|
|
110
|
-
function evaluate(s, fm, ctx, cands, targets, drawn) {
|
|
111
|
-
const down = fm.down,
|
|
112
|
-
|
|
214
|
+
function evaluate(s, fm, ctx, cands, targets, drawn, bk) {
|
|
215
|
+
const down = fm.down,
|
|
216
|
+
margin = ctx.margin,
|
|
217
|
+
model = swapped(fm.model, cands),
|
|
218
|
+
creepK = PRINTED_DEFAULTS.creep_modulus.value,
|
|
219
|
+
creep = swapped(fm.model, cands, creepK);
|
|
220
|
+
const solver = solveFrame(model),
|
|
221
|
+
creeper = solveFrame(creep);
|
|
113
222
|
const all = [...targets, ...cands.map((c) => alongOf(c.b, ctx))];
|
|
114
|
-
const sagOf = (t, res, values) =>
|
|
115
|
-
|
|
116
|
-
|
|
223
|
+
const sagOf = (t, res, values) =>
|
|
224
|
+
t.node ? ctx.sagAt(res, t.node(values), down) : ctx.sagAlong(res, t.beam, t.from, t.to, down).sag;
|
|
225
|
+
let def = null,
|
|
226
|
+
creepSag = null;
|
|
227
|
+
const per = new Map(cands.map((c) => [c.b.id, { stress: 0, compression: 0, case: null, squeezed: null }]));
|
|
117
228
|
for (const cs of fm.cases) {
|
|
118
|
-
const loads = fm.nodeLoads(cs.values, null, cs.push, cs.stall),
|
|
229
|
+
const loads = fm.nodeLoads(cs.values, null, cs.push, cs.stall),
|
|
230
|
+
res = stamp(fm, model, solver.statics({ loads })),
|
|
231
|
+
cr = stamp(fm, creep, creeper.statics({ loads }));
|
|
119
232
|
for (const t of all) {
|
|
120
233
|
// where the frame as drawn already misses this sag, the printed beam is held to the drawn frame's own figure
|
|
121
|
-
const base = drawn.get(`${t.what}|${cs.label}`) ?? 0,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
234
|
+
const base = drawn.get(`${t.what}|${cs.label}`) ?? 0,
|
|
235
|
+
missed = base > t.limit.value + 1e-12,
|
|
236
|
+
lim = missed ? base * (1 + DRAWN_SLACK) : t.limit.value;
|
|
237
|
+
const sag = sagOf(t, res, cs.values),
|
|
238
|
+
long = sagOf(t, cr, cs.values),
|
|
239
|
+
m = sag > 1e-12 ? lim / sag : Infinity,
|
|
240
|
+
ml = long > 1e-12 ? lim / long : Infinity;
|
|
241
|
+
if (!def || m < def.margin)
|
|
242
|
+
def = { margin: m, sag, limit: t.limit, what: t.what, case: cs.label, drawn: missed ? base : null };
|
|
243
|
+
if (!creepSag || ml < creepSag.margin)
|
|
244
|
+
creepSag = { margin: ml, sag: long, limit: t.limit, what: t.what, case: cs.label, drawn: missed ? base : null };
|
|
245
|
+
}
|
|
246
|
+
for (const e of res.elements) {
|
|
247
|
+
const p = per.get(e.of);
|
|
248
|
+
if (!p) continue;
|
|
249
|
+
if (e.stress && e.stress.peak > p.stress) {
|
|
250
|
+
p.stress = e.stress.peak;
|
|
251
|
+
p.case = cs.label;
|
|
252
|
+
}
|
|
253
|
+
if (e.axial < -p.compression) {
|
|
254
|
+
p.compression = -e.axial;
|
|
255
|
+
p.squeezed = cs;
|
|
256
|
+
}
|
|
125
257
|
}
|
|
126
|
-
for (const e of res.elements) { const p = per.get(e.of); if (!p) continue; if (e.stress && e.stress.peak > p.stress) { p.stress = e.stress.peak; p.case = cs.label; } if (e.axial < -p.compression) p.compression = -e.axial; }
|
|
127
258
|
}
|
|
259
|
+
// the whole frame's buckling with these beams printed, in the case that squeezes each most (as frame.buckling's
|
|
260
|
+
// second finding solves the frame as drawn), against the frame as drawn in the same case
|
|
261
|
+
const buckled = new Map();
|
|
262
|
+
const bucklingIn = (cs) => {
|
|
263
|
+
if (!buckled.has(cs.label)) {
|
|
264
|
+
const loads = fm.nodeLoads(cs.values, null, cs.push, cs.stall);
|
|
265
|
+
buckled.set(cs.label, { printed: frameBuckling(model, loads), drawn: bk.drawn(cs, loads) });
|
|
266
|
+
}
|
|
267
|
+
return buckled.get(cs.label);
|
|
268
|
+
};
|
|
128
269
|
let freq = null;
|
|
129
270
|
const moves = ctx.excitesOf(s).filter((x) => x.kind === 'move');
|
|
130
271
|
if (moves.length) {
|
|
131
272
|
const need = Math.max(...moves.map((x) => x.Hz)) * margin;
|
|
132
|
-
for (const cs of fm.poses) {
|
|
273
|
+
for (const cs of fm.poses) {
|
|
274
|
+
const low = solveFrame(subdivide({ ...model, masses: fm.nodeMasses(cs.values) }, 4)).modes({ count: 1 })
|
|
275
|
+
.frequencies[0];
|
|
276
|
+
if (!freq || low < freq.low) freq = { low, need, margin: low / need, case: cs.label };
|
|
277
|
+
}
|
|
133
278
|
}
|
|
134
279
|
const out = new Map();
|
|
135
280
|
for (const c of cands) {
|
|
136
|
-
const p = per.get(c.b.id),
|
|
137
|
-
|
|
138
|
-
|
|
281
|
+
const p = per.get(c.b.id),
|
|
282
|
+
I = Math.min(c.section.Iy, c.section.Iz),
|
|
283
|
+
Pcr = (Math.PI ** 2 * c.E * I) / c.b.L ** 2;
|
|
284
|
+
// the frame's factor where it is found; where it is not (the solve fails, or the frame tips as drawn), Euler's load
|
|
285
|
+
// with an end free to sway, twice the beam's length: the cautious one
|
|
286
|
+
let buckle = null;
|
|
287
|
+
if (p.compression > 1e-9) {
|
|
288
|
+
const q = bucklingIn(p.squeezed),
|
|
289
|
+
drawnFactor = q.drawn?.factor,
|
|
290
|
+
held = drawnFactor != null && drawnFactor < margin ? drawnFactor / (1 + DRAWN_SLACK) : margin;
|
|
291
|
+
buckle = q.printed
|
|
292
|
+
? {
|
|
293
|
+
factor: q.printed.factor,
|
|
294
|
+
lead: q.printed.lead,
|
|
295
|
+
held,
|
|
296
|
+
drawn: drawnFactor != null && drawnFactor < margin ? drawnFactor : null,
|
|
297
|
+
case: p.squeezed.label,
|
|
298
|
+
}
|
|
299
|
+
: {
|
|
300
|
+
factor: Pcr / 4 / p.compression,
|
|
301
|
+
lead: null,
|
|
302
|
+
held: margin,
|
|
303
|
+
drawn: null,
|
|
304
|
+
sway: true,
|
|
305
|
+
case: p.squeezed.label,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const m = {
|
|
309
|
+
deflection: def?.margin ?? Infinity,
|
|
310
|
+
creepSag: creepSag?.margin ?? Infinity,
|
|
311
|
+
stress: p.stress > 0 ? c.strength / p.stress / margin : Infinity,
|
|
312
|
+
buckling: buckle ? buckle.factor / buckle.held : Infinity,
|
|
313
|
+
creep: p.stress > 0 ? c.creepLimit / p.stress : Infinity,
|
|
314
|
+
...(freq ? { frequency: freq.margin } : {}),
|
|
315
|
+
};
|
|
139
316
|
const governs = Object.entries(m).reduce((q, x) => (x[1] < q[1] ? x : q));
|
|
140
|
-
out.set(c.b.id, {
|
|
317
|
+
out.set(c.b.id, {
|
|
318
|
+
c,
|
|
319
|
+
margins: m,
|
|
320
|
+
least: governs[1],
|
|
321
|
+
governs: governs[0],
|
|
322
|
+
stress: p.stress,
|
|
323
|
+
compression: p.compression,
|
|
324
|
+
euler: Pcr,
|
|
325
|
+
buckle,
|
|
326
|
+
def,
|
|
327
|
+
creepSag,
|
|
328
|
+
freq,
|
|
329
|
+
});
|
|
141
330
|
}
|
|
142
331
|
return out;
|
|
143
332
|
}
|
|
@@ -150,22 +339,47 @@ function joinsToChange(fm, b) {
|
|
|
150
339
|
const out = [];
|
|
151
340
|
for (const x of fm.joins) {
|
|
152
341
|
const kind = x.j.kind;
|
|
153
|
-
if (x.A === b && INTO_END.includes(kind))
|
|
154
|
-
|
|
342
|
+
if (x.A === b && INTO_END.includes(kind))
|
|
343
|
+
out.push({
|
|
344
|
+
join: x.j.index,
|
|
345
|
+
label: x.j.label,
|
|
346
|
+
why: `${x.j.label} screws into its end ${x.e}, where a printed beam has an insert, no bore to tap or pocket`,
|
|
347
|
+
});
|
|
348
|
+
else if (x.B === b && JOINS[kind]?.slot && String(x.j.address ?? '').split(/[.@]/)[0] !== 'top')
|
|
349
|
+
out.push({
|
|
350
|
+
join: x.j.index,
|
|
351
|
+
label: x.j.label,
|
|
352
|
+
why: `${x.j.label} lands on its ${String(x.j.address).split(/[.@]/)[0]} face, which a printed beam has closed`,
|
|
353
|
+
});
|
|
155
354
|
}
|
|
156
355
|
return out;
|
|
157
356
|
}
|
|
158
357
|
|
|
159
358
|
// what a margin is, in a few words
|
|
160
359
|
function sayMargin(r, k) {
|
|
161
|
-
const m = r.margins[k],
|
|
360
|
+
const m = r.margins[k],
|
|
361
|
+
x = (v) => (v === Infinity ? 'free' : `${n3(v, 2)}`);
|
|
162
362
|
// where the frame as drawn already misses the limit: the figure held to is its own sag plus DRAWN_SLACK
|
|
163
|
-
const held = (d) =>
|
|
363
|
+
const held = (d) =>
|
|
364
|
+
`${fig(d.drawn * (1 + DRAWN_SLACK))} mm, the frame as drawn (${fig(d.drawn)} mm, already past its ${fig(d.limit.value)} mm there, printed or not) and ${DRAWN_SLACK * 100}% more`;
|
|
164
365
|
const sagSaid = (d) => (d.drawn != null ? fig(d.sag) : n3(d.sag));
|
|
165
|
-
if (k === 'deflection')
|
|
166
|
-
|
|
167
|
-
if (k === '
|
|
168
|
-
|
|
366
|
+
if (k === 'deflection')
|
|
367
|
+
return `${x(m)} on sag (${sagSaid(r.def)} mm at ${r.def.what} against ${r.def.drawn != null ? held(r.def) : `${n3(r.def.limit.value)} mm, ${r.def.limit.from}`})`;
|
|
368
|
+
if (k === 'creepSag')
|
|
369
|
+
return `${x(m)} on sag as it creeps (${sagSaid(r.creepSag)} mm at ${r.creepSag.what}${r.creepSag.drawn != null ? ` against ${held(r.creepSag)}` : ''})`;
|
|
370
|
+
if (k === 'stress')
|
|
371
|
+
return `${x(m)} on stress (${n3(r.stress, 2)} MPa against ${n3(r.c.strength, 1)} MPa${r.c.spliced ? ' as spliced' : ''}, twice the margin wanted)`;
|
|
372
|
+
if (k === 'buckling') {
|
|
373
|
+
const q = r.buckle,
|
|
374
|
+
wanted =
|
|
375
|
+
q.drawn != null
|
|
376
|
+
? `held to the frame as drawn, which buckles at ${n3(q.drawn, 2)} times, ${DRAWN_SLACK * 100}% less`
|
|
377
|
+
: 'twice wanted';
|
|
378
|
+
const how = q.sway
|
|
379
|
+
? `the whole frame's buckling is not found, so it is taken free to sway at one end, at a quarter of Euler's load with both ends pinned`
|
|
380
|
+
: `the whole frame with it printed buckles at ${n3(q.factor, 2)} times its load${q.lead && q.lead !== r.c.b.id ? `, ${q.lead} moving most` : ''}`;
|
|
381
|
+
return `${x(m)} on buckling (${how}: about ${n3(q.factor * r.compression, 0)} N along it against its ${n3(r.compression, 1)} N, ${wanted}; Euler's load for it alone, both ends pinned, is ${n3(r.euler, 0)} N)`;
|
|
382
|
+
}
|
|
169
383
|
if (k === 'creep') return `${x(m)} on creep (${n3(r.stress, 2)} MPa held against ${n3(r.c.creepLimit, 2)} MPa)`;
|
|
170
384
|
return `${x(m)} on its lowest mode (${n3(r.freq.low, 1)} Hz against ${n3(r.freq.need, 1)} Hz, twice the task's moves)`;
|
|
171
385
|
}
|
|
@@ -176,55 +390,173 @@ function sayMargin(r, k) {
|
|
|
176
390
|
* @param {object} s a built assembly @param {object} fm frameModelOf's @param {Function} f the findings' sink @param {object} ctx frameChecks' helpers
|
|
177
391
|
*/
|
|
178
392
|
export function printableCheck(s, fm, f, ctx) {
|
|
179
|
-
const opts = printedOption(s.a.frame.printed)
|
|
393
|
+
const opts = printedOption(s.a.frame.printed);
|
|
180
394
|
const targets = [
|
|
181
|
-
...fm.loads.map((l) => {
|
|
395
|
+
...fm.loads.map((l) => {
|
|
396
|
+
const b = l.beam ?? l.mount.beam;
|
|
397
|
+
return {
|
|
398
|
+
what: l.where,
|
|
399
|
+
node: (values) => fm.nodeAt(b, l.beam ? l.z : fm.mountStation(l.mount, values)),
|
|
400
|
+
limit: ctx.limitFor(b, null),
|
|
401
|
+
};
|
|
402
|
+
}),
|
|
182
403
|
...fm.points.map((p) => ({ what: p.where, node: () => fm.nodeAt(p.beam, p.z), limit: ctx.limitFor(p.beam, null) })),
|
|
183
|
-
...fm.guides.map((g) => ({
|
|
404
|
+
...fm.guides.map((g) => ({
|
|
405
|
+
what: `guide ${g.id}`,
|
|
406
|
+
beam: g.beam,
|
|
407
|
+
from: g.from,
|
|
408
|
+
to: g.to,
|
|
409
|
+
limit: g.tolerance
|
|
410
|
+
? { value: g.tolerance.value, from: "the rail's own parallelism" }
|
|
411
|
+
: ctx.limitFor(g.beam, null),
|
|
412
|
+
})),
|
|
184
413
|
];
|
|
185
414
|
const rests = `the printed section's walls and infill, its plastic's figures and the creep shares (estimates until the beam coupon is measured)${fm.joins.length ? `, and ${ctx.restsJoins} as they are, made for metal beams` : ''}`;
|
|
186
|
-
const best = new Map(),
|
|
415
|
+
const best = new Map(),
|
|
416
|
+
none = [],
|
|
417
|
+
cache = new Map(),
|
|
418
|
+
drawn = drawnSags(fm, ctx, targets);
|
|
419
|
+
// the frame as drawn, its buckling in a case, solved once each: a printed beam is not blamed for a frame that
|
|
420
|
+
// already buckles sooner than twice its load
|
|
421
|
+
const drawnBuckling = new Map(),
|
|
422
|
+
bk = {
|
|
423
|
+
drawn: (cs, loads) => {
|
|
424
|
+
if (!drawnBuckling.has(cs.label)) drawnBuckling.set(cs.label, frameBuckling(fm.model, loads));
|
|
425
|
+
return drawnBuckling.get(cs.label);
|
|
426
|
+
},
|
|
427
|
+
};
|
|
187
428
|
for (const b of fm.beams.values()) {
|
|
188
|
-
let pick = null,
|
|
429
|
+
let pick = null,
|
|
430
|
+
why = null;
|
|
189
431
|
for (const pose of opts.pose ? [opts.pose] : ['lying', 'standing']) {
|
|
190
432
|
const c = candidate(b, opts, pose, cache);
|
|
191
433
|
if (!c) continue;
|
|
192
|
-
if (c.why) {
|
|
193
|
-
|
|
434
|
+
if (c.why) {
|
|
435
|
+
why = c.why;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
const r = evaluate(s, fm, ctx, [c], targets, drawn.sags, bk).get(b.id);
|
|
194
439
|
if (!pick || r.least > pick.least * 1.01) pick = r; // (lying down, its stronger way, unless standing is clearly better)
|
|
195
440
|
}
|
|
196
|
-
if (!pick) {
|
|
441
|
+
if (!pick) {
|
|
442
|
+
none.push({ b, why: why ?? `${b.id} prints neither way` });
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
197
445
|
best.set(b.id, pick);
|
|
198
446
|
}
|
|
199
|
-
const plastic = opts.material.toUpperCase(),
|
|
200
|
-
|
|
447
|
+
const plastic = opts.material.toUpperCase(),
|
|
448
|
+
poseSaid = (c) =>
|
|
449
|
+
c.pose === 'lying'
|
|
450
|
+
? `lying down${c.spliced ? `, spliced (${n3(c.b.L, 1)} mm, longer than the bed)` : ''}`
|
|
451
|
+
: 'standing up';
|
|
452
|
+
for (const { b, why } of none)
|
|
453
|
+
f('info', `${b.id} stays ${b.alloy ?? 'as it is'}: ${why}`, null, {
|
|
454
|
+
code: 'beam.printable',
|
|
455
|
+
between: [r4(b.A), r4(add(b.A, scale(b.u, b.L)))],
|
|
456
|
+
refs: { beam: b.id, material: opts.material, printable: false },
|
|
457
|
+
});
|
|
201
458
|
for (const r of best.values()) {
|
|
202
|
-
const c = r.c,
|
|
203
|
-
|
|
459
|
+
const c = r.c,
|
|
460
|
+
b = c.b,
|
|
461
|
+
ok = r.least >= 1,
|
|
462
|
+
order = Object.keys(r.margins)
|
|
463
|
+
.filter((k) => r.margins[k] !== Infinity)
|
|
464
|
+
.sort((p, q) => r.margins[p] - r.margins[q]);
|
|
465
|
+
const change = b.m.printed ? [] : joinsToChange(fm, b),
|
|
466
|
+
joinsSaid = change.length
|
|
467
|
+
? `. Its joins as drawn need changing to print it: ${change.map((x) => x.why).join('; ')}. A bracket or a gusset on its top slot takes it, its spring then a printed fitting's`
|
|
468
|
+
: '';
|
|
204
469
|
r.change = change;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
470
|
+
// a beam drawn printed is tried as it is drawn, in its own plastic: it stays printed, and has no metal to go back to
|
|
471
|
+
const own = b.m.printed ? (b.m.material?.name ?? opts.material).toUpperCase() : plastic,
|
|
472
|
+
margins = order.map((k) => sayMargin(r, k)).join('; ');
|
|
473
|
+
const text = b.m.printed
|
|
474
|
+
? ok
|
|
475
|
+
? `${b.id} stays printed (it is drawn printed), in ${own}, ${poseSaid(c)} (${c.profile}, ${n3(c.grams, 1)} g): its least margin is ${n3(r.least, 2)} times, ${said[r.governs]}. ${margins}. It rests on ${rests}`
|
|
476
|
+
: `${b.id} stays printed (it is drawn printed): in ${own}, ${poseSaid(c)} (${c.profile}), it misses by ${n3(1 / r.least, 2)} times on ${said[r.governs]}: a deeper section, a shorter span, or a metal beam. ${margins}. It rests on ${rests}`
|
|
477
|
+
: ok
|
|
478
|
+
? `${b.id} can be printed in ${plastic}, ${poseSaid(c)} (${c.profile}, ${n3(c.grams, 1)} g): its least margin is ${n3(r.least, 2)} times, ${said[r.governs]}. ${margins}${joinsSaid}. It rests on ${rests}`
|
|
479
|
+
: `${b.id} needs ${b.alloy ?? 'its own material'}: printed in ${plastic}, ${poseSaid(c)} (${c.profile}), it misses by ${n3(1 / r.least, 2)} times on ${said[r.governs]}. ${margins}. It rests on ${rests}`;
|
|
480
|
+
f(ok ? 'pass' : 'info', text, null, {
|
|
481
|
+
code: 'beam.printable',
|
|
482
|
+
at: r4(add(b.A, scale(b.u, b.L / 2))),
|
|
483
|
+
between: [r4(b.A), r4(add(b.A, scale(b.u, b.L)))],
|
|
484
|
+
values: {
|
|
485
|
+
margin: r3(r.least),
|
|
486
|
+
misses: ok ? null : r3(1 / r.least),
|
|
487
|
+
grams: r3(c.grams),
|
|
488
|
+
modulus: c.E,
|
|
489
|
+
strength: r3(c.strength),
|
|
490
|
+
margins: Object.fromEntries(Object.entries(r.margins).map(([k, v]) => [k, r3(v)])),
|
|
491
|
+
sag: r3(r.def?.sag),
|
|
492
|
+
limit: r3(r.def?.limit.value),
|
|
493
|
+
creepSag: r3(r.creepSag?.sag),
|
|
494
|
+
drawnSag: r.def?.drawn != null ? +r.def.drawn.toPrecision(3) : null,
|
|
495
|
+
},
|
|
496
|
+
refs: {
|
|
497
|
+
beam: b.id,
|
|
498
|
+
material: opts.material,
|
|
499
|
+
printable: ok,
|
|
500
|
+
pose: c.pose,
|
|
501
|
+
spliced: c.spliced,
|
|
502
|
+
profile: c.profile,
|
|
503
|
+
governs: r.governs,
|
|
504
|
+
alloy: b.alloy,
|
|
505
|
+
joins: change.map((x) => x.join),
|
|
506
|
+
restsOn: 'estimate',
|
|
507
|
+
},
|
|
508
|
+
});
|
|
211
509
|
}
|
|
212
510
|
// those that pass alone, printed together: put back the one that misses most until all of them hold
|
|
213
|
-
let together = [...best.values()].filter((r) => r.least >= 1).map((r) => r.c),
|
|
511
|
+
let together = [...best.values()].filter((r) => r.least >= 1).map((r) => r.c),
|
|
512
|
+
back = [],
|
|
513
|
+
least = null;
|
|
214
514
|
while (together.length) {
|
|
215
|
-
const rs = evaluate(s, fm, ctx, together, targets, drawn.sags
|
|
216
|
-
|
|
217
|
-
|
|
515
|
+
const rs = evaluate(s, fm, ctx, together, targets, drawn.sags, bk),
|
|
516
|
+
worst = [...rs.values()].reduce((p, q) => (q.least < p.least ? q : p));
|
|
517
|
+
if (worst.least >= 1) {
|
|
518
|
+
least = worst;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
back.push(worst.c.b.id);
|
|
522
|
+
together = together.filter((c) => c !== worst.c);
|
|
218
523
|
}
|
|
219
|
-
const all = fm.beams.size,
|
|
524
|
+
const all = fm.beams.size,
|
|
525
|
+
metal = [...fm.beams.keys()].filter((id) => !together.some((c) => c.b.id === id));
|
|
220
526
|
const changes = [...new Set(together.flatMap((c) => best.get(c.b.id).change ?? []).map((x) => x.join))];
|
|
221
|
-
const changeSaid = changes.length
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
527
|
+
const changeSaid = changes.length
|
|
528
|
+
? `. ${changes.length} of its joins need changing to a bracket or a gusset on a printed beam's top slot (each beam's finding says which)`
|
|
529
|
+
: '';
|
|
530
|
+
const text =
|
|
531
|
+
together.length === all
|
|
532
|
+
? `every beam of the frame can be printed in ${plastic} (${all}), printed together and solved once more: the least margin is ${sayMargin(least, least.governs)}${['deflection', 'creepSag', 'frequency'].includes(least.governs) ? '' : ` at ${least.c.b.id}`}; ${n3(
|
|
533
|
+
together.reduce((t, c) => t + c.grams, 0),
|
|
534
|
+
0,
|
|
535
|
+
)} g of ${plastic} in all`
|
|
536
|
+
: `${together.length} of the frame's ${all} beams can be printed in ${plastic}${together.length ? ` (${together.map((c) => c.b.id).join(', ')}), printed together and solved once more, the least margin ${sayMargin(least, least.governs)}` : ''}; ${metal.join(', ')} stay${metal.length === 1 ? 's' : ''} as ${metal.length === 1 ? 'it is' : 'they are'}${back.length ? `, of them ${back.join(', ')} passing alone but not printed with the rest` : ''}`;
|
|
537
|
+
const missedSaid = drawn.missed.length
|
|
538
|
+
? `. As drawn, unprinted, the frame already misses ${drawn.missed.map((x) => `${fig(x.sag)} mm at ${x.what} (against ${fig(x.limit.value)} mm)${x.along ? ' (along the beam, where frame.deflection does not look: it checks the load points, named points and guides)' : ' (frame.deflection fails there)'}`).join(', ')}: there a printed beam is held to the frame as drawn, within ${DRAWN_SLACK * 100}%, and blamed only where printing it makes that sag worse`
|
|
539
|
+
: '';
|
|
540
|
+
f(together.length === all ? 'pass' : 'info', `${text}${changeSaid}${missedSaid}. It rests on ${rests}`, null, {
|
|
541
|
+
code: 'beam.printable',
|
|
542
|
+
values: {
|
|
543
|
+
printable: together.length,
|
|
544
|
+
beams: all,
|
|
545
|
+
margin: r3(least?.least),
|
|
546
|
+
grams: r3(together.reduce((t, c) => t + c.grams, 0)),
|
|
547
|
+
},
|
|
548
|
+
refs: {
|
|
549
|
+
material: opts.material,
|
|
550
|
+
printable: together.map((c) => c.b.id),
|
|
551
|
+
metal,
|
|
552
|
+
back,
|
|
553
|
+
governs: least?.governs ?? null,
|
|
554
|
+
joins: changes,
|
|
555
|
+
missed: drawn.missed.map((x) => x.what),
|
|
556
|
+
poses: Object.fromEntries(together.map((c) => [c.b.id, c.pose])),
|
|
557
|
+
restsOn: 'estimate',
|
|
558
|
+
},
|
|
559
|
+
});
|
|
228
560
|
}
|
|
229
561
|
|
|
230
562
|
/**
|
|
@@ -239,28 +571,99 @@ export function couponChecks(s, fm, f, ctx) {
|
|
|
239
571
|
const p = b.m.printed;
|
|
240
572
|
if (!p) continue;
|
|
241
573
|
// beam.creep: its peak stress as drawn and in every pose, held for months
|
|
242
|
-
let stress = 0,
|
|
243
|
-
|
|
574
|
+
let stress = 0,
|
|
575
|
+
where = null;
|
|
576
|
+
for (const r of ctx.results)
|
|
577
|
+
for (const e of r.spring.elements)
|
|
578
|
+
if (e.of === b.id && e.stress && e.stress.peak > stress) {
|
|
579
|
+
stress = e.stress.peak;
|
|
580
|
+
where = r.case.label;
|
|
581
|
+
}
|
|
244
582
|
const c = beamCreep(b.m, { stress: r3(stress) });
|
|
245
|
-
f(
|
|
583
|
+
f(
|
|
584
|
+
c.level,
|
|
585
|
+
`${b.id}: ${c.text.replace(/^[^:]+: /, '')}${fm.cases.length > 1 ? `, worst ${where}` : ''}`,
|
|
586
|
+
c.level === 'fail' ? `${b.id}: creeps` : null,
|
|
587
|
+
{ code: 'beam.creep', at: r4(add(b.A, scale(b.u, b.L / 2))), values: c.values, refs: { ...c.refs, beam: b.id } },
|
|
588
|
+
);
|
|
246
589
|
// the coupon: two supports on it alone, no join, a mass on it
|
|
247
|
-
const sups = fm.supports.filter((x) => x.beam === b),
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
590
|
+
const sups = fm.supports.filter((x) => x.beam === b),
|
|
591
|
+
loads = fm.loads.filter((l) => l.beam === b);
|
|
592
|
+
if (
|
|
593
|
+
sups.length !== 2 ||
|
|
594
|
+
!sups.every((x) => x.said) ||
|
|
595
|
+
fm.joins.some((x) => x.A === b || x.B === b) ||
|
|
596
|
+
!loads.length
|
|
597
|
+
)
|
|
598
|
+
continue;
|
|
599
|
+
const mat = b.m.material.name,
|
|
600
|
+
lying = p.pose === 'lying',
|
|
601
|
+
z = lying ? '' : '_z',
|
|
602
|
+
E = p.modulus,
|
|
603
|
+
S = p.strength;
|
|
604
|
+
const solver = solveFrame(fm.model),
|
|
605
|
+
peak = (res) => Math.max(0, ...res.elements.filter((e) => e.of === b.id && e.stress).map((e) => e.stress.peak));
|
|
251
606
|
const self = peak(solver.statics({ loads: [] }));
|
|
252
607
|
for (const l of loads) {
|
|
253
|
-
const one = fm.nodeLoads(drawn.case.values, l),
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
608
|
+
const one = fm.nodeLoads(drawn.case.values, l),
|
|
609
|
+
res = solver.statics({ loads: one, gravity: [0, 0, 0] }),
|
|
610
|
+
node = one[0].node,
|
|
611
|
+
sag = ctx.sagAt(res, node, fm.down),
|
|
612
|
+
perKg = peak(res) / l.kg;
|
|
613
|
+
const breaks = (S - self) / perKg,
|
|
614
|
+
span = Math.abs(sups[0].z - sups[1].z);
|
|
615
|
+
const rests = `${mat}'s ${lying ? 'modulus along its layers' : 'modulus across its layers'} ${E} MPa${p.coupon?.modulus ? ` (${p.coupon.modulus}, ${p.modulusKind})` : " (the plastic's data sheet: an estimate for a printed beam)"} and its printed section, ${n3(p.section.inertiaX, 0)} mm⁴ from ${p.walls} walls and ${Math.round(p.infill * 100)}% infill (an estimate)`;
|
|
616
|
+
f(
|
|
617
|
+
'info',
|
|
618
|
+
`${b.id} is the beam coupon, printed ${lying ? 'lying down' : 'standing up'}, across ${n3(span, 1)} mm between ${sups.map((x) => x.where).join(' and ')}: ${n3(l.kg, 3)} kg at ${l.where} sags it ${n3(sag)} mm, from ${rests}. Read it with a dial and write it back: cad measured ${s.project}/${s.name} ${b.id}.sag=<mm>, and the modulus goes to ${mat}.beam_modulus${z}`,
|
|
619
|
+
null,
|
|
620
|
+
{
|
|
621
|
+
code: 'beam.coupon',
|
|
622
|
+
at: r4(fm.nodes[node]),
|
|
623
|
+
values: { sag: r3(sag), kg: l.kg, span: r3(span), modulus: E, inertia: p.section.inertiaX },
|
|
624
|
+
predict: {
|
|
625
|
+
name: `${b.id}.sag`,
|
|
626
|
+
figure: `sag of the beam coupon ${b.id} under ${l.kg} kg`,
|
|
627
|
+
value: r3(sag),
|
|
628
|
+
unit: 'mm',
|
|
629
|
+
coupon: {
|
|
630
|
+
rule: `${mat}.beam_modulus${z}`,
|
|
631
|
+
kind: 'modulus',
|
|
632
|
+
base: E,
|
|
633
|
+
sag,
|
|
634
|
+
unit: 'MPa',
|
|
635
|
+
what: `${n3(l.kg, 3)} kg at ${l.where}, across ${n3(span, 1)} mm`,
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
refs: { beam: b.id, rule: `${mat}.beam_modulus${z}`, pose: p.pose, kind: p.modulusKind },
|
|
639
|
+
},
|
|
640
|
+
);
|
|
641
|
+
f(
|
|
642
|
+
'info',
|
|
643
|
+
`${b.id}, the beam coupon: it breaks at about ${n3(breaks, 2)} kg hung at ${l.where}, where its stress reaches ${S} MPa (${p.coupon?.strength ? `${p.coupon.strength}, measured` : `${mat}'s strength ${lying ? 'along' : 'across'} its layers, ${p.strengthKind}`}). Last of all, pull it down there until it breaks (a luggage scale on the cord, its peak in kg), and write that: cad measured ${s.project}/${s.name} ${b.id}.break=<kg>, and the strength goes to ${mat}.beam_strength${z}`,
|
|
644
|
+
null,
|
|
645
|
+
{
|
|
646
|
+
code: 'beam.coupon',
|
|
647
|
+
at: r4(fm.nodes[node]),
|
|
648
|
+
values: { breaks: r3(breaks), strength: S, perKg: r3(perKg), self: r3(self) },
|
|
649
|
+
predict: {
|
|
650
|
+
name: `${b.id}.break`,
|
|
651
|
+
figure: `mass the beam coupon ${b.id} breaks at`,
|
|
652
|
+
value: r3(breaks),
|
|
653
|
+
unit: 'kg',
|
|
654
|
+
coupon: {
|
|
655
|
+
rule: `${mat}.beam_strength${z}`,
|
|
656
|
+
kind: 'strength',
|
|
657
|
+
base: S,
|
|
658
|
+
perKg,
|
|
659
|
+
self,
|
|
660
|
+
unit: 'MPa',
|
|
661
|
+
what: `hung at ${l.where}, across ${n3(span, 1)} mm`,
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
refs: { beam: b.id, rule: `${mat}.beam_strength${z}`, pose: p.pose, kind: p.strengthKind },
|
|
665
|
+
},
|
|
666
|
+
);
|
|
264
667
|
}
|
|
265
668
|
}
|
|
266
669
|
}
|
|
@@ -273,5 +676,7 @@ export function couponChecks(s, fm, f, ctx) {
|
|
|
273
676
|
* @param {number} predicted @param {number} measured
|
|
274
677
|
*/
|
|
275
678
|
export function couponFigure(c, predicted, measured) {
|
|
276
|
-
return Number(
|
|
679
|
+
return Number(
|
|
680
|
+
(c.kind === 'modulus' ? (c.base * (c.sag ?? predicted)) / measured : c.self + c.perKg * measured).toPrecision(4),
|
|
681
|
+
);
|
|
277
682
|
}
|