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