1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "pipes": [
12 "water at 20 C, 200 gpm through 300 ft of 3 in sch 40 steel with 6 elbows, 2 gate valves and 1 check valve, rise 20 ft",
13 "compressed air at 7 barg and 25 C, 300 scfm through 150 m of DN50 galvanized pipe, 4 elbows",
14 {
15 "fluid": "ethylene glycol 30%",
16 "temperature": "5 C",
17 "flow": "30 m3/h",
18 "material": "PVC",
19 "length": "80 m",
20 "fittings": [
21 "8 elbows",
22 "2 ball valves"
23 ],
24 "sizePipe": true
25 }
26 ],
27 "pumpSystems": [
28 {
29 "title": "Booster pump to a roof tank",
30 "fluid": "water",
31 "temperature": "60 F",
32 "pump": {
33 "curve": [
34 [
35 "0 gpm",
36 "160 ft"
37 ],
38 [
39 "100 gpm",
40 "155 ft"
41 ],
42 [
43 "200 gpm",
44 "140 ft"
45 ],
46 [
47 "300 gpm",
48 "115 ft"
49 ],
50 [
51 "400 gpm",
52 "80 ft"
53 ]
54 ],
55 "efficiency": [
56 [
57 "50 gpm",
58 "35%"
59 ],
60 [
61 "150 gpm",
62 "62%"
63 ],
64 [
65 "250 gpm",
66 "74%"
67 ],
68 [
69 "300 gpm",
70 "75%"
71 ],
72 [
73 "350 gpm",
74 "72%"
75 ],
76 [
77 "400 gpm",
78 "65%"
79 ]
80 ],
81 "npshr": [
82 [
83 "100 gpm",
84 "6 ft"
85 ],
86 [
87 "300 gpm",
88 "10 ft"
89 ],
90 [
91 "400 gpm",
92 "15 ft"
93 ]
94 ]
95 },
96 "staticHead": "85 ft",
97 "suction": {
98 "pipe": "5 in sch 40 steel",
99 "length": "20 ft",
100 "fittings": "entrance, 1 gate valve, 1 elbow",
101 "liquidLevel": "4 ft"
102 },
103 "discharge": "600 ft of 4 in sch 40 steel, 10 elbows, 1 check valve, 2 gate valves, exit"
104 }
105 ],
106 "networks": [
107 {
108 "title": "Two-loop town main",
109 "fluid": "water",
110 "temperature": "15 C",
111 "headloss": "hazen-williams",
112 "nodes": [
113 {
114 "id": "Tank",
115 "type": "tank",
116 "head": "95 m",
117 "x": 0,
118 "y": 0
119 },
120 {
121 "id": "A",
122 "elevation": "40 m",
123 "demand": "25 l/s",
124 "x": 1000,
125 "y": 0
126 },
127 {
128 "id": "B",
129 "elevation": "38 m",
130 "demand": "30 l/s",
131 "x": 2000,
132 "y": 0
133 },
134 {
135 "id": "C",
136 "elevation": "45 m",
137 "demand": "20 l/s",
138 "x": 2000,
139 "y": -900
140 },
141 {
142 "id": "D",
143 "elevation": "42 m",
144 "demand": "35 l/s",
145 "x": 1000,
146 "y": -900
147 },
148 {
149 "id": "E",
150 "elevation": "50 m",
151 "demand": "15 l/s",
152 "x": 0,
153 "y": -900
154 }
155 ],
156 "pipes": [
157 {
158 "id": "P1",
159 "from": "Tank",
160 "to": "A",
161 "length": "1000 m",
162 "diameter": "400 mm",
163 "C": 130
164 },
165 {
166 "id": "P2",
167 "from": "A",
168 "to": "B",
169 "length": "1000 m",
170 "diameter": "250 mm",
171 "C": 130
172 },
173 {
174 "id": "P3",
175 "from": "B",
176 "to": "C",
177 "length": "900 m",
178 "diameter": "200 mm",
179 "C": 130
180 },
181 {
182 "id": "P4",
183 "from": "D",
184 "to": "C",
185 "length": "1000 m",
186 "diameter": "200 mm",
187 "C": 130
188 },
189 {
190 "id": "P5",
191 "from": "A",
192 "to": "D",
193 "length": "900 m",
194 "diameter": "300 mm",
195 "C": 130
196 },
197 {
198 "id": "P6",
199 "from": "E",
200 "to": "D",
201 "length": "1000 m",
202 "diameter": "150 mm",
203 "C": 130
204 },
205 {
206 "id": "P7",
207 "from": "Tank",
208 "to": "E",
209 "length": "900 m",
210 "diameter": "200 mm",
211 "C": 130
212 }
213 ]
214 }
215 ]
216};
217
218
219const run = await client.actor("jumblemog/pipe-flow-calculator").call(input);
220
221
222console.log('Results from dataset');
223console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
224const { items } = await client.dataset(run.defaultDatasetId).listItems();
225items.forEach((item) => {
226 console.dir(item);
227});
228
229