-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateManiSizeOptions.js
More file actions
93 lines (77 loc) · 4.14 KB
/
createManiSizeOptions.js
File metadata and controls
93 lines (77 loc) · 4.14 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
function createManiSizeOptions() {
const manifoldType = document.getElementById('UserInput-manifoldType').value
const distalHead = +document.getElementById('UserInput-distalHead').value
const sasAreaLength = +document.getElementById("UserInput-sasAreaLength").value
const sasAreaWidth = +document.getElementById('result-minimumSASAreaWidth').value
const latSpacing = +document.getElementById("UserInput-latSpacing").value
const pipeMaterial = document.getElementById("UserInput-pipeMaterial").value
const perfDia = +document.getElementById("UserInput-perfDia").value
const perfSpacing = +document.getElementById("UserInput-perfSpacing").value
// The following switch statement determines the total lateral length (latLength) based on whether the manifold is location in the center ('Center') or the end ('End') of the SAS.
switch (pipeMaterial) {
case 'pvc':
roughCoeff = 140
break;
case 'abs':
roughCoeff = 130
break;
case 'hdpe':
roughCoeff = 140
break;
}
// The following switch statement determines the total lateral length (latLength) based on whether the manifold is location in the center ('Center') or the end ('End') of the SAS.
switch (manifoldType) {
case 'Center':
latLength = sasAreaLength / 2
break;
case 'End':
latLength = sasAreaLength
break;
}
// The following switch statement determines the total number of laterals (latNum) based on whether the manifold is location in the center ('Center') or the end ('End') of the SAS.
switch (manifoldType) {
case 'Center':
latNum = 2 * (sasAreaWidth / latSpacing)
break;
case 'End':
latNum = (sasAreaWidth / latSpacing)
break;
}
// This function calculates the perforation discharge rate (perfDis) using the perforation diameter (perfDia) and in-line distal head (distalHead)
const perfDis = () => 11.79 * (Math.pow(perfDia, 2)) * (Math.sqrt(distalHead))
// This function calculates the total number of perforations per lateral (perfNum) using the lateral length (latLength) and perforation spacing (perfSpacing)
const perfNum = () => Math.floor((latLength / perfSpacing))
// This function calculates the lateral discharge rate (Q) using the perforation discharge rate (perfDis) and the number of total number of perforations per lateral (N) */
const latDis = () => perfDis() * perfNum()
// The following switch statement determines the total discharge rate per trench (maniSegDis) based on whether the manifold is location in the center ('Center') or the end ('End') of the SAS.
switch (manifoldType) {
case 'Center':
maniSegDis = 2 * latDis()
break;
case 'End':
maniSegDis = latDis()
break;
}
const maniSegNum = () => (sasAreaWidth / latSpacing)
let maniFlowIterator = 0
let sumManiFrictionLoss = 0
do {
const maniDownStreamFlow = () => maniSegDis * (maniSegNum() - maniFlowIterator)
const maniSegFrictionFactor = () => 0.00098 * Math.pow(maniDownStreamFlow(), 1.85)
const maniSegFrictionLoss = () => latSpacing * maniSegFrictionFactor()
sumManiFrictionLoss += maniSegFrictionLoss()
maniFlowIterator++
} while (maniFlowIterator < maniSegNum())
const minimumManiDia = () => Math.ceil(Math.pow((sumManiFrictionLoss / (0.1 * distalHead)), 0.21))
const maniSizes = [1, 1.25, 1.5, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 18]
// The following while loop, chooses the nominal manifold size to use, based on the minimum manifold size (useManiDia) and the available nominal manifold sizes (maniSizes)
let maniSizeDifference = 1
let maniOptionSelector = document.getElementById("UserInput-maniSize");
let maniSizeIterator = 0;
while(maniSizeDifference > 0) {
maniSizeDifference = minimumManiDia() - maniSizes[maniSizeIterator];
useManiDia = maniSizes[maniSizeIterator];
maniOptionSelector.options[maniSizeIterator].disabled = true;
maniSizeIterator++;
}
}