Checks a pipe run's size and valves against its pipe spec and says how a branch is made and what bend radius the spec gives.
How the precision is kept
Sizes are nominal sizes from the pipe tables, compared as 64-bit numbers with an absolute tolerance of 1e-9. The branch rule is chosen by the ratio of the branch's nominal size to the header's.
Calculations under this policy
3 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
The pipe sizes between the spec's smallest and largest.
min − 1e-9 ≤ nominal ≤ max + 1e-9
Nominal sizes are compared as 64-bit numbers with an absolute 1e-9 either side.
addons/plant/lib/spec.js
lines 94 to 97
BimCraft 0.8.1
export function allowedSizes(spec) {
const lo = nominal(spec.sizes.min), hi = nominal(spec.sizes.max);
return sizesFor(spec.material, spec.cls).filter((s) => nominal(s) >= lo - 1e-9 && nominal(s) <= hi + 1e-9);
}
How a branch is made
64-bit
Whether a branch on a header is a tee, a reducing tee or a stub-in.
ratio = branch ÷ header; rule = first with ratio ≤ limit + 1e-9
One 64-bit division. A branch larger than the header by more than 1e-9 has no answer; with no matching rule a ratio of at least 1 − 1e-9 is a tee.
addons/plant/lib/spec.js
lines 104 to 111
BimCraft 0.8.1
/** How a branch of one size is made on a header of another, by the spec's rules; null when the branch is larger than the header. */
export function branchKind(spec, header, branch) {
const h = nominal(header), b = nominal(branch);
if (!(h > 0) || !(b > 0) || b > h + 1e-9) return null;
const ratio = b / h;
const rule = spec.branch.find((r) => ratio <= r.ratio + 1e-9);
return rule ? rule.kind : (ratio >= 1 - 1e-9 ? 'tee' : 'reducing-tee');
}
Bend radius of a spec
64-bit
The center-line radius of the spec's elbows for a size, in inches.
short: max(nominal size, outside diameter); long: the table's radius
A table value, or the larger of two table values; nothing is computed beyond the comparison.
addons/plant/lib/spec.js
lines 113 to 118
BimCraft 0.8.1
/** Centre-line radius of the spec's elbows in inches: the table's long radius (1.5 × nominal from 3/4), or one nominal size. */
export function bendRadius(spec, size) {
const p = pipeSize(spec.material, spec.cls, size);
if (!p) return null;
return spec.bends === 'short' ? Math.max(nominal(size), p.od) : tableBendRadius(p);
}
In detail
Method
Allowed sizes = the table sizes between the spec's minimum and maximum. Branch: ratio = branch ÷ header, and the first rule whose limit is not below it applies. Bend radius: the table's long radius, or for short bends the larger of the nominal size and the outside diameter.
Number types
64-bit numbers; sizes in inches.
Tolerances
1e-9 (absolute) on the size limits and on the branch ratio.
Limits
The starter rules use a reducing tee up to a ratio of 0.9999 and, where stub-ins are allowed, a stub-in up to 0.25.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.