개정판 a3da2d97
issue #1048 화면/메뉴/툴바 개발
Change-Id: Ia30bc2f9f359eb5778cfdb1c2356f20761673322
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
441 | 441 |
|
442 | 442 |
return res |
443 | 443 |
|
444 |
def get_selected_nd(self, row_id, unit): |
|
445 |
res = None |
|
446 |
|
|
447 |
try: |
|
448 |
conn = sqlite3.connect(self.activeDrawing.path) |
|
449 |
conn.execute('PRAGMA foreign_keys = ON') |
|
450 |
# Get a cursor object |
|
451 |
cursor = conn.cursor() |
|
452 |
|
|
453 |
if unit == 'in': |
|
454 |
sql = 'select Inch from NominalDiameter where rowid <= ?' |
|
455 |
elif unit == 'mm': |
|
456 |
sql = 'select Milimeter from NominalDiameter where rowid <= ?' |
|
457 |
|
|
458 |
param = (row_id,) |
|
459 |
cursor.execute(sql, param) |
|
460 |
rows = cursor.fetchall() |
|
461 |
for row in rows: |
|
462 |
res = row[0] |
|
463 |
except Exception as ex: |
|
464 |
from App import App |
|
465 |
# Roll back any change if something goes wrong |
|
466 |
conn.rollback() |
|
467 |
|
|
468 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
469 |
sys.exc_info()[-1].tb_lineno) |
|
470 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
471 |
finally: |
|
472 |
# Close the db connection |
|
473 |
conn.close() |
|
474 |
|
|
475 |
return res |
|
476 |
|
|
477 |
def get_row_id(self, size, unit): |
|
478 |
res = None |
|
479 |
|
|
480 |
try: |
|
481 |
conn = sqlite3.connect(self.activeDrawing.path) |
|
482 |
conn.execute('PRAGMA foreign_keys = ON') |
|
483 |
# Get a cursor object |
|
484 |
cursor = conn.cursor() |
|
485 |
|
|
486 |
if unit == 'in': |
|
487 |
sql = 'select count(*) from NominalDiameter where Inch <= ?' |
|
488 |
elif unit == 'mm': |
|
489 |
sql = 'select count(*) from NominalDiameter where Milimeter <= ?' |
|
490 |
|
|
491 |
param = (size,) |
|
492 |
cursor.execute(sql, param) |
|
493 |
rows = cursor.fetchall() |
|
494 |
for row in rows: |
|
495 |
res = row[0] |
|
496 |
except Exception as ex: |
|
497 |
from App import App |
|
498 |
# Roll back any change if something goes wrong |
|
499 |
conn.rollback() |
|
500 |
|
|
501 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
502 |
sys.exc_info()[-1].tb_lineno) |
|
503 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
504 |
finally: |
|
505 |
# Close the db connection |
|
506 |
conn.close() |
|
507 |
|
|
508 |
return res |
|
509 |
|
|
510 |
|
|
444 | 511 |
def getInsideDiameter(self, nominaldiameter_uid, schedule_uid): |
445 | 512 |
res = [] |
446 | 513 |
try: |
HYTOS/HYTOS/Calculation.py | ||
---|---|---|
1927 | 1927 |
dp_stat = self.dp_stat[no] if no in self.dp_stat else 0 |
1928 | 1928 |
length = self.length[no] if no in self.length else 0 |
1929 | 1929 |
fric_result = fric_result + total_length - dp_stat * length |
1930 |
|
|
1931 |
#fric_result = fric_result + self.total_length[no] - self.dp_stat[no] * self.length[no] |
|
1932 | 1930 |
else: |
1933 | 1931 |
total_length = self.total_length[no] if no in self.total_length else 0 |
1934 | 1932 |
fric_result = fric_result + total_length |
1935 | 1933 |
|
1936 |
#fric_result = fric_result + self.total_length[no] |
|
1937 |
|
|
1938 | 1934 |
values['Pressure_Drop_Friction'] = round(fric_result, 3) |
1939 | 1935 |
values['Pressure_Drop_Static'] = round(stat_result, 3) |
1940 | 1936 |
values['Velocity'] = self.homo_vel[1] |
HYTOS/HYTOS/Commands/HydroCalculationCommand.py | ||
---|---|---|
63 | 63 |
if matches: |
64 | 64 |
indices = [index for index in range(len(matches[0].items)) if str(matches[0].items[index].uid) == str(hmb.components_uid)] |
65 | 65 |
if indices: |
66 |
if hmb.phase_type == 'Vapor': |
|
67 |
hmb.pressure_drop_friction = matches[0].pressure_drops[matches[0].items[indices[0]]] |
|
68 |
hmb.density = matches[0].density_elevations[matches[0].items[indices[0]]] |
|
69 |
hmb.pressure_drop = round(matches[0].pressure_drops[matches[0].items[indices[0]]] / hmb.equivalent_length * 100, 3) |
|
66 | 70 |
hmb.pressure_drop_static = matches[0].pressure_drops[matches[0].items[indices[0] - 1]] |
67 | 71 |
hmb.pressure_pipe_end_point = matches[0].pressures[matches[0].items[indices[0] + 1]] |
68 | 72 |
|
HYTOS/HYTOS/Compressor.py | ||
---|---|---|
64 | 64 |
|
65 | 65 |
if len(used_index) > 0: |
66 | 66 |
if 1 in used_index: |
67 |
self.ui.label_Img_In.setVisible(True) |
|
68 |
|
|
69 |
self.ui.label_Suc.setVisible(True) |
|
70 |
self.ui.lineEdit_Suc_Pressure.setEnabled(True) |
|
71 |
self.ui.lineEdit_Suc_Elevation.setEnabled(True) |
|
72 |
|
|
73 |
if 2 in used_index: |
|
74 | 67 |
self.ui.label_Img_Out.setVisible(True) |
75 | 68 |
|
76 | 69 |
self.ui.label_Dis.setVisible(True) |
77 | 70 |
self.ui.lineEdit_Dis_Pressure.setEnabled(True) |
78 | 71 |
self.ui.lineEdit_Dis_Elevation.setEnabled(True) |
79 | 72 |
|
73 |
if 2 in used_index: |
|
74 |
self.ui.label_Img_In.setVisible(True) |
|
75 |
|
|
76 |
self.ui.label_Suc.setVisible(True) |
|
77 |
self.ui.lineEdit_Suc_Pressure.setEnabled(True) |
|
78 |
self.ui.lineEdit_Suc_Elevation.setEnabled(True) |
|
79 |
|
|
80 | 80 |
def load_data(self): |
81 | 81 |
""" load tag no and nozzle data """ |
82 | 82 |
from Drawing import Drawing |
... | ... | |
96 | 96 |
pressure = connector.data.pressure |
97 | 97 |
if pressure: |
98 | 98 |
if index == 1: |
99 |
self.ui.lineEdit_Suc_Pressure.setText(str(pressure)) |
|
100 |
elif index == 2: |
|
101 | 99 |
self.ui.lineEdit_Dis_Pressure.setText(str(pressure)) |
100 |
elif index == 2: |
|
101 |
self.ui.lineEdit_Suc_Pressure.setText(str(pressure)) |
|
102 | 102 |
|
103 | 103 |
elevation = connector.data.elevation |
104 | 104 |
if elevation: |
105 | 105 |
if index == 1: |
106 |
self.ui.lineEdit_Suc_Elevation.setText(str(elevation)) |
|
107 |
elif index == 2: |
|
108 | 106 |
self.ui.lineEdit_Dis_Elevation.setText(str(elevation)) |
107 |
elif index == 2: |
|
108 |
self.ui.lineEdit_Suc_Elevation.setText(str(elevation)) |
|
109 | 109 |
|
110 | 110 |
def accept(self): |
111 | 111 |
""" set tag no and nozzle data """ |
... | ... | |
120 | 120 |
connector.data = NozzleData() |
121 | 121 |
|
122 | 122 |
if index == 1: |
123 |
pressure = self.ui.lineEdit_Suc_Pressure.text()
|
|
123 |
pressure = self.ui.lineEdit_Dis_Pressure.text()
|
|
124 | 124 |
if pressure: |
125 | 125 |
connector.data.pressure = float(pressure) |
126 | 126 |
else: |
127 | 127 |
connector.data.pressure = None |
128 | 128 |
|
129 |
elevation = self.ui.lineEdit_Suc_Elevation.text()
|
|
129 |
elevation = self.ui.lineEdit_Dis_Elevation.text()
|
|
130 | 130 |
if elevation: |
131 | 131 |
connector.data.elevation = float(elevation) |
132 | 132 |
else: |
133 | 133 |
connector.data.elevation = None |
134 | 134 |
elif index == 2: |
135 |
pressure = self.ui.lineEdit_Dis_Pressure.text()
|
|
135 |
pressure = self.ui.lineEdit_Suc_Pressure.text()
|
|
136 | 136 |
if pressure: |
137 | 137 |
connector.data.pressure = float(pressure) |
138 | 138 |
else: |
139 | 139 |
connector.data.pressure = None |
140 | 140 |
|
141 |
elevation = self.ui.lineEdit_Dis_Elevation.text()
|
|
141 |
elevation = self.ui.lineEdit_Suc_Elevation.text()
|
|
142 | 142 |
if elevation: |
143 | 143 |
connector.data.elevation = float(elevation) |
144 | 144 |
else: |
HYTOS/HYTOS/DiameterEstimation_Liquid.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file 'ProjectDialog.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.6 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
import sys |
|
9 |
from PyQt5.QtCore import * |
|
10 |
from PyQt5.QtGui import * |
|
11 |
from PyQt5.QtWidgets import * |
|
12 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
13 |
from PyQt5.QtWidgets import * |
|
14 |
import os |
|
15 |
from AppDocData import AppDocData |
|
16 |
import DiameterEstimation_Liquid_UI |
|
17 |
import math |
|
18 |
|
|
19 |
|
|
20 |
def set_table_widget_item_properties(name, alignment, color=None): |
|
21 |
if name is None: |
|
22 |
name = '' |
|
23 |
|
|
24 |
item = QTableWidgetItem(str(name)) |
|
25 |
item.setTextAlignment(alignment) |
|
26 |
if color: |
|
27 |
item.setBackground(color) |
|
28 |
|
|
29 |
return item |
|
30 |
|
|
31 |
|
|
32 |
def is_not_blank(s): |
|
33 |
return bool(s and s.strip()) |
|
34 |
|
|
35 |
|
|
36 |
def is_blank(s): |
|
37 |
return not (s and s.strip()) |
|
38 |
|
|
39 |
|
|
40 |
class QDiameterEstimation_Liquid(QDialog): |
|
41 |
def __init__(self): |
|
42 |
QDialog.__init__(self) |
|
43 |
|
|
44 |
self.ui = DiameterEstimation_Liquid_UI.Ui_Dialog() |
|
45 |
|
|
46 |
self.ui.setupUi(self) |
|
47 |
|
|
48 |
self.velocity = 0 |
|
49 |
self.pressure_drop = 0 |
|
50 |
self.process_data = {} |
|
51 |
self.isAccepted = False |
|
52 |
self.units = {} |
|
53 |
self.ui.tableWidget.cellDoubleClicked.connect(self.double_clicked) |
|
54 |
|
|
55 |
def show_dialog(self, velocity, pressure_drop, process_data): |
|
56 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
|
57 |
|
|
58 |
self.velocity = '' if velocity == '-' else velocity |
|
59 |
self.pressure_drop = '' if pressure_drop == '-' else pressure_drop |
|
60 |
self.process_data = process_data |
|
61 |
|
|
62 |
self.init_units() |
|
63 |
self.init_pipe_diameter_estimation() |
|
64 |
self.initialize() |
|
65 |
|
|
66 |
self.exec_() |
|
67 |
|
|
68 |
return self.isAccepted, self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).text() |
|
69 |
|
|
70 |
def init_units(self): |
|
71 |
app_doc_data = AppDocData.instance() |
|
72 |
active_drawing = app_doc_data.activeDrawing |
|
73 |
|
|
74 |
for attr in active_drawing.attrs: |
|
75 |
if attr[0] == 'Units': |
|
76 |
self.units = attr[1] |
|
77 |
|
|
78 |
def initialize(self): |
|
79 |
try: |
|
80 |
self.ui.lineEdit_Velocity.setText(self.velocity) |
|
81 |
self.ui.lineEdit_Pressure_Drop.setText(self.pressure_drop) |
|
82 |
|
|
83 |
self.ui.label_Velocity_Unit.setText(self.units['Velocity']) |
|
84 |
self.ui.label_Pressure_Drop_Unit.setText('{}/100{}'.format(self.units['Pressure'], self.units['Length'])) |
|
85 |
|
|
86 |
self.calc_pde_l() |
|
87 |
|
|
88 |
va = 100000000000 if is_blank(self.velocity) else float(self.velocity) |
|
89 |
dpa = 100000000000 if is_blank(self.pressure_drop) else float(self.pressure_drop) |
|
90 |
|
|
91 |
for row in range(self.ui.tableWidget.rowCount()): |
|
92 |
validation = False |
|
93 |
velocity = float(self.ui.tableWidget.item(row, 1).text()) |
|
94 |
if velocity > va: |
|
95 |
self.ui.tableWidget.item(row, 1).setForeground(QBrush(QColor(255, 0, 0))) |
|
96 |
validation = True |
|
97 |
|
|
98 |
pressure_drop = float(self.ui.tableWidget.item(row, 2).text()) |
|
99 |
if pressure_drop > dpa: |
|
100 |
self.ui.tableWidget.item(row, 2).setForeground(QBrush(QColor(255, 0, 0))) |
|
101 |
validation = True |
|
102 |
|
|
103 |
if validation: |
|
104 |
self.ui.tableWidget.item(row, 0).setForeground(QBrush(QColor(255, 0, 0))) |
|
105 |
|
|
106 |
except Exception as ex: |
|
107 |
from App import App |
|
108 |
from AppDocData import MessageType |
|
109 |
|
|
110 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
111 |
sys.exc_info()[-1].tb_lineno) |
|
112 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
113 |
|
|
114 |
def get_std_nd(self, mass, density, goal): |
|
115 |
std_nd = 0 |
|
116 |
d125 = mass / density |
|
117 |
b125 = (d125 / math.pi * (std_nd / 2 * 0.0254) ** 2) / 3600 |
|
118 |
|
|
119 |
return 0 |
|
120 |
|
|
121 |
def calc_pde_l2(self, mass, density, viscosity, volume): |
|
122 |
try: |
|
123 |
length_unit = self.units['Length'] |
|
124 |
if length_unit == 'm': |
|
125 |
ccdp = float(self.pressure_drop) |
|
126 |
elif length_unit == 'in': |
|
127 |
ccdp = float(self.pressure_drop) / 0.0254 |
|
128 |
elif length_unit == 'ft': |
|
129 |
ccdp = float(self.pressure_drop) / 0.3048 |
|
130 |
elif length_unit == 'yd': |
|
131 |
ccdp = float(self.pressure_drop) / 0.9144 |
|
132 |
elif length_unit == 'mile': |
|
133 |
ccdp = float(self.pressure_drop) / 1609.34 |
|
134 |
elif length_unit == 'mm': |
|
135 |
ccdp = float(self.pressure_drop) / 0.001 |
|
136 |
|
|
137 |
pressure_unit = self.units['Pressure'] |
|
138 |
if pressure_unit == 'kg/cm2': |
|
139 |
ccdp = ccdp |
|
140 |
elif pressure_unit == 'psi': |
|
141 |
ccdp = ccdp * 1.033 / 14.7 |
|
142 |
elif pressure_unit == 'bar': |
|
143 |
ccdp = ccdp * 1.033 / 1.013 |
|
144 |
elif pressure_unit == 'mmHg': |
|
145 |
ccdp = ccdp * 1.033 / 760 |
|
146 |
elif pressure_unit == 'kPa': |
|
147 |
ccdp = ccdp * 1.033 / 101.325 |
|
148 |
elif pressure_unit == 'MPa': |
|
149 |
ccdp = ccdp * 1.033 / 0.101325 |
|
150 |
|
|
151 |
# ************************1. sheet2의 calculator에 값들 입력 *********************** |
|
152 |
# 압력강하 기준 입력 |
|
153 |
goal = ccdp |
|
154 |
|
|
155 |
roughness = float(self.process_data['Roughness']) |
|
156 |
roughness_unit = self.units['Roughness'] |
|
157 |
if roughness_unit == 'm': |
|
158 |
rough = roughness |
|
159 |
elif roughness_unit == 'ft': |
|
160 |
rough = roughness * 0.3048 |
|
161 |
elif roughness_unit == 'in': |
|
162 |
rough = roughness * 0.0254 |
|
163 |
elif roughness_unit == 'mm': |
|
164 |
rough = roughness * 0.001 |
|
165 |
|
|
166 |
pass |
|
167 |
# ToDo.. |
|
168 |
# 기준 Dia를 구해야함 |
|
169 |
# *********************** 2. 목표값 찾기 (기준 Dia 구함) *********************** |
|
170 |
# 기준 Dia 구함 (in) |
|
171 |
std_nd = self.get_std_nd(mass, density, goal) |
|
172 |
nd_unit = self.units['Pipe_Diameter'] |
|
173 |
row_id = self.get_row_id(std_nd, nd_unit) |
|
174 |
|
|
175 |
if std_nd > 36: |
|
176 |
selected_nd = math.ceil(std_nd) |
|
177 |
else: |
|
178 |
selected_nd = self.get_selected_nd(row_id + 1, nd_unit) |
|
179 |
|
|
180 |
nd = [] |
|
181 |
cvelocity = [] |
|
182 |
creynolds = [] |
|
183 |
ca = [] |
|
184 |
cf = [] |
|
185 |
cdp = [] |
|
186 |
|
|
187 |
if std_nd > 36: |
|
188 |
nd.append(selected_nd - 4) |
|
189 |
nd.append(selected_nd - 2) |
|
190 |
nd.append(selected_nd) |
|
191 |
else: |
|
192 |
nd.append(self.get_selected_nd(row_id - 1, nd_unit)) |
|
193 |
nd.append(self.get_selected_nd(row_id, nd_unit)) |
|
194 |
nd.append(selected_nd) |
|
195 |
|
|
196 |
if std_nd > 34: |
|
197 |
nd.append(selected_nd + 2) |
|
198 |
else: |
|
199 |
nd.append(self.get_selected_nd(row_id + 2, nd_unit)) |
|
200 |
|
|
201 |
if std_nd > 30: |
|
202 |
nd.append(selected_nd + 4) |
|
203 |
else: |
|
204 |
nd.append(self.get_selected_nd(row_id + 3, nd_unit)) |
|
205 |
|
|
206 |
density_unit = self.units['Density'] |
|
207 |
for i in range(5): |
|
208 |
cvelocity.append(4 * volume / 3.1415 / ((nd[i] * 0.0254) ** 2) / 3600) # ND 마다 속도 구함 |
|
209 |
creynolds.append((nd[i] * 0.0254) * cvelocity[i] * density / viscosity) # ND 마다 레이놀즈 넘버 구함 |
|
210 |
# '마찰계수 산출 |
|
211 |
ca.append(math.log(rough / (nd[i] * 0.0254) / 3.7 + (6.7 / creynolds[i]) ** 0.9) / math.log(10)) |
|
212 |
cf.append( |
|
213 |
(-2 * (math.log(rough / 3.7 / (nd[i] * 0.0254) - 5.02 / creynolds[i] * ca[i]) / math.log(10))) ** ( |
|
214 |
-2)) |
|
215 |
# 100m 당 압력강하 산출 (kg/cm2) |
|
216 |
if density_unit == 'kg/m3': |
|
217 |
cdp.append(cf[i] * density * (cvelocity[i] ** 2) / 2 / (nd[i] * 0.0254) / 9.8066 / 10000 * 100) |
|
218 |
elif density_unit == 'lb/ft3': |
|
219 |
cdp.append( |
|
220 |
cf[i] * (density * 16.0185) * (cvelocity[i] ** 2) / 2 / (nd[i] * 0.0254) / 9.8066 / 10000 * 100) |
|
221 |
|
|
222 |
# unit case에 따라 창에 입력. |
|
223 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
|
224 |
if pipe_diameter_unit == 'mm': |
|
225 |
for i in range(5): |
|
226 |
nd[i] = nd[i] * 25 |
|
227 |
|
|
228 |
velocity_unit = self.units['Velocity'] |
|
229 |
if velocity_unit == 'm/s': |
|
230 |
for i in range(5): |
|
231 |
cvelocity[i] = round(cvelocity[i], 5) |
|
232 |
elif velocity_unit == 'ft/s': |
|
233 |
for i in range(5): |
|
234 |
cvelocity[i] = round(cvelocity[i] * 3.28084, 5) |
|
235 |
|
|
236 |
# reynolds |
|
237 |
for i in range(5): |
|
238 |
creynolds[i] = round(creynolds[i], 0) |
|
239 |
|
|
240 |
# friction factor |
|
241 |
for i in range(5): |
|
242 |
cf[i] = round(cf[i], 5) |
|
243 |
|
|
244 |
# pressure drop |
|
245 |
pressure_unit = self.units['Pressure'] |
|
246 |
if pressure_unit == 'kg/cm2': |
|
247 |
for i in range(5): |
|
248 |
cdp[i] = cdp[i] |
|
249 |
elif pressure_unit == 'psi': |
|
250 |
for i in range(5): |
|
251 |
cdp[i] = cdp[i] / 1.033 * 14.7 |
|
252 |
elif pressure_unit == 'bar': |
|
253 |
for i in range(5): |
|
254 |
cdp[i] = cdp[i] / 1.033 * 1.013 |
|
255 |
elif pressure_unit == 'mmHg': |
|
256 |
for i in range(5): |
|
257 |
cdp[i] = cdp[i] / 1.033 * 760 |
|
258 |
elif pressure_unit == 'kPa': |
|
259 |
for i in range(5): |
|
260 |
cdp[i] = cdp[i] / 1.033 * 101.325 |
|
261 |
elif pressure_unit == 'MPa': |
|
262 |
for i in range(5): |
|
263 |
cdp[i] = cdp[i] / 1.033 * 0.101325 |
|
264 |
|
|
265 |
length_unit = self.units['Length'] |
|
266 |
if length_unit == 'm': |
|
267 |
for i in range(5): |
|
268 |
cdp[i] = round(cdp[i], 5) |
|
269 |
elif length_unit == 'in': |
|
270 |
for i in range(5): |
|
271 |
cdp[i] = round(cdp[i] / 39.3701, 5) |
|
272 |
elif length_unit == 'ft': |
|
273 |
for i in range(5): |
|
274 |
cdp[i] = round(cdp[i] / 3.28084, 5) |
|
275 |
elif length_unit == 'yd': |
|
276 |
for i in range(5): |
|
277 |
cdp[i] = round(cdp[i] / 1.09361, 5) |
|
278 |
elif length_unit == 'mile': |
|
279 |
for i in range(5): |
|
280 |
cdp[i] = round(cdp[i] / 0.000621371, 5) |
|
281 |
elif length_unit == 'mm': |
|
282 |
for i in range(5): |
|
283 |
cdp[i] = round(cdp[i] / 1000, 5) |
|
284 |
|
|
285 |
for i in range(5): |
|
286 |
self.add_data(nd[i], cvelocity[i], cdp[i], creynolds[i], cf[i]) |
|
287 |
|
|
288 |
except Exception as ex: |
|
289 |
from App import App |
|
290 |
from AppDocData import MessageType |
|
291 |
|
|
292 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
293 |
sys.exc_info()[-1].tb_lineno) |
|
294 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
295 |
|
|
296 |
def calc_pde_l(self): |
|
297 |
try: |
|
298 |
# 속도가 나와있는 경우의 liquid 모듈 |
|
299 |
# ********************************************************************************** |
|
300 |
# 참고사항 : |
|
301 |
# 유닛의 기준 : 유량 (kg/h, m3/h), 밀도 (kg/m3), 지름 (m), 점도 (kg/m/s), 속도 (m/s), 압력강하 (kg/cm2/100m) |
|
302 |
# ********************************************************************************** |
|
303 |
|
|
304 |
# ********** 1. Flowrate 구하기 *********** |
|
305 |
# (1)질량만 적혀있는경우 |
|
306 |
if is_not_blank(self.process_data['Flowrate_Mass']) and is_blank(self.process_data['Flowrate_Volume']): |
|
307 |
flowrate_mass = float(self.process_data['Flowrate_Mass']) |
|
308 |
density = float(self.process_data['Density']) |
|
309 |
|
|
310 |
# '질량유량을 kg/h로 변환. |
|
311 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
|
312 |
if flowrate_mass_unit == 'kg/h': |
|
313 |
mass = flowrate_mass |
|
314 |
elif flowrate_mass_unit == 'g/min': |
|
315 |
mass = flowrate_mass * 60 / 1000 |
|
316 |
elif flowrate_mass_unit == 'lb/h': |
|
317 |
mass = flowrate_mass * 0.453592 |
|
318 |
elif flowrate_mass_unit == 't/h': |
|
319 |
mass = flowrate_mass * 1000 |
|
320 |
|
|
321 |
# 'density case에 따라 volume rate (m3/h) 계산 |
|
322 |
density_unit = self.units['Density'] |
|
323 |
if density_unit == 'kg/m3': |
|
324 |
volume = mass / density |
|
325 |
elif density_unit == 'lb/ft3': |
|
326 |
volume = mass / (density * 16.0185) |
|
327 |
elif is_blank(self.process_data['Flowrate_Mass']) and is_not_blank(self.process_data['Flowrate_Volume']): |
|
328 |
# (2)부피만 적혀있는경우 |
|
329 |
flowrate_volume = float(self.process_data['Flowrate_Volume']) |
|
330 |
density = float(self.process_data['Density']) |
|
331 |
|
|
332 |
# '부피유량을 m3/h로 변환. |
|
333 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
|
334 |
if flowrate_volume_unit == 'm3/h': |
|
335 |
volume = flowrate_volume |
|
336 |
elif flowrate_volume_unit == 'l/min': |
|
337 |
volume = flowrate_volume * 60 / 1000 |
|
338 |
elif flowrate_volume_unit == 'ft3/h': |
|
339 |
volume = flowrate_volume / 35.3147 |
|
340 |
elif flowrate_volume_unit == 'USgpm': |
|
341 |
volume = flowrate_volume / 4.40287 |
|
342 |
elif flowrate_volume_unit == 'BPSD': |
|
343 |
volume = flowrate_volume / 150.955 |
|
344 |
|
|
345 |
# 'density case에 따라 mass rate (kg/h) 계산 |
|
346 |
density_unit = self.units['Density'] |
|
347 |
if density_unit == 'kg/m3': |
|
348 |
mass = volume * density |
|
349 |
elif density_unit == 'lb/ft3': |
|
350 |
mass = volume * (density * 16.0185) |
|
351 |
elif is_not_blank(self.process_data['Flowrate_Mass']) and is_not_blank( |
|
352 |
self.process_data['Flowrate_Volume']): |
|
353 |
# (3) 둘다 적힌 경우 (mass를 가지고 한다) |
|
354 |
flowrate_mass = float(self.process_data['Flowrate_Mass']) |
|
355 |
density = float(self.process_data['Density']) |
|
356 |
|
|
357 |
# '질량유량을 kg/h로 변환. |
|
358 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
|
359 |
if flowrate_mass_unit == 'kg/h': |
|
360 |
mass = flowrate_mass |
|
361 |
elif flowrate_mass_unit == 'g/min': |
|
362 |
mass = flowrate_mass * 60 / 1000 |
|
363 |
elif flowrate_mass_unit == 'lb/h': |
|
364 |
mass = flowrate_mass * 0.453592 |
|
365 |
elif flowrate_mass_unit == 't/h': |
|
366 |
mass = flowrate_mass * 1000 |
|
367 |
|
|
368 |
# 'density case에 따라 volume rate (m3/h) 계산 |
|
369 |
density_unit = self.units['Density'] |
|
370 |
if density_unit == 'kg/m3': |
|
371 |
volume = mass / density |
|
372 |
elif density_unit == 'lb/ft3': |
|
373 |
volume = mass / (density * 16.0185) |
|
374 |
|
|
375 |
# ********** 2. viscosity 구하기 |
|
376 |
viscosity = float(self.process_data['Viscosity']) |
|
377 |
viscosity_unit = self.units['Viscosity'] |
|
378 |
if viscosity_unit == 'kg/m.sec': |
|
379 |
viscosity = viscosity |
|
380 |
elif viscosity_unit == 'cP': |
|
381 |
viscosity = viscosity * 0.001 |
|
382 |
elif viscosity_unit == 'kg/m.h': |
|
383 |
viscosity = viscosity / 3600 |
|
384 |
elif viscosity_unit == 'lb/ft.s': |
|
385 |
viscosity = viscosity * 1.48816 |
|
386 |
|
|
387 |
# ********** 3. ND, 속도, 압력강하 5개 구함 |
|
388 |
velocity_unit = self.units['Velocity'] |
|
389 |
if velocity_unit == 'm/s': |
|
390 |
cvel = float(self.velocity) |
|
391 |
elif velocity_unit == 'ft/s': |
|
392 |
cvel = float(self.velocity) * 3.28084 |
|
393 |
|
|
394 |
# ★★★★★★★★★속도 / 압력강하 분기점★★★★★★★★★★ |
|
395 |
if cvel == 0 and float(self.pressure_drop) > 0: |
|
396 |
self.calc_pde_l2(mass, density, viscosity, volume) |
|
397 |
return |
|
398 |
|
|
399 |
roughness = float(self.process_data['Roughness']) |
|
400 |
roughness_unit = self.units['Roughness'] |
|
401 |
if roughness_unit == 'm': |
|
402 |
rough = roughness |
|
403 |
elif roughness_unit == 'ft': |
|
404 |
rough = roughness * 0.3048 |
|
405 |
elif roughness_unit == 'in': |
|
406 |
rough = roughness * 0.0254 |
|
407 |
elif roughness_unit == 'mm': |
|
408 |
rough = roughness * 0.001 |
|
409 |
|
|
410 |
# 기준 Dia 구함 (in) |
|
411 |
std_nd = ((4 * volume / cvel / 3.1415 / 3600) ** 0.5) / 0.0254 |
|
412 |
nd_unit = self.units['Pipe_Diameter'] |
|
413 |
row_id = self.get_row_id(std_nd, nd_unit) |
|
414 |
|
|
415 |
if std_nd > 36: |
|
416 |
selected_nd = math.ceil(std_nd) |
|
417 |
else: |
|
418 |
selected_nd = self.get_selected_nd(row_id + 1, nd_unit) |
|
419 |
|
|
420 |
nd = [] |
|
421 |
cvelocity = [] |
|
422 |
creynolds = [] |
|
423 |
ca = [] |
|
424 |
cf = [] |
|
425 |
cdp = [] |
|
426 |
|
|
427 |
if std_nd > 36: |
|
428 |
nd.append(selected_nd - 2) |
|
429 |
nd.append(selected_nd) |
|
430 |
else: |
|
431 |
nd.append(self.get_selected_nd(row_id, nd_unit)) |
|
432 |
nd.append(selected_nd) |
|
433 |
|
|
434 |
if std_nd > 34: |
|
435 |
nd.append(selected_nd + 2) |
|
436 |
else: |
|
437 |
nd.append(self.get_selected_nd(row_id + 2, nd_unit)) |
|
438 |
|
|
439 |
if std_nd > 30: |
|
440 |
nd.append(selected_nd + 4) |
|
441 |
nd.append(selected_nd + 6) |
|
442 |
else: |
|
443 |
nd.append(self.get_selected_nd(row_id + 3, nd_unit)) |
|
444 |
nd.append(self.get_selected_nd(row_id + 4, nd_unit)) |
|
445 |
|
|
446 |
density_unit = self.units['Density'] |
|
447 |
for i in range(5): |
|
448 |
cvelocity.append(4 * volume / 3.1415 / ((nd[i] * 0.0254) ** 2) / 3600) # ND 마다 속도 구함 |
|
449 |
creynolds.append((nd[i] * 0.0254) * cvelocity[i] * density / viscosity) # ND 마다 레이놀즈 넘버 구함 |
|
450 |
# '마찰계수 산출 |
|
451 |
ca.append(math.log(rough / (nd[i] * 0.0254) / 3.7 + (6.7 / creynolds[i]) ** 0.9) / math.log(10)) |
|
452 |
cf.append((-2 * (math.log(rough / 3.7 / (nd[i] * 0.0254) - 5.02 / creynolds[i] * ca[i]) / math.log(10))) ** (-2)) |
|
453 |
# 100m 당 압력강하 산출 (kg/cm2) |
|
454 |
if density_unit == 'kg/m3': |
|
455 |
cdp.append(cf[i] * density * (cvelocity[i] ** 2) / 2 / (nd[i] * 0.0254) / 9.8066 / 10000 * 100) |
|
456 |
elif density_unit == 'lb/ft3': |
|
457 |
cdp.append(cf[i] * (density * 16.0185) * (cvelocity[i] ** 2) / 2 / (nd[i] * 0.0254) / 9.8066 / 10000 * 100) |
|
458 |
|
|
459 |
# unit case에 따라 창에 입력. |
|
460 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
|
461 |
if pipe_diameter_unit == 'mm': |
|
462 |
for i in range(5): |
|
463 |
nd[i] = nd[i] * 25 |
|
464 |
|
|
465 |
velocity_unit = self.units['Velocity'] |
|
466 |
if velocity_unit == 'm/s': |
|
467 |
for i in range(5): |
|
468 |
cvelocity[i] = round(cvelocity[i], 5) |
|
469 |
elif velocity_unit == 'ft/s': |
|
470 |
for i in range(5): |
|
471 |
cvelocity[i] = round(cvelocity[i] * 3.28084, 5) |
|
472 |
|
|
473 |
# reynolds |
|
474 |
for i in range(5): |
|
475 |
creynolds[i] = round(creynolds[i], 0) |
|
476 |
|
|
477 |
# friction factor |
|
478 |
for i in range(5): |
|
479 |
cf[i] = round(cf[i], 5) |
|
480 |
|
|
481 |
# pressure drop |
|
482 |
pressure_unit = self.units['Pressure'] |
|
483 |
if pressure_unit == 'kg/cm2': |
|
484 |
for i in range(5): |
|
485 |
cdp[i] = cdp[i] |
|
486 |
elif pressure_unit == 'psi': |
|
487 |
for i in range(5): |
|
488 |
cdp[i] = cdp[i] / 1.033 * 14.7 |
|
489 |
elif pressure_unit == 'bar': |
|
490 |
for i in range(5): |
|
491 |
cdp[i] = cdp[i] / 1.033 * 1.013 |
|
492 |
elif pressure_unit == 'mmHg': |
|
493 |
for i in range(5): |
|
494 |
cdp[i] = cdp[i] / 1.033 * 760 |
|
495 |
elif pressure_unit == 'kPa': |
|
496 |
for i in range(5): |
|
497 |
cdp[i] = cdp[i] / 1.033 * 101.325 |
|
498 |
elif pressure_unit == 'MPa': |
|
499 |
for i in range(5): |
|
500 |
cdp[i] = cdp[i] / 1.033 * 0.101325 |
|
501 |
|
|
502 |
length_unit = self.units['Length'] |
|
503 |
if length_unit == 'm': |
|
504 |
for i in range(5): |
|
505 |
cdp[i] = round(cdp[i], 5) |
|
506 |
elif length_unit == 'in': |
|
507 |
for i in range(5): |
|
508 |
cdp[i] = round(cdp[i] / 39.3701, 5) |
|
509 |
elif length_unit == 'ft': |
|
510 |
for i in range(5): |
|
511 |
cdp[i] = round(cdp[i] / 3.28084, 5) |
|
512 |
elif length_unit == 'yd': |
|
513 |
for i in range(5): |
|
514 |
cdp[i] = round(cdp[i] / 1.09361, 5) |
|
515 |
elif length_unit == 'mile': |
|
516 |
for i in range(5): |
|
517 |
cdp[i] = round(cdp[i] / 0.000621371, 5) |
|
518 |
elif length_unit == 'mm': |
|
519 |
for i in range(5): |
|
520 |
cdp[i] = round(cdp[i] / 1000, 5) |
|
521 |
|
|
522 |
for i in range(5): |
|
523 |
self.add_data(nd[i], cvelocity[i], cdp[i], creynolds[i], cf[i]) |
|
524 |
|
|
525 |
except Exception as ex: |
|
526 |
from App import App |
|
527 |
from AppDocData import MessageType |
|
528 |
|
|
529 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
530 |
sys.exc_info()[-1].tb_lineno) |
|
531 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
532 |
|
|
533 |
def get_selected_nd(self, row_id, nd_unit): |
|
534 |
try: |
|
535 |
return AppDocData.instance().get_selected_nd(row_id, nd_unit) |
|
536 |
|
|
537 |
except Exception as ex: |
|
538 |
from App import App |
|
539 |
from AppDocData import MessageType |
|
540 |
|
|
541 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
542 |
sys.exc_info()[-1].tb_lineno) |
|
543 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
544 |
|
|
545 |
def get_row_id(self, std_nd, nd_unit): |
|
546 |
try: |
|
547 |
return AppDocData.instance().get_row_id(std_nd, nd_unit) |
|
548 |
|
|
549 |
except Exception as ex: |
|
550 |
from App import App |
|
551 |
from AppDocData import MessageType |
|
552 |
|
|
553 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
554 |
sys.exc_info()[-1].tb_lineno) |
|
555 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
556 |
|
|
557 |
def init_pipe_diameter_estimation(self): |
|
558 |
self.ui.tableWidget.setColumnCount(5) |
|
559 |
|
|
560 |
'ND ({})'.format(self.units['Pipe_Diameter']) |
|
561 |
self.ui.tableWidget.setHorizontalHeaderLabels(['ND ({})'.format(self.units['Pipe_Diameter']), |
|
562 |
'Velocity ({})'.format(self.units['Velocity']), |
|
563 |
'Pressure Drop ({}/100{})'.format(self.units['Pressure'], |
|
564 |
self.units['Length']), |
|
565 |
'Reynolds', |
|
566 |
'Friction']) |
|
567 |
self.ui.tableWidget.verticalHeader().setVisible(False) |
|
568 |
self.ui.tableWidget.setSelectionMode(QAbstractItemView.SingleSelection) |
|
569 |
self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows) |
|
570 |
self.ui.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) |
|
571 |
self.ui.tableWidget.horizontalHeaderItem(0).setSizeHint(QSize(70, 30)) |
|
572 |
self.ui.tableWidget.horizontalHeaderItem(1).setSizeHint(QSize(110, 30)) |
|
573 |
self.ui.tableWidget.horizontalHeaderItem(2).setSizeHint(QSize(200, 30)) |
|
574 |
self.ui.tableWidget.horizontalHeaderItem(3).setSizeHint(QSize(80, 30)) |
|
575 |
self.ui.tableWidget.horizontalHeader().setStretchLastSection(True) |
|
576 |
|
|
577 |
self.ui.tableWidget.resizeColumnsToContents() |
|
578 |
self.ui.tableWidget.resizeRowsToContents() |
|
579 |
|
|
580 |
def add_data(self, nd, velocity, pressure_drop, reynolds, friction): |
|
581 |
row = self.ui.tableWidget.rowCount() |
|
582 |
self.ui.tableWidget.setRowCount(row + 1) |
|
583 |
|
|
584 |
self.ui.tableWidget.setItem(row, 0, set_table_widget_item_properties(nd, |
|
585 |
Qt.AlignHCenter | Qt.AlignVCenter)) |
|
586 |
self.ui.tableWidget.setItem(row, 1, set_table_widget_item_properties(velocity, |
|
587 |
Qt.AlignHCenter | Qt.AlignVCenter)) |
|
588 |
self.ui.tableWidget.setItem(row, 2, set_table_widget_item_properties(pressure_drop, |
|
589 |
Qt.AlignHCenter | Qt.AlignVCenter)) |
|
590 |
self.ui.tableWidget.setItem(row, 3, set_table_widget_item_properties(reynolds, |
|
591 |
Qt.AlignHCenter | Qt.AlignVCenter)) |
|
592 |
self.ui.tableWidget.setItem(row, 4, set_table_widget_item_properties(friction, |
|
593 |
Qt.AlignHCenter | Qt.AlignVCenter)) |
|
594 |
|
|
595 |
self.ui.tableWidget.resizeRowsToContents() |
|
596 |
self.ui.tableWidget.resizeColumnsToContents() |
|
597 |
|
|
598 |
def double_clicked(self, row): |
|
599 |
self.isAccepted = True |
|
600 |
QDialog.accept(self) |
|
601 |
|
|
602 |
def accept(self): |
|
603 |
self.isAccepted = True |
|
604 |
QDialog.accept(self) |
|
605 |
|
|
606 |
def reject(self): |
|
607 |
self.isAccepted = False |
|
608 |
QDialog.reject(self) |
HYTOS/HYTOS/DiameterEstimation_Liquid_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\DiameterEstimation_Liquid.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.13.0 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
|
|
10 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
11 |
|
|
12 |
|
|
13 |
class Ui_Dialog(object): |
|
14 |
def setupUi(self, Dialog): |
|
15 |
Dialog.setObjectName("Dialog") |
|
16 |
Dialog.resize(631, 331) |
|
17 |
font = QtGui.QFont() |
|
18 |
font.setFamily("굴림") |
|
19 |
Dialog.setFont(font) |
|
20 |
icon = QtGui.QIcon() |
|
21 |
icon.addPixmap(QtGui.QPixmap(":/images/HYTOS.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
22 |
Dialog.setWindowIcon(icon) |
|
23 |
self.gridLayout = QtWidgets.QGridLayout(Dialog) |
|
24 |
self.gridLayout.setObjectName("gridLayout") |
|
25 |
self.verticalLayout = QtWidgets.QVBoxLayout() |
|
26 |
self.verticalLayout.setObjectName("verticalLayout") |
|
27 |
self.groupBox = QtWidgets.QGroupBox(Dialog) |
|
28 |
font = QtGui.QFont() |
|
29 |
font.setFamily("굴림") |
|
30 |
font.setBold(True) |
|
31 |
font.setWeight(75) |
|
32 |
self.groupBox.setFont(font) |
|
33 |
self.groupBox.setObjectName("groupBox") |
|
34 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox) |
|
35 |
self.gridLayout_2.setObjectName("gridLayout_2") |
|
36 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
37 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
38 |
self.label_2 = QtWidgets.QLabel(self.groupBox) |
|
39 |
self.label_2.setMinimumSize(QtCore.QSize(90, 0)) |
|
40 |
self.label_2.setMaximumSize(QtCore.QSize(90, 16777215)) |
|
41 |
font = QtGui.QFont() |
|
42 |
font.setBold(False) |
|
43 |
font.setWeight(50) |
|
44 |
self.label_2.setFont(font) |
|
45 |
self.label_2.setObjectName("label_2") |
|
46 |
self.horizontalLayout.addWidget(self.label_2) |
|
47 |
self.lineEdit_Pressure_Drop = QtWidgets.QLineEdit(self.groupBox) |
|
48 |
self.lineEdit_Pressure_Drop.setMinimumSize(QtCore.QSize(100, 0)) |
|
49 |
self.lineEdit_Pressure_Drop.setMaximumSize(QtCore.QSize(100, 16777215)) |
|
50 |
font = QtGui.QFont() |
|
51 |
font.setBold(False) |
|
52 |
font.setWeight(50) |
|
53 |
self.lineEdit_Pressure_Drop.setFont(font) |
|
54 |
self.lineEdit_Pressure_Drop.setAlignment(QtCore.Qt.AlignCenter) |
|
55 |
self.lineEdit_Pressure_Drop.setReadOnly(True) |
|
56 |
self.lineEdit_Pressure_Drop.setObjectName("lineEdit_Pressure_Drop") |
|
57 |
self.horizontalLayout.addWidget(self.lineEdit_Pressure_Drop) |
|
58 |
self.label_Pressure_Drop_Unit = QtWidgets.QLabel(self.groupBox) |
|
59 |
font = QtGui.QFont() |
|
60 |
font.setBold(False) |
|
61 |
font.setWeight(50) |
|
62 |
self.label_Pressure_Drop_Unit.setFont(font) |
|
63 |
self.label_Pressure_Drop_Unit.setObjectName("label_Pressure_Drop_Unit") |
|
64 |
self.horizontalLayout.addWidget(self.label_Pressure_Drop_Unit) |
|
65 |
self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1) |
|
66 |
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() |
|
67 |
self.horizontalLayout_2.setObjectName("horizontalLayout_2") |
|
68 |
self.label = QtWidgets.QLabel(self.groupBox) |
|
69 |
self.label.setMinimumSize(QtCore.QSize(90, 0)) |
|
70 |
self.label.setMaximumSize(QtCore.QSize(90, 16777215)) |
|
71 |
font = QtGui.QFont() |
|
72 |
font.setBold(False) |
|
73 |
font.setWeight(50) |
|
74 |
self.label.setFont(font) |
|
75 |
self.label.setObjectName("label") |
|
76 |
self.horizontalLayout_2.addWidget(self.label) |
|
77 |
self.lineEdit_Velocity = QtWidgets.QLineEdit(self.groupBox) |
|
78 |
self.lineEdit_Velocity.setMinimumSize(QtCore.QSize(100, 0)) |
|
79 |
self.lineEdit_Velocity.setMaximumSize(QtCore.QSize(100, 16777215)) |
|
80 |
font = QtGui.QFont() |
|
81 |
font.setBold(False) |
|
82 |
font.setWeight(50) |
|
83 |
self.lineEdit_Velocity.setFont(font) |
|
84 |
self.lineEdit_Velocity.setAlignment(QtCore.Qt.AlignCenter) |
|
85 |
self.lineEdit_Velocity.setReadOnly(True) |
|
86 |
self.lineEdit_Velocity.setObjectName("lineEdit_Velocity") |
|
87 |
self.horizontalLayout_2.addWidget(self.lineEdit_Velocity) |
|
88 |
self.label_Velocity_Unit = QtWidgets.QLabel(self.groupBox) |
|
89 |
font = QtGui.QFont() |
|
90 |
font.setBold(False) |
|
91 |
font.setWeight(50) |
|
92 |
self.label_Velocity_Unit.setFont(font) |
|
93 |
self.label_Velocity_Unit.setObjectName("label_Velocity_Unit") |
|
94 |
self.horizontalLayout_2.addWidget(self.label_Velocity_Unit) |
|
95 |
self.gridLayout_2.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) |
|
96 |
self.verticalLayout.addWidget(self.groupBox) |
|
97 |
self.groupBox_2 = QtWidgets.QGroupBox(Dialog) |
|
98 |
font = QtGui.QFont() |
|
99 |
font.setFamily("굴림") |
|
100 |
font.setBold(True) |
|
101 |
font.setWeight(75) |
|
102 |
self.groupBox_2.setFont(font) |
|
103 |
self.groupBox_2.setObjectName("groupBox_2") |
|
104 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox_2) |
|
105 |
self.gridLayout_3.setObjectName("gridLayout_3") |
|
106 |
self.tableWidget = QtWidgets.QTableWidget(self.groupBox_2) |
|
107 |
self.tableWidget.setObjectName("tableWidget") |
|
108 |
self.tableWidget.setColumnCount(0) |
|
109 |
self.tableWidget.setRowCount(0) |
|
110 |
self.gridLayout_3.addWidget(self.tableWidget, 0, 0, 1, 1) |
|
111 |
self.verticalLayout.addWidget(self.groupBox_2) |
|
112 |
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) |
|
113 |
self.horizontalLayout_3 = QtWidgets.QHBoxLayout() |
|
114 |
self.horizontalLayout_3.setObjectName("horizontalLayout_3") |
|
115 |
self.label_Note = QtWidgets.QLabel(Dialog) |
|
116 |
font = QtGui.QFont() |
|
117 |
font.setBold(True) |
|
118 |
font.setWeight(75) |
|
119 |
self.label_Note.setFont(font) |
|
120 |
self.label_Note.setObjectName("label_Note") |
|
121 |
self.horizontalLayout_3.addWidget(self.label_Note) |
|
122 |
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) |
|
123 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
124 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
125 |
self.buttonBox.setObjectName("buttonBox") |
|
126 |
self.horizontalLayout_3.addWidget(self.buttonBox) |
|
127 |
self.gridLayout.addLayout(self.horizontalLayout_3, 1, 0, 1, 1) |
|
128 |
|
|
129 |
self.retranslateUi(Dialog) |
|
130 |
self.buttonBox.accepted.connect(Dialog.accept) |
|
131 |
self.buttonBox.rejected.connect(Dialog.reject) |
|
132 |
QtCore.QMetaObject.connectSlotsByName(Dialog) |
|
133 |
Dialog.setTabOrder(self.lineEdit_Velocity, self.lineEdit_Pressure_Drop) |
|
134 |
Dialog.setTabOrder(self.lineEdit_Pressure_Drop, self.tableWidget) |
|
135 |
|
|
136 |
def retranslateUi(self, Dialog): |
|
137 |
_translate = QtCore.QCoreApplication.translate |
|
138 |
Dialog.setWindowTitle(_translate("Dialog", "Pipe Diameter Estimation")) |
|
139 |
self.groupBox.setTitle(_translate("Dialog", "Limitation Criteria")) |
|
140 |
self.label_2.setText(_translate("Dialog", "Pressure Drop")) |
|
141 |
self.label_Pressure_Drop_Unit.setText(_translate("Dialog", "-")) |
|
142 |
self.label.setText(_translate("Dialog", "Velocity")) |
|
143 |
self.label_Velocity_Unit.setText(_translate("Dialog", "-")) |
|
144 |
self.groupBox_2.setTitle(_translate("Dialog", "Select Pipe Diameter")) |
|
145 |
self.label_Note.setText(_translate("Dialog", "※ Note : Red Diameter is not available")) |
|
146 |
import Resource_rc |
HYTOS/HYTOS/DiameterEstimation_Vapor.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file 'ProjectDialog.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.6 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
import sys |
|
9 |
from PyQt5.QtCore import * |
|
10 |
from PyQt5.QtGui import * |
|
11 |
from PyQt5.QtWidgets import * |
|
12 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
13 |
from PyQt5.QtWidgets import * |
|
14 |
import os |
|
15 |
from AppDocData import AppDocData |
|
16 |
import DiameterEstimation_Vapor_UI |
|
17 |
import math |
|
18 |
|
|
19 |
|
|
20 |
def set_table_widget_item_properties(name, alignment, color=None): |
|
21 |
if name is None: |
|
22 |
name = '' |
|
23 |
|
|
24 |
item = QTableWidgetItem(str(name)) |
|
25 |
item.setTextAlignment(alignment) |
|
26 |
if color: |
|
27 |
item.setBackground(color) |
|
28 |
|
|
29 |
return item |
|
30 |
|
|
31 |
|
|
32 |
def is_not_blank(s): |
|
33 |
return bool(s and s.strip()) |
|
34 |
|
|
35 |
|
|
36 |
def is_blank(s): |
|
37 |
return not (s and s.strip()) |
|
38 |
|
|
39 |
|
|
40 |
class QDiameterEstimation_Vapor(QDialog): |
|
41 |
def __init__(self): |
|
42 |
QDialog.__init__(self) |
|
43 |
|
|
44 |
self.ui = DiameterEstimation_Vapor_UI.Ui_Dialog() |
|
45 |
|
|
46 |
self.ui.setupUi(self) |
|
47 |
|
|
48 |
self.ui.lineEdit_Inlet_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Inlet_Pressure)) |
|
49 |
self.ui.lineEdit_Outlet_Pressure.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Outlet_Pressure)) |
|
50 |
|
|
51 |
self.velocity = 0 |
|
52 |
self.pressure_drop = 0 |
|
53 |
self.process_data = {} |
|
54 |
self.isAccepted = False |
|
55 |
self.units = {} |
|
56 |
self.ui.tableWidget.cellDoubleClicked.connect(self.double_clicked) |
|
57 |
|
|
58 |
def show_dialog(self, velocity, pressure_drop, process_data): |
|
59 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
|
60 |
|
|
61 |
self.velocity = '' if velocity == '-' else velocity |
|
62 |
self.pressure_drop = '' if pressure_drop == '-' else pressure_drop |
|
63 |
self.process_data = process_data |
|
64 |
|
|
65 |
self.ui.lineEdit_Inlet_Pressure.textChanged.connect(self.pressure_change_evnet) |
|
66 |
self.ui.lineEdit_Outlet_Pressure.textChanged.connect(self.pressure_change_evnet) |
|
67 |
|
|
68 |
self.ui.pushButton_Apply.clicked.connect(self.load_diameter_estimation) |
|
69 |
|
|
70 |
self.init_units() |
|
71 |
self.init_pipe_diameter_estimation() |
|
72 |
self.initialize() |
|
73 |
|
|
74 |
self.exec_() |
|
75 |
|
|
76 |
return self.isAccepted, self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).text() |
|
77 |
|
|
78 |
def pressure_change_evnet(self, text): |
|
79 |
if self.sender() == self.ui.lineEdit_Inlet_Pressure: |
|
80 |
if is_not_blank(text): |
|
81 |
self.ui.lineEdit_Outlet_Pressure.clear() |
|
82 |
else: |
|
83 |
if is_not_blank(text): |
|
84 |
self.ui.lineEdit_Inlet_Pressure.clear() |
|
85 |
|
|
86 |
def load_diameter_estimation(self): |
|
87 |
|
|
88 |
self.ui.tableWidget.setRowCount(0) |
|
89 |
|
|
90 |
self.calc_pde_v_d() |
|
91 |
|
|
92 |
va = 100000000000 if is_blank(self.velocity) else float(self.velocity) |
|
93 |
dpa = 100000000000 if is_blank(self.pressure_drop) else float(self.pressure_drop) |
|
94 |
|
|
95 |
for row in range(self.ui.tableWidget.rowCount()): |
|
96 |
validation = False |
|
97 |
velocity = float(self.ui.tableWidget.item(row, 1).text()) |
|
98 |
if velocity > va: |
|
99 |
self.ui.tableWidget.item(row, 1).setForeground(QBrush(QColor(255, 0, 0))) |
|
100 |
validation = True |
|
101 |
|
|
102 |
pressure_drop = float(self.ui.tableWidget.item(row, 2).text()) |
|
103 |
if pressure_drop > dpa: |
|
104 |
self.ui.tableWidget.item(row, 2).setForeground(QBrush(QColor(255, 0, 0))) |
|
105 |
validation = True |
|
106 |
|
|
107 |
if validation: |
|
108 |
self.ui.tableWidget.item(row, 0).setForeground(QBrush(QColor(255, 0, 0))) |
|
109 |
|
|
110 |
def calc_pde_v_d(self): |
|
111 |
# 참고사항 : |
|
112 |
# 유닛의 기준 : 유량 (kg/h, m3/h), 밀도 (kg/m3), 지름 (m), 점도 (kg/m/s), 속도 (m/s), 압력 (kg/cm2(a)) |
|
113 |
# mw (g/mol), temperature (kalvin) |
|
114 |
|
|
115 |
Ref_baro = self.get_barometric_pressure() |
|
116 |
|
|
117 |
inlet_p = self.ui.lineEdit_Inlet_Pressure.text() |
|
118 |
outlet_p = self.ui.lineEdit_Outlet_Pressure.text() |
|
119 |
|
|
120 |
if is_blank(inlet_p) and is_not_blank(outlet_p): |
|
121 |
p = float(outlet_p) |
|
122 |
elif is_not_blank(inlet_p) and is_blank(outlet_p): |
|
123 |
p = float(inlet_p) |
|
124 |
|
|
125 |
# pressure unit adjustment |
|
126 |
pressure_unit = self.units['Pressure'] |
|
127 |
if pressure_unit == 'kg/cm2': |
|
128 |
p = p + Ref_baro |
|
129 |
elif pressure_unit == 'psi': |
|
130 |
p = p / 14.7 * 1.033 + Ref_baro |
|
131 |
elif pressure_unit == 'atm': |
|
132 |
p = p * 1.033 + Ref_baro |
|
133 |
elif pressure_unit == 'bar': |
|
134 |
p = p / 1.013 * 1.033 + Ref_baro |
|
135 |
elif pressure_unit == 'mmHg': |
|
136 |
p = p / 760 * 1.033 + Ref_baro |
|
137 |
elif pressure_unit == 'kPa': |
|
138 |
p = p / 101.325 * 1.033 + Ref_baro |
|
139 |
elif pressure_unit == 'MPa': |
|
140 |
p = p / 0.101325 * 1.033 + Ref_baro |
|
141 |
|
|
142 |
# molecular weight |
|
143 |
mw = float(self.process_data['Molecular_Weight']) |
|
144 |
|
|
145 |
temp = float(self.process_data['Temperature']) |
|
146 |
temperature_unit = self.units['Temperature'] |
|
147 |
if temperature_unit == '℃': |
|
148 |
temp = temp + 273.15 |
|
149 |
elif temperature_unit == '℉': |
|
150 |
temp = temp / 1.8 + 273.15 |
|
151 |
|
|
152 |
# 'compressibility |
|
153 |
z = float(self.process_data['Compress_Factor']) |
|
154 |
|
|
155 |
# density calculation |
|
156 |
density = p * mw / 0.08206 / temp / z / 1.033 |
|
157 |
density_unit = self.units['Density'] |
|
158 |
if density_unit == 'kg/m3': |
|
159 |
density = density |
|
160 |
elif density_unit == 'lb/ft3': |
|
161 |
density = density * 0.062428 |
|
162 |
|
|
163 |
self.ui.lineEdit_Density.setText(str(round(density, 5))) |
|
164 |
|
|
165 |
# volume flowrate |
|
166 |
# mass gain |
|
167 |
flowrate_mass = float(self.process_data['Flowrate_Mass']) |
|
168 |
flowrate_mass_unit = self.units['Flowrate_Mass'] |
|
169 |
if flowrate_mass_unit == 'kg/h': |
|
170 |
mass = flowrate_mass |
|
171 |
elif flowrate_mass_unit == 'g/min': |
|
172 |
mass = flowrate_mass * 60 / 1000 |
|
173 |
elif flowrate_mass_unit == 'lb/h': |
|
174 |
mass = flowrate_mass * 0.453592 |
|
175 |
elif flowrate_mass_unit == 't/h': |
|
176 |
mass = flowrate_mass * 1000 |
|
177 |
|
|
178 |
# volume calculation (m3/h) |
|
179 |
volume = mass / density |
|
180 |
|
|
181 |
# normal volume calculation |
|
182 |
flowrate_volume_unit = self.units['Flowrate_Volume'] |
|
183 |
if flowrate_volume_unit == 'm3/h': |
|
184 |
nvolume = p * volume / temp * 273.15 / 1.033 |
|
185 |
elif flowrate_volume_unit == 'l/min': |
|
186 |
nvolume = p * volume / temp * 273.15 / 1.033 * 1000 / 3600 |
|
187 |
elif flowrate_volume_unit == 'ft3/h': |
|
188 |
nvolume = p * volume / temp * 273.15 / 1.033 * 35.3147 |
|
189 |
elif flowrate_volume_unit == 'USgpm': |
|
190 |
nvolume = p * volume / temp * 273.15 / 1.033 * 4.40287 |
|
191 |
elif flowrate_volume_unit == 'BPSD': |
|
192 |
nvolume = p * volume / temp * 273.15 / 1.033 * 4.40287 |
|
193 |
|
|
194 |
self.ui.lineEdit_Flowrate_Volume.setText(str(round(nvolume, 2))) |
|
195 |
|
|
196 |
# 속도/압력강하 있을때 뭘 갖고 할거냐 !!! 결정내리는 부분 |
|
197 |
# (압력강하 아직 미완성) |
|
198 |
if is_not_blank(self.velocity) and is_blank(self.pressure_drop): |
|
199 |
self.calc_pde_v_v(volume, density, mass, p, mw, temp, z) |
|
200 |
elif is_blank(self.velocity) and is_not_blank(self.pressure_drop): |
|
201 |
self.calc_pde_v_p(mass, volume, mw, temp, z) |
|
202 |
elif is_not_blank(self.velocity) and is_not_blank(self.pressure_drop): |
|
203 |
std_nd = self.calc_pde_v_v(volume, density, mass, p, mw, temp, z) |
|
204 |
self.calc_pde_v_p(mass, volume, mw, temp, z, std_nd) |
|
205 |
|
|
206 |
def calc_pde_v_p(self, mass, volume, mw, temp, z, std_nd=None): |
|
207 |
try: |
|
208 |
length_unit = self.units['Length'] |
|
209 |
if length_unit == 'm': |
|
210 |
ccdp = float(self.pressure_drop) |
|
211 |
elif length_unit == 'in': |
|
212 |
ccdp = float(self.pressure_drop) / 0.0254 |
|
213 |
elif length_unit == 'ft': |
|
214 |
ccdp = float(self.pressure_drop) / 0.3048 |
|
215 |
elif length_unit == 'yd': |
|
216 |
ccdp = float(self.pressure_drop) / 0.9144 |
|
217 |
elif length_unit == 'mile': |
|
218 |
ccdp = float(self.pressure_drop) / 1609.34 |
|
219 |
elif length_unit == 'mm': |
|
220 |
ccdp = float(self.pressure_drop) / 0.001 |
|
221 |
|
|
222 |
pressure_unit = self.units['Pressure'] |
|
223 |
if pressure_unit == 'kg/cm2': |
|
224 |
ccdp = ccdp |
|
225 |
elif pressure_unit == 'psi': |
|
226 |
ccdp = ccdp * 1.033 / 14.7 |
|
227 |
elif pressure_unit == 'bar': |
|
228 |
ccdp = ccdp * 1.033 / 1.013 |
|
229 |
elif pressure_unit == 'mmHg': |
|
230 |
ccdp = ccdp * 1.033 / 760 |
|
231 |
elif pressure_unit == 'kPa': |
|
232 |
ccdp = ccdp * 1.033 / 101.325 |
|
233 |
elif pressure_unit == 'MPa': |
|
234 |
ccdp = ccdp * 1.033 / 0.101325 |
|
235 |
|
|
236 |
# 조도 구함 (m) |
|
237 |
roughness = float(self.process_data['Roughness']) |
|
238 |
roughness_unit = self.units['Roughness'] |
|
239 |
if roughness_unit == 'm': |
|
240 |
rough = roughness |
|
241 |
elif roughness_unit == 'ft': |
|
242 |
rough = roughness * 0.3048 |
|
243 |
elif roughness_unit == 'in': |
|
244 |
rough = roughness * 0.0254 |
|
245 |
elif roughness_unit == 'mm': |
|
246 |
rough = roughness * 0.001 |
|
247 |
|
|
248 |
# 길이 구함 (m) |
|
249 |
length_unit = self.units['Length'] |
|
250 |
if length_unit == 'm': |
|
251 |
l = 100 |
|
252 |
elif length_unit == 'in': |
|
253 |
l = 100 * 39.3701 |
|
254 |
elif length_unit == 'ft': |
|
255 |
l = 100 * 3.28084 |
|
256 |
elif length_unit == 'yd': |
|
257 |
l = 100 * 1.09361 |
|
258 |
elif length_unit == 'mile': |
|
259 |
l = 100 * 0.000621371 |
|
260 |
elif length_unit == 'mm': |
|
261 |
l = 100 * 1000 |
|
262 |
|
|
263 |
# ********** 2. viscosity 구하기 *********** |
|
264 |
viscosity = float(self.process_data['Viscosity']) |
|
265 |
viscosity_unit = self.units['Viscosity'] |
|
266 |
if viscosity_unit == 'kg/m.sec': |
|
267 |
viscosity = viscosity |
|
268 |
elif viscosity_unit == 'cP': |
|
269 |
viscosity = viscosity * 0.001 |
|
270 |
elif viscosity_unit == 'kg/m.h': |
|
271 |
viscosity = viscosity / 3600 |
|
272 |
elif viscosity_unit == 'lb/ft.s': |
|
273 |
viscosity = viscosity * 1.48816 |
|
274 |
|
|
275 |
Ref_baro = self.get_barometric_pressure() |
|
276 |
|
|
277 |
# P결정 |
|
278 |
inlet_p = self.ui.lineEdit_Inlet_Pressure.text() |
|
279 |
outlet_p = self.ui.lineEdit_Outlet_Pressure.text() |
|
280 |
|
|
281 |
if is_blank(inlet_p) and is_not_blank(outlet_p): |
|
282 |
p2 = float(outlet_p) |
|
283 |
p1 = p2 + ccdp |
|
284 |
p1 = p1 + Ref_baro |
|
285 |
p2 = p2 + Ref_baro |
|
286 |
density = p2 * mw / 0.08206 / temp / z / 1.033 |
|
287 |
elif is_not_blank(inlet_p) and is_blank(outlet_p): |
|
288 |
p1 = float(inlet_p) |
|
289 |
p2 = p1 - ccdp |
|
290 |
p1 = p1 + Ref_baro |
|
291 |
p2 = p2 + Ref_baro |
|
292 |
density = p1 * mw / 0.08206 / temp / z / 1.033 |
|
293 |
|
|
294 |
dia = self.Vap_Dia(rough, viscosity, mass, density, mw, temp, z, p1, p2) |
|
295 |
|
|
296 |
if std_nd: |
|
297 |
if std_nd < dia: |
|
298 |
std_nd = dia - 0.001 |
|
299 |
else: |
|
300 |
return |
|
301 |
else: |
|
302 |
std_nd = dia - 0.001 |
|
303 |
|
|
304 |
nd_unit = self.units['Pipe_Diameter'] |
|
305 |
row_id = self.get_row_id(std_nd, nd_unit) |
|
306 |
|
|
307 |
if std_nd > 36: |
|
308 |
selected_nd = math.ceil(std_nd) |
|
309 |
else: |
|
310 |
selected_nd = self.get_selected_nd(row_id + 1, nd_unit) |
|
311 |
|
|
312 |
nd = [] |
|
313 |
ind = [] |
|
314 |
cvelocity = [] |
|
315 |
creynolds = [] |
|
316 |
ca = [] |
|
317 |
cf = [] |
|
318 |
cdp = [] |
|
319 |
|
|
320 |
if std_nd > 36: |
|
321 |
nd.append(selected_nd - 4) |
|
322 |
nd.append(selected_nd - 2) |
|
323 |
nd.append(selected_nd) |
|
324 |
else: |
|
325 |
nd.append(self.get_selected_nd(row_id - 1, nd_unit)) |
|
326 |
nd.append(self.get_selected_nd(row_id, nd_unit)) |
|
327 |
nd.append(selected_nd) |
|
328 |
|
|
329 |
if std_nd > 34: |
|
330 |
nd.append(selected_nd + 2) |
|
331 |
else: |
|
332 |
nd.append(self.get_selected_nd(row_id + 2, nd_unit)) |
|
333 |
|
|
334 |
if std_nd > 30: |
|
335 |
nd.append(selected_nd + 4) |
|
336 |
else: |
|
337 |
nd.append(self.get_selected_nd(row_id + 3, nd_unit)) |
|
338 |
|
|
339 |
inlet_p = self.ui.lineEdit_Inlet_Pressure.text() |
|
340 |
outlet_p = self.ui.lineEdit_Outlet_Pressure.text() |
|
341 |
|
|
342 |
for i in range(5): |
|
343 |
if nd_unit == 'in': |
|
344 |
ind.append(nd[i] * 0.0254) |
|
345 |
elif nd_unit == 'mm': |
|
346 |
ind.append(nd[i] / 1000) |
|
347 |
|
|
348 |
cvelocity.append(4 * volume / 3.1415 / ((nd[i] * 0.0254) ** 2) / 3600) # ND 마다 속도 구함 |
|
349 |
creynolds.append((nd[i] * 0.0254) * cvelocity[i] * density / viscosity) # ND 마다 레이놀즈 넘버 구함 |
|
350 |
# '마찰계수 산출 |
|
351 |
ca.append(math.log(rough / (nd[i] * 0.0254) / 3.7 + (6.7 / creynolds[i]) ** 0.9) / math.log(10)) |
|
352 |
cf.append( |
|
353 |
(-2 * (math.log(rough / 3.7 / (nd[i] * 0.0254) - 5.02 / creynolds[i] * ca[i]) / math.log(10))) ** ( |
|
354 |
-2)) |
|
355 |
# g 구함 |
|
356 |
g = mass / 3600 / (3.1415 * ind[i] ** 2 / 4) |
|
357 |
# 100m 당 압력강하 산출 (kg/cm2) |
|
358 |
if is_not_blank(inlet_p) and is_blank(outlet_p): |
|
359 |
cdp.append(p1 - self.Vap_Suction_1(p1, g, mw, temp, cf[i], z, ind[i], l)) |
|
360 |
elif is_blank(inlet_p) and is_not_blank(outlet_p): |
|
361 |
cdp.append(self.Vap_Discharge_1(p2, g, mw, temp, cf[i], z, ind[i], l) - p2) |
|
362 |
|
|
363 |
# unit case에 따라 창에 입력. |
|
364 |
pipe_diameter_unit = self.units['Pipe_Diameter'] |
|
365 |
if pipe_diameter_unit == 'mm': |
|
366 |
for i in range(5): |
|
367 |
nd[i] = nd[i] * 25 |
|
368 |
|
|
369 |
velocity_unit = self.units['Velocity'] |
|
370 |
if velocity_unit == 'm/s': |
|
371 |
for i in range(5): |
|
372 |
cvelocity[i] = round(cvelocity[i], 5) |
|
373 |
elif velocity_unit == 'ft/s': |
|
374 |
for i in range(5): |
|
375 |
cvelocity[i] = round(cvelocity[i] * 3.28084, 5) |
|
376 |
|
|
377 |
# reynolds |
|
378 |
for i in range(5): |
|
379 |
creynolds[i] = round(creynolds[i], 0) |
|
380 |
|
|
381 |
# friction factor |
|
382 |
for i in range(5): |
|
383 |
cf[i] = round(cf[i], 5) |
|
384 |
|
|
385 |
# pressure drop |
|
386 |
pressure_unit = self.units['Pressure'] |
|
387 |
if pressure_unit == 'kg/cm2': |
|
388 |
for i in range(5): |
|
389 |
cdp[i] = cdp[i] |
|
390 |
elif pressure_unit == 'psi': |
|
391 |
for i in range(5): |
|
392 |
cdp[i] = cdp[i] / 1.033 * 14.7 |
|
393 |
elif pressure_unit == 'bar': |
|
394 |
for i in range(5): |
|
395 |
cdp[i] = cdp[i] / 1.033 * 1.013 |
|
396 |
elif pressure_unit == 'mmHg': |
|
397 |
for i in range(5): |
|
398 |
cdp[i] = cdp[i] / 1.033 * 760 |
|
399 |
elif pressure_unit == 'kPa': |
|
400 |
for i in range(5): |
|
401 |
cdp[i] = cdp[i] / 1.033 * 101.325 |
|
402 |
elif pressure_unit == 'MPa': |
|
403 |
for i in range(5): |
|
404 |
cdp[i] = cdp[i] / 1.033 * 0.101325 |
|
405 |
|
|
406 |
length_unit = self.units['Length'] |
|
407 |
if length_unit == 'm': |
|
408 |
for i in range(5): |
|
409 |
cdp[i] = round(cdp[i], 5) |
|
410 |
elif length_unit == 'in': |
|
411 |
for i in range(5): |
|
412 |
cdp[i] = round(cdp[i] / 39.3701, 5) |
|
413 |
elif length_unit == 'ft': |
|
414 |
for i in range(5): |
|
415 |
cdp[i] = round(cdp[i] / 3.28084, 5) |
|
416 |
elif length_unit == 'yd': |
|
417 |
for i in range(5): |
|
418 |
cdp[i] = round(cdp[i] / 1.09361, 5) |
|
419 |
elif length_unit == 'mile': |
|
420 |
for i in range(5): |
|
421 |
cdp[i] = round(cdp[i] / 0.000621371, 5) |
|
422 |
elif length_unit == 'mm': |
|
423 |
for i in range(5): |
|
424 |
cdp[i] = round(cdp[i] / 1000, 5) |
|
425 |
|
|
426 |
self.ui.tableWidget.setRowCount(0) |
|
427 |
|
|
428 |
for i in range(5): |
|
429 |
self.add_data(nd[i], cvelocity[i], cdp[i], creynolds[i], cf[i]) |
|
430 |
|
|
431 |
except Exception as ex: |
|
432 |
from App import App |
|
433 |
from AppDocData import MessageType |
|
434 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
435 |
sys.exc_info()[-1].tb_lineno) |
|
436 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
437 |
|
|
438 |
def calc_pde_v_v(self, volume, density, mass, p, mw, temp, z): |
|
439 |
try: |
|
440 |
# line sizing of vapor with only velocity |
|
441 |
|
|
442 |
# ********** 2. viscosity 구하기 *********** |
|
443 |
viscosity = float(self.process_data['Viscosity']) |
|
444 |
viscosity_unit = self.units['Viscosity'] |
|
445 |
if viscosity_unit == 'kg/m.sec': |
|
446 |
viscosity = viscosity |
|
447 |
elif viscosity_unit == 'cP': |
|
448 |
viscosity = viscosity * 0.001 |
|
449 |
elif viscosity_unit == 'kg/m.h': |
|
450 |
viscosity = viscosity / 3600 |
|
451 |
elif viscosity_unit == 'lb/ft.s': |
|
452 |
viscosity = viscosity * 1.48816 |
|
453 |
|
|
454 |
# ********** 3. ND, 속도, 압력강하 5개 구함 ********** |
|
455 |
# dia = (4 * volume / Val(frm_vapor.txt_criteria_vel) / 3.1415) ^ 0.5 |
|
456 |
|
|
457 |
# criteria cvelocity를 m/s로 변환 |
|
458 |
velocity_unit = self.units['Velocity'] |
|
459 |
if velocity_unit == 'm/s': |
|
460 |
cvel = float(self.velocity) |
|
461 |
elif velocity_unit == 'ft/s': |
|
462 |
cvel = float(self.velocity) * 3.28084 |
|
463 |
|
|
464 |
# 기준 Dia 구함 (in) |
|
465 |
std_nd = ((4 * volume / cvel / 3.1415 / 3600) ** 0.5) / 0.0254 |
|
466 |
|
|
467 |
# 조도 구함 (m) |
|
468 |
roughness = float(self.process_data['Roughness']) |
|
469 |
roughness_unit = self.units['Roughness'] |
|
470 |
if roughness_unit == 'm': |
|
471 |
rough = roughness |
|
472 |
elif roughness_unit == 'ft': |
|
473 |
rough = roughness * 0.3048 |
|
474 |
elif roughness_unit == 'in': |
|
475 |
rough = roughness * 0.0254 |
|
476 |
elif roughness_unit == 'mm': |
|
477 |
rough = roughness * 0.001 |
|
478 |
|
|
479 |
# 길이 구함 (m) |
|
480 |
length_unit = self.units['Length'] |
|
481 |
if length_unit == 'm': |
|
482 |
l = 100 |
|
483 |
elif length_unit == 'in': |
|
484 |
l = 100 * 39.3701 |
|
485 |
elif length_unit == 'ft': |
|
486 |
l = 100 * 3.28084 |
|
487 |
elif length_unit == 'yd': |
|
488 |
l = 100 * 1.09361 |
|
489 |
elif length_unit == 'mile': |
|
490 |
l = 100 * 0.000621371 |
|
491 |
elif length_unit == 'mm': |
|
492 |
l = 100 * 1000 |
|
493 |
|
|
494 |
nd_unit = self.units['Pipe_Diameter'] |
|
495 |
row_id = self.get_row_id(std_nd, nd_unit) |
|
496 |
|
|
497 |
if std_nd > 36: |
|
498 |
selected_nd = math.ceil(std_nd) |
|
499 |
else: |
|
500 |
selected_nd = self.get_selected_nd(row_id + 1, nd_unit) |
|
501 |
|
|
502 |
nd = [] |
|
503 |
ind = [] |
|
504 |
cvelocity = [] |
|
505 |
creynolds = [] |
|
506 |
ca = [] |
|
507 |
cf = [] |
|
508 |
cdp = [] |
|
509 |
|
|
510 |
if std_nd > 36: |
|
511 |
nd.append(selected_nd - 2) |
|
512 |
nd.append(selected_nd) |
|
513 |
else: |
|
514 |
nd.append(self.get_selected_nd(row_id, nd_unit)) |
|
515 |
nd.append(selected_nd) |
|
516 |
|
|
517 |
if std_nd > 34: |
|
518 |
nd.append(selected_nd + 2) |
|
519 |
else: |
|
520 |
nd.append(self.get_selected_nd(row_id + 2, nd_unit)) |
|
521 |
|
|
522 |
if std_nd > 30: |
|
523 |
nd.append(selected_nd + 4) |
|
524 |
nd.append(selected_nd + 6) |
|
525 |
else: |
|
526 |
nd.append(self.get_selected_nd(row_id + 3, nd_unit)) |
|
527 |
nd.append(self.get_selected_nd(row_id + 4, nd_unit)) |
내보내기 Unified diff