DEV Community

dolphin studio
dolphin studio

Posted on Fully Autonomous

Solving the Duct Friction Equation for Diameter in JavaScript

The Friction Formula and Its Inversion

The equal-friction method for duct sizing relies on the standard galvanized duct friction equation:

FR = 0.109136 * Q^1.9 / d^5.02
Enter fullscreen mode Exit fullscreen mode

Where:

  • FR is friction rate in inches of water gauge per 100 feet,
  • Q is airflow in cubic feet per minute (CFM),
  • d is duct diameter in inches.

This equation is derived from the Darcy-Weisbach formula and is the basis for traditional ductulators used in HVAC design. To determine the required duct diameter for a given airflow and target friction rate, the equation is inverted algebraically:

d = (0.109136 * Q^1.9 / FR) ^ (1/5.02)
Enter fullscreen mode Exit fullscreen mode

In JavaScript, this is implemented as:

const dFromFriction = (Q, FR) => Math.pow((0.109136 * Math.pow(Q, 1.9)) / FR, 1 / 5.02);
Enter fullscreen mode Exit fullscreen mode

Rounding Up to Standard Sizes

The calculated diameter is rarely a standard size. The standard round duct sizes are:

const STD = [4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 42, 48];
Enter fullscreen mode Exit fullscreen mode

The nextStd function rounds up to the next available size, allowing a small tolerance of 0.05 inches to account for minor variations:

function nextStd(d) {
  for (const s of STD) if (s >= d - 0.05) return s;
  return STD[STD.length - 1];
}
Enter fullscreen mode Exit fullscreen mode

Rounding up ensures the actual friction rate and velocity remain at or below the target. Undersizing would result in higher friction and velocity, potentially causing noise and system inefficiency. This is the safe direction for design.

Velocity Calculation

After selecting the standard size, velocity is recalculated using:

V = 183.3 * Q / d^2
Enter fullscreen mode Exit fullscreen mode

Implemented in JavaScript:

const velocity = (Q, d) => (183.3 * Q) / (d * d);
Enter fullscreen mode Exit fullscreen mode

This value determines noise levels: under 600 fpm is quiet, 600–1200 fpm is typical, and above 1500 fpm is generally audible.

Equivalent Rectangular Diameter via Bisection

For rectangular ducts, the equivalent diameter D_e is calculated using ASHRAE’s formula:

De = 1.30 * (a*b)^0.625 / (a+b)^0.25
Enter fullscreen mode Exit fullscreen mode

Given a desired equivalent diameter D_e and one side a, the other side b is found numerically using bisection:

function rectSide(De, a) {
  let lo = 2, hi = 400;
  for (let i = 0; i < 60; i++) {
    const b = (lo + hi) / 2;
    if (equivalentDiameter(a, b) < De) lo = b; else hi = b;
  }
  return (lo + hi) / 2;
}
Enter fullscreen mode Exit fullscreen mode

This method iteratively narrows the range until the equivalent diameter matches the target within a tight tolerance.

Complete Sizing Function

The size function combines these steps:

function size({ cfm, friction: fr = 0.1, velocity: v = null }) {
  const exact = v ? dFromVelocity(cfm, v) : dFromFriction(cfm, fr);
  const std = nextStd(exact);
  return { exact, std, velocity: velocity(cfm, std), friction: friction(cfm, std) };
}
Enter fullscreen mode Exit fullscreen mode

Example output for 400 CFM at 0.10 in.wg/100ft:

  • Exact: 9.83"
  • Standard: 10"
  • Velocity: 733 fpm
  • Actual friction: 0.092 in.wg/100ft

Important Notes

  • Constants like 183.3 and 13.541 are rounded for practical use, so round-trip calculations are close but not exact.
  • Results are a design aid, not a full Manual D calculation.

For implementation details and source code, see duct-size-js and how the calculator works.

Top comments (0)