개정판 cfc1d570
issue #1048 : 화면/메뉴/툴바 개발
Change-Id: I013470a39aa4d9acc9192691a31120c3093ef899
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
60 | 60 |
class MessageType(Enum): |
61 | 61 |
Normal = 1 |
62 | 62 |
Error = 2 |
63 |
Information = 3 |
|
63 | 64 |
|
64 | 65 |
class AppDocData(SingletonInstane): |
65 | 66 |
|
... | ... | |
143 | 144 |
templateDbPath = os.path.join(path, 'Template.db') |
144 | 145 |
return templateDbPath |
145 | 146 |
|
147 |
def getTemplateSymbolCategoryList(self): |
|
148 |
symbolCategoryList = [] |
|
149 |
|
|
150 |
conn = sqlite3.connect(self.getTemplateDbPath()) |
|
151 |
with conn: |
|
152 |
cursor = conn.cursor() |
|
153 |
sql = 'SELECT distinct category FROM SymbolType ORDER BY Category' |
|
154 |
try: |
|
155 |
cursor.execute(sql) |
|
156 |
rows = cursor.fetchall() |
|
157 |
for row in rows: |
|
158 |
symbolCategoryList.append((row[0])) |
|
159 |
except Exception as ex: |
|
160 |
from App import App |
|
161 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
162 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
163 |
|
|
164 |
return symbolCategoryList |
|
165 |
|
|
166 |
def getTemplateSymbolTypeList(self, category): |
|
167 |
symbolCategoryList = [] |
|
168 |
|
|
169 |
conn = sqlite3.connect(self.getTemplateDbPath()) |
|
170 |
with conn: |
|
171 |
cursor = conn.cursor() |
|
172 |
sql = 'SELECT UID, Type FROM SymbolType Where Category = ? ORDER BY Type' |
|
173 |
|
|
174 |
try: |
|
175 |
param = (category,) |
|
176 |
cursor.execute(sql, param) |
|
177 |
rows = cursor.fetchall() |
|
178 |
for row in rows: |
|
179 |
symbolCategoryList.append((row[0], row[1])) |
|
180 |
except Exception as ex: |
|
181 |
from App import App |
|
182 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
183 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
184 |
|
|
185 |
return symbolCategoryList |
|
186 |
|
|
187 |
|
|
188 |
def updateTemplateSymbol(self, uid, originalPoint, connectionPoint): |
|
189 |
isUpdated = False |
|
190 |
|
|
191 |
try: |
|
192 |
conn = sqlite3.connect(self.getTemplateDbPath()) |
|
193 |
conn.execute('PRAGMA foreign_keys = ON') |
|
194 |
# Get a cursor object |
|
195 |
cursor = conn.cursor() |
|
196 |
|
|
197 |
sql = """Update Symbols |
|
198 |
set OriginalPoint = ? |
|
199 |
, ConnectionPoint = ? |
|
200 |
where UID = ?""" |
|
201 |
|
|
202 |
param = (originalPoint, connectionPoint, uid) |
|
203 |
cursor.execute(sql, param) |
|
204 |
conn.commit() |
|
205 |
isUpdated = True |
|
206 |
# Catch the exception |
|
207 |
except Exception as ex: |
|
208 |
from App import App |
|
209 |
# Roll back any change if something goes wrong |
|
210 |
conn.rollback() |
|
211 |
|
|
212 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
213 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
214 |
finally: |
|
215 |
# Close the db connection |
|
216 |
conn.close() |
|
217 |
return isUpdated |
|
218 |
|
|
219 |
|
|
220 |
def getTemplateSymbolNameList(self, typeUID): |
|
221 |
symbolCategoryList = [] |
|
222 |
|
|
223 |
conn = sqlite3.connect(self.getTemplateDbPath()) |
|
224 |
with conn: |
|
225 |
cursor = conn.cursor() |
|
226 |
sql = 'SELECT UID, Name, OriginalPoint, ConnectionPoint FROM Symbols Where SymbolType_UID = ? ORDER BY Name' |
|
227 |
|
|
228 |
try: |
|
229 |
param = (typeUID,) |
|
230 |
cursor.execute(sql, param) |
|
231 |
rows = cursor.fetchall() |
|
232 |
for row in rows: |
|
233 |
symbolCategoryList.append((row[0], row[1], row[2], row[3])) |
|
234 |
except Exception as ex: |
|
235 |
from App import App |
|
236 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
237 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
238 |
|
|
239 |
return symbolCategoryList |
|
240 |
|
|
241 |
|
|
146 | 242 |
def getAppDbPath(self): |
147 | 243 |
""" |
148 | 244 |
@brief Get application DB file path in ProgramData |
HYTOS/HYTOS/Calculation.py | ||
---|---|---|
6 | 6 |
import os |
7 | 7 |
from AppDocData import * |
8 | 8 |
import math |
9 |
from App import App |
|
10 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
|
11 |
from SymbolSvgItem import SymbolSvgItem |
|
9 | 12 |
|
10 | 13 |
class Conversion: |
11 |
def __init__(self, hmb, decimal): |
|
12 |
self.initUnits() |
|
13 |
self._hmb = hmb |
|
14 |
def __init__(self, decimal): |
|
14 | 15 |
self._decimal = decimal |
15 |
|
|
16 |
curUnitsList = AppDocData.instance().getConfigs('Units') |
|
17 |
for curUnit in curUnitsList: |
|
18 |
if curUnit.key == 'Flowrate_Mass': |
|
19 |
if curUnit.value != self.pre_flowrate_mass_unit: |
|
20 |
self.convert_flowrate_mass(curUnit.value) |
|
21 |
elif curUnit.key == 'Flowrate_Volume': |
|
22 |
if curUnit.value != self.pre_flowrate_volume_unit: |
|
23 |
self.convert_flowrate_volume(curUnit.value) |
|
24 |
elif curUnit.key == 'Density': |
|
25 |
if curUnit.value != self.pre_density_unit: |
|
26 |
self.convert_density(curUnit.value) |
|
27 |
elif curUnit.key == 'Viscosity': |
|
28 |
if curUnit.value != self.pre_viscosity_unit: |
|
29 |
self.convert_viscosity(curUnit.value) |
|
30 |
elif curUnit.key == 'Temperature': |
|
31 |
if curUnit.value != self.pre_temperature_unit: |
|
32 |
self.convert_temperature(curUnit.value) |
|
33 |
elif curUnit.key == 'Pressure': |
|
34 |
if curUnit.value != self.pre_pressure_unit: |
|
35 |
self.convert_pressure(curUnit.value) |
|
36 |
elif curUnit.key == 'Velocity': |
|
37 |
if curUnit.value != self.pre_velocity_unit: |
|
38 |
self.convert_velocity(curUnit.value) |
|
39 |
elif curUnit.key == 'Velocity': |
|
40 |
if curUnit.value != self.pre_velocity_unit: |
|
41 |
self.convert_velocity(curUnit.value) |
|
42 |
elif curUnit.key == 'Length': |
|
43 |
if curUnit.value != self.pre_length_unit: |
|
44 |
self.convert_length(curUnit.value) |
|
45 |
elif curUnit.key == 'Pipe_Diameter': |
|
46 |
if curUnit.value != self.pre_pipe_diameter_unit: |
|
47 |
self.convert_pipe_diameter(curUnit.value) |
|
48 |
elif curUnit.key == 'Roughness': |
|
49 |
if curUnit.value != self.pre_roughness_unit: |
|
50 |
self.convert_roughness(curUnit.value) |
|
51 |
elif curUnit.key == 'Power': |
|
52 |
if curUnit.value != self.pre_power_unit: |
|
53 |
self.convert_power(curUnit.value) |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
def convert_flowrate_mass(self, curUnit): |
|
60 |
convert_factor = 1 |
|
61 |
|
|
62 |
if self.pre_flowrate_mass_unit == 'kg/h': |
|
63 |
if curUnit == 'g/min': |
|
64 |
convert_factor = 16.6667 |
|
65 |
elif curUnit == 'lb/h': |
|
66 |
convert_factor = 2.2046 |
|
67 |
elif curUnit == 't/h': |
|
68 |
convert_factor = 0.001 |
|
69 |
elif self.pre_flowrate_mass_unit == 'g/min': |
|
70 |
if curUnit == 'kg/h': |
|
71 |
convert_factor = 1 / 16.6667 |
|
72 |
elif curUnit == 'lb/h': |
|
73 |
convert_factor = 0.132277 |
|
74 |
elif curUnit == 't/h': |
|
75 |
convert_factor = 0.00006 |
|
76 |
elif self.pre_flowrate_mass_unit == 'lb/h': |
|
77 |
if curUnit == 'kg/h': |
|
78 |
convert_factor = 1 / 2.2046 |
|
79 |
elif curUnit == 'g/min': |
|
80 |
convert_factor = 1 / 0.132277 |
|
81 |
elif curUnit == 't/h': |
|
82 |
convert_factor = 0.0004536 |
|
83 |
elif self.pre_flowrate_mass_unit == 't/h': |
|
84 |
if curUnit == 'kg/h': |
|
85 |
convert_factor = 1 / 0.001 |
|
86 |
elif curUnit == 'g/min': |
|
87 |
convert_factor = 1 / 0.00006 |
|
88 |
elif curUnit == 'lb/h': |
|
89 |
convert_factor = 1 / 0.0004536 |
|
90 |
|
|
91 |
if self._hmb.flowrate_mass: |
|
92 |
self._hmb.flowrate_mass = round(self._hmb.flowrate_mass * convert_factor, self._decimal) |
|
93 |
|
|
94 |
|
|
95 |
def convert_flowrate_volume(self, curUnit): |
|
96 |
convert_factor = 1 |
|
97 |
|
|
98 |
if self.pre_flowrate_volume_unit == 'm3/h': |
|
99 |
if curUnit == 'l/min': |
|
100 |
convert_factor = 16.6667 |
|
101 |
elif curUnit == 'ft3/h': |
|
102 |
convert_factor = 35.31466 |
|
103 |
elif curUnit == 'USgpm': |
|
104 |
convert_factor = 4.402867 |
|
105 |
elif curUnit == 'BPSD': |
|
106 |
convert_factor = 150.955464 |
|
107 |
elif self.pre_flowrate_volume_unit == 'l/min': |
|
108 |
if curUnit == 'm3/h': |
|
109 |
convert_factor = 1 / 16.6667 |
|
110 |
elif curUnit == 'ft3/h': |
|
111 |
convert_factor = 2.1188796 |
|
112 |
elif curUnit == 'USgpm': |
|
113 |
convert_factor = 0.264172 |
|
114 |
elif curUnit == 'BPSD': |
|
115 |
convert_factor = 9.05732784 |
|
116 |
elif self.pre_flowrate_volume_unit == 'ft3/h': |
|
117 |
if curUnit == 'm3/h': |
|
118 |
convert_factor = 1 / 35.31466 |
|
119 |
elif curUnit == 'l/min': |
|
120 |
convert_factor = 1 / 2.1188796 |
|
121 |
elif curUnit == 'USgpm': |
|
122 |
convert_factor = 0.124675333 |
|
123 |
elif curUnit == 'BPSD': |
|
124 |
convert_factor = 9.05732784 |
|
125 |
elif self.pre_flowrate_volume_unit == 'USgpm': |
|
126 |
if curUnit == 'm3/h': |
|
127 |
convert_factor = 1 / 4.402867 |
|
128 |
elif curUnit == 'l/min': |
|
129 |
convert_factor = 1 / 0.264172 |
|
130 |
elif curUnit == 'ft3/h': |
|
131 |
convert_factor = 1 / 0.124675333 |
|
132 |
elif curUnit == 'BPSD': |
|
133 |
convert_factor = 34.2857088 |
|
134 |
elif self.pre_flowrate_volume_unit == 'BPSD': |
|
135 |
if curUnit == 'm3/h': |
|
136 |
convert_factor = 1 / 150.955464 |
|
137 |
elif curUnit == 'l/min': |
|
138 |
convert_factor = 1 / 9.05732784 |
|
139 |
elif curUnit == 'ft3/h': |
|
140 |
convert_factor = 1 / 4.2745824 |
|
141 |
elif curUnit == 'USgpm': |
|
142 |
convert_factor = 1 / 34.2857088 |
|
143 |
|
|
144 |
if self._hmb.flowrate_volume: |
|
145 |
self._hmb.flowrate_volume = round(self._hmb.flowrate_volume * convert_factor, self._decimal) |
|
146 |
|
|
147 |
def convert_density(self, curUnit): |
|
148 |
convert_factor = 1 |
|
149 |
|
|
150 |
if self.pre_density_unit == 'kg/m3': |
|
151 |
if curUnit == 'lb/ft3': |
|
152 |
convert_factor = 0.06242797 |
|
153 |
elif self.pre_density_unit == 'lb/ft3': |
|
154 |
if curUnit == 'kg/m3': |
|
155 |
convert_factor =1 / 0.06242797 |
|
16 |
|
|
17 |
self.pre_units = {} |
|
18 |
self.cur_units = {} |
|
19 |
|
|
20 |
self.getCurrentUnits() |
|
21 |
self.getPreviousUnits() |
|
22 |
|
|
23 |
self.convert_HMB() |
|
24 |
self.convert_Nozzle() |
|
25 |
|
|
26 |
def convert_HMB(self): |
|
27 |
from Drawing import Drawing |
|
28 |
from Calculation import Conversion |
|
29 |
|
|
30 |
try: |
|
31 |
app_doc_data = AppDocData.instance() |
|
32 |
drawing = app_doc_data.activeDrawing |
|
33 |
|
|
34 |
hmbs = drawing.hmbTable._hmbs |
|
35 |
if hmbs is not None: |
|
36 |
for hmb in hmbs: |
|
37 |
if hmb.flowrate_mass: |
|
38 |
hmb.flowrate_mass = self.convert_flowrate_mass(hmb.flowrate_mass) |
|
39 |
if hmb.flowrate_volume: |
|
40 |
hmb.flowrate_volume = self.convert_flowrate_volume(hmb.flowrate_volume) |
|
41 |
if hmb.density: |
|
42 |
hmb.density = self.convert_density(hmb.density) |
|
43 |
if hmb.viscosity: |
|
44 |
hmb.viscosity = self.convert_viscosity(hmb.viscosity) |
|
45 |
if hmb.temperature: |
|
46 |
hmb.temperature = self.convert_temperature(hmb.temperature) |
|
47 |
if hmb.nominal_pipe_size: |
|
48 |
hmb.nominal_pipe_size = self.convert_pipe_diameter(hmb.nominal_pipe_size) |
|
49 |
if hmb.inside_pipe_size: |
|
50 |
hmb.inside_pipe_size = self.convert_pipe_diameter(hmb.inside_pipe_size) |
|
51 |
if hmb.straight_length: |
|
52 |
hmb.straight_length = self.convert_length(hmb.straight_length) |
|
53 |
if hmb.straight_length: |
|
54 |
hmb.straight_length = self.convert_length(hmb.straight_length) |
|
55 |
if hmb.equivalent_length_input: |
|
56 |
hmb.equivalent_length_input = self.convert_length(hmb.equivalent_length_input) |
|
57 |
if hmb.fitting_length: |
|
58 |
hmb.fitting_length = self.convert_length(hmb.fitting_length) |
|
59 |
if hmb.equivalent_length_cal: |
|
60 |
hmb.equivalent_length_cal = self.convert_length(hmb.equivalent_length_cal) |
|
61 |
if hmb.roughness: |
|
62 |
hmb.roughness = self.convert_roughness(hmb.roughness) |
|
63 |
if hmb.limitation_velocity: |
|
64 |
hmb.limitation_velocity = self.convert_velocity(hmb.limitation_velocity) |
|
65 |
if hmb.limitation_pressure_drop: |
|
66 |
hmb.limitation_pressure_drop = self.convert_pressure(hmb.limitation_pressure_drop) |
|
67 |
if hmb.velocity: |
|
68 |
hmb.velocity = self.convert_velocity(hmb.velocity) |
|
69 |
if hmb.pressure_drop: |
|
70 |
hmb.pressure_drop = self.convert_pressure(hmb.pressure_drop) |
|
71 |
if hmb.pressure_drop_friction: |
|
72 |
hmb.pressure_drop_friction = self.convert_pressure(hmb.pressure_drop_friction) |
|
73 |
if hmb.pressure_drop_static: |
|
74 |
hmb.pressure_drop_static = self.convert_pressure(hmb.pressure_drop_static) |
|
75 |
if hmb.pressure_pipe_end_point: |
|
76 |
hmb.pressure_pipe_end_point = self.convert_pressure(hmb.pressure_pipe_end_point) |
|
77 |
if hmb.power: |
|
78 |
hmb.power = self.convert_power(hmb.power) |
|
79 |
|
|
80 |
except Exception as ex: |
|
81 |
from App import App |
|
82 |
from AppDocData import MessageType |
|
83 |
|
|
84 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
85 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
86 |
|
|
87 |
|
|
88 |
def convert_flowrate_mass(self, value): |
|
89 |
pre_unit = self.pre_units['Flowrate_Mass'] |
|
90 |
cur_unit = self.cur_units['Flowrate_Mass'] |
|
91 |
|
|
92 |
if pre_unit == cur_unit: |
|
93 |
return value |
|
94 |
|
|
95 |
if pre_unit == 'kg/h': |
|
96 |
if cur_unit == 'g/min': convert_factor = 16.6667 |
|
97 |
elif cur_unit == 'lb/h': convert_factor = 2.2046 |
|
98 |
elif cur_unit == 't/h': convert_factor = 0.001 |
|
99 |
elif pre_unit == 'g/min': |
|
100 |
if cur_unit == 'kg/h': convert_factor = 1 / 16.6667 |
|
101 |
elif cur_unit == 'lb/h': convert_factor = 0.132277 |
|
102 |
elif cur_unit == 't/h': convert_factor = 0.00006 |
|
103 |
elif pre_unit == 'lb/h': |
|
104 |
if cur_unit == 'kg/h': convert_factor = 1 / 2.2046 |
|
105 |
elif cur_unit == 'g/min': convert_factor = 1 / 0.132277 |
|
106 |
elif cur_unit == 't/h': convert_factor = 0.0004536 |
|
107 |
elif pre_unit == 't/h': |
|
108 |
if cur_unit == 'kg/h': convert_factor = 1 / 0.001 |
|
109 |
elif cur_unit == 'g/min': convert_factor = 1 / 0.00006 |
|
110 |
elif cur_unit == 'lb/h': convert_factor = 1 / 0.0004536 |
|
111 |
|
|
112 |
return round(value * convert_factor, self._decimal) |
|
113 |
|
|
114 |
def convert_flowrate_volume(self, value): |
|
115 |
pre_unit = self.pre_units['Flowrate_Volume'] |
|
116 |
cur_unit = self.cur_units['Flowrate_Volume'] |
|
117 |
|
|
118 |
if pre_unit == cur_unit: |
|
119 |
return value |
|
120 |
|
|
121 |
if pre_unit == 'm3/h': |
|
122 |
if cur_unit == 'l/min': convert_factor = 16.6667 |
|
123 |
elif cur_unit == 'ft3/h': convert_factor = 35.31466 |
|
124 |
elif cur_unit == 'USgpm': convert_factor = 4.402867 |
|
125 |
elif cur_unit == 'BPSD': convert_factor = 150.955464 |
|
126 |
elif pre_unit == 'l/min': |
|
127 |
if cur_unit == 'm3/h': convert_factor = 1 / 16.6667 |
|
128 |
elif cur_unit == 'ft3/h': convert_factor = 2.1188796 |
|
129 |
elif cur_unit == 'USgpm': convert_factor = 0.264172 |
|
130 |
elif cur_unit == 'BPSD': convert_factor = 9.05732784 |
|
131 |
elif pre_unit == 'ft3/h': |
|
132 |
if cur_unit == 'm3/h': convert_factor = 1 / 35.31466 |
|
133 |
elif cur_unit == 'l/min': convert_factor = 1 / 2.1188796 |
|
134 |
elif cur_unit == 'USgpm': convert_factor = 0.124675333 |
|
135 |
elif cur_unit == 'BPSD': convert_factor = 9.05732784 |
|
136 |
elif pre_unit == 'USgpm': |
|
137 |
if cur_unit == 'm3/h': convert_factor = 1 / 4.402867 |
|
138 |
elif cur_unit == 'l/min': convert_factor = 1 / 0.264172 |
|
139 |
elif cur_unit == 'ft3/h': convert_factor = 1 / 0.124675333 |
|
140 |
elif cur_unit == 'BPSD': convert_factor = 34.2857088 |
|
141 |
elif pre_unit == 'BPSD': |
|
142 |
if cur_unit == 'm3/h': convert_factor = 1 / 150.955464 |
|
143 |
elif cur_unit == 'l/min': convert_factor = 1 / 9.05732784 |
|
144 |
elif cur_unit == 'ft3/h': convert_factor = 1 / 4.2745824 |
|
145 |
elif cur_unit == 'USgpm': convert_factor = 1 / 34.2857088 |
|
146 |
|
|
147 |
return round(value * convert_factor, self._decimal) |
|
148 |
|
|
149 |
|
|
150 |
def convert_density(self, value): |
|
151 |
pre_unit = self.pre_units['Density'] |
|
152 |
cur_unit = self.cur_units['Density'] |
|
153 |
|
|
154 |
if pre_unit == cur_unit: |
|
155 |
return value |
|
156 |
|
|
157 |
if pre_unit == 'kg/m3': |
|
158 |
if cur_unit == 'lb/ft3': convert_factor = 0.06242797 |
|
159 |
elif pre_unit == 'lb/ft3': |
|
160 |
if cur_unit == 'kg/m3': convert_factor =1 / 0.06242797 |
|
156 | 161 |
|
157 |
if self._hmb.density: |
|
158 |
self._hmb.density = round(self._hmb.density * convert_factor, self._decimal) |
|
159 |
|
|
160 |
def convert_viscosity(self, curUnit): |
|
161 |
convert_factor = 1 |
|
162 |
|
|
163 |
if self.pre_viscosity_unit == 'cP': |
|
164 |
if curUnit == 'kg/m.sec': |
|
165 |
convert_factor = 0.001 |
|
166 |
elif curUnit == 'kg/m.h': |
|
167 |
convert_factor = 3.6 |
|
168 |
elif curUnit == 'lb/ft.sec': |
|
169 |
convert_factor = 0.000671969 |
|
170 |
elif self.pre_viscosity_unit == 'kg/m.sec': |
|
171 |
if curUnit == 'cP': |
|
172 |
convert_factor = 1 / 0.001 |
|
173 |
elif curUnit == 'kg/m.h': |
|
174 |
convert_factor = 3600 |
|
175 |
elif curUnit == 'lb/ft.sec': |
|
176 |
convert_factor = 0.671969 |
|
177 |
elif self.pre_viscosity_unit == 'kg/m.h': |
|
178 |
if curUnit == 'cP': |
|
179 |
convert_factor = 1 / 3.6 |
|
180 |
elif curUnit == 'kg/m.sec': |
|
181 |
convert_factor = 1 / 3600 |
|
182 |
elif curUnit == 'lb/ft.sec': |
|
183 |
convert_factor = 0.000186658 |
|
184 |
elif self.pre_viscosity_unit == 'lb/ft.sec': |
|
185 |
if curUnit == 'cP': |
|
186 |
convert_factor = 1 / 0.000671969 |
|
187 |
elif curUnit == 'kg/m.sec': |
|
188 |
convert_factor = 1 / 0.671969 |
|
189 |
elif curUnit == 'kg/m.h': |
|
190 |
convert_factor = 1 / 0.000186658 |
|
162 |
return round(value * convert_factor, self._decimal) |
|
163 |
|
|
164 |
def convert_viscosity(self, value): |
|
165 |
pre_unit = self.pre_units['Viscosity'] |
|
166 |
cur_unit = self.cur_units['Viscosity'] |
|
167 |
|
|
168 |
if pre_unit == cur_unit: |
|
169 |
return value |
|
170 |
|
|
171 |
if pre_unit == 'cP': |
|
172 |
if cur_unit == 'kg/m.sec': convert_factor = 0.001 |
|
173 |
elif cur_unit == 'kg/m.h': convert_factor = 3.6 |
|
174 |
elif cur_unit == 'lb/ft.sec': convert_factor = 0.000671969 |
|
175 |
elif pre_unit == 'kg/m.sec': |
|
176 |
if cur_unit == 'cP': convert_factor = 1 / 0.001 |
|
177 |
elif cur_unit == 'kg/m.h': convert_factor = 3600 |
|
178 |
elif cur_unit == 'lb/ft.sec': convert_factor = 0.671969 |
|
179 |
elif pre_unit == 'kg/m.h': |
|
180 |
if cur_unit == 'cP': convert_factor = 1 / 3.6 |
|
181 |
elif cur_unit == 'kg/m.sec': convert_factor = 1 / 3600 |
|
182 |
elif cur_unit == 'lb/ft.sec': convert_factor = 0.000186658 |
|
183 |
elif pre_unit == 'lb/ft.sec': |
|
184 |
if cur_unit == 'cP': convert_factor = 1 / 0.000671969 |
|
185 |
elif cur_unit == 'kg/m.sec': convert_factor = 1 / 0.671969 |
|
186 |
elif cur_unit == 'kg/m.h': convert_factor = 1 / 0.000186658 |
|
191 | 187 |
|
192 |
if self._hmb.viscosity: |
|
193 |
self._hmb.viscosity = round(self._hmb.viscosity * convert_factor, self._decimal) |
|
194 |
|
|
195 |
def convert_temperature(self, curUnit): |
|
196 |
if self._hmb.temperature: |
|
197 |
if curUnit == '℉': |
|
198 |
self._hmb.temperature = round(1.8* self._hmb.temperature + 32, self._decimal) |
|
199 |
elif curUnit == '℃': |
|
200 |
self._hmb.temperature = round((self._hmb.temperature - 32) / 1.8, self._decimal) |
|
201 |
|
|
202 |
def convert_pressure(self, curUnit): |
|
203 |
convert_factor = 1 |
|
204 |
|
|
205 |
if self.pre_pressure_unit == 'kg/cm2': |
|
206 |
if curUnit == 'psi': |
|
207 |
convert_factor = 14.22334 |
|
208 |
elif curUnit == 'atm': |
|
209 |
convert_factor = 0.9678411 |
|
210 |
elif curUnit == 'bar': |
|
211 |
convert_factor = 0.980665 |
|
212 |
elif curUnit == 'mmHg': |
|
213 |
convert_factor = 735.5591 |
|
214 |
elif curUnit == 'kPa': |
|
215 |
convert_factor = 98.0665 |
|
216 |
elif curUnit == 'MPa': |
|
217 |
convert_factor = 0.0980665 |
|
218 |
elif self.pre_viscosity_unit == 'psi': |
|
219 |
if curUnit == 'kg/cm2': |
|
220 |
convert_factor = 1 / 14.22334 |
|
221 |
elif curUnit == 'atm': |
|
222 |
convert_factor = 0.06804596 |
|
223 |
elif curUnit == 'bar': |
|
224 |
convert_factor = 0.06894757 |
|
225 |
elif curUnit == 'mmHg': |
|
226 |
convert_factor = 51.71492 |
|
227 |
elif curUnit == 'kPa': |
|
228 |
convert_factor = 6.894757 |
|
229 |
elif curUnit == 'MPa': |
|
230 |
convert_factor = 0.006894757 |
|
231 |
elif self.pre_viscosity_unit == 'atm': |
|
232 |
if curUnit == 'kg/cm2': |
|
233 |
convert_factor = 1 / 0.9678411 |
|
234 |
elif curUnit == 'psi': |
|
235 |
convert_factor = 1 / 0.06804596 |
|
236 |
elif curUnit == 'bar': |
|
237 |
convert_factor = 1.01325 |
|
238 |
elif curUnit == 'mmHg': |
|
239 |
convert_factor = 759.9998 |
|
240 |
elif curUnit == 'kPa': |
|
241 |
convert_factor = 101.325 |
|
242 |
elif curUnit == 'MPa': |
|
243 |
convert_factor = 0.101325 |
|
244 |
elif self.pre_viscosity_unit == 'bar': |
|
245 |
if curUnit == 'kg/cm2': |
|
246 |
convert_factor = 1 / 0.980665 |
|
247 |
elif curUnit == 'psi': |
|
248 |
convert_factor = 1 / 0.06894757 |
|
249 |
elif curUnit == 'atm': |
|
250 |
convert_factor = 1 / 1.01325 |
|
251 |
elif curUnit == 'mmHg': |
|
252 |
convert_factor = 750.0615 |
|
253 |
elif curUnit == 'kPa': |
|
254 |
convert_factor = 100 |
|
255 |
elif curUnit == 'MPa': |
|
256 |
convert_factor = 0.1 |
|
257 |
elif self.pre_viscosity_unit == 'mmHg': |
|
258 |
if curUnit == 'kg/cm2': |
|
259 |
convert_factor = 1 / 735.5591 |
|
260 |
elif curUnit == 'psi': |
|
261 |
convert_factor = 1 / 51.71492 |
|
262 |
elif curUnit == 'atm': |
|
263 |
convert_factor = 1 / 759.9998 |
|
264 |
elif curUnit == 'bar': |
|
265 |
convert_factor = 1 / 750.0615 |
|
266 |
elif curUnit == 'kPa': |
|
267 |
convert_factor = 0.1333224 |
|
268 |
elif curUnit == 'MPa': |
|
269 |
convert_factor = 0.0001333224 |
|
270 |
elif self.pre_viscosity_unit == 'kPa': |
|
271 |
if curUnit == 'kg/cm2': |
|
272 |
convert_factor = 1 / 98.0665 |
|
273 |
elif curUnit == 'psi': |
|
274 |
convert_factor = 1 / 6.894757 |
|
275 |
elif curUnit == 'atm': |
|
276 |
convert_factor = 1 / 101.325 |
|
277 |
elif curUnit == 'bar': |
|
278 |
convert_factor = 1 / 100 |
|
279 |
elif curUnit == 'mmHg': |
|
280 |
convert_factor = 1 / 0.1333224 |
|
281 |
elif curUnit == 'MPa': |
|
282 |
convert_factor = 1 / 1000 |
|
283 |
elif self.pre_viscosity_unit == 'MPa': |
|
284 |
if curUnit == 'kg/cm2': |
|
285 |
convert_factor = 1 / 98.0665 * 1000 |
|
286 |
elif curUnit == 'psi': |
|
287 |
convert_factor = 1 / 6.894757 * 1000 |
|
288 |
elif curUnit == 'atm': |
|
289 |
convert_factor = 1 / 101.325 * 1000 |
|
290 |
elif curUnit == 'bar': |
|
291 |
convert_factor = 1 / 100 * 1000 |
|
292 |
elif curUnit == 'mmHg': |
|
293 |
convert_factor = 1 / 0.1333224 * 1000 |
|
294 |
elif curUnit == 'kPa': |
|
295 |
convert_factor = 1 # 기존 소스에 없음 |
|
296 |
|
|
297 |
if self._hmb.limitation_pressure_drop: |
|
298 |
self._hmb.limitation_pressure_drop = round(self._hmb.limitation_pressure_drop * convert_factor, self._decimal) |
|
299 |
|
|
300 |
if self._hmb.pressure_drop: |
|
301 |
self._hmb.pressure_drop = round(self._hmb.pressure_drop * convert_factor, self._decimal) |
|
302 |
|
|
303 |
if self._hmb.pressure_drop_friction: |
|
304 |
self._hmb.pressure_drop_friction = round(self._hmb.pressure_drop_friction * convert_factor, self._decimal) |
|
305 |
|
|
306 |
if self._hmb.pressure_drop_static: |
|
307 |
self._hmb.pressure_drop_static = round(self._hmb.pressure_drop_static * convert_factor, self._decimal) |
|
308 |
|
|
309 |
if self._hmb.pressure_pipe_end_point: |
|
310 |
self._hmb.pressure_pipe_end_point = round(self._hmb.pressure_pipe_end_point * convert_factor, self._decimal) |
|
311 |
|
|
312 |
def convert_velocity(self, curUnit): |
|
313 |
convert_factor = 1 |
|
314 |
|
|
315 |
if self.pre_velocity_unit == 'm/s': |
|
316 |
if curUnit == 'ft/s': |
|
317 |
convert_factor = 3.28084 |
|
318 |
elif self.pre_velocity_unit == 'ft/s': |
|
319 |
if curUnit == 'm/s': |
|
320 |
convert_factor = 1 / 3.28084 |
|
321 |
|
|
322 |
if self._hmb.limitation_velocity: |
|
323 |
self._hmb.limitation_velocity = round(self._hmb.limitation_velocity * convert_factor, self._decimal) |
|
324 |
|
|
325 |
if self._hmb.velocity: |
|
326 |
self._hmb.velocity = round(self._hmb.velocity * convert_factor, self._decimal) |
|
327 |
|
|
328 |
def convert_length(self, curUnit): |
|
329 |
convert_factor = 1 |
|
330 |
|
|
331 |
if self.pre_length_unit == 'in': |
|
332 |
if curUnit == 'm': |
|
333 |
convert_factor = 0.0254 |
|
334 |
elif curUnit == 'ft': |
|
335 |
convert_factor = 0.083333 |
|
336 |
elif curUnit == 'yd': |
|
337 |
convert_factor = 0.0277778 |
|
338 |
elif curUnit == 'mile': |
|
339 |
convert_factor = 0.00001578283 |
|
340 |
elif curUnit == 'mm': |
|
341 |
convert_factor = 25.4 |
|
342 |
elif self.pre_length_unit == 'm': |
|
343 |
if curUnit == 'in': |
|
344 |
convert_factor = 1 / 0.0254 |
|
345 |
elif curUnit == 'ft': |
|
346 |
convert_factor = 3.28084 |
|
347 |
elif curUnit == 'yd': |
|
348 |
convert_factor = 1.093613 |
|
349 |
elif curUnit == 'mile': |
|
350 |
convert_factor = 0.000621371 |
|
351 |
elif curUnit == 'mm': |
|
352 |
convert_factor = 1000 |
|
353 |
elif self.pre_length_unit == 'ft': |
|
354 |
if curUnit == 'in': |
|
355 |
convert_factor = 1 / 0.083333 |
|
356 |
elif curUnit == 'm': |
|
357 |
convert_factor = 1 / 3.28084 |
|
358 |
elif curUnit == 'yd': |
|
359 |
convert_factor = 0.33333 |
|
360 |
elif curUnit == 'mile': |
|
361 |
convert_factor = 0.000189394 |
|
362 |
elif curUnit == 'mm': |
|
363 |
convert_factor = 304.8 |
|
364 |
elif self.pre_length_unit == 'yd': |
|
365 |
if curUnit == 'in': |
|
366 |
convert_factor = 1 / 0.277778 |
|
367 |
elif curUnit == 'm': |
|
368 |
convert_factor = 1 / 1.093613 |
|
369 |
elif curUnit == 'ft': |
|
370 |
convert_factor = 1 / 0.33333 |
|
371 |
elif curUnit == 'mile': |
|
372 |
convert_factor = 0.000568182 |
|
373 |
elif curUnit == 'mm': |
|
374 |
convert_factor = 914.4 |
|
375 |
elif self.pre_length_unit == 'mile': |
|
376 |
if curUnit == 'in': |
|
377 |
convert_factor = 1 / 0.00001578283 |
|
378 |
elif curUnit == 'm': |
|
379 |
convert_factor = 1 / 0.000621371 |
|
380 |
elif curUnit == 'ft': |
|
381 |
convert_factor = 1 / 0.000189394 |
|
382 |
elif curUnit == 'yd': |
|
383 |
convert_factor = 1 / 0.000568182 |
|
384 |
elif curUnit == 'mm': |
|
385 |
convert_factor = 1609344 |
|
386 |
elif self.pre_length_unit == 'mm': |
|
387 |
if curUnit == 'in': |
|
388 |
convert_factor = 1 / 25.4 |
|
389 |
elif curUnit == 'm': |
|
390 |
convert_factor = 1 / 1000 |
|
391 |
elif curUnit == 'ft': |
|
392 |
convert_factor = 1 / 304.8 |
|
393 |
elif curUnit == 'yd': |
|
394 |
convert_factor = 1 / 914.4 |
|
395 |
elif curUnit == 'mile': |
|
396 |
convert_factor = 1 / 1609344 |
|
397 |
|
|
398 |
if self._hmb.straight_length: |
|
399 |
self._hmb.straight_length = round(self._hmb.straight_length * convert_factor, self._decimal) |
|
400 |
|
|
401 |
if self._hmb.equivalent_length: |
|
402 |
self._hmb.equivalent_length = round(self._hmb.equivalent_length * convert_factor, self._decimal) |
|
403 |
|
|
404 |
def convert_pipe_diameter(self, curUnit): |
|
405 |
convert_factor = 1 |
|
406 |
|
|
407 |
if self.pre_pipe_diameter_unit == 'in': |
|
408 |
if curUnit == 'mm': |
|
409 |
convert_factor = 25.4 |
|
410 |
elif self.pre_pipe_diameter_unit == 'mm': |
|
411 |
if curUnit == 'in': |
|
412 |
convert_factor = 1 / 25.4 |
|
413 |
|
|
414 |
if self._hmb.nominal_pipe_size: |
|
415 |
self._hmb.nominal_pipe_size = round(self._hmb.nominal_pipe_size * convert_factor, self._decimal) |
|
416 |
|
|
417 |
if self._hmb.inside_pipe_size: |
|
418 |
self._hmb.inside_pipe_size = round(self._hmb.inside_pipe_size * convert_factor, self._decimal) |
|
419 |
|
|
420 |
def convert_roughness(self, curUnit): |
|
421 |
convert_factor = 1 |
|
422 |
|
|
423 |
if self.pre_roughness_unit == 'in': |
|
424 |
if curUnit == 'm': |
|
425 |
convert_factor = 0.0254 |
|
426 |
elif curUnit == 'ft': |
|
427 |
convert_factor = 0.083333 |
|
428 |
elif curUnit == 'mm': |
|
429 |
convert_factor = 25.4 |
|
430 |
elif self.pre_roughness_unit == 'm': |
|
431 |
if curUnit == 'in': |
|
432 |
convert_factor = 1 / 0.0254 |
|
433 |
elif curUnit == 'ft': |
|
434 |
convert_factor = 3.28084 |
|
435 |
elif curUnit == 'mm': |
|
436 |
convert_factor = 1000 |
|
437 |
elif self.pre_roughness_unit == 'ft': |
|
438 |
if curUnit == 'in': |
|
439 |
convert_factor = 1 / 0.083333 |
|
440 |
elif curUnit == 'm': |
|
441 |
convert_factor = 1 / 3.28084 |
|
442 |
elif curUnit == 'mm': |
|
443 |
convert_factor = 304.8 |
|
444 |
elif self.pre_roughness_unit == 'mm': |
|
445 |
if curUnit == 'in': |
|
446 |
convert_factor = 1 / 25.4 |
|
447 |
elif curUnit == 'm': |
|
448 |
convert_factor = 1 / 1000 |
|
449 |
elif curUnit == 'ft': |
|
450 |
convert_factor = 1 / 304.8 |
|
451 |
|
|
452 |
if self._hmb.roughness: |
|
453 |
self._hmb.roughness = round(self._hmb.roughness * convert_factor, self._decimal) |
|
454 |
|
|
455 |
def convert_power(self, curUnit): |
|
456 |
convert_factor = 1 |
|
457 |
|
|
458 |
if self.pre_power_unit == 'kW': |
|
459 |
if curUnit == 'kcal/h': |
|
460 |
convert_factor = 860.4207 |
|
461 |
elif curUnit == 'btu/h': |
|
462 |
convert_factor = 3414.425 |
|
463 |
elif curUnit == 'Hp': |
|
464 |
convert_factor = 1.359622 |
|
465 |
elif curUnit == 'kg.m/sec': |
|
466 |
convert_factor = 101.9716 |
|
467 |
elif curUnit == 'ft.lb/sec': |
|
468 |
convert_factor = 737.5621 |
|
469 |
elif self.pre_power_unit == 'kcal/h': |
|
470 |
if curUnit == 'kW': |
|
471 |
convert_factor = 1 / 860.4207 |
|
472 |
elif curUnit == 'btu/h': |
|
473 |
convert_factor = 3.96832 |
|
474 |
elif curUnit == 'Hp': |
|
475 |
convert_factor = 0.001580182 |
|
476 |
elif curUnit == 'kg.m/sec': |
|
477 |
convert_factor = 0.1185137 |
|
478 |
elif curUnit == 'ft.lb/sec': |
|
479 |
convert_factor = 0.857211 |
|
480 |
elif self.pre_power_unit == 'btu/h': |
|
481 |
if curUnit == 'kW': |
|
482 |
convert_factor = 1 / 3414.425 |
|
483 |
elif curUnit == 'kcal/h': |
|
484 |
convert_factor = 1 / 3.96832 |
|
485 |
elif curUnit == 'Hp': |
|
486 |
convert_factor = 0.000398199 |
|
487 |
elif curUnit == 'kg.m/sec': |
|
488 |
convert_factor = 0.02986495 |
|
489 |
elif curUnit == 'ft.lb/sec': |
|
490 |
convert_factor = 0.2160136 |
|
491 |
elif self.pre_power_unit == 'Hp': |
|
492 |
if curUnit == 'kW': |
|
493 |
convert_factor = 11 / 1.359622 |
|
494 |
elif curUnit == 'kcal/h': |
|
495 |
convert_factor = 1 / 0.001580182 |
|
496 |
elif curUnit == 'btu/h': |
|
497 |
convert_factor = 1 / 0.000398199 |
|
498 |
elif curUnit == 'kg.m/sec': |
|
499 |
convert_factor = 75.00001 |
|
500 |
elif curUnit == 'ft.lb/sec': |
|
501 |
convert_factor = 542.4761 |
|
502 |
elif self.pre_power_unit == 'kg.m/sec': |
|
503 |
if curUnit == 'kW': |
|
504 |
convert_factor = 1 / 101.9716 |
|
505 |
elif curUnit == 'kcal/h': |
|
506 |
convert_factor = 1 / 0.1185137 |
|
507 |
elif curUnit == 'btu/h': |
|
508 |
convert_factor = 1 / 0.02986495 |
|
509 |
elif curUnit == 'Hp': |
|
510 |
convert_factor = 1 / 75.00001 |
|
511 |
elif curUnit == 'ft.lb/sec': |
|
512 |
convert_factor = 7.233014 |
|
513 |
elif self.pre_power_unit == 'ft.lb/sec': |
|
514 |
if curUnit == 'kW': |
|
515 |
convert_factor = 1 / 737.5621 |
|
516 |
elif curUnit == 'kcal/h': |
|
517 |
convert_factor = 1 / 0.857211 |
|
518 |
elif curUnit == 'btu/h': |
|
519 |
convert_factor = 1 / 0.2160136 |
|
520 |
elif curUnit == 'Hp': |
|
521 |
convert_factor = 1 / 542.4761 |
|
522 |
elif curUnit == 'kg.m/sec': |
|
523 |
convert_factor = 1 / 7.233014 |
|
524 |
|
|
525 |
if self._hmb.power: |
|
526 |
self._hmb.power = round(self._hmb.power * convert_factor, self._decimal) |
|
527 |
|
|
188 |
return round(value * convert_factor, self._decimal) |
|
528 | 189 |
|
529 |
def initUnits(self): |
|
530 |
activeDrawing = AppDocData.instance().activeDrawing |
|
190 |
def convert_temperature(self, value): |
|
191 |
pre_unit = self.pre_units['Temperature'] |
|
192 |
cur_unit = self.cur_units['Temperature'] |
|
193 |
|
|
194 |
if pre_unit == cur_unit: |
|
195 |
return value |
|
196 |
|
|
197 |
if cur_unit == '℉': |
|
198 |
return round(1.8 * value + 32, self._decimal) |
|
199 |
elif cur_unit == '℃': |
|
200 |
return round((value - 32) / 1.8, self._decimal) |
|
531 | 201 |
|
532 |
for attr in activeDrawing.attrs: |
|
533 |
if attr[0] == 'Units': |
|
534 |
self.pre_flowrate_mass_unit = attr[1]['Flowrate_Mass'] |
|
535 |
self.pre_flowrate_volume_unit = attr[1]['Flowrate_Volume'] |
|
536 |
self.pre_density_unit = attr[1]['Density'] |
|
537 |
self.pre_viscosity_unit = attr[1]['Viscosity'] |
|
538 |
self.pre_velocity_unit = attr[1]['Velocity'] |
|
539 |
self.pre_pressure_unit = attr[1]['Pressure'] |
|
540 |
self.pre_length_unit = attr[1]['Length'] |
|
541 |
self.pre_pipe_diameter_unit = attr[1]['Pipe_Diameter'] |
|
542 |
self.pre_roughness_unit = attr[1]['Roughness'] |
|
543 |
self.pre_temperature_unit = attr[1]['Temperature'] |
|
544 |
self.pre_power_unit = attr[1]['Power'] |
|
202 |
def convert_pipe_diameter(self, value): |
|
203 |
pre_unit = self.pre_units['Pipe_Diameter'] |
|
204 |
cur_unit = self.cur_units['Pipe_Diameter'] |
|
205 |
|
|
206 |
if pre_unit == cur_unit: |
|
207 |
return value |
|
208 |
|
|
209 |
if pre_unit == 'in': |
|
210 |
if cur_unit == 'mm': convert_factor = 25.4 |
|
211 |
elif pre_unit == 'mm': |
|
212 |
if cur_unit == 'in': convert_factor = 1 / 25.4 |
|
213 |
|
|
214 |
return round(value * convert_factor, self._decimal) |
|
215 |
|
|
216 |
def convert_length(self, value): |
|
217 |
pre_unit = self.pre_units['Length'] |
|
218 |
cur_unit = self.cur_units['Length'] |
|
219 |
|
|
220 |
if pre_unit == cur_unit: |
|
221 |
return value |
|
222 |
|
|
223 |
if pre_unit == 'in': |
|
224 |
if cur_unit == 'm': convert_factor = 0.0254 |
|
225 |
elif cur_unit == 'ft': convert_factor = 0.083333 |
|
226 |
elif cur_unit == 'yd': convert_factor = 0.0277778 |
|
227 |
elif cur_unit == 'mile': convert_factor = 0.00001578283 |
|
228 |
elif cur_unit == 'mm': convert_factor = 25.4 |
|
229 |
elif pre_unit == 'm': |
|
230 |
if cur_unit == 'in': convert_factor = 1 / 0.0254 |
|
231 |
elif cur_unit == 'ft': convert_factor = 3.28084 |
|
232 |
elif cur_unit == 'yd': convert_factor = 1.093613 |
|
233 |
elif cur_unit == 'mile': convert_factor = 0.000621371 |
|
234 |
elif cur_unit == 'mm': convert_factor = 1000 |
|
235 |
elif pre_unit == 'ft': |
|
236 |
if cur_unit == 'in': convert_factor = 1 / 0.083333 |
|
237 |
elif cur_unit == 'm': convert_factor = 1 / 3.28084 |
|
238 |
elif cur_unit == 'yd': convert_factor = 0.33333 |
|
239 |
elif cur_unit == 'mile': convert_factor = 0.000189394 |
|
240 |
elif cur_unit == 'mm': convert_factor = 304.8 |
|
241 |
elif pre_unit == 'yd': |
|
242 |
if cur_unit == 'in': convert_factor = 1 / 0.277778 |
|
243 |
elif cur_unit == 'm': convert_factor = 1 / 1.093613 |
|
244 |
elif cur_unit == 'ft': convert_factor = 1 / 0.33333 |
|
245 |
elif cur_unit == 'mile': convert_factor = 0.000568182 |
|
246 |
elif cur_unit == 'mm': convert_factor = 914.4 |
|
247 |
elif pre_unit == 'mile': |
|
248 |
if cur_unit == 'in': convert_factor = 1 / 0.00001578283 |
|
249 |
elif cur_unit == 'm': convert_factor = 1 / 0.000621371 |
|
250 |
elif cur_unit == 'ft': convert_factor = 1 / 0.000189394 |
|
251 |
elif cur_unit == 'yd': convert_factor = 1 / 0.000568182 |
|
252 |
elif cur_unit == 'mm': convert_factor = 1609344 |
|
253 |
elif pre_unit == 'mm': |
|
254 |
if cur_unit == 'in': convert_factor = 1 / 25.4 |
|
255 |
elif cur_unit == 'm': convert_factor = 1 / 1000 |
|
256 |
elif cur_unit == 'ft': convert_factor = 1 / 304.8 |
|
257 |
elif cur_unit == 'yd': convert_factor = 1 / 914.4 |
|
258 |
elif cur_unit == 'mile': convert_factor = 1 / 1609344 |
|
259 |
|
|
260 |
return round(value * convert_factor, self._decimal) |
|
261 |
|
|
262 |
def convert_roughness(self, value): |
|
263 |
pre_unit = self.pre_units['Roughness'] |
|
264 |
cur_unit = self.cur_units['Roughness'] |
|
265 |
|
|
266 |
if pre_unit == cur_unit: |
|
267 |
return value |
|
268 |
|
|
269 |
if pre_unit == 'in': |
|
270 |
if cur_unit == 'm': convert_factor = 0.0254 |
|
271 |
elif cur_unit == 'ft': convert_factor = 0.083333 |
|
272 |
elif cur_unit == 'mm': convert_factor = 25.4 |
|
273 |
elif pre_unit == 'm': |
|
274 |
if cur_unit == 'in': convert_factor = 1 / 0.0254 |
|
275 |
elif cur_unit == 'ft': convert_factor = 3.28084 |
|
276 |
elif cur_unit == 'mm': convert_factor = 1000 |
|
277 |
elif pre_unit == 'ft': |
|
278 |
if cur_unit == 'in': convert_factor = 1 / 0.083333 |
|
279 |
elif cur_unit == 'm': convert_factor = 1 / 3.28084 |
|
280 |
elif cur_unit == 'mm': convert_factor = 304.8 |
|
281 |
elif pre_unit == 'mm': |
|
282 |
if cur_unit == 'in': convert_factor = 1 / 25.4 |
|
283 |
elif cur_unit == 'm': convert_factor = 1 / 1000 |
|
284 |
elif cur_unit == 'ft': convert_factor = 1 / 304.8 |
|
285 |
|
|
286 |
return round(value * convert_factor, self._decimal) |
|
287 |
|
|
288 |
def convert_velocity(self, value): |
|
289 |
pre_unit = self.pre_units['Velocity'] |
|
290 |
cur_unit = self.cur_units['Velocity'] |
|
291 |
|
|
292 |
if pre_unit == cur_unit: |
|
293 |
return value |
|
294 |
|
|
295 |
if pre_unit == 'm/s': |
|
296 |
if cur_unit == 'ft/s': convert_factor = 3.28084 |
|
297 |
elif pre_unit == 'ft/s': |
|
298 |
if cur_unit == 'm/s': convert_factor = 1 / 3.28084 |
|
299 |
|
|
300 |
return round(value * convert_factor, self._decimal) |
|
301 |
|
|
302 |
def convert_pressure(self, value): |
|
303 |
pre_unit = self.pre_units['Pressure'] |
|
304 |
cur_unit = self.cur_units['Pressure'] |
|
305 |
|
|
306 |
if pre_unit == cur_unit: |
|
307 |
return value |
|
308 |
|
|
309 |
if pre_unit == 'kg/cm2': |
|
310 |
if cur_unit == 'psi': convert_factor = 14.22334 |
|
311 |
elif cur_unit == 'atm': convert_factor = 0.9678411 |
|
312 |
elif cur_unit == 'bar': convert_factor = 0.980665 |
|
313 |
elif cur_unit == 'mmHg': convert_factor = 735.5591 |
|
314 |
elif cur_unit == 'kPa': convert_factor = 98.0665 |
|
315 |
elif cur_unit == 'MPa': convert_factor = 0.0980665 |
|
316 |
elif pre_unit == 'psi': |
|
317 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 14.22334 |
|
318 |
elif cur_unit == 'atm': convert_factor = 0.06804596 |
|
319 |
elif cur_unit == 'bar': convert_factor = 0.06894757 |
|
320 |
elif cur_unit == 'mmHg': convert_factor = 51.71492 |
|
321 |
elif cur_unit == 'kPa': convert_factor = 6.894757 |
|
322 |
elif cur_unit == 'MPa': convert_factor = 0.006894757 |
|
323 |
elif pre_unit == 'atm': |
|
324 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 0.9678411 |
|
325 |
elif cur_unit == 'psi': convert_factor = 1 / 0.06804596 |
|
326 |
elif cur_unit == 'bar': convert_factor = 1.01325 |
|
327 |
elif cur_unit == 'mmHg': convert_factor = 759.9998 |
|
328 |
elif cur_unit == 'kPa': convert_factor = 101.325 |
|
329 |
elif cur_unit == 'MPa': convert_factor = 0.101325 |
|
330 |
elif pre_unit == 'bar': |
|
331 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 0.980665 |
|
332 |
elif cur_unit == 'psi': convert_factor = 1 / 0.06894757 |
|
333 |
elif cur_unit == 'atm': convert_factor = 1 / 1.01325 |
|
334 |
elif cur_unit == 'mmHg': convert_factor = 750.0615 |
|
335 |
elif cur_unit == 'kPa': convert_factor = 100 |
|
336 |
elif cur_unit == 'MPa': convert_factor = 0.1 |
|
337 |
elif pre_unit == 'mmHg': |
|
338 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 735.5591 |
|
339 |
elif cur_unit == 'psi': convert_factor = 1 / 51.71492 |
|
340 |
elif cur_unit == 'atm': convert_factor = 1 / 759.9998 |
|
341 |
elif cur_unit == 'bar': convert_factor = 1 / 750.0615 |
|
342 |
elif cur_unit == 'kPa': convert_factor = 0.1333224 |
|
343 |
elif cur_unit == 'MPa': convert_factor = 0.0001333224 |
|
344 |
elif pre_unit == 'kPa': |
|
345 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 98.0665 |
|
346 |
elif cur_unit == 'psi': convert_factor = 1 / 6.894757 |
|
347 |
elif cur_unit == 'atm': convert_factor = 1 / 101.325 |
|
348 |
elif cur_unit == 'bar': convert_factor = 1 / 100 |
|
349 |
elif cur_unit == 'mmHg': convert_factor = 1 / 0.1333224 |
|
350 |
elif cur_unit == 'MPa': convert_factor = 1 / 1000 |
|
351 |
elif pre_unit == 'MPa': |
|
352 |
if cur_unit == 'kg/cm2': convert_factor = 1 / 98.0665 * 1000 |
|
353 |
elif cur_unit == 'psi': convert_factor = 1 / 6.894757 * 1000 |
|
354 |
elif cur_unit == 'atm': convert_factor = 1 / 101.325 * 1000 |
|
355 |
elif cur_unit == 'bar': convert_factor = 1 / 100 * 1000 |
|
356 |
elif cur_unit == 'mmHg': convert_factor = 1 / 0.1333224 * 1000 |
|
357 |
elif cur_unit == 'kPa': convert_factor = 1 # 기존 소스에 없음 |
|
358 |
|
|
359 |
return round(value * convert_factor, self._decimal) |
|
360 |
|
|
361 |
def convert_power(self, value): |
|
362 |
pre_unit = self.pre_units['Power'] |
|
363 |
cur_unit = self.cur_units['Power'] |
|
364 |
|
|
365 |
if pre_unit == cur_unit: |
|
366 |
return value |
|
367 |
|
|
368 |
if pre_unit == 'kW': |
|
369 |
if cur_unit == 'kcal/h': convert_factor = 860.4207 |
|
370 |
elif cur_unit == 'btu/h': convert_factor = 3414.425 |
|
371 |
elif cur_unit == 'Hp': convert_factor = 1.359622 |
|
372 |
elif cur_unit == 'kg.m/sec': convert_factor = 101.9716 |
|
373 |
elif cur_unit == 'ft.lb/sec': convert_factor = 737.5621 |
|
374 |
elif pre_unit == 'kcal/h': |
|
375 |
if cur_unit == 'kW': convert_factor = 1 / 860.4207 |
|
376 |
elif cur_unit == 'btu/h': convert_factor = 3.96832 |
|
377 |
elif cur_unit == 'Hp': convert_factor = 0.001580182 |
|
378 |
elif cur_unit == 'kg.m/sec': convert_factor = 0.1185137 |
|
379 |
elif cur_unit == 'ft.lb/sec': convert_factor = 0.857211 |
|
380 |
elif pre_unit == 'btu/h': |
|
381 |
if cur_unit == 'kW': convert_factor = 1 / 3414.425 |
|
382 |
elif cur_unit == 'kcal/h': convert_factor = 1 / 3.96832 |
|
383 |
elif cur_unit == 'Hp': convert_factor = 0.000398199 |
|
384 |
elif cur_unit == 'kg.m/sec': convert_factor = 0.02986495 |
|
385 |
elif cur_unit == 'ft.lb/sec': convert_factor = 0.2160136 |
|
386 |
elif pre_unit == 'Hp': |
|
387 |
if cur_unit == 'kW': convert_factor = 11 / 1.359622 |
|
388 |
elif cur_unit == 'kcal/h': convert_factor = 1 / 0.001580182 |
|
389 |
elif cur_unit == 'btu/h': convert_factor = 1 / 0.000398199 |
|
390 |
elif cur_unit == 'kg.m/sec': convert_factor = 75.00001 |
|
391 |
elif cur_unit == 'ft.lb/sec': convert_factor = 542.4761 |
|
392 |
elif pre_unit == 'kg.m/sec': |
|
393 |
if cur_unit == 'kW': convert_factor = 1 / 101.9716 |
|
394 |
elif cur_unit == 'kcal/h': convert_factor = 1 / 0.1185137 |
|
395 |
elif cur_unit == 'btu/h': convert_factor = 1 / 0.02986495 |
|
396 |
elif cur_unit == 'Hp': convert_factor = 1 / 75.00001 |
|
397 |
elif cur_unit == 'ft.lb/sec': convert_factor = 7.233014 |
|
398 |
elif pre_unit == 'ft.lb/sec': |
|
399 |
if cur_unit == 'kW': convert_factor = 1 / 737.5621 |
|
400 |
elif cur_unit == 'kcal/h': convert_factor = 1 / 0.857211 |
|
401 |
elif cur_unit == 'btu/h': convert_factor = 1 / 0.2160136 |
|
402 |
elif cur_unit == 'Hp': convert_factor = 1 / 542.4761 |
|
403 |
elif cur_unit == 'kg.m/sec': convert_factor = 1 / 7.233014 |
|
404 |
|
|
405 |
return round(value * convert_factor, self._decimal) |
|
406 |
|
|
407 |
|
|
408 |
def convert_Nozzle(self): |
|
409 |
from App import App |
|
410 |
try: |
|
411 |
self.graphicsView = App.mainWnd().graphicsView |
|
412 |
|
|
413 |
items = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem] |
|
414 |
for item in items: |
|
415 |
for connector in item.connectors: |
|
416 |
if connector.data.pressure: |
|
417 |
connector.data.pressure= self.convert_pressure(connector.data.pressure) |
|
418 |
if connector.data.pressure_drop: |
|
419 |
connector.data.pressure_drop= self.convert_pressure(connector.data.pressure_drop) |
|
420 |
if connector.data.elevation: |
|
421 |
connector.data.elevation= self.convert_length(connector.data.elevation) |
|
422 |
except Exception as ex: |
|
423 |
from App import App |
|
424 |
from AppDocData import MessageType |
|
425 |
|
|
426 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
427 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
428 |
|
|
429 |
def getCurrentUnits(self): |
|
430 |
from AppDocData import AppDocData |
|
431 |
try: |
|
432 |
curUnitsList = AppDocData.instance().getConfigs('Units') |
|
433 |
for curUnit in curUnitsList: |
|
434 |
self.cur_units[curUnit.key] = curUnit.value |
|
435 |
|
|
436 |
except Exception as ex: |
|
437 |
from App import App |
|
438 |
from AppDocData import MessageType |
|
439 |
|
|
440 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
441 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
545 | 442 |
|
443 |
def getPreviousUnits(self): |
|
444 |
from AppDocData import AppDocData |
|
445 |
try: |
|
446 |
activeDrawing = AppDocData.instance().activeDrawing |
|
546 | 447 |
|
448 |
for attr in activeDrawing.attrs: |
|
449 |
if attr[0] == 'Units': |
|
450 |
self.pre_units = attr[1] |
|
451 |
|
|
452 |
except Exception as ex: |
|
453 |
from App import App |
|
454 |
from AppDocData import MessageType |
|
455 |
|
|
456 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
457 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
547 | 458 |
|
548 | 459 |
class Calculation: |
549 | 460 |
def __init__(self, hmb): |
550 | 461 |
self.initUnits() |
551 | 462 |
self._hmb = hmb |
552 | 463 |
|
553 |
# To Do : Make a loop |
|
554 |
|
|
555 | 464 |
if self._hmb.phase_type == 'Vapor': |
556 | 465 |
self.calculation_Vapor() |
557 | 466 |
elif self._hmb.phase_type == 'Liquid': |
558 |
self.calculation_Liquid() |
|
467 |
if self.validation_check_Liquid() == True: |
|
468 |
self.calculation_Liquid() |
|
559 | 469 |
elif self._hmb.phase_type == 'Mixed': |
560 | 470 |
self.calculation_Mixed() |
561 | 471 |
|
472 |
|
|
473 |
def get_equivalent_length(self): |
|
474 |
if self._hmb.equivalent_length_input: |
|
475 |
return self._hmb.equivalent_length_input |
|
476 |
else: |
|
477 |
return self._hmb.equivalent_length_cal |
|
478 |
|
|
479 |
def validation_check_Liquid(self): |
|
480 |
from App import App |
|
481 |
from AppDocData import MessageType |
|
482 |
|
|
483 |
result = False |
|
484 |
|
|
485 |
# 1. Equivalent Length |
|
486 |
equivalent_length = self.get_equivalent_length() |
|
487 |
if equivalent_length is None: |
|
488 |
message = 'The equivalent length of stream <{}> is not inputted.'.format(self._hmb.stream_no) |
|
489 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
490 |
return result |
|
491 |
|
|
492 |
if self._hmb.flowrate_mass is None and self._hmb.flowrate_volume is None: |
|
493 |
message = 'You have to input mass or volume flowrate of stream <{}>.'.format(self._hmb.stream_no) |
|
494 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
495 |
return result |
|
496 |
|
|
497 |
if self._hmb.density is None: |
|
498 |
message = 'You have to input the density of stream <{}>.'.format(self._hmb.stream_no) |
|
499 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
500 |
return result |
|
501 |
|
|
502 |
if self._hmb.inside_pipe_size is None: |
|
503 |
message = 'You have to input the ID of stream <{}>.'.format(self._hmb.stream_no) |
|
504 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
505 |
return result |
|
506 |
|
|
507 |
if self._hmb.viscosity is None: |
|
508 |
message = 'You have to input the viscosity of stream <{}>.'.format(self._hmb.stream_no) |
|
509 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
510 |
return result |
|
511 |
|
|
512 |
if self._hmb.roughness is None: |
|
513 |
message = 'You have to input the roughness of stream <{}>.'.format(self._hmb.stream_no) |
|
514 |
App.mainWnd().addMessage.emit(MessageType.Information, message) |
|
515 |
return result |
|
516 |
|
|
517 |
return True |
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
562 | 522 |
def initUnits(self): |
563 |
activeDrawing = AppDocData.instance().activeDrawing |
|
564 |
|
|
565 |
for attr in activeDrawing.attrs: |
|
566 |
if attr[0] == 'Units': |
|
567 |
self.flowrate_mass_unit = attr[1]['Flowrate_Mass'] |
|
568 |
self.flowrate_volume_unit = attr[1]['Flowrate_Volume'] |
|
569 |
self.density_unit = attr[1]['Density'] |
|
570 |
self.viscosity_unit = attr[1]['Viscosity'] |
|
571 |
self.velocity_unit = attr[1]['Velocity'] |
|
572 |
self.pressure_unit = attr[1]['Pressure'] |
|
573 |
self.length_unit = attr[1]['Length'] |
|
574 |
self.pipe_diameter_unit = attr[1]['Pipe_Diameter'] |
|
575 |
self.roughness_unit = attr[1]['Roughness'] |
|
576 |
self.temperature_unit = attr[1]['Temperature'] |
|
523 |
try: |
|
524 |
activeDrawing = AppDocData.instance().activeDrawing |
|
525 |
|
|
526 |
for attr in activeDrawing.attrs: |
|
527 |
if attr[0] == 'Units': |
|
528 |
self.flowrate_mass_unit = attr[1]['Flowrate_Mass'] |
|
529 |
self.flowrate_volume_unit = attr[1]['Flowrate_Volume'] |
|
530 |
self.density_unit = attr[1]['Density'] |
|
531 |
self.viscosity_unit = attr[1]['Viscosity'] |
|
532 |
self.velocity_unit = attr[1]['Velocity'] |
|
533 |
self.pressure_unit = attr[1]['Pressure'] |
|
534 |
self.length_unit = attr[1]['Length'] |
|
535 |
self.pipe_diameter_unit = attr[1]['Pipe_Diameter'] |
|
536 |
self.roughness_unit = attr[1]['Roughness'] |
|
537 |
self.temperature_unit = attr[1]['Temperature'] |
|
538 |
except Exception as ex: |
|
539 |
from App import App |
|
540 |
from AppDocData import MessageType |
|
541 |
|
|
542 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
543 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
577 | 544 |
|
578 | 545 |
def getBarometricPressure(self): |
579 |
barometric_pressure = None |
|
580 |
|
|
546 |
|
|
581 | 547 |
if self.pressure_unit == 'kg/cm2': |
582 | 548 |
barometric_pressure = 1.033 |
583 | 549 |
elif self.pressure_unit == 'bar': |
... | ... | |
594 | 560 |
return barometric_pressure |
595 | 561 |
|
596 | 562 |
def calculation_Vapor(self): |
597 |
|
|
598 |
# (1) density 입력 |
|
599 |
|
|
600 |
Ref_baro = self.getBarometricPressure() |
|
563 |
try: |
|
564 |
# (1) density 입력 |
|
601 | 565 |
|
602 |
press2 = 100 # To쪽 Equipment의 Pressure |
|
603 |
|
|
604 |
# '여기에 아래의 p를 이용하여 density를 넣는 항을 만들어줘야함 |
|
605 |
# 'pressure를 k.g.a로 맞춤 |
|
606 |
if self.pressure_unit == 'kg/cm2': |
|
607 |
press2 = press2 + Ref_baro |
|
608 |
elif self.pressure_unit == 'psi': |
|
609 |
press2 = press2 / 14.7 * 1.033 + Ref_baro |
|
610 |
elif self.pressure_unit == 'atm': |
|
611 |
press2 = press2 * 1.033 + Ref_baro |
|
612 |
elif self.pressure_unit == 'bar': |
|
613 |
press2 = press2 / 1.013 * 1.033 + Ref_baro |
|
614 |
elif self.pressure_unit == 'mmHg': |
|
615 |
press2 = press2 / 760 * 1.033 + Ref_baro |
|
616 |
elif self.pressure_unit == 'kPa': |
|
617 |
press2 = press2 / 101.325 * 1.033 + Ref_baro |
|
618 |
elif self.pressure_unit == 'MPa': |
|
619 |
press2 = press2 / 0.101325 * 1.033 + Ref_baro |
|
620 |
|
|
621 |
# temp 가져오기 |
|
622 |
temp = self._hmb.temperature |
|
623 |
|
|
624 |
# temp를 kalvin으로 맞추기 |
|
625 |
if self.temperature_unit == '℃': |
|
626 |
temp = temp + 273.15 |
|
627 |
elif self.temperature_unit == '℉': |
|
628 |
temp = (temp - 32) / 1.8 + 273.15 |
|
566 |
Ref_baro = self.getBarometricPressure() |
|
629 | 567 |
|
630 |
# 'MW 가져오기 |
|
631 |
mw = self._hmb.molecular_weight |
|
568 |
press2 = 100 # To쪽 Equipment의 Pressure |
|
632 | 569 |
|
633 |
# 'Z 가져오기 |
|
634 |
z = self._hmb.compress_factor |
|
570 |
# '여기에 아래의 p를 이용하여 density를 넣는 항을 만들어줘야함 |
|
571 |
# 'pressure를 k.g.a로 맞춤 |
|
572 |
if self.pressure_unit == 'kg/cm2': |
|
573 |
press2 = press2 + Ref_baro |
|
574 |
elif self.pressure_unit == 'psi': |
|
575 |
press2 = press2 / 14.7 * 1.033 + Ref_baro |
|
576 |
elif self.pressure_unit == 'atm': |
|
577 |
press2 = press2 * 1.033 + Ref_baro |
|
578 |
elif self.pressure_unit == 'bar': |
|
579 |
press2 = press2 / 1.013 * 1.033 + Ref_baro |
|
580 |
elif self.pressure_unit == 'mmHg': |
|
581 |
press2 = press2 / 760 * 1.033 + Ref_baro |
|
582 |
elif self.pressure_unit == 'kPa': |
|
583 |
press2 = press2 / 101.325 * 1.033 + Ref_baro |
|
584 |
elif self.pressure_unit == 'MPa': |
|
585 |
press2 = press2 / 0.101325 * 1.033 + Ref_baro |
|
635 | 586 |
|
636 |
# 밀도 계산 |
|
637 |
density2 = press2 * mw / 0.08206 / temp / z / 1.033 |
|
587 |
# temp 가져오기 |
|
588 |
temp = self._hmb.temperature |
|
589 |
|
|
590 |
# temp를 kalvin으로 맞추기 |
|
591 |
if self.temperature_unit == '℃': |
|
592 |
temp = temp + 273.15 |
|
593 |
elif self.temperature_unit == '℉': |
|
594 |
temp = (temp - 32) / 1.8 + 273.15 |
|
638 | 595 |
|
639 |
# '밀도 입력 |
|
640 |
if self.density_unit == 'kg/m3': |
|
641 |
density2 = density2 |
|
642 |
elif self.density_unit == 'lb/ft3': |
|
643 |
density2 = density2 * 0.062428 |
|
596 |
# 'MW 가져오기 |
|
597 |
mw = self._hmb.molecular_weight |
|
644 | 598 |
|
599 |
# 'Z 가져오기 |
|
600 |
z = self._hmb.compress_factor |
|
645 | 601 |
|
602 |
# 밀도 계산 |
|
603 |
density2 = press2 * mw / 0.08206 / temp / z / 1.033 |
|
646 | 604 |
|
647 |
# (2) static P를 계산 |
|
648 |
# 1. density 받음 |
|
649 |
if self.density_unit == 'kg/m3': |
|
650 |
density2 = density2 |
|
651 |
elif self.density_unit == 'lb/ft3': |
|
652 |
density2 = density2 * 16.0185 |
|
605 |
# '밀도 입력 |
|
606 |
if self.density_unit == 'kg/m3': |
|
607 |
density2 = density2 |
|
608 |
elif self.density_unit == 'lb/ft3': |
|
609 |
density2 = density2 * 0.062428 |
|
653 | 610 |
|
654 |
# 2. elevation 받음 |
|
655 |
el1 = 200 # From쪽 Equipment의 Elevation |
|
656 |
el2 = 100 # To쪽 Equipment의 Elevation |
|
657 |
if self.length_unit == 'm': |
|
658 |
el1 = el1 |
|
659 |
el2 = el2 |
|
660 |
elif self.length_unit == "in": |
|
661 |
el1 = el1 * 0.0254 |
|
662 |
el2 = el2 * 0.0254 |
|
663 |
elif self.length_unit == "ft": |
|
664 |
el1 = el1 * 0.3048 |
|
665 |
el2 = el2 * 0.3048 |
|
666 |
elif self.length_unit == "yd": |
|
667 |
el1 = el1 * 0.9144 |
|
668 |
el2 = el2 * 0.9144 |
|
669 |
elif self.length_unit == "mm": |
|
670 |
el1 = el1 * 0.001 |
|
671 |
el2 = el2 * 0.001 |
|
672 |
elif self.length_unit == 'mile': |
|
673 |
el1 = el1 * 1609.34 |
|
674 |
el2 = el2 * 1609.34 |
|
675 | 611 |
|
676 |
# 3. static head 계산 |
|
677 |
# 'atm으로 계산된 dp |
|
678 |
stat_dp = (el2 - el1) * density2 / 1000 * 9.80665 / 101.325 |
|
679 | 612 |
|
680 |
# 4. 압력 유닛에 맞춰 뿌리기 |
|
681 |
if self.pressure_unit == 'kg/cm2': |
|
682 |
stat_dp = stat_dp * 1.033 |
|
683 |
elif self.pressure_unit == 'psi': |
|
684 |
stat_dp = stat_dp * 14.7 |
|
685 |
elif self.pressure_unit == 'atm': |
|
686 |
stat_dp = stat_dp |
|
687 |
elif self.pressure_unit == 'bar': |
|
688 |
stat_dp = stat_dp * 1.013 |
|
689 |
elif self.pressure_unit == 'mmHg': |
|
690 |
stat_dp = stat_dp * 1.013 |
|
691 |
elif self.pressure_unit == 'kPa': |
|
692 |
stat_dp = stat_dp * 101.325 |
|
693 |
elif self.pressure_unit == 'MPa': |
|
694 |
stat_dp = stat_dp * 0.101325 |
|
613 |
# (2) static P를 계산 |
|
614 |
# 1. density 받음 |
|
615 |
if self.density_unit == 'kg/m3': |
|
616 |
density2 = density2 |
|
617 |
elif self.density_unit == 'lb/ft3': |
|
618 |
density2 = density2 * 16.0185 |
|
695 | 619 |
|
620 |
# 2. elevation 받음 |
|
621 |
el1 = 200 # From쪽 Equipment의 Elevation |
|
622 |
el2 = 100 # To쪽 Equipment의 Elevation |
|
623 |
if self.length_unit == 'm': |
|
624 |
el1 = el1 |
|
625 |
el2 = el2 |
|
626 |
elif self.length_unit == "in": |
|
627 |
el1 = el1 * 0.0254 |
|
628 |
el2 = el2 * 0.0254 |
|
629 |
elif self.length_unit == "ft": |
|
630 |
el1 = el1 * 0.3048 |
|
631 |
el2 = el2 * 0.3048 |
|
632 |
elif self.length_unit == "yd": |
|
633 |
el1 = el1 * 0.9144 |
|
634 |
el2 = el2 * 0.9144 |
|
635 |
elif self.length_unit == "mm": |
|
636 |
el1 = el1 * 0.001 |
|
637 |
el2 = el2 * 0.001 |
|
638 |
elif self.length_unit == 'mile': |
|
639 |
el1 = el1 * 1609.34 |
|
640 |
el2 = el2 * 1609.34 |
|
696 | 641 |
|
697 |
# '(3) pressure drop 계산 |
|
698 |
# 'vapor인 경우 압력강하를 계산해주고 넣어주는 모듈 |
|
642 |
# 3. static head 계산 |
|
643 |
# 'atm으로 계산된 dp |
|
644 |
stat_dp = (el2 - el1) * density2 / 1000 * 9.80665 / 101.325 |
|
699 | 645 |
|
700 |
# '입력된 vapor의 압력과 밀도를 가지고 끊어서 계산하는 factor를 적용했을때 length가 얼마나 나오는지 판별하는 것. |
|
701 |
ida = self._hmb.inside_pipe_size |
|
702 |
if self.pipe_diameter_unit == 'in': |
|
703 |
ida = ida * 0.0254 |
|
704 |
elif self.pipe_diameter_unit == 'mm': |
|
705 |
ida = ida / 1000 |
|
706 |
|
|
707 |
# 'mass 가져오기 기준 kg/h |
|
708 |
mass = self._hmb.flowrate_mass |
|
709 |
if self.flowrate_mass_unit == 'kg/h': |
|
710 |
mass = mass |
|
711 |
elif self.flowrate_mass_unit == 'g/min': |
|
712 |
mass = mass * 60 / 1000 |
|
713 |
elif self.flowrate_mass_unit == 'lb/h': |
|
714 |
mass = mass * 0.453592 |
|
715 |
elif self.flowrate_mass_unit == 't/h': |
|
716 |
mass = mass * 1000 |
|
717 |
|
|
718 |
# 'g 구하기 (kg/m2/s) |
|
719 |
g = mass / 3600 / (3.1415 * ida ** 2 / 4) |
|
646 |
# 4. 압력 유닛에 맞춰 뿌리기 |
|
647 |
if self.pressure_unit == 'kg/cm2': |
|
648 |
stat_dp = stat_dp * 1.033 |
|
649 |
elif self.pressure_unit == 'psi': |
|
650 |
stat_dp = stat_dp * 14.7 |
|
651 |
elif self.pressure_unit == 'atm': |
|
652 |
stat_dp = stat_dp |
|
653 |
elif self.pressure_unit == 'bar': |
|
654 |
stat_dp = stat_dp * 1.013 |
|
655 |
elif self.pressure_unit == 'mmHg': |
|
656 |
stat_dp = stat_dp * 1.013 |
|
657 |
elif self.pressure_unit == 'kPa': |
|
658 |
stat_dp = stat_dp * 101.325 |
|
659 |
elif self.pressure_unit == 'MPa': |
|
660 |
stat_dp = stat_dp * 0.101325 |
|
720 | 661 |
|
721 |
# '속도 계산 (m/s) |
|
722 |
velocity = 4 * mass / density2 / 3.1415 / ida ** 2 / 3600 |
|
723 |
|
|
724 |
# 'k 가져오기 |
|
725 |
k = self._hmb.specific_heat_ratio |
|
726 |
|
|
727 |
# 'Mach Number 계산 |
|
728 |
mach = velocity / ((k * 9.80665 * 847.28 * temp / mw) ** 0.5) |
|
729 |
|
|
730 |
# '부피유량 계산 |
|
731 |
volume = mass / density2 |
|
732 |
|
|
733 |
# '현재 volume은 m3/h임. 부피유량 단위에 맞춰 뿌려줌 |
|
734 |
if self.flowrate_volume_unit == 'm3/h': |
|
735 |
volume = round(volume, 3) |
|
736 |
elif self.flowrate_volume_unit == 'l/min': |
|
737 |
volume = round(volume / 60 * 1000, 3) |
|
738 |
elif self.flowrate_volume_unit == 'ft3/h': |
|
739 |
volume = round(volume * 35.3147, 3) |
|
740 |
elif self.flowrate_volume_unit == 'USgpm': |
|
741 |
volume = round(volume * 4.40287, 3) |
|
742 |
elif self.flowrate_volume_unit == 'BPSD': |
|
743 |
volume = round(volume * 150.955, 3) |
|
744 |
|
|
745 |
viscosity = self._hmb.viscosity |
|
746 |
# ' viscosity 유닛 변환 (모두 kg/m.s로 바꿀것임) |
|
747 |
if self.viscosity_unit == 'kg/m.sec': |
|
748 |
viscosity = viscosity |
|
749 |
elif self.viscosity_unit == 'cP': |
|
750 |
viscosity = viscosity * 0.001 |
|
751 |
elif self.viscosity_unit == 'kg/m.h': |
|
752 |
viscosity = viscosity / 3600 |
|
753 |
elif self.viscosity_unit == 'lb/ft.sec': |
|
754 |
viscosity = viscosity * 1.48816 |
|
755 | 662 |
|
756 |
# 'density case에 따라 re계산 |
|
757 |
if self.density_unit == 'kg/m3': |
|
758 |
reynolds = ida * velocity * density2 / viscosity |
|
759 |
elif self.density_unit == 'lb/ft3': |
|
760 |
reynolds = ida * velocity * (density2 * 16.0185) / viscosity |
|
761 |
|
|
762 |
rough = self._hmb.roughness |
|
763 |
# 'roughness 를 m로 바꿔줌 |
|
764 |
if self.roughness_unit == 'm': |
|
765 |
rough = rough |
|
766 |
elif self.roughness_unit == 'ft': |
|
767 |
rough = rough * 0.3048 |
|
768 |
elif self.roughness_unit == 'in': |
|
769 |
rough = rough * 0.0254 |
|
770 |
elif self.roughness_unit == 'mm': |
|
771 |
rough = rough * 0.001 |
|
772 |
|
|
773 |
# ' reynolds수에 따라 Fanning/Chen friction factor 계산 |
|
774 |
if reynolds <= 2100: |
|
775 |
f = 4 * 16 / reynolds |
|
776 |
else: |
|
777 |
af = math.log(rough / ida / 3.7 + (6.7 / reynolds) ** 0.9) / math.log(10) |
|
778 |
f = (-2 * (math.log(rough / 3.7 / ida - 5.02 / reynolds * af) / math.log(10))) ** (-2) |
|
663 |
# '(3) pressure drop 계산 |
|
664 |
# 'vapor인 경우 압력강하를 계산해주고 넣어주는 모듈 |
|
779 | 665 |
|
780 |
# '속도와 마하 수 입력 |
|
781 |
if self.velocity_unit == 'm/s': |
|
782 |
self._hmb.velocity = round(velocity, 3) |
|
783 |
elif self.velocity_unit == 'ft/s': |
|
784 |
self._hmb.velocity = round(velocity * 3.28084, 3) |
|
666 |
# '입력된 vapor의 압력과 밀도를 가지고 끊어서 계산하는 factor를 적용했을때 length가 얼마나 나오는지 판별하는 것. |
|
667 |
ida = self._hmb.inside_pipe_size |
|
668 |
if self.pipe_diameter_unit == 'in': |
|
669 |
ida = ida * 0.0254 |
내보내기 Unified diff