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