hytos / HYTOS / HYTOS / Calculation.py @ 560f9bc9
이력 | 보기 | 이력해설 | 다운로드 (119 KB)
1 |
# coding: utf-8
|
---|---|
2 |
"""
|
3 |
This is calculation module
|
4 |
"""
|
5 |
import sys |
6 |
import os |
7 |
from AppDocData import * |
8 |
import math |
9 |
from App import App |
10 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
11 |
from SymbolSvgItem import SymbolSvgItem |
12 |
|
13 |
|
14 |
class Conversion: |
15 |
def __init__(self, decimal): |
16 |
self._decimal = decimal
|
17 |
|
18 |
self.pre_units = {}
|
19 |
self.cur_units = {}
|
20 |
|
21 |
self.getCurrentUnits()
|
22 |
self.getPreviousUnits()
|
23 |
|
24 |
self.convert_HMB()
|
25 |
self.convert_Nozzle()
|
26 |
|
27 |
def convert_HMB(self): |
28 |
from Drawing import Drawing |
29 |
from Calculation import Conversion |
30 |
|
31 |
try:
|
32 |
app_doc_data = AppDocData.instance() |
33 |
drawing = app_doc_data.activeDrawing |
34 |
|
35 |
hmbs = drawing.hmbTable._hmbs |
36 |
if hmbs is not None: |
37 |
for hmb in hmbs: |
38 |
if hmb.flowrate_mass:
|
39 |
hmb.flowrate_mass = self.convert_flowrate_mass(hmb.flowrate_mass)
|
40 |
if hmb.flowrate_volume:
|
41 |
hmb.flowrate_volume = self.convert_flowrate_volume(hmb.flowrate_volume)
|
42 |
if hmb.density:
|
43 |
hmb.density = self.convert_density(hmb.density)
|
44 |
if hmb.viscosity:
|
45 |
hmb.viscosity = self.convert_viscosity(hmb.viscosity)
|
46 |
if hmb.temperature:
|
47 |
hmb.temperature = self.convert_temperature(hmb.temperature)
|
48 |
if hmb.nominal_pipe_size:
|
49 |
hmb.nominal_pipe_size = self.convert_pipe_diameter(hmb.nominal_pipe_size)
|
50 |
if hmb.inside_pipe_size:
|
51 |
hmb.inside_pipe_size = self.convert_pipe_diameter(hmb.inside_pipe_size)
|
52 |
if hmb.straight_length:
|
53 |
hmb.straight_length = self.convert_length(hmb.straight_length)
|
54 |
if hmb.equivalent_length:
|
55 |
hmb.equivalent_length = self.convert_length(hmb.equivalent_length)
|
56 |
if hmb.equivalent_length_input:
|
57 |
hmb.equivalent_length_input = self.convert_length(hmb.equivalent_length_input)
|
58 |
if hmb.fitting_length:
|
59 |
hmb.fitting_length = self.convert_length(hmb.fitting_length)
|
60 |
if hmb.equivalent_length_cal:
|
61 |
hmb.equivalent_length_cal = self.convert_length(hmb.equivalent_length_cal)
|
62 |
if hmb.roughness:
|
63 |
hmb.roughness = self.convert_roughness(hmb.roughness)
|
64 |
if hmb.limitation_velocity:
|
65 |
hmb.limitation_velocity = self.convert_velocity(hmb.limitation_velocity)
|
66 |
if hmb.limitation_pressure_drop:
|
67 |
hmb.limitation_pressure_drop = self.convert_pressure(hmb.limitation_pressure_drop)
|
68 |
if hmb.velocity:
|
69 |
hmb.velocity = self.convert_velocity(hmb.velocity)
|
70 |
if hmb.pressure_drop:
|
71 |
hmb.pressure_drop = self.convert_pressure(hmb.pressure_drop)
|
72 |
if hmb.pressure_drop_friction:
|
73 |
hmb.pressure_drop_friction = self.convert_pressure(hmb.pressure_drop_friction)
|
74 |
if hmb.pressure_drop_static:
|
75 |
hmb.pressure_drop_static = self.convert_pressure(hmb.pressure_drop_static)
|
76 |
if hmb.pressure_pipe_end_point:
|
77 |
hmb.pressure_pipe_end_point = self.convert_pressure(hmb.pressure_pipe_end_point)
|
78 |
if hmb.power:
|
79 |
hmb.power = self.convert_power(hmb.power)
|
80 |
# Mixed Data
|
81 |
if hmb.vapor_flowrate_mass:
|
82 |
hmb.vapor_flowrate_mass = self.convert_flowrate_mass(hmb.vapor_flowrate_mass)
|
83 |
if hmb.vapor_density:
|
84 |
hmb.vapor_density = self.convert_density(hmb.vapor_density)
|
85 |
if hmb.vapor_viscosity:
|
86 |
hmb.vapor_viscosity = self.convert_viscosity(hmb.vapor_viscosity)
|
87 |
if hmb.vapor_pressure:
|
88 |
hmb.vapor_pressure = self.convert_pressure(hmb.vapor_pressure)
|
89 |
if hmb.vapor_temperature:
|
90 |
hmb.vapor_temperature = self.convert_temperature(hmb.vapor_temperature)
|
91 |
if hmb.liquid_flowrate_mass:
|
92 |
hmb.liquid_flowrate_mass = self.convert_flowrate_mass(hmb.liquid_flowrate_mass)
|
93 |
if hmb.liquid_density:
|
94 |
hmb.liquid_density = self.convert_density(hmb.liquid_density)
|
95 |
if hmb.liquid_viscosity:
|
96 |
hmb.liquid_viscosity = self.convert_viscosity(hmb.liquid_viscosity)
|
97 |
|
98 |
except Exception as ex: |
99 |
from App import App |
100 |
from AppDocData import MessageType |
101 |
|
102 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
103 |
sys.exc_info()[-1].tb_lineno)
|
104 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
105 |
|
106 |
def convert_flowrate_mass(self, value): |
107 |
pre_unit = self.pre_units['Flowrate_Mass'] |
108 |
cur_unit = self.cur_units['Flowrate_Mass'] |
109 |
|
110 |
if pre_unit == cur_unit:
|
111 |
return value
|
112 |
|
113 |
if is_string(value):
|
114 |
return value
|
115 |
|
116 |
if pre_unit == 'kg/h': |
117 |
if cur_unit == 'g/min': |
118 |
convert_factor = 16.6667
|
119 |
elif cur_unit == 'lb/h': |
120 |
convert_factor = 2.2046
|
121 |
elif cur_unit == 't/h': |
122 |
convert_factor = 0.001
|
123 |
elif pre_unit == 'g/min': |
124 |
if cur_unit == 'kg/h': |
125 |
convert_factor = 1 / 16.6667 |
126 |
elif cur_unit == 'lb/h': |
127 |
convert_factor = 0.132277
|
128 |
elif cur_unit == 't/h': |
129 |
convert_factor = 0.00006
|
130 |
elif pre_unit == 'lb/h': |
131 |
if cur_unit == 'kg/h': |
132 |
convert_factor = 1 / 2.2046 |
133 |
elif cur_unit == 'g/min': |
134 |
convert_factor = 1 / 0.132277 |
135 |
elif cur_unit == 't/h': |
136 |
convert_factor = 0.0004536
|
137 |
elif pre_unit == 't/h': |
138 |
if cur_unit == 'kg/h': |
139 |
convert_factor = 1 / 0.001 |
140 |
elif cur_unit == 'g/min': |
141 |
convert_factor = 1 / 0.00006 |
142 |
elif cur_unit == 'lb/h': |
143 |
convert_factor = 1 / 0.0004536 |
144 |
|
145 |
return round(value * convert_factor, self._decimal) |
146 |
|
147 |
def convert_flowrate_volume(self, value): |
148 |
pre_unit = self.pre_units['Flowrate_Volume'] |
149 |
cur_unit = self.cur_units['Flowrate_Volume'] |
150 |
|
151 |
if pre_unit == cur_unit:
|
152 |
return value
|
153 |
|
154 |
if is_string(value):
|
155 |
return value
|
156 |
|
157 |
if pre_unit == 'm3/h': |
158 |
if cur_unit == 'l/min': |
159 |
convert_factor = 16.6667
|
160 |
elif cur_unit == 'ft3/h': |
161 |
convert_factor = 35.31466
|
162 |
elif cur_unit == 'USgpm': |
163 |
convert_factor = 4.402867
|
164 |
elif cur_unit == 'BPSD': |
165 |
convert_factor = 150.955464
|
166 |
elif pre_unit == 'l/min': |
167 |
if cur_unit == 'm3/h': |
168 |
convert_factor = 1 / 16.6667 |
169 |
elif cur_unit == 'ft3/h': |
170 |
convert_factor = 2.1188796
|
171 |
elif cur_unit == 'USgpm': |
172 |
convert_factor = 0.264172
|
173 |
elif cur_unit == 'BPSD': |
174 |
convert_factor = 9.05732784
|
175 |
elif pre_unit == 'ft3/h': |
176 |
if cur_unit == 'm3/h': |
177 |
convert_factor = 1 / 35.31466 |
178 |
elif cur_unit == 'l/min': |
179 |
convert_factor = 1 / 2.1188796 |
180 |
elif cur_unit == 'USgpm': |
181 |
convert_factor = 0.124675333
|
182 |
elif cur_unit == 'BPSD': |
183 |
convert_factor = 9.05732784
|
184 |
elif pre_unit == 'USgpm': |
185 |
if cur_unit == 'm3/h': |
186 |
convert_factor = 1 / 4.402867 |
187 |
elif cur_unit == 'l/min': |
188 |
convert_factor = 1 / 0.264172 |
189 |
elif cur_unit == 'ft3/h': |
190 |
convert_factor = 1 / 0.124675333 |
191 |
elif cur_unit == 'BPSD': |
192 |
convert_factor = 34.2857088
|
193 |
elif pre_unit == 'BPSD': |
194 |
if cur_unit == 'm3/h': |
195 |
convert_factor = 1 / 150.955464 |
196 |
elif cur_unit == 'l/min': |
197 |
convert_factor = 1 / 9.05732784 |
198 |
elif cur_unit == 'ft3/h': |
199 |
convert_factor = 1 / 4.2745824 |
200 |
elif cur_unit == 'USgpm': |
201 |
convert_factor = 1 / 34.2857088 |
202 |
|
203 |
return round(value * convert_factor, self._decimal) |
204 |
|
205 |
def convert_density(self, value): |
206 |
pre_unit = self.pre_units['Density'] |
207 |
cur_unit = self.cur_units['Density'] |
208 |
|
209 |
if pre_unit == cur_unit:
|
210 |
return value
|
211 |
|
212 |
if is_string(value):
|
213 |
return value
|
214 |
|
215 |
if pre_unit == 'kg/m3': |
216 |
if cur_unit == 'lb/ft3': convert_factor = 0.06242797 |
217 |
elif pre_unit == 'lb/ft3': |
218 |
if cur_unit == 'kg/m3': convert_factor = 1 / 0.06242797 |
219 |
|
220 |
return round(value * convert_factor, self._decimal) |
221 |
|
222 |
def convert_viscosity(self, value): |
223 |
pre_unit = self.pre_units['Viscosity'] |
224 |
cur_unit = self.cur_units['Viscosity'] |
225 |
|
226 |
if pre_unit == cur_unit:
|
227 |
return value
|
228 |
|
229 |
if is_string(value):
|
230 |
return value
|
231 |
|
232 |
if pre_unit == 'cP': |
233 |
if cur_unit == 'kg/m.sec': |
234 |
convert_factor = 0.001
|
235 |
elif cur_unit == 'kg/m.h': |
236 |
convert_factor = 3.6
|
237 |
elif cur_unit == 'lb/ft.sec': |
238 |
convert_factor = 0.000671969
|
239 |
elif pre_unit == 'kg/m.sec': |
240 |
if cur_unit == 'cP': |
241 |
convert_factor = 1 / 0.001 |
242 |
elif cur_unit == 'kg/m.h': |
243 |
convert_factor = 3600
|
244 |
elif cur_unit == 'lb/ft.sec': |
245 |
convert_factor = 0.671969
|
246 |
elif pre_unit == 'kg/m.h': |
247 |
if cur_unit == 'cP': |
248 |
convert_factor = 1 / 3.6 |
249 |
elif cur_unit == 'kg/m.sec': |
250 |
convert_factor = 1 / 3600 |
251 |
elif cur_unit == 'lb/ft.sec': |
252 |
convert_factor = 0.000186658
|
253 |
elif pre_unit == 'lb/ft.sec': |
254 |
if cur_unit == 'cP': |
255 |
convert_factor = 1 / 0.000671969 |
256 |
elif cur_unit == 'kg/m.sec': |
257 |
convert_factor = 1 / 0.671969 |
258 |
elif cur_unit == 'kg/m.h': |
259 |
convert_factor = 1 / 0.000186658 |
260 |
|
261 |
return round(value * convert_factor, self._decimal) |
262 |
|
263 |
def convert_temperature(self, value): |
264 |
pre_unit = self.pre_units['Temperature'] |
265 |
cur_unit = self.cur_units['Temperature'] |
266 |
|
267 |
if pre_unit == cur_unit:
|
268 |
return value
|
269 |
|
270 |
if is_string(value):
|
271 |
return value
|
272 |
|
273 |
if cur_unit == '℉': |
274 |
return round(1.8 * value + 32, self._decimal) |
275 |
elif cur_unit == '℃': |
276 |
return round((value - 32) / 1.8, self._decimal) |
277 |
|
278 |
def convert_pipe_diameter(self, value): |
279 |
pre_unit = self.pre_units['Pipe_Diameter'] |
280 |
cur_unit = self.cur_units['Pipe_Diameter'] |
281 |
|
282 |
if pre_unit == cur_unit:
|
283 |
return value
|
284 |
|
285 |
if is_string(value):
|
286 |
return value
|
287 |
|
288 |
if pre_unit == 'in': |
289 |
if cur_unit == 'mm': convert_factor = 25.4 |
290 |
elif pre_unit == 'mm': |
291 |
if cur_unit == 'in': convert_factor = 1 / 25.4 |
292 |
|
293 |
return round(value * convert_factor, self._decimal) |
294 |
|
295 |
def convert_length(self, value): |
296 |
pre_unit = self.pre_units['Length'] |
297 |
cur_unit = self.cur_units['Length'] |
298 |
|
299 |
if pre_unit == cur_unit:
|
300 |
return value
|
301 |
|
302 |
if is_string(value):
|
303 |
return value
|
304 |
|
305 |
if pre_unit == 'in': |
306 |
if cur_unit == 'm': |
307 |
convert_factor = 0.0254
|
308 |
elif cur_unit == 'ft': |
309 |
convert_factor = 0.083333
|
310 |
elif cur_unit == 'yd': |
311 |
convert_factor = 0.0277778
|
312 |
elif cur_unit == 'mile': |
313 |
convert_factor = 0.00001578283
|
314 |
elif cur_unit == 'mm': |
315 |
convert_factor = 25.4
|
316 |
elif pre_unit == 'm': |
317 |
if cur_unit == 'in': |
318 |
convert_factor = 1 / 0.0254 |
319 |
elif cur_unit == 'ft': |
320 |
convert_factor = 3.28084
|
321 |
elif cur_unit == 'yd': |
322 |
convert_factor = 1.093613
|
323 |
elif cur_unit == 'mile': |
324 |
convert_factor = 0.000621371
|
325 |
elif cur_unit == 'mm': |
326 |
convert_factor = 1000
|
327 |
elif pre_unit == 'ft': |
328 |
if cur_unit == 'in': |
329 |
convert_factor = 1 / 0.083333 |
330 |
elif cur_unit == 'm': |
331 |
convert_factor = 1 / 3.28084 |
332 |
elif cur_unit == 'yd': |
333 |
convert_factor = 0.33333
|
334 |
elif cur_unit == 'mile': |
335 |
convert_factor = 0.000189394
|
336 |
elif cur_unit == 'mm': |
337 |
convert_factor = 304.8
|
338 |
elif pre_unit == 'yd': |
339 |
if cur_unit == 'in': |
340 |
convert_factor = 1 / 0.277778 |
341 |
elif cur_unit == 'm': |
342 |
convert_factor = 1 / 1.093613 |
343 |
elif cur_unit == 'ft': |
344 |
convert_factor = 1 / 0.33333 |
345 |
elif cur_unit == 'mile': |
346 |
convert_factor = 0.000568182
|
347 |
elif cur_unit == 'mm': |
348 |
convert_factor = 914.4
|
349 |
elif pre_unit == 'mile': |
350 |
if cur_unit == 'in': |
351 |
convert_factor = 1 / 0.00001578283 |
352 |
elif cur_unit == 'm': |
353 |
convert_factor = 1 / 0.000621371 |
354 |
elif cur_unit == 'ft': |
355 |
convert_factor = 1 / 0.000189394 |
356 |
elif cur_unit == 'yd': |
357 |
convert_factor = 1 / 0.000568182 |
358 |
elif cur_unit == 'mm': |
359 |
convert_factor = 1609344
|
360 |
elif pre_unit == 'mm': |
361 |
if cur_unit == 'in': |
362 |
convert_factor = 1 / 25.4 |
363 |
elif cur_unit == 'm': |
364 |
convert_factor = 1 / 1000 |
365 |
elif cur_unit == 'ft': |
366 |
convert_factor = 1 / 304.8 |
367 |
elif cur_unit == 'yd': |
368 |
convert_factor = 1 / 914.4 |
369 |
elif cur_unit == 'mile': |
370 |
convert_factor = 1 / 1609344 |
371 |
|
372 |
return round(value * convert_factor, self._decimal) |
373 |
|
374 |
def convert_roughness(self, value): |
375 |
pre_unit = self.pre_units['Roughness'] |
376 |
cur_unit = self.cur_units['Roughness'] |
377 |
|
378 |
if pre_unit == cur_unit:
|
379 |
return value
|
380 |
|
381 |
if is_string(value):
|
382 |
return value
|
383 |
|
384 |
if pre_unit == 'in': |
385 |
if cur_unit == 'm': |
386 |
convert_factor = 0.0254
|
387 |
elif cur_unit == 'ft': |
388 |
convert_factor = 0.083333
|
389 |
elif cur_unit == 'mm': |
390 |
convert_factor = 25.4
|
391 |
elif pre_unit == 'm': |
392 |
if cur_unit == 'in': |
393 |
convert_factor = 1 / 0.0254 |
394 |
elif cur_unit == 'ft': |
395 |
convert_factor = 3.28084
|
396 |
elif cur_unit == 'mm': |
397 |
convert_factor = 1000
|
398 |
elif pre_unit == 'ft': |
399 |
if cur_unit == 'in': |
400 |
convert_factor = 1 / 0.083333 |
401 |
elif cur_unit == 'm': |
402 |
convert_factor = 1 / 3.28084 |
403 |
elif cur_unit == 'mm': |
404 |
convert_factor = 304.8
|
405 |
elif pre_unit == 'mm': |
406 |
if cur_unit == 'in': |
407 |
convert_factor = 1 / 25.4 |
408 |
elif cur_unit == 'm': |
409 |
convert_factor = 1 / 1000 |
410 |
elif cur_unit == 'ft': |
411 |
convert_factor = 1 / 304.8 |
412 |
|
413 |
return round(value * convert_factor, self._decimal) |
414 |
|
415 |
def convert_velocity(self, value): |
416 |
pre_unit = self.pre_units['Velocity'] |
417 |
cur_unit = self.cur_units['Velocity'] |
418 |
|
419 |
if pre_unit == cur_unit:
|
420 |
return value
|
421 |
|
422 |
if is_string(value):
|
423 |
return value
|
424 |
|
425 |
if pre_unit == 'm/s': |
426 |
if cur_unit == 'ft/s': convert_factor = 3.28084 |
427 |
elif pre_unit == 'ft/s': |
428 |
if cur_unit == 'm/s': convert_factor = 1 / 3.28084 |
429 |
|
430 |
return round(value * convert_factor, self._decimal) |
431 |
|
432 |
def convert_pressure(self, value): |
433 |
pre_unit = self.pre_units['Pressure'] |
434 |
cur_unit = self.cur_units['Pressure'] |
435 |
|
436 |
if pre_unit == cur_unit:
|
437 |
return value
|
438 |
|
439 |
if is_string(value):
|
440 |
return value
|
441 |
|
442 |
if pre_unit == 'kg/cm2': |
443 |
if cur_unit == 'psi': |
444 |
convert_factor = 14.22334
|
445 |
elif cur_unit == 'atm': |
446 |
convert_factor = 0.9678411
|
447 |
elif cur_unit == 'bar': |
448 |
convert_factor = 0.980665
|
449 |
elif cur_unit == 'mmHg': |
450 |
convert_factor = 735.5591
|
451 |
elif cur_unit == 'kPa': |
452 |
convert_factor = 98.0665
|
453 |
elif cur_unit == 'MPa': |
454 |
convert_factor = 0.0980665
|
455 |
elif pre_unit == 'psi': |
456 |
if cur_unit == 'kg/cm2': |
457 |
convert_factor = 1 / 14.22334 |
458 |
elif cur_unit == 'atm': |
459 |
convert_factor = 0.06804596
|
460 |
elif cur_unit == 'bar': |
461 |
convert_factor = 0.06894757
|
462 |
elif cur_unit == 'mmHg': |
463 |
convert_factor = 51.71492
|
464 |
elif cur_unit == 'kPa': |
465 |
convert_factor = 6.894757
|
466 |
elif cur_unit == 'MPa': |
467 |
convert_factor = 0.006894757
|
468 |
elif pre_unit == 'atm': |
469 |
if cur_unit == 'kg/cm2': |
470 |
convert_factor = 1 / 0.9678411 |
471 |
elif cur_unit == 'psi': |
472 |
convert_factor = 1 / 0.06804596 |
473 |
elif cur_unit == 'bar': |
474 |
convert_factor = 1.01325
|
475 |
elif cur_unit == 'mmHg': |
476 |
convert_factor = 759.9998
|
477 |
elif cur_unit == 'kPa': |
478 |
convert_factor = 101.325
|
479 |
elif cur_unit == 'MPa': |
480 |
convert_factor = 0.101325
|
481 |
elif pre_unit == 'bar': |
482 |
if cur_unit == 'kg/cm2': |
483 |
convert_factor = 1 / 0.980665 |
484 |
elif cur_unit == 'psi': |
485 |
convert_factor = 1 / 0.06894757 |
486 |
elif cur_unit == 'atm': |
487 |
convert_factor = 1 / 1.01325 |
488 |
elif cur_unit == 'mmHg': |
489 |
convert_factor = 750.0615
|
490 |
elif cur_unit == 'kPa': |
491 |
convert_factor = 100
|
492 |
elif cur_unit == 'MPa': |
493 |
convert_factor = 0.1
|
494 |
elif pre_unit == 'mmHg': |
495 |
if cur_unit == 'kg/cm2': |
496 |
convert_factor = 1 / 735.5591 |
497 |
elif cur_unit == 'psi': |
498 |
convert_factor = 1 / 51.71492 |
499 |
elif cur_unit == 'atm': |
500 |
convert_factor = 1 / 759.9998 |
501 |
elif cur_unit == 'bar': |
502 |
convert_factor = 1 / 750.0615 |
503 |
elif cur_unit == 'kPa': |
504 |
convert_factor = 0.1333224
|
505 |
elif cur_unit == 'MPa': |
506 |
convert_factor = 0.0001333224
|
507 |
elif pre_unit == 'kPa': |
508 |
if cur_unit == 'kg/cm2': |
509 |
convert_factor = 1 / 98.0665 |
510 |
elif cur_unit == 'psi': |
511 |
convert_factor = 1 / 6.894757 |
512 |
elif cur_unit == 'atm': |
513 |
convert_factor = 1 / 101.325 |
514 |
elif cur_unit == 'bar': |
515 |
convert_factor = 1 / 100 |
516 |
elif cur_unit == 'mmHg': |
517 |
convert_factor = 1 / 0.1333224 |
518 |
elif cur_unit == 'MPa': |
519 |
convert_factor = 1 / 1000 |
520 |
elif pre_unit == 'MPa': |
521 |
if cur_unit == 'kg/cm2': |
522 |
convert_factor = 1 / 98.0665 * 1000 |
523 |
elif cur_unit == 'psi': |
524 |
convert_factor = 1 / 6.894757 * 1000 |
525 |
elif cur_unit == 'atm': |
526 |
convert_factor = 1 / 101.325 * 1000 |
527 |
elif cur_unit == 'bar': |
528 |
convert_factor = 1 / 100 * 1000 |
529 |
elif cur_unit == 'mmHg': |
530 |
convert_factor = 1 / 0.1333224 * 1000 |
531 |
elif cur_unit == 'kPa': |
532 |
convert_factor = 1 # 기존 소스에 없음 |
533 |
|
534 |
return round(value * convert_factor, self._decimal) |
535 |
|
536 |
def convert_power(self, value): |
537 |
pre_unit = self.pre_units['Power'] |
538 |
cur_unit = self.cur_units['Power'] |
539 |
|
540 |
if pre_unit == cur_unit:
|
541 |
return value
|
542 |
|
543 |
if is_string(value):
|
544 |
return value
|
545 |
|
546 |
if pre_unit == 'kW': |
547 |
if cur_unit == 'kcal/h': |
548 |
convert_factor = 860.4207
|
549 |
elif cur_unit == 'btu/h': |
550 |
convert_factor = 3414.425
|
551 |
elif cur_unit == 'Hp': |
552 |
convert_factor = 1.359622
|
553 |
elif cur_unit == 'kg.m/sec': |
554 |
convert_factor = 101.9716
|
555 |
elif cur_unit == 'ft.lb/sec': |
556 |
convert_factor = 737.5621
|
557 |
elif pre_unit == 'kcal/h': |
558 |
if cur_unit == 'kW': |
559 |
convert_factor = 1 / 860.4207 |
560 |
elif cur_unit == 'btu/h': |
561 |
convert_factor = 3.96832
|
562 |
elif cur_unit == 'Hp': |
563 |
convert_factor = 0.001580182
|
564 |
elif cur_unit == 'kg.m/sec': |
565 |
convert_factor = 0.1185137
|
566 |
elif cur_unit == 'ft.lb/sec': |
567 |
convert_factor = 0.857211
|
568 |
elif pre_unit == 'btu/h': |
569 |
if cur_unit == 'kW': |
570 |
convert_factor = 1 / 3414.425 |
571 |
elif cur_unit == 'kcal/h': |
572 |
convert_factor = 1 / 3.96832 |
573 |
elif cur_unit == 'Hp': |
574 |
convert_factor = 0.000398199
|
575 |
elif cur_unit == 'kg.m/sec': |
576 |
convert_factor = 0.02986495
|
577 |
elif cur_unit == 'ft.lb/sec': |
578 |
convert_factor = 0.2160136
|
579 |
elif pre_unit == 'Hp': |
580 |
if cur_unit == 'kW': |
581 |
convert_factor = 11 / 1.359622 |
582 |
elif cur_unit == 'kcal/h': |
583 |
convert_factor = 1 / 0.001580182 |
584 |
elif cur_unit == 'btu/h': |
585 |
convert_factor = 1 / 0.000398199 |
586 |
elif cur_unit == 'kg.m/sec': |
587 |
convert_factor = 75.00001
|
588 |
elif cur_unit == 'ft.lb/sec': |
589 |
convert_factor = 542.4761
|
590 |
elif pre_unit == 'kg.m/sec': |
591 |
if cur_unit == 'kW': |
592 |
convert_factor = 1 / 101.9716 |
593 |
elif cur_unit == 'kcal/h': |
594 |
convert_factor = 1 / 0.1185137 |
595 |
elif cur_unit == 'btu/h': |
596 |
convert_factor = 1 / 0.02986495 |
597 |
elif cur_unit == 'Hp': |
598 |
convert_factor = 1 / 75.00001 |
599 |
elif cur_unit == 'ft.lb/sec': |
600 |
convert_factor = 7.233014
|
601 |
elif pre_unit == 'ft.lb/sec': |
602 |
if cur_unit == 'kW': |
603 |
convert_factor = 1 / 737.5621 |
604 |
elif cur_unit == 'kcal/h': |
605 |
convert_factor = 1 / 0.857211 |
606 |
elif cur_unit == 'btu/h': |
607 |
convert_factor = 1 / 0.2160136 |
608 |
elif cur_unit == 'Hp': |
609 |
convert_factor = 1 / 542.4761 |
610 |
elif cur_unit == 'kg.m/sec': |
611 |
convert_factor = 1 / 7.233014 |
612 |
|
613 |
return round(value * convert_factor, self._decimal) |
614 |
|
615 |
def convert_Nozzle(self): |
616 |
from App import App |
617 |
try:
|
618 |
self.graphicsView = App.mainWnd().graphicsView
|
619 |
|
620 |
items = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem] |
621 |
for item in items: |
622 |
for connector in item.connectors: |
623 |
if connector.data:
|
624 |
if connector.data.pressure:
|
625 |
connector.data.pressure = self.convert_pressure(connector.data.pressure)
|
626 |
if connector.data.pressure_drop:
|
627 |
connector.data.pressure_drop = self.convert_pressure(connector.data.pressure_drop)
|
628 |
if connector.data.elevation:
|
629 |
connector.data.elevation = self.convert_length(connector.data.elevation)
|
630 |
if connector.data.over_design_cv:
|
631 |
connector.data.over_design_cv = self.convert_pressure(connector.data.over_design_cv)
|
632 |
|
633 |
except Exception as ex: |
634 |
from App import App |
635 |
from AppDocData import MessageType |
636 |
|
637 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
638 |
sys.exc_info()[-1].tb_lineno)
|
639 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
640 |
|
641 |
def getCurrentUnits(self): |
642 |
from AppDocData import AppDocData |
643 |
try:
|
644 |
curUnitsList = AppDocData.instance().getConfigs('Units')
|
645 |
for curUnit in curUnitsList: |
646 |
self.cur_units[curUnit.key] = curUnit.value
|
647 |
|
648 |
except Exception as ex: |
649 |
from App import App |
650 |
from AppDocData import MessageType |
651 |
|
652 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
653 |
sys.exc_info()[-1].tb_lineno)
|
654 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
655 |
|
656 |
def getPreviousUnits(self): |
657 |
from AppDocData import AppDocData |
658 |
try:
|
659 |
activeDrawing = AppDocData.instance().activeDrawing |
660 |
|
661 |
for attr in activeDrawing.attrs: |
662 |
if attr[0] == 'Units': |
663 |
self.pre_units = attr[1] |
664 |
|
665 |
except Exception as ex: |
666 |
from App import App |
667 |
from AppDocData import MessageType |
668 |
|
669 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
670 |
sys.exc_info()[-1].tb_lineno)
|
671 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
672 |
|
673 |
|
674 |
def is_string(s): |
675 |
return isinstance(s, str) |
676 |
|
677 |
|
678 |
def is_blank(s): |
679 |
return not (s and s.strip()) |
680 |
|
681 |
|
682 |
def is_not_blank(s): |
683 |
return bool(s and s.strip()) |
684 |
|
685 |
|
686 |
class Calculation_Mixed: |
687 |
def __init__(self, item, process, geometry): |
688 |
self.item = item
|
689 |
self.process = process
|
690 |
self.geometry = geometry
|
691 |
self.units = {}
|
692 |
|
693 |
self.mixed_pressure_variation = []
|
694 |
|
695 |
self.calc_factor = None |
696 |
self.tp_flow = None |
697 |
self.tp_C = None |
698 |
self.tp_rea_rough = None |
699 |
self.tp_dp_fric = None |
700 |
self.tp_angle = None |
701 |
self.tp_dp_stat = None |
702 |
self.tp_pipe_total_drop = None |
703 |
self.tp_dp_momen = None |
704 |
self.tp_pressure = None |
705 |
self.tp_pressure_ratio = None |
706 |
self.tp_length = None |
707 |
self.tp_id = None |
708 |
self.tp_element_dp = None |
709 |
self.l_vel = None |
710 |
self.l_dp_fric = None |
711 |
self.v_vel = None |
712 |
self.v_dp_fric = None |
713 |
self.v_temp = None |
714 |
self.v_density = None |
715 |
self.kval = None |
716 |
|
717 |
self.l_density = None |
718 |
self.l_visco = None |
719 |
self.v_visco = None |
720 |
self._lambda = None |
721 |
|
722 |
self.tp_homo_den = None |
723 |
self.tp_mean_den = None |
724 |
self.tp_homo_vel = None |
725 |
self.tp_mean_vel = None |
726 |
self.tp_max_vel = None |
727 |
self.tp_ero_vel = None |
728 |
self.tp_void = None |
729 |
|
730 |
self.no = None |
731 |
self.element = {}
|
732 |
self.inside_diameter = {}
|
733 |
self.length = {}
|
734 |
self.angle = {}
|
735 |
self.k = {}
|
736 |
self.pressure = {}
|
737 |
self.void = {}
|
738 |
self.quality = {}
|
739 |
self.mean_den = {} # Display : Density = > Mean.Den |
740 |
self.homo_den = {} # 새로 추가 : Homo.Den |
741 |
self.density = {} # Display : V.Den |
742 |
self.mean_vel = {} # Display : Mean Vel |
743 |
self.homo_vel = {} # 새로 추가 : Homo Vel |
744 |
self.max_vel = {}
|
745 |
self.ero_vel = {}
|
746 |
self.x = {}
|
747 |
self.y = {}
|
748 |
self.regime = {}
|
749 |
self.dp_fric = {}
|
750 |
self.dp_stat = {}
|
751 |
self.dp_momen = {}
|
752 |
self.total = {}
|
753 |
|
754 |
self.init_units()
|
755 |
self.tp_cal()
|
756 |
|
757 |
def init_units(self): |
758 |
try:
|
759 |
app_doc_data = AppDocData.instance() |
760 |
self.units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0] |
761 |
except Exception as ex: |
762 |
from App import App |
763 |
from AppDocData import MessageType |
764 |
|
765 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
766 |
sys.exc_info()[-1].tb_lineno)
|
767 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
768 |
|
769 |
def get_mixed_calc_factor(self): |
770 |
try:
|
771 |
app_doc_data = AppDocData.instance() |
772 |
|
773 |
mixed_calc_factor = app_doc_data.getConfigs('Calculation', 'Mixed_Calc_Factor') |
774 |
if len(mixed_calc_factor) == 1: |
775 |
return 1 - (int(mixed_calc_factor[0].value) / 100) |
776 |
else:
|
777 |
return 0.95 |
778 |
except Exception as ex: |
779 |
from App import App |
780 |
from AppDocData import MessageType |
781 |
|
782 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
783 |
sys.exc_info()[-1].tb_lineno)
|
784 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
785 |
|
786 |
def get_barometric_pressure(self): |
787 |
try:
|
788 |
unit = self.units['Pressure'] |
789 |
if unit == 'kg/cm2': |
790 |
barometric_pressure = 1.033
|
791 |
elif unit == 'bar': |
792 |
barometric_pressure = 1.01325 / 0.980665 |
793 |
elif unit == 'psi': |
794 |
barometric_pressure = 14.7 / 14.22334 |
795 |
elif unit == 'mmHg': |
796 |
barometric_pressure = 760 / 735.5591 |
797 |
elif unit == 'kPa': |
798 |
barometric_pressure = 101.325 / 98.0665 |
799 |
elif unit == 'MPa': |
800 |
barometric_pressure = 0.101325 / 0.0980665 |
801 |
|
802 |
return barometric_pressure
|
803 |
except Exception as ex: |
804 |
from App import App |
805 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
806 |
sys.exc_info()[-1].tb_lineno)
|
807 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
808 |
|
809 |
def tp_geo_check(self, row): |
810 |
element = self.geometry.item(row, 0).text() |
811 |
|
812 |
if element == 'Pipe': |
813 |
inside_diameter = self.geometry.item(row, 3).text() |
814 |
roughness = self.geometry.item(row, 4).text() |
815 |
length = self.geometry.item(row, 5).text() |
816 |
if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(length): |
817 |
return False |
818 |
elif element == 'Bend': |
819 |
inside_diameter = self.geometry.item(row, 3).text() |
820 |
roughness = self.geometry.item(row, 4).text() |
821 |
angle = self.geometry.item(row, 6).text() |
822 |
rpd = self.geometry.item(row, 7).text() |
823 |
if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(angle) and is_not_blank(rpd): |
824 |
return False |
825 |
elif element == 'Nozzle In' or element == 'Nozzle Out' or element == 'Check Valve' or element == 'Ball Valve' or element == 'Gate Valve' or element == 'Globe Valve' or element == 'Butterfly Valve': |
826 |
inside_diameter = self.geometry.item(row, 3).text() |
827 |
roughness = self.geometry.item(row, 4).text() |
828 |
if is_not_blank(inside_diameter) and is_not_blank(roughness): |
829 |
return False |
830 |
elif element == 'Reducer' or element == 'Expander': |
831 |
inside_diameter = self.geometry.item(row, 3).text() |
832 |
roughness = self.geometry.item(row, 4).text() |
833 |
angle = self.geometry.item(row, 6).text() |
834 |
d1_d2 = self.geometry.item(row, 8).text() |
835 |
if is_not_blank(inside_diameter) and is_not_blank(roughness) and is_not_blank(angle) and is_not_blank( |
836 |
d1_d2): |
837 |
return False |
838 |
|
839 |
return True |
840 |
|
841 |
def tp_c_cal(self): |
842 |
try:
|
843 |
if self.tp_massflux >= 300: |
844 |
tp_massflux_c = self.tp_massflux
|
845 |
else:
|
846 |
tp_massflux_c = 300 + ((300 - self.tp_massflux) ** 2 / 40) |
847 |
|
848 |
tp_c1 = 2 + (32 * (1 - 0.16 * (2.5 + self._lambda) ** 2) ** 3) / (1 + 0.005664 * tp_massflux_c ** 0.8) |
849 |
tp_c2 = (self.v_density / self.l_density) ** 0.5 + (self.l_density / self.v_density) ** 0.5 |
850 |
tp_c3 = ((self.l_density / self.v_density) ** 0.125) / ( |
851 |
(self.tp_quality + (1 - self.tp_quality) * (self.v_density / self.l_density)) ** 0.5) |
852 |
|
853 |
if tp_c1 > tp_c2:
|
854 |
tp_c_prime = tp_c1 |
855 |
else:
|
856 |
# (5) 최종 판별
|
857 |
if tp_c3 > tp_c2 > tp_c1:
|
858 |
tp_c_prime = tp_c2 |
859 |
elif tp_c2 > tp_c3 > tp_c1:
|
860 |
tp_c_prime = tp_c3 |
861 |
elif tp_c2 > tp_c1 > tp_c3:
|
862 |
tp_c_prime = tp_c1 |
863 |
|
864 |
self.tp_C = tp_c_prime * ((1 + 10 ** (-200 * self.tp_rea_rough)) / 2) |
865 |
except Exception as ex: |
866 |
from App import App |
867 |
from AppDocData import MessageType |
868 |
|
869 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
870 |
sys.exc_info()[-1].tb_lineno)
|
871 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
872 |
|
873 |
def tp_fric(self, row): |
874 |
try:
|
875 |
l_rey = self.tp_massflux * (1 - self.tp_quality) * self.tp_id / self.l_visco |
876 |
v_rey = self.tp_massflux * self.tp_quality * self.tp_id / self.v_visco |
877 |
|
878 |
roughness_unit = self.units['Roughness'] |
879 |
tp_rough = float(self.geometry.item(row, 4).text()) |
880 |
if roughness_unit == 'm': |
881 |
tp_rough = tp_rough |
882 |
elif roughness_unit == 'ft': |
883 |
tp_rough = tp_rough * 0.3048
|
884 |
elif roughness_unit == 'in': |
885 |
tp_rough = tp_rough * 0.0254
|
886 |
elif roughness_unit == 'mm': |
887 |
tp_rough = tp_rough * 0.001
|
888 |
|
889 |
self.tp_rea_rough = tp_rough / self.tp_id |
890 |
|
891 |
if l_rey <= 2100: |
892 |
l_f = 16 / l_rey
|
893 |
else:
|
894 |
l_f = (-4 * (math.log(tp_rough / 3.7 / self.tp_id - 5.02 / l_rey * ( |
895 |
math.log(tp_rough / self.tp_id / 3.7 + (6.7 / l_rey) ** 0.9) / math.log(10))) / math.log(10))) ** ( |
896 |
-2)
|
897 |
|
898 |
if v_rey <= 2100: |
899 |
v_f = 16 / v_rey
|
900 |
else:
|
901 |
v_f = (-4 * (math.log(tp_rough / 3.7 / self.tp_id - 5.02 / v_rey * ( |
902 |
math.log(tp_rough / self.tp_id / 3.7 + (6.7 / v_rey) ** 0.9) / math.log(10))) / math.log(10))) ** ( |
903 |
-2)
|
904 |
|
905 |
# 이 f 값들은 현재 moody friction factor들임
|
906 |
self.l_vel = self.tp_flow * (1 - self.tp_quality) / self.l_density / self.tp_id ** 2 / 3.1415 * 4 |
907 |
self.v_vel = self.tp_flow * self.tp_quality / self.v_density / self.tp_id ** 2 / 3.1415 * 4 |
908 |
|
909 |
self.l_dp_fric = 2 * l_f * 1 * self.tp_massflux ** 2 * (1 - self.tp_quality) ** 2 / self.tp_id / self.l_density / 101325 * 1.033 |
910 |
self.v_dp_fric = 2 * v_f * 1 * self.tp_massflux ** 2 * self.tp_quality ** 2 / self.tp_id / self.v_density / 101325 * 1.033 |
911 |
|
912 |
self.tp_c_cal()
|
913 |
|
914 |
self.tp_dp_fric = self.l_dp_fric + self.tp_C * (self.l_dp_fric * self.v_dp_fric) ** 0.5 + self.v_dp_fric |
915 |
except Exception as ex: |
916 |
from App import App |
917 |
from AppDocData import MessageType |
918 |
|
919 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
920 |
sys.exc_info()[-1].tb_lineno)
|
921 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
922 |
|
923 |
def tp_stat(self, row): |
924 |
try:
|
925 |
angle = self.geometry.item(row, 6).text() |
926 |
if is_not_blank(angle):
|
927 |
self.tp_angle = float(angle) |
928 |
else:
|
929 |
self.tp_angle = 0 |
930 |
|
931 |
self.tp_dp_stat = self.tp_mean_den * 9.81 * 1 * math.sin(self.tp_angle / 180 * 3.1415) / 101325 * 1.033 |
932 |
except Exception as ex: |
933 |
from App import App |
934 |
from AppDocData import MessageType |
935 |
|
936 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
937 |
sys.exc_info()[-1].tb_lineno)
|
938 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
939 |
|
940 |
def momen(self): |
941 |
try:
|
942 |
self.tp_pipe_total_drop = (self.tp_dp_fric + self.tp_dp_stat) / ( |
943 |
(1 - (self.tp_massflux ** 2 * self.tp_quality / (self.tp_pressure / 1.033 * 101325) / self.v_density))) |
944 |
|
945 |
self.tp_dp_momen = self.tp_pipe_total_drop - self.tp_dp_fric - self.tp_dp_stat |
946 |
|
947 |
except Exception as ex: |
948 |
from App import App |
949 |
from AppDocData import MessageType |
950 |
|
951 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
952 |
sys.exc_info()[-1].tb_lineno)
|
953 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
954 |
|
955 |
def tp_dp_input(self): |
956 |
try:
|
957 |
# 현재 kg/cm2/m
|
958 |
pressure_unit = self.units['Pressure'] |
959 |
if pressure_unit == 'kg/cm2': |
960 |
self.tp_dp_fric = self.tp_dp_fric |
961 |
self.tp_dp_stat = self.tp_dp_stat |
962 |
self.tp_dp_momen = self.tp_dp_momen |
963 |
elif pressure_unit == 'psi': |
964 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 * 14.7 |
965 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 * 14.7 |
966 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 * 14.7 |
967 |
elif pressure_unit == 'atm': |
968 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 |
969 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 |
970 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 |
971 |
elif pressure_unit == 'bar': |
972 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 * 1.033 |
973 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 * 1.033 |
974 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 * 1.033 |
975 |
elif pressure_unit == 'mmHg': |
976 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 * 760 |
977 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 * 760 |
978 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 * 760 |
979 |
elif pressure_unit == 'kPa': |
980 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 * 101.325 |
981 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 * 101.325 |
982 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 * 101.325 |
983 |
elif pressure_unit == 'MPa': |
984 |
self.tp_dp_fric = self.tp_dp_fric / 1.033 * 0.101325 |
985 |
self.tp_dp_stat = self.tp_dp_stat / 1.033 * 0.101325 |
986 |
self.tp_dp_momen = self.tp_dp_momen / 1.033 * 0.101325 |
987 |
|
988 |
length_unit = self.units['Length'] |
989 |
if length_unit == 'm': |
990 |
self.tp_dp_fric = self.tp_dp_fric |
991 |
self.tp_dp_stat = self.tp_dp_stat |
992 |
self.tp_dp_momen = self.tp_dp_momen |
993 |
elif length_unit == 'in': |
994 |
self.tp_dp_fric = self.tp_dp_fric / 39.3701 |
995 |
self.tp_dp_stat = self.tp_dp_stat / 39.3701 |
996 |
self.tp_dp_momen = self.tp_dp_momen / 39.3701 |
997 |
elif length_unit == 'ft': |
998 |
self.tp_dp_fric = self.tp_dp_fric / 3.28084 |
999 |
self.tp_dp_stat = self.tp_dp_stat / 3.28084 |
1000 |
self.tp_dp_momen = self.tp_dp_momen / 3.28084 |
1001 |
elif length_unit == 'yd': |
1002 |
self.tp_dp_fric = self.tp_dp_fric / 1.09361 |
1003 |
self.tp_dp_stat = self.tp_dp_stat / 1.09361 |
1004 |
self.tp_dp_momen = self.tp_dp_momen / 1.09361 |
1005 |
elif length_unit == 'mile': |
1006 |
self.tp_dp_fric = self.tp_dp_fric / 0.000621371 |
1007 |
self.tp_dp_stat = self.tp_dp_stat / 0.000621371 |
1008 |
self.tp_dp_momen = self.tp_dp_momen / 0.000621371 |
1009 |
elif length_unit == 'mm': |
1010 |
self.tp_dp_fric = self.tp_dp_fric / 1000 |
1011 |
self.tp_dp_stat = self.tp_dp_stat / 1000 |
1012 |
self.tp_dp_momen = self.tp_dp_momen / 1000 |
1013 |
|
1014 |
self.dp_fric[self.no] = self.tp_dp_fric |
1015 |
self.dp_stat[self.no] = self.tp_dp_stat |
1016 |
self.dp_momen[self.no] = self.tp_dp_momen |
1017 |
|
1018 |
except Exception as ex: |
1019 |
from App import App |
1020 |
from AppDocData import MessageType |
1021 |
|
1022 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1023 |
sys.exc_info()[-1].tb_lineno)
|
1024 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1025 |
|
1026 |
def tp_v_density_cal(self): |
1027 |
try:
|
1028 |
# (1) vapor 를 kg/m3로 맞춤
|
1029 |
if is_not_blank(self.process['v_density']): |
1030 |
density_unit = self.units['Density'] |
1031 |
if density_unit == 'kg/m3': |
1032 |
self.v_density = self.v_density * self.tp_pressure_ratio |
1033 |
elif density_unit == 'lb/ft3': |
1034 |
self.v_density = self.v_density * 16.0185 * self.tp_pressure_ratio |
1035 |
else:
|
1036 |
temperature_unit = self.units['Temperature'] |
1037 |
if temperature_unit == '℃': |
1038 |
self.v_temp = float(self.process['v_temp']) + 273.15 |
1039 |
elif temperature_unit == '℉': |
1040 |
self.v_temp = (float(self.process['v_temp']) - 32) / 1.8 + 273.15 |
1041 |
|
1042 |
v_mw = float(self.process['v_mw']) |
1043 |
v_z = float(self.process['v_z']) |
1044 |
self.v_density = self.tp_pressure * v_mw / 0.08206 / self.v_temp / v_z / 1.033 |
1045 |
|
1046 |
|
1047 |
except Exception as ex: |
1048 |
from App import App |
1049 |
from AppDocData import MessageType |
1050 |
|
1051 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1052 |
sys.exc_info()[-1].tb_lineno)
|
1053 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1054 |
|
1055 |
def regime_input(self, xx, yy, regime): |
1056 |
try:
|
1057 |
self.x[self.no] = xx |
1058 |
self.y[self.no] = yy |
1059 |
self.regime[self.no] = regime |
1060 |
except Exception as ex: |
1061 |
from App import App |
1062 |
from AppDocData import MessageType |
1063 |
|
1064 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1065 |
sys.exc_info()[-1].tb_lineno)
|
1066 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1067 |
|
1068 |
def tp_ho_regime(self): |
1069 |
try:
|
1070 |
hoX = (self.l_dp_fric / self.v_dp_fric) ** 0.5 |
1071 |
|
1072 |
hoFr = (self.tp_massflux * self.tp_quality / self.v_density) * ( |
1073 |
self.v_density / ((self.l_density - self.v_density) * self.tp_id * 9.81)) ** 0.5 |
1074 |
hoFr1 = 1 / ((hoX ** 1.76) + 2 * (hoX ** 0.5) + 0.45) |
1075 |
|
1076 |
hoK = hoFr * (self.tp_massflux * (1 - self.tp_quality) * self.tp_id / self.l_visco) ** 0.5 |
1077 |
hoK1 = (0.13 * hoX ** -0.39 + 0.21 * hoX ** 0.39) ** -1.67 |
1078 |
|
1079 |
hoT = ((self.l_dp_fric / 1.033 * 101325) / (9.81 * (self.l_density - self.v_density))) ** 0.5 |
1080 |
hoT1 = (0.72 + 0.05 * hoX ** 0.8) ** -0.5 |
1081 |
|
1082 |
if hoFr1 > hoFr:
|
1083 |
# K와 X의 비교
|
1084 |
if hoK1 > hoK:
|
1085 |
regime = 'Stratified'
|
1086 |
elif hoK1 < hoK:
|
1087 |
regime = 'Wavy'
|
1088 |
YY = hoK / 1000
|
1089 |
elif hoFr1 < hoFr:
|
1090 |
if hoX < 1.6: |
1091 |
regime = 'Annular'
|
1092 |
YY = hoFr |
1093 |
else:
|
1094 |
if hoT > hoT1:
|
1095 |
regime = 'Bubble'
|
1096 |
YY = hoT |
1097 |
if hoT < hoFr1:
|
1098 |
YY = hoFr1 |
1099 |
elif hoT < hoT1:
|
1100 |
regime = 'Slug / Plug'
|
1101 |
YY = hoT |
1102 |
if hoT < hoFr1:
|
1103 |
YY = hoFr1 |
1104 |
|
1105 |
xx = hoX |
1106 |
|
1107 |
self.regime_input(xx, YY, regime)
|
1108 |
|
1109 |
except Exception as ex: |
1110 |
from App import App |
1111 |
from AppDocData import MessageType |
1112 |
|
1113 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1114 |
sys.exc_info()[-1].tb_lineno)
|
1115 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1116 |
|
1117 |
def tp_vd_regime(self): |
1118 |
try:
|
1119 |
a_o = 1.2903 * self.l_vel - 0.25806 |
1120 |
o_p = 0.984375 * self.l_vel - 0.39375 |
1121 |
|
1122 |
if self.v_vel > o_p: |
1123 |
regime = 'Annular'
|
1124 |
else:
|
1125 |
if self.v_vel > o_p: |
1126 |
regime = 'Oscillary'
|
1127 |
else:
|
1128 |
regime = 'Bubble'
|
1129 |
|
1130 |
XX = self.l_vel
|
1131 |
YY = self.v_vel
|
1132 |
|
1133 |
self.regime_input(XX, YY, regime)
|
1134 |
except Exception as ex: |
1135 |
from App import App |
1136 |
from AppDocData import MessageType |
1137 |
|
1138 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1139 |
sys.exc_info()[-1].tb_lineno)
|
1140 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1141 |
|
1142 |
def tp_vu_regime(self): |
1143 |
try:
|
1144 |
xx = self.l_density * self.l_vel ** 2 |
1145 |
YY = self.v_density * self.v_vel ** 2 |
1146 |
|
1147 |
xbub = 32000 * (YY / 1.15) ** -1.4175 |
1148 |
ybub = 7500 * (YY / 3.2) ** -0.3214 |
1149 |
|
1150 |
# bubble
|
1151 |
if YY < 3.2 and xx > xbub: |
1152 |
regime = 'Bubble'
|
1153 |
self.regime_input(xx, YY, regime)
|
1154 |
return
|
1155 |
|
1156 |
if 10 > YY > 3.2 and xx > ybub: |
1157 |
regime = 'Bubble'
|
1158 |
self.regime_input(xx, YY, regime)
|
1159 |
return
|
1160 |
|
1161 |
if 10 < YY < 100 and xx > 5200: |
1162 |
regime = 'Bubble'
|
1163 |
self.regime_input(xx, YY, regime)
|
1164 |
return
|
1165 |
|
1166 |
# churn
|
1167 |
churn1 = 6.5 * (YY / 0.1) ** 0.4375 |
1168 |
churn2 = 17.8 * (YY / 1) ** 0.7496 |
1169 |
churn3 = 100 * (YY / 10) ** 1.4256 |
1170 |
churn4 = 525 * (YY / 32) ** 3.9719 |
1171 |
churn5 = 10 * (YY / 100) ** -2.5129 |
1172 |
|
1173 |
if YY > 100 and xx < 10 and xx < churn5: |
1174 |
regime = 'Churn'
|
1175 |
self.regime_input(xx, YY, regime)
|
1176 |
return
|
1177 |
|
1178 |
if YY < 1 and xx < churn1: |
1179 |
regime = 'Churn'
|
1180 |
self.regime_input(xx, YY, regime)
|
1181 |
return
|
1182 |
|
1183 |
if YY < 10 and xx < churn2: |
1184 |
regime = 'Churn'
|
1185 |
self.regime_input(xx, YY, regime)
|
1186 |
return
|
1187 |
|
1188 |
if YY < 32 and xx < churn3: |
1189 |
regime = 'Churn'
|
1190 |
self.regime_input(xx, YY, regime)
|
1191 |
return
|
1192 |
|
1193 |
if YY < 57 and xx < churn4: |
1194 |
regime = 'Churn'
|
1195 |
self.regime_input(xx, YY, regime)
|
1196 |
return
|
1197 |
|
1198 |
if YY < 100 and xx < 5200 and xx < churn4: |
1199 |
regime = 'Churn'
|
1200 |
self.regime_input(xx, YY, regime)
|
1201 |
return
|
1202 |
|
1203 |
# Wispy Annular
|
1204 |
wisa1 = 1150 * (YY / 1000) ** 0.2704 |
1205 |
wisa2 = 1575 * (YY / 3200) ** 0.9016 |
1206 |
|
1207 |
if 100 < YY < 1000 and xx > 1150: |
1208 |
regime = 'Wispy Annular'
|
1209 |
self.regime_input(xx, YY, regime)
|
1210 |
return
|
1211 |
|
1212 |
if 10000 < YY < 3200 and xx > wisa1: |
1213 |
regime = 'Wispy Annular'
|
1214 |
self.regime_input(xx, YY, regime)
|
1215 |
return
|
1216 |
|
1217 |
if YY > 3200 and xx > wisa2: |
1218 |
regime = 'Wispy Annular'
|
1219 |
self.regime_input(xx, YY, regime)
|
1220 |
return
|
1221 |
|
1222 |
# Annular
|
1223 |
ann1 = 1150 * (YY / 1000) ** 0.2704 |
1224 |
ann2 = 1575 * (YY / 3200) ** 0.9016 |
1225 |
ann3 = 10 * (YY / 100) ** -2.5129 |
1226 |
|
1227 |
if 100 < YY < 1000 and 10 < xx < 1150: |
1228 |
regime = 'Annular'
|
1229 |
self.regime_input(xx, YY, regime)
|
1230 |
return
|
1231 |
|
1232 |
if 1000 < YY < 3200 and xx < ann1: |
1233 |
regime = 'Annular'
|
1234 |
self.regime_input(xx, YY, regime)
|
1235 |
return
|
1236 |
|
1237 |
if YY > 3200 and xx < ann2: |
1238 |
regime = 'Annular'
|
1239 |
self.regime_input(xx, YY, regime)
|
1240 |
return
|
1241 |
|
1242 |
if 10 > xx > ann3 and YY > 100: |
1243 |
regime = 'Annular'
|
1244 |
self.regime_input(xx, YY, regime)
|
1245 |
return
|
1246 |
|
1247 |
# Bubbly Plug
|
1248 |
bslug1 = 6.5 * (YY / 0.1) ** 0.4375 |
1249 |
bslug2 = 17.8 * (YY / 1) ** 0.7496 |
1250 |
bslug3 = 100 * (YY / 10) ** 1.4256 |
1251 |
bslug4 = 525 * (YY / 32) ** 3.9719 |
1252 |
bslug5 = 32000 * (YY / 1.15) ** -1.4175 |
1253 |
bslug6 = 7500 * (YY / 3.2) ** -0.3214 |
1254 |
|
1255 |
if YY < 1 and bslug1 < xx < bslug5: |
1256 |
if xx > 1000: |
1257 |
regime = 'Bubbly Plug'
|
1258 |
elif xx < 1000: |
1259 |
regime = 'Plug'
|
1260 |
self.regime_input(xx, YY, regime)
|
1261 |
return
|
1262 |
|
1263 |
if YY < 3.2 and bslug1 < xx < bslug5: |
1264 |
if xx > 1000: |
1265 |
regime = 'Bubbly Plug'
|
1266 |
elif xx < 1000: |
1267 |
regime = 'Plug'
|
1268 |
self.regime_input(xx, YY, regime)
|
1269 |
return
|
1270 |
|
1271 |
if YY < 10 and bslug2 < xx < bslug6: |
1272 |
if xx > 1000: |
1273 |
regime = 'Bubbly Plug'
|
1274 |
elif xx < 1000: |
1275 |
regime = 'Plug'
|
1276 |
self.regime_input(xx, YY, regime)
|
1277 |
return
|
1278 |
|
1279 |
if YY < 32 and bslug3 < xx < 5200: |
1280 |
if xx > 1000: |
1281 |
regime = 'Bubbly Plug'
|
1282 |
elif xx < 1000: |
1283 |
regime = 'Plug'
|
1284 |
self.regime_input(xx, YY, regime)
|
1285 |
return
|
1286 |
|
1287 |
if YY < 57 and bslug4 < xx < 5200: |
1288 |
if xx > 1000: |
1289 |
regime = 'Bubbly Plug'
|
1290 |
elif xx < 1000: |
1291 |
regime = 'Plug'
|
1292 |
self.regime_input(xx, YY, regime)
|
1293 |
return
|
1294 |
|
1295 |
except Exception as ex: |
1296 |
from App import App |
1297 |
from AppDocData import MessageType |
1298 |
|
1299 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1300 |
sys.exc_info()[-1].tb_lineno)
|
1301 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1302 |
|
1303 |
def tp_regime(self, row): |
1304 |
try:
|
1305 |
angle = self.geometry.item(row, 6).text() |
1306 |
if is_not_blank(angle):
|
1307 |
self.tp_angle = float(angle) |
1308 |
else:
|
1309 |
self.tp_angle = 0 |
1310 |
|
1311 |
if self.tp_angle == 0: |
1312 |
self.tp_ho_regime()
|
1313 |
elif self.tp_angle < 0: |
1314 |
self.tp_vd_regime()
|
1315 |
elif self.tp_angle > 0: |
1316 |
self.tp_vu_regime()
|
1317 |
|
1318 |
self.mixed_pressure_variation[self.no][15] = self.x[self.no] |
1319 |
self.mixed_pressure_variation[self.no][16] = self.y[self.no] |
1320 |
self.mixed_pressure_variation[self.no][17] = str(self.regime[self.no]) |
1321 |
except Exception as ex: |
1322 |
from App import App |
1323 |
from AppDocData import MessageType |
1324 |
|
1325 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1326 |
sys.exc_info()[-1].tb_lineno)
|
1327 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1328 |
|
1329 |
def tp_calc_end(self, row): |
1330 |
try:
|
1331 |
element = self.geometry.item(row, 0).text() |
1332 |
if element == 'Pipe': |
1333 |
self.tp_pressure_ratio = (self.tp_pressure - self.tp_length * self.tp_pipe_total_drop) / self.tp_pressure |
1334 |
self.tp_pressure = self.tp_pressure - self.tp_length * self.tp_pipe_total_drop |
1335 |
|
1336 |
# 현재 length = m
|
1337 |
length_unit = self.units['Length'] |
1338 |
if length_unit == 'm': |
1339 |
total = self.tp_length
|
1340 |
elif length_unit == 'in': |
1341 |
total = self.tp_length * 39.3701 |
1342 |
elif length_unit == 'ft': |
1343 |
total = self.tp_length * 3.28084 |
1344 |
elif length_unit == 'yd': |
1345 |
total = self.tp_length * 1.09361 |
1346 |
elif length_unit == 'mile': |
1347 |
total = self.tp_length * 0.000621371 |
1348 |
elif length_unit == 'mm': |
1349 |
total = self.tp_length * 1000 |
1350 |
|
1351 |
# 현재 kg/cm2/m
|
1352 |
pressure_unit = self.units['Pressure'] |
1353 |
if pressure_unit == 'kg/cm2': |
1354 |
total = total * self.tp_pipe_total_drop
|
1355 |
elif pressure_unit == 'psi': |
1356 |
total = total * self.tp_pipe_total_drop / 1.033 * 14.7 |
1357 |
elif pressure_unit == 'atm': |
1358 |
total = total * self.tp_pipe_total_drop / 1.033 |
1359 |
elif pressure_unit == 'bar': |
1360 |
total = total * self.tp_pipe_total_drop / 1.033 * 1.033 |
1361 |
elif pressure_unit == 'mmHg': |
1362 |
total = total * self.tp_pipe_total_drop / 1.033 * 760 |
1363 |
elif pressure_unit == 'kPa': |
1364 |
total = total * self.tp_pipe_total_drop / 1.033 * 101.325 |
1365 |
elif pressure_unit == 'MPa': |
1366 |
total = total * self.tp_pipe_total_drop / 1.033 * 0.101325 |
1367 |
|
1368 |
if length_unit == 'm': |
1369 |
total = total |
1370 |
elif length_unit == 'in': |
1371 |
total = total / 39.3701
|
1372 |
elif length_unit == 'ft': |
1373 |
total = total / 3.28084
|
1374 |
elif length_unit == 'yd': |
1375 |
total = total / 1.09361
|
1376 |
elif length_unit == 'mile': |
1377 |
total = total / 0.000621371
|
1378 |
elif length_unit == 'mm': |
1379 |
total = total / 1000
|
1380 |
|
1381 |
self.total[self.no] = total |
1382 |
else:
|
1383 |
self.tp_pressure_ratio = (self.tp_pressure - self.tp_element_dp) / self.tp_pressure |
1384 |
self.tp_pressure = self.tp_pressure - self.tp_element_dp |
1385 |
|
1386 |
# 현재 kg/cm2/m
|
1387 |
pressure_unit = self.units['Pressure'] |
1388 |
if pressure_unit == 'kg/cm2': |
1389 |
total = self.tp_element_dp
|
1390 |
elif pressure_unit == 'psi': |
1391 |
total = self.tp_element_dp / 1.033 * 14.7 |
1392 |
elif pressure_unit == 'atm': |
1393 |
total = self.tp_element_dp / 1.033 |
1394 |
elif pressure_unit == 'bar': |
1395 |
total = self.tp_element_dp / 1.033 * 1.033 |
1396 |
elif pressure_unit == 'mmHg': |
1397 |
total = self.tp_element_dp / 1.033 * 760 |
1398 |
elif pressure_unit == 'kPa': |
1399 |
total = self.tp_element_dp / 1.033 * 101.325 |
1400 |
elif pressure_unit == 'MPa': |
1401 |
total = self.tp_element_dp / 1.033 * 0.101325 |
1402 |
|
1403 |
self.total[self.no] = total |
1404 |
|
1405 |
self.tp_v_density_cal()
|
1406 |
self.void_frac(row)
|
1407 |
self.tp_property_input(row)
|
1408 |
if element == 'Pipe': |
1409 |
self.tp_regime(row)
|
1410 |
|
1411 |
except Exception as ex: |
1412 |
from App import App |
1413 |
from AppDocData import MessageType |
1414 |
|
1415 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1416 |
sys.exc_info()[-1].tb_lineno)
|
1417 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1418 |
|
1419 |
def decision_length(self, row): |
1420 |
try:
|
1421 |
length_unit = self.units['Length'] |
1422 |
length = float(self.geometry.item(row, 5).text()) |
1423 |
if length_unit == 'm': |
1424 |
self.tp_length = length
|
1425 |
elif length_unit == 'in': |
1426 |
self.tp_length = length * 0.0254 |
1427 |
elif length_unit == 'ft': |
1428 |
self.tp_length = length * 0.3048 |
1429 |
elif length_unit == 'yd': |
1430 |
self.tp_length = length * 0.9144 |
1431 |
elif length_unit == 'mile': |
1432 |
self.tp_length = length * 1609.344 |
1433 |
elif length_unit == 'mm': |
1434 |
self.tp_length = length * 0.001 |
1435 |
|
1436 |
# '5% 분기점
|
1437 |
tp_pressure_est = self.tp_pressure * self.calc_factor |
1438 |
|
1439 |
if (self.tp_pressure - tp_pressure_est) > (self.tp_length * self.tp_pipe_total_drop): |
1440 |
self.tp_calc_end(row)
|
1441 |
elif (self.tp_pressure - tp_pressure_est) < (self.tp_length * self.tp_pipe_total_drop): |
1442 |
# 이 안에다 for 문들 다시 만들어야 함 모자란 길이 반복 계산
|
1443 |
tp_remain_length = self.tp_length - (self.tp_pressure - tp_pressure_est) / self.tp_pipe_total_drop |
1444 |
self.tp_length = (self.tp_pressure - tp_pressure_est) / self.tp_pipe_total_drop |
1445 |
|
1446 |
tp_total_length = tp_remain_length + self.tp_length
|
1447 |
|
1448 |
# 무조건 처음에 한번은 해야할것 (tp_calc_end와 동일)
|
1449 |
self.tp_calc_end(row)
|
1450 |
|
1451 |
self.no += 1 |
1452 |
|
1453 |
tp_trial_length = 0
|
1454 |
for tp_trial in range(1, 100): |
1455 |
tp_trial_length += self.tp_length
|
1456 |
self.tp_fric(row)
|
1457 |
self.tp_stat(row)
|
1458 |
self.momen()
|
1459 |
|
1460 |
tp_pressure_est = self.tp_pressure * self.calc_factor |
1461 |
tp_remain_length = tp_total_length - tp_trial_length - (self.tp_pressure - tp_pressure_est) / self.tp_pipe_total_drop |
1462 |
|
1463 |
# tp_length 재정의
|
1464 |
if tp_remain_length < 0: |
1465 |
# 계산이 끝나는 시점
|
1466 |
self.tp_length = tp_total_length - tp_trial_length
|
1467 |
self.tp_dp_input()
|
1468 |
self.tp_calc_end(row)
|
1469 |
break
|
1470 |
elif tp_remain_length > 0: |
1471 |
self.tp_length = (self.tp_pressure - tp_pressure_est) / self.tp_pipe_total_drop |
1472 |
self.tp_dp_input()
|
1473 |
self.tp_calc_end(row)
|
1474 |
self.no += 1 |
1475 |
except Exception as ex: |
1476 |
from App import App |
1477 |
from AppDocData import MessageType |
1478 |
|
1479 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1480 |
sys.exc_info()[-1].tb_lineno)
|
1481 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1482 |
|
1483 |
def tp_pipe_cal(self, row): |
1484 |
try:
|
1485 |
self.tp_fric(row)
|
1486 |
self.tp_stat(row)
|
1487 |
self.momen()
|
1488 |
self.tp_dp_input()
|
1489 |
self.decision_length(row)
|
1490 |
except Exception as ex: |
1491 |
from App import App |
1492 |
from AppDocData import MessageType |
1493 |
|
1494 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1495 |
sys.exc_info()[-1].tb_lineno)
|
1496 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1497 |
|
1498 |
def tp_bend_cal(self, row): |
1499 |
try:
|
1500 |
tp_rperd = float(self.geometry.item(row, 7).text()) |
1501 |
|
1502 |
k = self.geometry.item(row, 9).text() |
1503 |
if is_not_blank(k):
|
1504 |
self.kval = float(k) |
1505 |
else:
|
1506 |
roughness_unit = self.units['Roughness'] |
1507 |
tp_rough = float(self.geometry.item(row, 4).text()) |
1508 |
if roughness_unit == 'm': |
1509 |
tp_rough = tp_rough |
1510 |
elif roughness_unit == 'ft': |
1511 |
tp_rough = tp_rough * 0.3048
|
1512 |
elif roughness_unit == 'in': |
1513 |
tp_rough = tp_rough * 0.0254
|
1514 |
elif roughness_unit == 'mm': |
1515 |
tp_rough = tp_rough * 0.001
|
1516 |
|
1517 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
1518 |
id = float(self.geometry.item(row, 3).text()) |
1519 |
if pipe_diameter_unit == 'in': |
1520 |
self.tp_id = id * 0.0254 |
1521 |
elif pipe_diameter_unit == 'mm': |
1522 |
self.tp_id = id / 1000 |
1523 |
|
1524 |
angle = float(self.geometry.item(row, 6).text()) |
1525 |
self.tp_rea_rough = tp_rough / self.tp_id |
1526 |
self.tp_angle = 3.141593 * angle / 180 |
1527 |
|
1528 |
rey = self.tp_massflux * self.tp_id / self.l_visco |
1529 |
if rey <= 2100: |
1530 |
f = 16 / rey
|
1531 |
else:
|
1532 |
f = (-2 * (math.log(tp_rough / 3.7 / self.tp_id - 5.02 / rey * ( |
1533 |
math.log(tp_rough / self.tp_id / 3.7 + (6.7 / rey) ** 0.9) / math.log(10))) / math.log(10))) ** ( |
1534 |
-2)
|
1535 |
|
1536 |
kf = f * tp_rperd * self.tp_angle
|
1537 |
|
1538 |
if self.tp_rea_rough < 3 * 10 ** -5: |
1539 |
fed = 0.027
|
1540 |
else:
|
1541 |
fed = 0.153 + (0.0121 * math.log(self.tp_rea_rough)) |
1542 |
|
1543 |
if rey < 10 ** 4: |
1544 |
fre = 0.8854
|
1545 |
elif rey > 3.5 * 10 ** 5: |
1546 |
fre = 0.667
|
1547 |
else:
|
1548 |
fre = 1.45 - 0.0613 * math.log(rey) |
1549 |
|
1550 |
kb1 = 2 * self.tp_angle / 3.141593 * tp_rperd ** 0.5 |
1551 |
kb = kb1 * fed + math.exp(-tp_rperd) * fre |
1552 |
|
1553 |
self.kval = kf + kb
|
1554 |
|
1555 |
bpara = 1 + 2.2 / (self.kval * (2 + tp_rperd)) |
1556 |
|
1557 |
pilo = 1 + (self.l_density / self.v_density - 1) * (bpara * self.tp_quality * (1 - self.tp_quality) + self.tp_quality ** 2) |
1558 |
|
1559 |
tp_bend_dp = self.kval * (self.tp_massflux ** 2 / 2 / self.l_density) * pilo / 101325 * 1.033 |
1560 |
|
1561 |
self.kval = round(self.kval, 2) |
1562 |
self.tp_element_dp = tp_bend_dp
|
1563 |
|
1564 |
self.tp_calc_end(row)
|
1565 |
|
1566 |
except Exception as ex: |
1567 |
from App import App |
1568 |
from AppDocData import MessageType |
1569 |
|
1570 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1571 |
sys.exc_info()[-1].tb_lineno)
|
1572 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1573 |
|
1574 |
def tp_nozzl_cal(self, row): |
1575 |
try:
|
1576 |
k = self.geometry.item(row, 9).text() |
1577 |
if is_not_blank(k):
|
1578 |
self.kval = float(k) |
1579 |
else:
|
1580 |
element = self.geometry.item(row, 0).text() |
1581 |
if element == 'Nozzle In': |
1582 |
self.kval = 1 |
1583 |
elif element == 'Nozzle Out': |
1584 |
self.kval = 0.5 |
1585 |
|
1586 |
rat = self.l_density / self.v_density |
1587 |
rho = (self.v_density * self.l_density) / (self.tp_quality * (self.l_density - self.v_density) + self.v_density) |
1588 |
rath = (self.l_density / rho) ** 0.5 |
1589 |
braca = (self.tp_quality * rat) + (rath * (1 - self.tp_quality)) |
1590 |
bracb = 1 + (rath - 1) ** 2 / (rat ** 0.5 - 1) |
1591 |
bracb = bracb * (1 - self.tp_quality) / rath + self.tp_quality |
1592 |
pilo = braca * bracb |
1593 |
|
1594 |
# kg/cm2의 단위로 되어있음
|
1595 |
tp_nozzl_total_dp = (self.kval * self.tp_massflux ** 2 / 2 / self.l_density) * pilo / 101325 * 1.033 |
1596 |
self.tp_element_dp = tp_nozzl_total_dp
|
1597 |
|
1598 |
self.tp_calc_end(row)
|
1599 |
|
1600 |
except Exception as ex: |
1601 |
from App import App |
1602 |
from AppDocData import MessageType |
1603 |
|
1604 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1605 |
sys.exc_info()[-1].tb_lineno)
|
1606 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1607 |
|
1608 |
def tp_expander_cal(self, row): |
1609 |
try:
|
1610 |
rod = float(self.geometry.item(row, 8).text()) |
1611 |
rod = 1 / rod # '이부분, d1/d2 정책으로 인하여 변경되었음 |
1612 |
|
1613 |
k = self.geometry.item(row, 9).text() |
1614 |
if is_not_blank(k):
|
1615 |
self.kval = float(k) |
1616 |
else:
|
1617 |
angle = float(self.geometry.item(row, 6).text()) |
1618 |
if angle <= 22.5: |
1619 |
self.kval = 2.6 * (1 - rod ** 2) ** 2 / rod ** 4 * math.sin(3.141593 / 180) |
1620 |
else:
|
1621 |
self.kval = (1 - rod ** 2) ** 2 / rod ** 4 |
1622 |
|
1623 |
sigma = rod ** 2
|
1624 |
|
1625 |
flsq = (1 - self.tp_quality) ** 2 |
1626 |
pilo = (self.tp_quality ** 2 / self.tp_void) * (self.l_density / self.v_density) + flsq / (1 - self.tp_void) |
1627 |
tp_expander_total_dp = ((self.kval - 1 + 1 / sigma ** 2) * self.tp_massflux ** 2 / 2 / self.l_density) * pilo / 10 ** 5 / 1.013 * 1.033 |
1628 |
|
1629 |
self.tp_element_dp = tp_expander_total_dp
|
1630 |
|
1631 |
self.tp_calc_end(row)
|
1632 |
|
1633 |
except Exception as ex: |
1634 |
from App import App |
1635 |
from AppDocData import MessageType |
1636 |
|
1637 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1638 |
sys.exc_info()[-1].tb_lineno)
|
1639 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1640 |
|
1641 |
def tp_reducer_cal(self, row): |
1642 |
try:
|
1643 |
ang = float(self.geometry.item(row, 6).text()) |
1644 |
rod = float(self.geometry.item(row, 8).text()) |
1645 |
id = float(self.geometry.item(row, 3).text()) |
1646 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
1647 |
if pipe_diameter_unit == 'in': |
1648 |
self.tp_id = id * 0.0254 |
1649 |
elif pipe_diameter_unit == 'mm': |
1650 |
self.tp_id = id / 1000 |
1651 |
|
1652 |
sigma = rod ** 2
|
1653 |
dcube = sigma * rod |
1654 |
dfive = sigma ** 2 * rod
|
1655 |
ak1 = (8.54038 * dfive) - (19.2214 * sigma ** 2) |
1656 |
ak2 = (14.24265 * dcube) - (4.53854 * sigma) |
1657 |
ak3 = (0.39543 * rod) + 0.57806 |
1658 |
self.kval = ak1 + ak2 + ak3
|
1659 |
|
1660 |
if ang < 90: |
1661 |
theta = float(self.geometry.item(row, 6).text()) / 90 |
1662 |
c1 = 0.01791 * math.exp(-9.624 * theta) |
1663 |
c2 = theta * (1 + theta)
|
1664 |
c3 = 0.03614 * c2 ** 4.79082 |
1665 |
cc = (c1 + c3) ** 0.25
|
1666 |
|
1667 |
self.kval = (ak1 + ak2 + ak3) * cc
|
1668 |
|
1669 |
if is_not_blank(self.geometry.item(row, 9).text()): |
1670 |
self.kval = float(self.geometry.item(row, 9).text()) |
1671 |
|
1672 |
# fric 구하기
|
1673 |
l_rey = self.tp_massflux * (1 - self.tp_quality) * self.tp_id / self.l_visco |
1674 |
v_rey = self.tp_massflux * self.tp_quality * self.tp_id / self.v_visco |
1675 |
|
1676 |
roughness_unit = self.units['Roughness'] |
1677 |
tp_rough = float(self.geometry.item(row, 4).text()) |
1678 |
if roughness_unit == 'm': |
1679 |
tp_rough = tp_rough |
1680 |
elif roughness_unit == 'ft': |
1681 |
tp_rough = tp_rough * 0.3048
|
1682 |
elif roughness_unit == 'in': |
1683 |
tp_rough = tp_rough * 0.0254
|
1684 |
elif roughness_unit == 'mm': |
1685 |
tp_rough = tp_rough * 0.001
|
1686 |
|
1687 |
self.tp_rea_rough = tp_rough / self.tp_id |
1688 |
|
1689 |
if l_rey <= 2100: |
1690 |
l_f = 16 / l_rey
|
1691 |
else:
|
1692 |
l_f = (-4 * (math.log(tp_rough / 3.7 / self.tp_id - 5.02 / l_rey * ( |
1693 |
math.log(tp_rough / self.tp_id / 3.7 + (6.7 / l_rey) ** 0.9) / math.log(10))) / math.log(10))) ** ( |
1694 |
-2)
|
1695 |
|
1696 |
if v_rey <= 2100: |
1697 |
v_f = 16 / v_rey
|
1698 |
else:
|
1699 |
v_f = (-4 * (math.log(tp_rough / 3.7 / self.tp_id - 5.02 / v_rey * ( |
1700 |
math.log(tp_rough / self.tp_id / 3.7 + (6.7 / v_rey) ** 0.9) / math.log(10))) / math.log(10))) ** ( |
1701 |
-2)
|
1702 |
|
1703 |
# dmvel 정의
|
1704 |
l_flowrate = float(self.process['l_flowrate']) |
1705 |
v_flowrate = float(self.process['v_flowrate']) |
1706 |
|
1707 |
ddia = (rod * self.tp_id)
|
1708 |
dmvel = (l_flowrate + v_flowrate) / 3600 / (3.141592 / 4 * ddia ** 2) |
1709 |
|
1710 |
drat = self.l_density / self.v_density |
1711 |
ratff = (l_f * self.v_density) / (v_f * self.l_density) |
1712 |
xlm = ratff ** 0.5 * (1 - self.tp_quality) / self.tp_quality |
1713 |
rxlm = 1 / xlm
|
1714 |
flsq = (1 - self.tp_quality) ** 2 |
1715 |
alm = rxlm * (l_f / v_f) ** 0.5
|
1716 |
alms = alm ** 2
|
1717 |
coff = drat ** 0.5 + (1 / drat) ** 0.5 |
1718 |
phisq = 1 + coff * alm + alms
|
1719 |
tpfm = phisq * flsq |
1720 |
|
1721 |
# kg/cm2
|
1722 |
tp_reducer_total_dp = (( |
1723 |
self.kval + 1 - sigma ** 2) * dmvel ** 2 / 2 / self.l_density) * tpfm / 10 ** 5 / 1.013 * 1.033 |
1724 |
self.tp_element_dp = tp_reducer_total_dp
|
1725 |
|
1726 |
self.tp_calc_end(row)
|
1727 |
except Exception as ex: |
1728 |
from App import App |
1729 |
from AppDocData import MessageType |
1730 |
|
1731 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1732 |
sys.exc_info()[-1].tb_lineno)
|
1733 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1734 |
|
1735 |
def tp_valve_cal(self, row): |
1736 |
try:
|
1737 |
k = self.geometry.item(row, 9).text() |
1738 |
if is_not_blank(k):
|
1739 |
self.kval = float(k) |
1740 |
else:
|
1741 |
element = self.geometry.item(row, 0).text() |
1742 |
if element == 'Check Valve': |
1743 |
self.kval = 7 |
1744 |
elif element == 'Ball Valve': |
1745 |
self.kval = 0.1 |
1746 |
elif element == 'Gate Valve': |
1747 |
self.kval = 0.2 |
1748 |
elif element == 'Globe Valve': |
1749 |
self.kval = 0.2 |
1750 |
elif element == 'Butterfly Valve': |
1751 |
inside_diameter = float(self.geometry.item(row, 3).text()) |
1752 |
if inside_diameter < 8.5: |
1753 |
self.kval = 0.76 |
1754 |
elif 9 < inside_diameter < 15: |
1755 |
self.kval = 0.49 |
1756 |
elif 15 < inside_diameter < 25: |
1757 |
self.kval = 0.33 |
1758 |
else:
|
1759 |
self.kval = 0.25 |
1760 |
|
1761 |
rat = self.l_density / self.v_density |
1762 |
rho = (self.v_density * self.l_density) / (self.tp_quality * (self.l_density - self.v_density) + self.v_density) |
1763 |
rath = (self.l_density / rho) ** 0.5 |
1764 |
braca = (self.tp_quality * rat) + (rath * (1 - self.tp_quality)) |
1765 |
bracb = 1 + (rath - 1) ** 2 / (rat ** 0.5 - 1) |
1766 |
bracb = bracb * (1 - self.tp_quality) / rath + self.tp_quality |
1767 |
pilo = braca * bracb |
1768 |
|
1769 |
# kg/cm2의 단위로 되어있음
|
1770 |
tp_valve_total_dp = (self.kval * self.tp_massflux ** 2 / 2 / self.l_density) * pilo / 101325 * 1.033 |
1771 |
self.tp_element_dp = tp_valve_total_dp
|
1772 |
|
1773 |
self.tp_calc_end(row)
|
1774 |
|
1775 |
except Exception as ex: |
1776 |
from App import App |
1777 |
from AppDocData import MessageType |
1778 |
|
1779 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1780 |
sys.exc_info()[-1].tb_lineno)
|
1781 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1782 |
|
1783 |
def get_equivalent_length(self): |
1784 |
equivalent_length = 0
|
1785 |
|
1786 |
for row in range(self.geometry.rowCount()): |
1787 |
if is_not_blank(self.geometry.item(row, 5).text()): |
1788 |
length = float(self.geometry.item(row, 5).text()) |
1789 |
if length:
|
1790 |
equivalent_length += length |
1791 |
|
1792 |
return equivalent_length
|
1793 |
|
1794 |
def tp_result_input(self): |
1795 |
from AppDocData import AppDocData |
1796 |
try:
|
1797 |
drawing = AppDocData.instance().activeDrawing |
1798 |
if drawing:
|
1799 |
values = {} |
1800 |
values['Phase_Type'] = 'Mixed' |
1801 |
values['Vapor_Flowrate_Mass'] = self.process['v_flowrate'] |
1802 |
values['Vapor_Density'] = self.process['v_density'] |
1803 |
values['Vapor_Viscosity'] = self.process['v_viscosity'] |
1804 |
values['Vapor_Pressure'] = self.process['tp_pressure'] |
1805 |
values['Vapor_Temperature'] = self.process['v_temp'] |
1806 |
values['Vapor_Molecular_Weight'] = self.process['v_mw'] |
1807 |
values['Vapor_Compress_Factor'] = self.process['v_z'] |
1808 |
values['Liquid_Flowrate_Mass'] = self.process['l_flowrate'] |
1809 |
values['Liquid_Density'] = self.process['l_density'] |
1810 |
values['Liquid_Viscosity'] = self.process['l_viscosity'] |
1811 |
values['Flowrate_Mass'] = float(self.process['v_flowrate']) + float(self.process['l_flowrate']) |
1812 |
values['Viscosity'] = 'Mixed' |
1813 |
values['Temperature'] = self.process['v_temp'] |
1814 |
values['Molecular_Weight'] = self.process['v_mw'] |
1815 |
values['Specific_Heat_Ratio'] = 'Mixed' |
1816 |
values['Compress_Factor'] = self.process['v_z'] |
1817 |
values['Limitation_Velocity'] = 'Mixed' |
1818 |
values['Limitation_Pressure_Drop'] = 'Mixed' |
1819 |
values['Reynolds'] = 'Mixed' |
1820 |
values['Friction_Factor'] = 'Mixed' |
1821 |
values['Pressure_Drop'] = 'Mixed' |
1822 |
values['Nominal_Pipe_Size'] = self.geometry.item(0, 1).text() |
1823 |
values['Schedule_No'] = self.geometry.item(0, 2).text() |
1824 |
values['Inside_Pipe_Size'] = self.geometry.item(0, 3).text() |
1825 |
values['Straight_Length'] = 'Mixed' |
1826 |
equivalent_length = self.get_equivalent_length()
|
1827 |
values['Equivalent_Length'] = equivalent_length
|
1828 |
values['Equivalent_Length_Cal'] = equivalent_length
|
1829 |
values['Roughness'] = self.geometry.item(0, 4).text() |
1830 |
|
1831 |
# 이하는 계산 결과 값
|
1832 |
|
1833 |
stat_result = 0
|
1834 |
fric_result = 0
|
1835 |
|
1836 |
# gravity
|
1837 |
for no in range(self.no): |
1838 |
if no in self.total: |
1839 |
dp_stat = self.dp_stat[no] if no in self.dp_stat else 0 |
1840 |
length = self.length[no] if no in self.length else 0 |
1841 |
stat_result = stat_result + dp_stat * length |
1842 |
|
1843 |
# stat_result = stat_result + self.dp_stat[no] * self.length[no]
|
1844 |
|
1845 |
# friction
|
1846 |
for no in range(self.no): |
1847 |
if no in self.total: |
1848 |
if no in self.length: |
1849 |
total = self.total[no] if no in self.total else 0 |
1850 |
dp_stat = self.dp_stat[no] if no in self.dp_stat else 0 |
1851 |
length = self.length[no] if no in self.length else 0 |
1852 |
fric_result = fric_result + total - dp_stat * length |
1853 |
else:
|
1854 |
total = self.total[no] if no in self.total else 0 |
1855 |
fric_result = fric_result + total |
1856 |
|
1857 |
values['Pressure_Drop_Friction'] = round(fric_result, 3) |
1858 |
values['Pressure_Drop_Static'] = round(stat_result, 3) |
1859 |
|
1860 |
# max_mean_den
|
1861 |
max_mean_den = sys.float_info.min |
1862 |
for no in range(self.no): |
1863 |
if no in self.mean_den: |
1864 |
mean_den = self.mean_den[no] if no in self.mean_den else 0 |
1865 |
if mean_den > max_mean_den:
|
1866 |
max_mean_den = mean_den |
1867 |
|
1868 |
# max_homo_den
|
1869 |
max_homo_den = sys.float_info.min |
1870 |
for no in range(self.no): |
1871 |
if no in self.homo_den: |
1872 |
homo_den = self.homo_den[no] if no in self.homo_den else 0 |
1873 |
if homo_den > max_homo_den:
|
1874 |
max_homo_den = homo_den |
1875 |
|
1876 |
|
1877 |
|
1878 |
# max_mean_vel
|
1879 |
max_mean_vel = sys.float_info.min |
1880 |
for no in range(self.no): |
1881 |
if no in self.mean_vel: |
1882 |
mean_vel = self.mean_vel[no] if no in self.mean_vel else 0 |
1883 |
if mean_vel > max_mean_vel:
|
1884 |
max_mean_vel = mean_vel |
1885 |
|
1886 |
# max_homo_vel
|
1887 |
max_homo_vel = sys.float_info.min |
1888 |
for no in range(self.no): |
1889 |
if no in self.homo_vel: |
1890 |
homo_vel = self.homo_vel[no] if no in self.homo_vel else 0 |
1891 |
if homo_vel > max_homo_vel:
|
1892 |
max_homo_vel = homo_vel |
1893 |
|
1894 |
values['Density'] = max(max_mean_den, max_homo_den) # self.mean_den[0] |
1895 |
values['Velocity'] = max(max_mean_vel, max_homo_vel) # self.mean_vel[1] |
1896 |
|
1897 |
# 부피유량 계산
|
1898 |
values['Flowrate_Volume'] = round(values['Flowrate_Mass'] / values['Density'], 3) |
1899 |
'''
|
1900 |
tp_volume = self.tp_flow / self.tp_mean_den * 3600
|
1901 |
# 현재 tp_volume은 m3/h임.부피유량 단위에 맞춰 뿌려줌
|
1902 |
flowrate_volume_unit = self.units['Flowrate_Volume']
|
1903 |
if flowrate_volume_unit == 'm3/h':
|
1904 |
tp_volume = round(tp_volume, 3)
|
1905 |
elif flowrate_volume_unit == 'l/min':
|
1906 |
tp_volume = round(tp_volume / 60 * 1000, 3)
|
1907 |
elif flowrate_volume_unit == 'ft3/h':
|
1908 |
tp_volume = round(tp_volume * 35.3147, 3)
|
1909 |
elif flowrate_volume_unit == 'USgpm':
|
1910 |
tp_volume = round(tp_volume * 4.40287, 3)
|
1911 |
elif flowrate_volume_unit == 'BPSD':
|
1912 |
tp_volume = round(tp_volume * 150.955, 3)
|
1913 |
|
1914 |
values['Flowrate_Volume'] = tp_volume
|
1915 |
'''
|
1916 |
drawing.hmbTable.updateByUID(self.item.uid, values)
|
1917 |
except Exception as ex: |
1918 |
from App import App |
1919 |
from AppDocData import MessageType |
1920 |
|
1921 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1922 |
sys.exc_info()[-1].tb_lineno)
|
1923 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1924 |
|
1925 |
def tp_cal(self): |
1926 |
try:
|
1927 |
self.no = 0 |
1928 |
|
1929 |
Ref_baro = self.get_barometric_pressure()
|
1930 |
self.calc_factor = self.get_mixed_calc_factor() |
1931 |
|
1932 |
# (1) fixed property
|
1933 |
# mass flowrate
|
1934 |
l_flowrate = float(self.process['l_flowrate']) |
1935 |
v_flowrate = float(self.process['v_flowrate']) |
1936 |
|
1937 |
# mass flowrate를 kg/s로 맞춘다
|
1938 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
1939 |
if flowrate_mass_unit == 'kg/h': |
1940 |
self.tp_flow = (l_flowrate + v_flowrate) / 3600 |
1941 |
elif flowrate_mass_unit == 'g/min': |
1942 |
self.tp_flow = (l_flowrate + v_flowrate) / 60 / 1000 |
1943 |
elif flowrate_mass_unit == 'lb/h': |
1944 |
self.tp_flow = (l_flowrate + v_flowrate) * 0.000125998 |
1945 |
elif flowrate_mass_unit == 't/h': |
1946 |
self.tp_flow = (l_flowrate + v_flowrate) * 0.277778 |
1947 |
|
1948 |
# liquid density
|
1949 |
density_unit = self.units['Density'] |
1950 |
if density_unit == 'kg/m3': |
1951 |
self.l_density = float(self.process['l_density']) |
1952 |
elif density_unit == 'lb/ft3': |
1953 |
self.l_density = float(self.process['l_density']) * 16.0185 |
1954 |
|
1955 |
# viscosity
|
1956 |
viscosity_unit = self.units['Viscosity'] |
1957 |
if viscosity_unit == 'kg/m.sec': |
1958 |
self.l_visco = float(self.process['l_viscosity']) |
1959 |
self.v_visco = float(self.process['v_viscosity']) |
1960 |
elif viscosity_unit == 'cP': |
1961 |
self.l_visco = float(self.process['l_viscosity']) * 0.001 |
1962 |
self.v_visco = float(self.process['v_viscosity']) * 0.001 |
1963 |
elif viscosity_unit == 'kg/m.h': |
1964 |
self.l_visco = float(self.process['l_viscosity']) / 3600 |
1965 |
self.v_visco = float(self.process['v_viscosity']) / 3600 |
1966 |
elif viscosity_unit == 'lb/ft.s': |
1967 |
self.l_visco = float(self.process['l_viscosity']) * 47.8803 |
1968 |
self.v_visco = float(self.process['v_viscosity']) * 47.8803 |
1969 |
|
1970 |
# quality 구하기
|
1971 |
self.tp_quality = v_flowrate / (l_flowrate + v_flowrate)
|
1972 |
|
1973 |
# (2) initial pressure and property
|
1974 |
# set initial point pressure
|
1975 |
tp_pressure = float(self.process['tp_pressure']) |
1976 |
|
1977 |
# pressure를 k/g.a로 맞춘다
|
1978 |
pressure_unit = self.units['Pressure'] |
1979 |
if pressure_unit == 'kg/cm2': |
1980 |
self.tp_pressure = tp_pressure + Ref_baro
|
1981 |
elif pressure_unit == 'psi': |
1982 |
self.tp_pressure = tp_pressure / 14.7 * 1.033 + Ref_baro |
1983 |
elif pressure_unit == 'atm': |
1984 |
self.tp_pressure = tp_pressure * 1.033 + Ref_baro |
1985 |
elif pressure_unit == 'bar': |
1986 |
self.tp_pressure = tp_pressure / 1.013 * 1.033 + Ref_baro |
1987 |
elif pressure_unit == 'mmHg': |
1988 |
self.tp_pressure = tp_pressure / 760 * 1.033 + Ref_baro |
1989 |
elif pressure_unit == 'kPa': |
1990 |
self.tp_pressure = tp_pressure / 101.325 * 1.033 + Ref_baro |
1991 |
elif pressure_unit == 'MPa': |
1992 |
self.tp_pressure = tp_pressure / 0.101325 * 1.033 + Ref_baro |
1993 |
|
1994 |
self.tp_property(0) |
1995 |
self.tp_property_input()
|
1996 |
|
1997 |
self.no += 1 |
1998 |
|
1999 |
row_count = self.geometry.rowCount()
|
2000 |
for row in range(row_count): |
2001 |
if self.tp_geo_check(row): |
2002 |
break
|
2003 |
|
2004 |
element = self.geometry.item(row, 0).text() |
2005 |
if element == 'Pipe': |
2006 |
self.tp_pipe_cal(row)
|
2007 |
elif element == 'Bend': |
2008 |
self.tp_bend_cal(row)
|
2009 |
elif element == 'Nozzle In': |
2010 |
self.tp_nozzl_cal(row)
|
2011 |
elif element == 'Nozzle Out': |
2012 |
self.tp_nozzl_cal(row)
|
2013 |
elif element == 'Check Valve': |
2014 |
self.tp_valve_cal(row)
|
2015 |
elif element == 'Ball Valve': |
2016 |
self.tp_valve_cal(row)
|
2017 |
elif element == 'Gate Valve': |
2018 |
self.tp_valve_cal(row)
|
2019 |
elif element == 'Globe Valve': |
2020 |
self.tp_valve_cal(row)
|
2021 |
elif element == 'Butterfly Valve': |
2022 |
self.tp_valve_cal(row)
|
2023 |
elif element == 'Reducer': |
2024 |
self.tp_reducer_cal(row)
|
2025 |
elif element == 'Expander': |
2026 |
self.tp_expander_cal(row)
|
2027 |
|
2028 |
self.no += 1 |
2029 |
|
2030 |
self.tp_result_input()
|
2031 |
except Exception as ex: |
2032 |
from App import App |
2033 |
from AppDocData import MessageType |
2034 |
|
2035 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2036 |
sys.exc_info()[-1].tb_lineno)
|
2037 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2038 |
|
2039 |
def tp_property_input(self, row=None): |
2040 |
try:
|
2041 |
baro_P = self.get_barometric_pressure()
|
2042 |
|
2043 |
# 처음 이면
|
2044 |
if row is not None: |
2045 |
element = 'Element.{}_{}'.format(str(row), self.geometry.item(row, 0).text()) |
2046 |
else:
|
2047 |
element = 'Start Point'
|
2048 |
|
2049 |
self.element[self.no] = element |
2050 |
|
2051 |
# pressure (현재 kga)
|
2052 |
pressure_unit = self.units['Pressure'] |
2053 |
if pressure_unit == 'kg/cm2': |
2054 |
p = self.tp_pressure - baro_P
|
2055 |
elif pressure_unit == 'psi': |
2056 |
p = self.tp_pressure / 1.033 * 14.7 - baro_P |
2057 |
elif pressure_unit == 'atm': |
2058 |
p = self.tp_pressure / 1.033 |
2059 |
elif pressure_unit == 'bar': |
2060 |
p = self.tp_pressure / 1.033 * 1.033 - baro_P |
2061 |
elif pressure_unit == 'mmHg': |
2062 |
p = self.tp_pressure / 1.033 * 760 - baro_P |
2063 |
elif pressure_unit == 'kPa': |
2064 |
p = self.tp_pressure / 1.033 * 101.325 - baro_P |
2065 |
elif pressure_unit == 'MPa': |
2066 |
p = self.tp_pressure / 1.033 * 0.101325 - baro_P |
2067 |
|
2068 |
self.pressure[self.no] = p |
2069 |
|
2070 |
# density (현재 kg/m3)
|
2071 |
density_unit = self.units['Density'] |
2072 |
if density_unit == 'kg/m3': |
2073 |
d = self.tp_mean_den
|
2074 |
vd = self.v_density
|
2075 |
else:
|
2076 |
d = self.tp_mean_den * 0.062428 |
2077 |
vd = self.v_density * 0.062428 |
2078 |
|
2079 |
self.mean_den[self.no] = d |
2080 |
self.density[self.no] = vd |
2081 |
|
2082 |
# velocity (m/s)
|
2083 |
velocity_unit = self.units['Velocity'] |
2084 |
if velocity_unit == 'm/s': |
2085 |
av = self.tp_mean_vel # self.tp_homo_vel |
2086 |
mv = self.tp_max_vel
|
2087 |
ev = self.tp_ero_vel
|
2088 |
elif velocity_unit == 'ft/s': |
2089 |
av = self.tp_mean_vel * 3.28084 # self.tp_homo_vel * 3.28084 |
2090 |
mv = self.tp_max_vel * 3.28084 |
2091 |
ev = self.tp_ero_vel * 3.28084 |
2092 |
|
2093 |
self.mean_vel[self.no] = av |
2094 |
self.max_vel[self.no] = mv |
2095 |
self.ero_vel[self.no] = ev |
2096 |
|
2097 |
self.homo_den[self.no] = self.tp_homo_den |
2098 |
self.homo_vel[self.no] = self.tp_homo_vel |
2099 |
|
2100 |
# dimensionless
|
2101 |
self.void[self.no] = self.tp_void |
2102 |
self.quality[self.no] = self.tp_quality |
2103 |
|
2104 |
if element != 'Start Point': |
2105 |
# dia (현재 m)
|
2106 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
2107 |
if pipe_diameter_unit == 'in': |
2108 |
id = self.tp_id / 0.0254 |
2109 |
elif pipe_diameter_unit == 'mm': |
2110 |
id = self.tp_id * 1000 |
2111 |
|
2112 |
self.inside_diameter[self.no] = id |
2113 |
|
2114 |
if element.find('Pipe') == -1: |
2115 |
self.angle[self.no] = None |
2116 |
else:
|
2117 |
# Element가 Pipe인 경우만 l가 있음
|
2118 |
length_unit = self.units['Length'] |
2119 |
if length_unit == 'm': |
2120 |
l = self.tp_length
|
2121 |
elif length_unit == 'in': |
2122 |
l = self.tp_length * 39.3701 |
2123 |
elif length_unit == 'ft': |
2124 |
l = self.tp_length * 3.28084 |
2125 |
elif length_unit == 'yd': |
2126 |
l = self.tp_length * 1.09361 |
2127 |
elif length_unit == 'mile': |
2128 |
l = self.tp_length * 0.000621371 |
2129 |
elif length_unit == 'mm': |
2130 |
l = self.tp_length * 1000 |
2131 |
|
2132 |
self.length[self.no] = l |
2133 |
|
2134 |
if element.find('Valve') > -1: |
2135 |
self.angle[self.no] = None |
2136 |
else:
|
2137 |
# Element가 Valve가 아닌경우에만 있음
|
2138 |
self.angle[self.no] = self.tp_angle |
2139 |
|
2140 |
if element.find('Pipe') == -1: |
2141 |
# Element가 Pipe가 아닌경우에는 k가 있음
|
2142 |
self.k[self.no] = self.kval |
2143 |
|
2144 |
key = self.no
|
2145 |
inside_diameter = self.inside_diameter[key] if key in self.inside_diameter else None |
2146 |
length = self.length[key] if key in self.length else None |
2147 |
angle = self.angle[key] if key in self.angle else None |
2148 |
k = self.k[key] if key in self.k else None |
2149 |
pressure = self.pressure[key] if key in self.pressure else None |
2150 |
void = self.void[key] if key in self.void else None |
2151 |
quality = self.quality[key] if key in self.quality else None |
2152 |
mean_den = self.mean_den[key] if key in self.mean_den else None |
2153 |
homo_den = self.homo_den[key] if key in self.homo_den else None |
2154 |
v_density = self.density[key] if key in self.density else None |
2155 |
mean_vel = self.mean_vel[key] if key in self.mean_vel else None |
2156 |
homo_vel = self.homo_vel[key] if key in self.homo_vel else None |
2157 |
max_vel = self.max_vel[key] if key in self.max_vel else None |
2158 |
ero_vel = self.ero_vel[key] if key in self.ero_vel else None |
2159 |
x = self.x[key] if key in self.x else None |
2160 |
y = self.y[key] if key in self.y else None |
2161 |
regime = self.regime[key] if key in self.regime else None |
2162 |
dp_fric = self.dp_fric[key] if key in self.dp_fric else None |
2163 |
dp_stat = self.dp_stat[key] if key in self.dp_stat else None |
2164 |
dp_momen = self.dp_momen[key] if key in self.dp_momen else None |
2165 |
total = self.total[key] if key in self.total else None |
2166 |
|
2167 |
self.mixed_pressure_variation.append([element, inside_diameter, length, angle, k, pressure, void,
|
2168 |
quality, mean_den, homo_den, v_density, mean_vel, homo_vel, max_vel, ero_vel, |
2169 |
x, y, regime, dp_fric, dp_stat, dp_momen, total]) |
2170 |
|
2171 |
except Exception as ex: |
2172 |
from App import App |
2173 |
from AppDocData import MessageType |
2174 |
|
2175 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2176 |
sys.exc_info()[-1].tb_lineno)
|
2177 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2178 |
|
2179 |
def tp_property(self, row): |
2180 |
try:
|
2181 |
# (0) density calculation
|
2182 |
|
2183 |
# vapor
|
2184 |
self.tp_v_density_cal_initial()
|
2185 |
self.void_frac(row)
|
2186 |
|
2187 |
except Exception as ex: |
2188 |
from App import App |
2189 |
from AppDocData import MessageType |
2190 |
|
2191 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2192 |
sys.exc_info()[-1].tb_lineno)
|
2193 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2194 |
|
2195 |
def void_frac(self, row): |
2196 |
try:
|
2197 |
tp_id = self.geometry.item(row, 3).text() |
2198 |
if is_not_blank(tp_id):
|
2199 |
# diameter를 m로 맞춘다
|
2200 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
2201 |
if pipe_diameter_unit == 'in': |
2202 |
self.tp_id = float(tp_id) * 0.0254 |
2203 |
elif pipe_diameter_unit == 'mm': |
2204 |
self.tp_id = float(tp_id) / 1000 |
2205 |
|
2206 |
# massflux 구한다 (kg/m^2s) 현재 tp_flow = kg/s, tp_id = m
|
2207 |
self.tp_massflux = self.tp_flow / ((3.1415 / 4) * (self.tp_id ** 2)) |
2208 |
|
2209 |
angle = self.geometry.item(row, 6).text() |
2210 |
if is_not_blank(angle):
|
2211 |
self.tp_angle = float(angle) |
2212 |
else:
|
2213 |
self.tp_angle = 0 |
2214 |
|
2215 |
# (2) void frac
|
2216 |
tp_vr1 = self.tp_quality / (1 - self.tp_quality) * self.l_density / self.v_density |
2217 |
tp_vr = math.log(tp_vr1) / math.log(10)
|
2218 |
tp_g = math.log(self.tp_massflux) / math.log(10) |
2219 |
|
2220 |
if 0 < self.tp_angle < 90: |
2221 |
tp_a = 1.667 - 0.00206 * self.tp_angle + 0.247 * math.sin(2 * self.tp_angle * 3.1415 / 180) |
2222 |
elif 0 > self.tp_angle > -90: |
2223 |
tp_a = 1.667 + 0.00652 * self.tp_angle + 0.772 * math.sin(2 * self.tp_angle * 3.1415 / 180) |
2224 |
elif self.tp_angle == 90: |
2225 |
tp_a = 1.482
|
2226 |
elif self.tp_angle == 0: |
2227 |
tp_a = 1.667
|
2228 |
elif self.tp_angle == -90: |
2229 |
tp_a = 1.081
|
2230 |
|
2231 |
baroczy = (self.v_density / self.l_density) * (self.l_visco / self.v_visco) ** 0.2 |
2232 |
if baroczy < 0.00316: |
2233 |
baroczy = 0.00316
|
2234 |
|
2235 |
self._lambda = math.log(baroczy) / math.log(10) |
2236 |
|
2237 |
tp_logK = (-tp_a * self._lambda) / (tp_g + 0.7563) * (1 + 0.1292 * self._lambda * (1 - 0.3792 * tp_vr) * ( |
2238 |
self._lambda + 4.007) * (1 + 0.1377 * tp_g)) |
2239 |
|
2240 |
tp_K = 10 ** tp_logK
|
2241 |
if tp_K < 1: |
2242 |
tp_K = 1
|
2243 |
|
2244 |
self.tp_void = 1 / (1 + tp_K / tp_vr1) |
2245 |
|
2246 |
# mean density 계산 (kg/m3)
|
2247 |
self.tp_mean_den = self.l_density * (1 - self.tp_void) + self.v_density * self.tp_void |
2248 |
|
2249 |
# homogeneous density 계산 (kg/m3)
|
2250 |
l_flowrate = float(self.process['l_flowrate']) |
2251 |
v_flowrate = float(self.process['v_flowrate']) |
2252 |
|
2253 |
self.tp_homo_den = self.l_density * (1 - ((v_flowrate / self.v_density) / ( |
2254 |
(v_flowrate / self.v_density) + (l_flowrate / self.l_density)))) + self.v_density * ( |
2255 |
(v_flowrate / self.v_density) / (
|
2256 |
(v_flowrate / self.v_density) + (l_flowrate / self.l_density))) |
2257 |
|
2258 |
# mean velocity (m/s)
|
2259 |
self.tp_mean_vel = self.tp_massflux / self.tp_mean_den |
2260 |
|
2261 |
# homogeneous vel (m/s)
|
2262 |
self.tp_homo_vel = self.tp_massflux * self.tp_quality / self.v_density + self.tp_massflux * (1 - self.tp_quality) / self.l_density |
2263 |
|
2264 |
# max velocity (m/s)
|
2265 |
self.tp_max_vel = 122 / (self.tp_homo_den ** 0.5) |
2266 |
|
2267 |
# erosion velocity (m/s)
|
2268 |
self.tp_ero_vel = 195 / (self.tp_homo_den ** 0.5) |
2269 |
else:
|
2270 |
return
|
2271 |
except Exception as ex: |
2272 |
from App import App |
2273 |
from AppDocData import MessageType |
2274 |
|
2275 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2276 |
sys.exc_info()[-1].tb_lineno)
|
2277 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2278 |
|
2279 |
def tp_v_density_cal_initial(self): |
2280 |
try:
|
2281 |
# (1) vapor 를 kg/m3로 맞춤
|
2282 |
if is_not_blank(self.process['v_density']): |
2283 |
density_unit = self.units['Density'] |
2284 |
if density_unit == 'kg/m3': |
2285 |
self.v_density = float(self.process['v_density']) |
2286 |
elif density_unit == 'lb/ft3': |
2287 |
self.v_density = float(self.process['v_density']) * 16.0185 |
2288 |
else:
|
2289 |
temperature_unit = self.units['Temperature'] |
2290 |
if temperature_unit == '℃': |
2291 |
self.v_temp = float(self.process['v_temp']) + 273.15 |
2292 |
elif temperature_unit == '℉': |
2293 |
self.v_temp = (float(self.process['v_temp']) - 32) / 1.8 + 273.15 |
2294 |
|
2295 |
v_mw = float(self.process['v_mw']) |
2296 |
v_z = float(self.process['v_z']) |
2297 |
self.v_density = self.tp_pressure * v_mw / 0.08206 / self.v_temp / v_z / 1.033 |
2298 |
|
2299 |
except Exception as ex: |
2300 |
from App import App |
2301 |
from AppDocData import MessageType |
2302 |
|
2303 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2304 |
sys.exc_info()[-1].tb_lineno)
|
2305 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2306 |
|
2307 |
|
2308 |
class Calculation: |
2309 |
def __init__(self, hmb): |
2310 |
self._hmb = hmb
|
2311 |
self.units = {}
|
2312 |
|
2313 |
self.init_units()
|
2314 |
|
2315 |
if self._hmb.phase_type == 'Liquid': |
2316 |
if self.validation_check_Liquid(): |
2317 |
self.calculation_Liquid()
|
2318 |
|
2319 |
def validation_check_vapor(self): |
2320 |
result = False
|
2321 |
|
2322 |
if self._hmb.inside_pipe_size is None: |
2323 |
message = 'You have to input the ID of stream <{}>.'.format(self._hmb.stream_no) |
2324 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2325 |
return result
|
2326 |
|
2327 |
if self._hmb.flowrate_mass is None: |
2328 |
message = 'You have to input mass flowrate of stream <{}>.'.format(self._hmb.stream_no) |
2329 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2330 |
return result
|
2331 |
|
2332 |
if self._hmb.specific_heat_ratio is None: |
2333 |
message = 'You have to input the specific heat ratio of stream <{}>.'.format(self._hmb.stream_no) |
2334 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2335 |
return result
|
2336 |
|
2337 |
if self._hmb.viscosity is None: |
2338 |
message = 'You have to input the viscosity of stream <{}>.'.format(self._hmb.stream_no) |
2339 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2340 |
return result
|
2341 |
|
2342 |
if self._hmb.roughness is None: |
2343 |
message = 'You have to input the roughness of stream <{}>.'.format(self._hmb.stream_no) |
2344 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2345 |
return result
|
2346 |
|
2347 |
return True |
2348 |
|
2349 |
def validation_check_Liquid(self): |
2350 |
from App import App |
2351 |
from AppDocData import MessageType |
2352 |
|
2353 |
result = False
|
2354 |
|
2355 |
# 1. Equivalent Length
|
2356 |
if self._hmb.equivalent_length is None: |
2357 |
message = 'The equivalent length of stream <{}> is not inputted.'.format(self._hmb.stream_no) |
2358 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2359 |
return result
|
2360 |
|
2361 |
if self._hmb.flowrate_mass is None and self._hmb.flowrate_volume is None: |
2362 |
message = 'You have to input mass or volume flowrate of stream <{}>.'.format(self._hmb.stream_no) |
2363 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2364 |
return result
|
2365 |
|
2366 |
if self._hmb.density is None: |
2367 |
message = 'You have to input the density of stream <{}>.'.format(self._hmb.stream_no) |
2368 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2369 |
return result
|
2370 |
|
2371 |
if self._hmb.inside_pipe_size is None: |
2372 |
message = 'You have to input the ID of stream <{}>.'.format(self._hmb.stream_no) |
2373 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2374 |
return result
|
2375 |
|
2376 |
if self._hmb.viscosity is None: |
2377 |
message = 'You have to input the viscosity of stream <{}>.'.format(self._hmb.stream_no) |
2378 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2379 |
return result
|
2380 |
|
2381 |
if self._hmb.roughness is None: |
2382 |
message = 'You have to input the roughness of stream <{}>.'.format(self._hmb.stream_no) |
2383 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
2384 |
return result
|
2385 |
|
2386 |
return True |
2387 |
|
2388 |
def init_units(self): |
2389 |
try:
|
2390 |
app_doc_data = AppDocData.instance() |
2391 |
self.units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0] |
2392 |
except Exception as ex: |
2393 |
from App import App |
2394 |
from AppDocData import MessageType |
2395 |
|
2396 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2397 |
sys.exc_info()[-1].tb_lineno)
|
2398 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2399 |
|
2400 |
def get_barometric_pressure(self): |
2401 |
pressure_unit = self.units['Pressure'] |
2402 |
|
2403 |
if pressure_unit == 'kg/cm2': |
2404 |
barometric_pressure = 1.033
|
2405 |
elif pressure_unit == 'bar': |
2406 |
barometric_pressure = 1.01325 / 0.980665 |
2407 |
elif pressure_unit == 'psi': |
2408 |
barometric_pressure = 14.7 / 14.22334 |
2409 |
elif pressure_unit == 'mmHg': |
2410 |
barometric_pressure = 760 / 735.5591 |
2411 |
elif pressure_unit == 'kPa': |
2412 |
barometric_pressure = 101.325 / 98.0665 |
2413 |
elif pressure_unit == 'MPa': |
2414 |
barometric_pressure = 0.101325 / 0.0980665 |
2415 |
|
2416 |
return barometric_pressure
|
2417 |
|
2418 |
def getLiquid_Drop_Method(self): |
2419 |
appDocData = AppDocData.instance() |
2420 |
|
2421 |
# Calculation
|
2422 |
liquid_dp_method = appDocData.getConfigs('Calculation', 'Liquid_Drop_Method') |
2423 |
|
2424 |
if len(liquid_dp_method) == 1: |
2425 |
return liquid_dp_method[0].value |
2426 |
else:
|
2427 |
return 'darcy' |
2428 |
|
2429 |
def calculation_Liquid(self): |
2430 |
try:
|
2431 |
liquid_dp_method = self.getLiquid_Drop_Method()
|
2432 |
|
2433 |
if liquid_dp_method == 'darcy': |
2434 |
self.liquid_calc_darcy()
|
2435 |
elif liquid_dp_method == 'hagen': |
2436 |
self.liquid_calc_hagen()
|
2437 |
|
2438 |
except Exception as ex: |
2439 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2440 |
sys.exc_info()[-1].tb_lineno)
|
2441 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2442 |
|
2443 |
def liquid_calc_darcy(self): |
2444 |
from App import App |
2445 |
from AppDocData import MessageType |
2446 |
from CalculationValidation import QCalculationValidation |
2447 |
|
2448 |
try:
|
2449 |
'''
|
2450 |
Incompressible Line 계산
|
2451 |
|
2452 |
**********************************************************************************
|
2453 |
참고사항 :
|
2454 |
유닛의 기준 : 유량 (kg/h, m3/h), 밀도 (kg/m3), 지름 (m), 점도 (kg/m/s), 속도 (m/s), 압력강하 (kg/cm2/100m)
|
2455 |
**********************************************************************************
|
2456 |
'''
|
2457 |
|
2458 |
# ********** 1. Flowrate 구하기 ***********
|
2459 |
# (1)질량만 적혀있는경우
|
2460 |
if is_not_blank(str(self._hmb.flowrate_mass)) and is_blank(str(self._hmb.flowrate_volume)): |
2461 |
density = self._hmb.density
|
2462 |
|
2463 |
# '질량유량을 kg/h로 변환.
|
2464 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2465 |
if flowrate_mass_unit == 'kg/h': |
2466 |
mass = self._hmb.flowrate_mass
|
2467 |
elif flowrate_mass_unit == 'g/min': |
2468 |
mass = self._hmb.flowrate_mass * 60 / 1000 |
2469 |
elif flowrate_mass_unit == 'lb/h': |
2470 |
mass = self._hmb.flowrate_mass * 0.453592 |
2471 |
elif flowrate_mass_unit == 't/h': |
2472 |
mass = self._hmb.flowrate_mass * 1000 |
2473 |
|
2474 |
# 'density case에 따라 volume rate (m3/h) 계산
|
2475 |
density_unit = self.units['Density'] |
2476 |
if density_unit == 'kg/m3': |
2477 |
volume = mass / density |
2478 |
elif density_unit == 'lb/ft3': |
2479 |
volume = mass / (density * 16.0185)
|
2480 |
|
2481 |
# '부피 유닛에 맞춰서 뿌려줌
|
2482 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2483 |
if flowrate_volume_unit == 'm3/h': |
2484 |
self._hmb.flowrate_volume = round(volume, 3) |
2485 |
elif flowrate_volume_unit == 'l/min': |
2486 |
self._hmb.flowrate_volume = round(volume / 60 * 1000, 3) |
2487 |
elif flowrate_volume_unit == 'ft3/h': |
2488 |
self._hmb.flowrate_volume = round(volume * 35.3147, 3) |
2489 |
elif flowrate_volume_unit == 'USgpm': |
2490 |
self._hmb.flowrate_volume = round(volume * 4.40287, 3) |
2491 |
elif flowrate_volume_unit == 'BPSD': |
2492 |
self._hmb.flowrate_volume = round(volume * 150.955, 3) |
2493 |
|
2494 |
elif is_blank(str(self._hmb.flowrate_mass)) and is_not_blank(str(self._hmb.flowrate_volume)): # (2)부피만 적혀있는경우 |
2495 |
density = self._hmb.density
|
2496 |
|
2497 |
# '부피유량을 m3/h로 변환.
|
2498 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2499 |
if flowrate_volume_unit == 'm3/h': |
2500 |
volume = self._hmb.flowrate_volume
|
2501 |
elif flowrate_volume_unit == 'l/min': |
2502 |
volume = self._hmb.flowrate_volume * 60 / 1000 |
2503 |
elif flowrate_volume_unit == 'ft3/h': |
2504 |
volume = self._hmb.flowrate_volume / 35.3147 |
2505 |
elif flowrate_volume_unit == 'USgpm': |
2506 |
volume = self._hmb.flowrate_volume / 4.40287 |
2507 |
elif flowrate_volume_unit == 'BPSD': |
2508 |
volume = self._hmb.flowrate_volume / 150.955 |
2509 |
|
2510 |
# 'density case에 따라 mass rate (kg/h) 계산
|
2511 |
density_unit = self.units['Density'] |
2512 |
if density_unit == 'kg/m3': |
2513 |
mass = volume * density |
2514 |
elif density_unit == 'lb/ft3': |
2515 |
mass = volume * (density * 16.0185)
|
2516 |
|
2517 |
# '질량 유닛에 맞춰서 뿌려줌
|
2518 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2519 |
if flowrate_mass_unit == 'kg/h': |
2520 |
self._hmb.flowrate_mass = round(mass, 3) |
2521 |
elif flowrate_mass_unit == 'g/min': |
2522 |
self._hmb.flowrate_mass = round(mass / 60 * 1000, 3) |
2523 |
elif flowrate_mass_unit == 'lb/h': |
2524 |
self._hmb.flowrate_mass = round(mass * 2.20462, 3) |
2525 |
elif flowrate_mass_unit == 't/h': |
2526 |
self._hmb.flowrate_mass = round(mass * 1000, 3) |
2527 |
elif is_not_blank(str(self._hmb.flowrate_mass)) and is_not_blank(str(self._hmb.flowrate_volume)): |
2528 |
# (5-3) 둘다 적힌 경우
|
2529 |
density = self._hmb.density
|
2530 |
|
2531 |
# '질량유량을 kg/h로 변환.
|
2532 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2533 |
if flowrate_mass_unit == 'kg/h': |
2534 |
mass = self._hmb.flowrate_mass
|
2535 |
elif flowrate_mass_unit == 'g/min': |
2536 |
mass = self._hmb.flowrate_mass * 60 / 1000 |
2537 |
elif flowrate_mass_unit == 'lb/h': |
2538 |
mass = self._hmb.flowrate_mass * 0.453592 |
2539 |
elif flowrate_mass_unit == 't/h': |
2540 |
mass = self._hmb.flowrate_mass * 1000 |
2541 |
|
2542 |
# 'density case에 따라 volume rate (m3/h) 계산
|
2543 |
density_unit = self.units['Density'] |
2544 |
if density_unit == 'kg/m3': |
2545 |
volume = mass / density |
2546 |
elif density_unit == 'lb/ft3': |
2547 |
volume = mass / (density * 16.0185)
|
2548 |
|
2549 |
# '부피 유닛에 맞춰서 뿌려줌
|
2550 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2551 |
if flowrate_volume_unit == 'm3/h': |
2552 |
self._hmb.flowrate_volume = round(volume, 3) |
2553 |
elif flowrate_volume_unit == 'l/min': |
2554 |
self._hmb.flowrate_volume = round(volume / 60 * 1000, 3) |
2555 |
elif flowrate_volume_unit == 'ft3/h': |
2556 |
self._hmb.flowrate_volume = round(volume * 35.3147, 3) |
2557 |
elif flowrate_volume_unit == 'USgpm': |
2558 |
self._hmb.flowrate_volume = round(volume * 4.40287, 3) |
2559 |
elif flowrate_volume_unit == 'BPSD': |
2560 |
self._hmb.flowrate_volume = round(volume * 150.955, 3) |
2561 |
|
2562 |
# ********** 2. Velocity 구하기 ***********
|
2563 |
# '지름을 m로 변환
|
2564 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
2565 |
inside_pipe_size = self._hmb.inside_pipe_size
|
2566 |
if is_blank(str(inside_pipe_size)): |
2567 |
dlg = QCalculationValidation() |
2568 |
detail = 'You have to input the ID of stream <{}>'.format(self._hmb.stream_no) |
2569 |
dlg.show_dialog('Calculation will be terminated!', [detail])
|
2570 |
return
|
2571 |
|
2572 |
if pipe_diameter_unit == 'in': |
2573 |
ida = self._hmb.inside_pipe_size * 0.0254 |
2574 |
elif pipe_diameter_unit == 'mm': |
2575 |
ida = self._hmb.inside_pipe_size / 1000 |
2576 |
|
2577 |
# '속도 계산 (m/s)
|
2578 |
velocity = 4 * volume / 3.1415 / ida ** 2 / 3600 |
2579 |
|
2580 |
# '속도 유닛에 맞춰서 뿌려줌
|
2581 |
velocity_unit = self.units['Velocity'] |
2582 |
if velocity_unit == 'm/s': |
2583 |
self._hmb.velocity = round(velocity, 3) |
2584 |
elif velocity_unit == 'ft/s': |
2585 |
self._hmb.velocity = round(velocity * 3.28084, 3) |
2586 |
|
2587 |
# ********** 3. Reynolds 수 구하기 ***********
|
2588 |
|
2589 |
# ' viscosity 유닛 변환 (모두 kg/m.s로 바꿀것임)
|
2590 |
viscosity_unit = self.units['Viscosity'] |
2591 |
if viscosity_unit == 'kg/m.sec': |
2592 |
viscosity = self._hmb.viscosity
|
2593 |
elif viscosity_unit == 'cP': |
2594 |
viscosity = self._hmb.viscosity * 0.001 |
2595 |
elif viscosity_unit == 'kg/m.h': |
2596 |
viscosity = self._hmb.viscosity / 3600 |
2597 |
elif viscosity_unit == 'lb/ft.s': |
2598 |
viscosity = self._hmb.viscosity * 1.48816 |
2599 |
|
2600 |
# 'density case에 따라 re계산
|
2601 |
density_unit = self.units['Density'] |
2602 |
if density_unit == 'kg/m3': |
2603 |
reynolds = ida * velocity * density / viscosity |
2604 |
elif density_unit == 'lb/ft3': |
2605 |
reynolds = ida * velocity * (density * 16.0185) / viscosity
|
2606 |
|
2607 |
# 'MACH 넘버 자리이므로 미입력 처리
|
2608 |
self._hmb.reynolds = '-' |
2609 |
|
2610 |
# ********** 4. Friction Factor 구하기 ***********
|
2611 |
# 'roughness 를 m로 바꿔줌
|
2612 |
roughness_unit = self.units['Roughness'] |
2613 |
if roughness_unit == 'm': |
2614 |
rough = self._hmb.roughness
|
2615 |
elif roughness_unit == 'ft': |
2616 |
rough = self._hmb.roughness * 0.3048 |
2617 |
elif roughness_unit == 'in': |
2618 |
rough = self._hmb.roughness * 0.0254 |
2619 |
elif roughness_unit == 'mm': |
2620 |
rough = self._hmb.roughness * 0.001 |
2621 |
|
2622 |
# ' reynolds수에 따라 Fanning/Chen friction factor 계산
|
2623 |
if reynolds <= 2100: |
2624 |
f = 4 * 16 / reynolds |
2625 |
else:
|
2626 |
a = math.log(rough / ida / 3.7 + (6.7 / reynolds) ** 0.9) / math.log(10) |
2627 |
f = (-2 * (math.log(rough / 3.7 / ida - 5.02 / reynolds * a) / math.log(10))) ** (-2) |
2628 |
|
2629 |
# '뿌려줌
|
2630 |
self._hmb.friction_factor = round(f, 3) |
2631 |
|
2632 |
# ********** 5. pressure Drop 구하기 ***********
|
2633 |
# '100m 당 압력강하를 kg/cm2 단위로 구한 후, 설정된 유닛에 맞춰서 conversion후 기입해줌.
|
2634 |
density_unit = self.units['Density'] |
2635 |
if density_unit == 'kg/m3': |
2636 |
# 100m 당 압력강하
|
2637 |
dp = f * density * (velocity ** 2) / 2 / ida / 9.8066 / 10000 * 100 |
2638 |
elif density_unit == 'lb/ft3': |
2639 |
# 100m 당 압력강하
|
2640 |
dp = f * (density * 16.0185) * (velocity ** 2) / 2 / ida / 9.8066 / 10000 * 100 |
2641 |
|
2642 |
pressure_unit = self.units['Pressure'] |
2643 |
if pressure_unit == 'psi': |
2644 |
dp = dp / 1.033 * 14.7 |
2645 |
elif pressure_unit == 'atm': |
2646 |
dp = dp / 1.033
|
2647 |
elif pressure_unit == 'bar': |
2648 |
dp = dp / 1.033 * 1.013 |
2649 |
elif pressure_unit == 'mmHg': |
2650 |
dp = dp / 1.033 * 760 |
2651 |
elif pressure_unit == 'kPa': |
2652 |
dp = dp / 1.033 * 101.325 |
2653 |
elif pressure_unit == 'MPa': |
2654 |
dp = dp / 1.033 * 0.101325 |
2655 |
|
2656 |
length_unit = self.units['Length'] |
2657 |
if length_unit == 'm': |
2658 |
self._hmb.pressure_drop = round(dp, 3) |
2659 |
elif length_unit == 'in': |
2660 |
self._hmb.pressure_drop = round(dp / 39.3701, 3) |
2661 |
elif length_unit == 'ft': |
2662 |
self._hmb.pressure_drop = round(dp / 3.28084, 3) |
2663 |
elif length_unit == 'yd': |
2664 |
self._hmb.pressure_drop = round(dp / 1.09361, 3) |
2665 |
elif length_unit == 'mile': |
2666 |
self._hmb.pressure_drop = round(dp / 0.000621371, 3) |
2667 |
elif length_unit == 'mm': |
2668 |
self._hmb.pressure_drop = round(dp / 1000, 3) |
2669 |
|
2670 |
# '100m 당 압력강하를 상당길이에 맞춰서 전체 압력강하로 넣어줌 ..
|
2671 |
self._hmb.pressure_drop_friction = round(self._hmb.pressure_drop / 100 * self._hmb.equivalent_length, 3) |
2672 |
|
2673 |
except Exception as ex: |
2674 |
|
2675 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2676 |
sys.exc_info()[-1].tb_lineno)
|
2677 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2678 |
|
2679 |
def liquid_calc_hagen(self): |
2680 |
from CalculationValidation import QCalculationValidation |
2681 |
'''
|
2682 |
**************************************************************
|
2683 |
Hagen-Williams 모드에서 사용할 지배식은 다음과 같다.
|
2684 |
h[m] = 10.67 / C^1.85 * Q[m3/s]^1.85 / dia[m]^4.87
|
2685 |
dP[k/g/1m] = h[m] * S.G / 10
|
2686 |
**************************************************************
|
2687 |
'''
|
2688 |
|
2689 |
# ********** 1. Flowrate 구하기 ***********
|
2690 |
if is_not_blank(str(self._hmb.flowrate_mass)) and is_blank(str(self._hmb.flowrate_volume)): # (1)질량만 적혀있는경우 |
2691 |
density = self._hmb.density
|
2692 |
|
2693 |
# '질량유량을 kg/h로 변환.
|
2694 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2695 |
if flowrate_mass_unit == 'kg/h': |
2696 |
mass = self._hmb.flowrate_mass
|
2697 |
elif flowrate_mass_unit == 'g/min': |
2698 |
mass = self._hmb.flowrate_mass * 60 / 1000 |
2699 |
elif flowrate_mass_unit == 'lb/h': |
2700 |
mass = self._hmb.flowrate_mass * 0.453592 |
2701 |
elif flowrate_mass_unit == 't/h': |
2702 |
mass = self._hmb.flowrate_mass * 1000 |
2703 |
|
2704 |
# 'density case에 따라 volume rate (m3/h) 계산
|
2705 |
density_unit = self.units['Density'] |
2706 |
if density_unit == 'kg/m3': |
2707 |
volume = mass / density |
2708 |
elif density_unit == 'lb/ft3': |
2709 |
volume = mass / (density * 16.0185)
|
2710 |
|
2711 |
# '부피 유닛에 맞춰서 뿌려줌
|
2712 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2713 |
if flowrate_volume_unit == 'm3/h': |
2714 |
self._hmb.flowrate_volume = round(volume, 3) |
2715 |
elif flowrate_volume_unit == 'l/min': |
2716 |
self._hmb.flowrate_volume = round(volume / 60 * 1000, 3) |
2717 |
elif flowrate_volume_unit == 'ft3/h': |
2718 |
self._hmb.flowrate_volume = round(volume * 35.3147, 3) |
2719 |
elif flowrate_volume_unit == 'USgpm': |
2720 |
self._hmb.flowrate_volume = round(volume * 4.40287, 3) |
2721 |
elif flowrate_volume_unit == 'BPSD': |
2722 |
self._hmb.flowrate_volume = round(volume * 150.955, 3) |
2723 |
|
2724 |
elif is_blank(str(self._hmb.flowrate_mass)) and is_not_blank(str(self._hmb.flowrate_volume)): # (2)부피만 적혀있는경우 |
2725 |
density = self._hmb.density
|
2726 |
|
2727 |
# '부피유량을 m3/h로 변환.
|
2728 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2729 |
if flowrate_volume_unit == 'm3/h': |
2730 |
volume = self._hmb.flowrate_volume
|
2731 |
elif flowrate_volume_unit == 'l/min': |
2732 |
volume = self._hmb.flowrate_volume * 60 / 1000 |
2733 |
elif flowrate_volume_unit == 'ft3/h': |
2734 |
volume = self._hmb.flowrate_volume / 35.3147 |
2735 |
elif flowrate_volume_unit == 'USgpm': |
2736 |
volume = self._hmb.flowrate_volume / 4.40287 |
2737 |
elif flowrate_volume_unit == 'BPSD': |
2738 |
volume = self._hmb.flowrate_volume / 150.955 |
2739 |
|
2740 |
# 'density case에 따라 mass rate (kg/h) 계산
|
2741 |
density_unit = self.units['Density'] |
2742 |
if density_unit == 'kg/m3': |
2743 |
mass = volume * density |
2744 |
elif density_unit == 'lb/ft3': |
2745 |
mass = volume * (density * 16.0185)
|
2746 |
|
2747 |
# '질량 유닛에 맞춰서 뿌려줌
|
2748 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2749 |
if flowrate_mass_unit == 'kg/h': |
2750 |
self._hmb.flowrate_mass = round(mass, 3) |
2751 |
elif flowrate_mass_unit == 'g/min': |
2752 |
self._hmb.flowrate_mass = round(mass / 60 * 1000, 3) |
2753 |
elif flowrate_mass_unit == 'lb/h': |
2754 |
self._hmb.flowrate_mass = round(mass * 2.20462, 3) |
2755 |
elif flowrate_mass_unit == 't/h': |
2756 |
self._hmb.flowrate_mass = round(mass * 1000, 3) |
2757 |
|
2758 |
else:
|
2759 |
# '(5-3) 둘다 적힌 경우
|
2760 |
density = self._hmb.density
|
2761 |
|
2762 |
# '질량유량을 kg/h로 변환.
|
2763 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
2764 |
if flowrate_mass_unit == 'kg/h': |
2765 |
mass = self._hmb.flowrate_mass
|
2766 |
elif flowrate_mass_unit == 'g/min': |
2767 |
mass = self._hmb.flowrate_mass * 60 / 1000 |
2768 |
elif flowrate_mass_unit == 'lb/h': |
2769 |
mass = self._hmb.flowrate_mass * 0.453592 |
2770 |
elif flowrate_mass_unit == 't/h': |
2771 |
mass = self._hmb.flowrate_mass * 1000 |
2772 |
|
2773 |
# 'density case에 따라 volume rate (m3/h) 계산
|
2774 |
density_unit = self.units['Density'] |
2775 |
if density_unit == 'kg/m3': |
2776 |
volume = mass / density |
2777 |
elif density_unit == 'lb/ft3': |
2778 |
volume = mass / (density * 16.0185)
|
2779 |
|
2780 |
# '부피 유닛에 맞춰서 뿌려줌
|
2781 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
2782 |
if flowrate_volume_unit == 'm3/h': |
2783 |
self._hmb.flowrate_volume = round(volume, 3) |
2784 |
elif flowrate_volume_unit == 'l/min': |
2785 |
self._hmb.flowrate_volume = round(volume / 60 * 1000, 3) |
2786 |
elif flowrate_volume_unit == 'ft3/h': |
2787 |
self._hmb.flowrate_volume = round(volume * 35.3147, 3) |
2788 |
elif flowrate_volume_unit == 'USgpm': |
2789 |
self._hmb.flowrate_volume = round(volume * 4.40287, 3) |
2790 |
elif flowrate_volume_unit == 'BPSD': |
2791 |
self._hmb.flowrate_volume = round(volume * 150.955, 3) |
2792 |
|
2793 |
# ****************** 2. 지름 구하기 ****************** ******************
|
2794 |
|
2795 |
# '지름을 m로 변환
|
2796 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
2797 |
inside_pipe_size = self._hmb.inside_pipe_size
|
2798 |
if is_blank(str(inside_pipe_size)): |
2799 |
dlg = QCalculationValidation() |
2800 |
detail = 'You have to input the ID of stream <{}>'.format(self._hmb.stream_no) |
2801 |
dlg.show_dialog('Calculation will be terminated!', [detail])
|
2802 |
return
|
2803 |
|
2804 |
if pipe_diameter_unit == 'in': |
2805 |
ida = self._hmb.inside_pipe_size * 0.0254 |
2806 |
elif pipe_diameter_unit == 'mm': |
2807 |
ida = self._hmb.inside_pipe_size / 1000 |
2808 |
|
2809 |
# '속도 계산 (m/s)
|
2810 |
velocity = 4 * volume / 3.1415 / ida ** 2 / 3600 |
2811 |
|
2812 |
# '속도 유닛에 맞춰서 뿌려줌
|
2813 |
velocity_unit = self.units['Velocity'] |
2814 |
if velocity_unit == 'm/s': |
2815 |
self._hmb.velocity = round(velocity, 3) |
2816 |
elif velocity_unit == 'ft/s': |
2817 |
self._hmb.velocity = round(velocity * 3.28084, 3) |
2818 |
|
2819 |
# ' viscosity 유닛 변환 (모두 kg/m.s로 바꿀것임)
|
2820 |
viscosity_unit = self.units['Viscosity'] |
2821 |
if viscosity_unit == 'kg/m.sec': |
2822 |
viscosity = self._hmb.viscosity
|
2823 |
elif viscosity_unit == 'cP': |
2824 |
viscosity = self._hmb.viscosity * 0.001 |
2825 |
elif viscosity_unit == 'kg/m.h': |
2826 |
viscosity = self._hmb.viscosity / 3600 |
2827 |
elif viscosity_unit == 'lb/ft.s': |
2828 |
viscosity = self._hmb.viscosity * 1.48816 |
2829 |
|
2830 |
# 'density case에 따라 re계산
|
2831 |
density_unit = self.units['Density'] |
2832 |
if density_unit == 'kg/m3': |
2833 |
reynolds = ida * velocity * density / viscosity |
2834 |
elif density_unit == 'lb/ft3': |
2835 |
reynolds = ida * velocity * (density * 16.0185) / viscosity
|
2836 |
|
2837 |
# 'MACH 넘버 자리이므로 미입력 처리
|
2838 |
self._hmb.reynolds = '-' |
2839 |
|
2840 |
# ''****************** 3. roughness 가져오기 ****************** ******************
|
2841 |
rough = self._hmb.roughness # '무차원 상수이다 |
2842 |
|
2843 |
# ' ********** 4. pressure Drop 구하기 ***********
|
2844 |
|
2845 |
volume = volume / 3600
|
2846 |
# '현재 volume은 m3/s
|
2847 |
|
2848 |
# '본격 계산 '단위 [m]
|
2849 |
dp = 10.67 / (rough ** 1.85) * (volume ** 1.85) / (ida ** 4.87) |
2850 |
|
2851 |
# 'density case에 따라 dp계산 '단위 [k/g/1m]
|
2852 |
density_unit = self.units['Density'] |
2853 |
if density_unit == 'kg/m3': |
2854 |
dp = dp * (density / 1000) / 10 |
2855 |
elif density_unit == 'lb/ft3': |
2856 |
dp = dp * ((density * 16.0185) / 1000) / 10 |
2857 |
|
2858 |
dp = dp * 100
|
2859 |
|
2860 |
# '현재 100m 당으로 산출되었다
|
2861 |
pressure_unit = self.units['Pressure'] |
2862 |
if pressure_unit == 'psi': |
2863 |
dp = dp / 1.033 * 14.7 |
2864 |
elif pressure_unit == 'atm': |
2865 |
dp = dp / 1.033
|
2866 |
elif pressure_unit == 'bar': |
2867 |
dp = dp / 1.033 * 1.013 |
2868 |
elif pressure_unit == 'mmHg': |
2869 |
dp = dp / 1.033 * 760 |
2870 |
elif pressure_unit == 'kPa': |
2871 |
dp = dp / 1.033 * 101.325 |
2872 |
elif pressure_unit == 'MPa': |
2873 |
dp = dp / 1.033 * 0.101325 |
2874 |
|
2875 |
length_unit = self.units['Length'] |
2876 |
if length_unit == 'm': |
2877 |
self._hmb.pressure_drop = round(dp, 3) |
2878 |
elif length_unit == 'in': |
2879 |
self._hmb.pressure_drop = round(dp / 39.3701, 3) |
2880 |
elif length_unit == 'ft': |
2881 |
self._hmb.pressure_drop = round(dp / 3.28084, 3) |
2882 |
elif length_unit == 'yd': |
2883 |
self._hmb.pressure_drop = round(dp / 1.09361, 3) |
2884 |
elif length_unit == 'mile': |
2885 |
self._hmb.pressure_drop = round(dp / 0.000621371, 3) |
2886 |
elif length_unit == 'mm': |
2887 |
self._hmb.pressure_drop = round(dp / 1000, 3) |
2888 |
|
2889 |
# '100m 당 압력강하를 상당길이에 맞춰서 전체 압력강하로 넣어줌 ..
|
2890 |
self._hmb.pressure_drop_friction = round(self._hmb.pressure_drop / 100 * self._hmb.equivalent_length, 3) |
2891 |
|
2892 |
# 'friction factor는 필요없음
|
2893 |
self._hmb.friction_factor = None |
2894 |
|