-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhorizontal_pipe_check.js
More file actions
72 lines (59 loc) · 2.32 KB
/
horizontal_pipe_check.js
File metadata and controls
72 lines (59 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// horizontal_pipe_check.js
// Check if horizontal pipe can sustain the required flow (Darcy–Weisbach + Colebrook–White)
const input = require('./inputData');
const { calculateReynoldsNumber, solveColebrookWhite } = require('./utils');
/**
* Calculates maximum flow rate through a horizontal pipe using Darcy–Weisbach and Colebrook–White equations
* @param {number} diameter - internal pipe diameter (m)
* @param {number} length - pipe length (m)
* @param {number} slope - pipe slope (m/m)
* @param {number} roughness - absolute roughness of the pipe (m)
* @param {number} viscosity - kinematic viscosity of fluid (m²/s)
* @param {number} fillingDegreeHor - degree of filling (0 < x <= 1)
* @returns {number} maxFlowLps - max flow in liters per second (L/s)
*/
function calculateHorizontalPipeCapacity(
diameter,
length,
slope,
roughness,
viscosity,
fillingDegreeHor
) {
const g = 9.81;
// Hydraulic radius (assuming circular pipe partially filled)
const rHydraulic = (diameter * fillingDegreeHor) / 2;
// Use slope as head loss per unit length
const hf = slope * length;
// Estimate velocity iteratively
const area = (Math.PI * Math.pow(diameter, 2)) / 4 * fillingDegreeHor
;
let velocity = Math.sqrt(2 * g * hf);
const reynolds = calculateReynoldsNumber(velocity, diameter, viscosity);
const frictionFactor = solveColebrookWhite(reynolds, diameter, roughness);
velocity = Math.sqrt((2 * g * hf) / (1 + frictionFactor * length / diameter));
const flowRate = velocity * area; // m³/s
return flowRate * 1000; // convert to L/s
}
module.exports = {
calculateHorizontalPipeCapacity,
testHorizontalPipe: () => {
const totalRequiredFlow = require('./OWS_size_calc').calculateRequiredOWSFlowRate();
const flowPerBranch = totalRequiredFlow / input.pipeBranchCount;
const branchCapacity = calculateHorizontalPipeCapacity(
input.pipeDiameterM,
input.horizontalLengthM,
input.pipeSlopeMPerM,
input.roughnessM,
input.kinematicViscosityM2s,
input. fillingDegreeHor
);
const totalCapacity = branchCapacity * input.pipeBranchCount;
return {
flowPerBranch: flowPerBranch.toFixed(3),
branchCapacity: branchCapacity.toFixed(3),
totalCapacity: totalCapacity.toFixed(3),
isSufficient: totalCapacity >= totalRequiredFlow,
};
}
};