프로젝트

일반

사용자정보

개정판 c746da3d

IDc746da3da04726c8f5073aa45843af3bb701c72d
상위 5e7a1307
하위 f5fb9c3d

김연진이(가) 약 5년 전에 추가함

issue #1200 : Vapor 계산식

Change-Id: I1a36b65cfbbf5eb182f42fec9656274e9b226b88

차이점 보기:

HYTOS/HYTOS/Calculation.py
10 10
from EngineeringConnectorItem import QEngineeringConnectorItem
11 11
from SymbolSvgItem import SymbolSvgItem
12 12

  
13

  
13 14
class Conversion:
14 15
    def __init__(self, decimal):
15 16
        self._decimal = decimal
16
        
17

  
17 18
        self.pre_units = {}
18 19
        self.cur_units = {}
19 20

  
......
30 31
        try:
31 32
            app_doc_data = AppDocData.instance()
32 33
            drawing = app_doc_data.activeDrawing
33
                
34

  
34 35
            hmbs = drawing.hmbTable._hmbs
35
            if hmbs is not None:            
36
                for hmb in hmbs:     
36
            if hmbs is not None:
37
                for hmb in hmbs:
37 38
                    if hmb.flowrate_mass:
38 39
                        hmb.flowrate_mass = self.convert_flowrate_mass(hmb.flowrate_mass)
39 40
                    if hmb.flowrate_volume:
......
80 81
        except Exception as ex:
81 82
            from App import App
82 83
            from AppDocData import MessageType
83
            
84
            message = 'error occurred({}) 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 84

  
85
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
86
                                                           sys.exc_info()[-1].tb_lineno)
87
            App.mainWnd().addMessage.emit(MessageType.Error, message)
87 88

  
88
    def convert_flowrate_mass(self, value):               
89
    def convert_flowrate_mass(self, value):
89 90
        pre_unit = self.pre_units['Flowrate_Mass']
90 91
        cur_unit = self.cur_units['Flowrate_Mass']
91 92

  
......
93 94
            return value
94 95

  
95 96
        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
97
            if cur_unit == 'g/min':
98
                convert_factor = 16.6667
99
            elif cur_unit == 'lb/h':
100
                convert_factor = 2.2046
101
            elif cur_unit == 't/h':
102
                convert_factor = 0.001
99 103
        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
104
            if cur_unit == 'kg/h':
105
                convert_factor = 1 / 16.6667
106
            elif cur_unit == 'lb/h':
107
                convert_factor = 0.132277
108
            elif cur_unit == 't/h':
109
                convert_factor = 0.00006
103 110
        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
111
            if cur_unit == 'kg/h':
112
                convert_factor = 1 / 2.2046
113
            elif cur_unit == 'g/min':
114
                convert_factor = 1 / 0.132277
115
            elif cur_unit == 't/h':
116
                convert_factor = 0.0004536
107 117
        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
118
            if cur_unit == 'kg/h':
119
                convert_factor = 1 / 0.001
120
            elif cur_unit == 'g/min':
121
                convert_factor = 1 / 0.00006
122
            elif cur_unit == 'lb/h':
123
                convert_factor = 1 / 0.0004536
111 124

  
112 125
        return round(value * convert_factor, self._decimal)
113 126

  
......
119 132
            return value
120 133

  
121 134
        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
135
            if cur_unit == 'l/min':
136
                convert_factor = 16.6667
137
            elif cur_unit == 'ft3/h':
138
                convert_factor = 35.31466
139
            elif cur_unit == 'USgpm':
140
                convert_factor = 4.402867
141
            elif cur_unit == 'BPSD':
142
                convert_factor = 150.955464
126 143
        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
144
            if cur_unit == 'm3/h':
145
                convert_factor = 1 / 16.6667
146
            elif cur_unit == 'ft3/h':
147
                convert_factor = 2.1188796
148
            elif cur_unit == 'USgpm':
149
                convert_factor = 0.264172
150
            elif cur_unit == 'BPSD':
151
                convert_factor = 9.05732784
131 152
        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
153
            if cur_unit == 'm3/h':
154
                convert_factor = 1 / 35.31466
155
            elif cur_unit == 'l/min':
156
                convert_factor = 1 / 2.1188796
157
            elif cur_unit == 'USgpm':
158
                convert_factor = 0.124675333
159
            elif cur_unit == 'BPSD':
160
                convert_factor = 9.05732784
136 161
        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
162
            if cur_unit == 'm3/h':
163
                convert_factor = 1 / 4.402867
164
            elif cur_unit == 'l/min':
165
                convert_factor = 1 / 0.264172
166
            elif cur_unit == 'ft3/h':
167
                convert_factor = 1 / 0.124675333
168
            elif cur_unit == 'BPSD':
169
                convert_factor = 34.2857088
141 170
        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
171
            if cur_unit == 'm3/h':
172
                convert_factor = 1 / 150.955464
173
            elif cur_unit == 'l/min':
174
                convert_factor = 1 / 9.05732784
175
            elif cur_unit == 'ft3/h':
176
                convert_factor = 1 / 4.2745824
177
            elif cur_unit == 'USgpm':
178
                convert_factor = 1 / 34.2857088
146 179

  
147 180
        return round(value * convert_factor, self._decimal)
148 181

  
149

  
150 182
    def convert_density(self, value):
151 183
        pre_unit = self.pre_units['Density']
152 184
        cur_unit = self.cur_units['Density']
......
155 187
            return value
156 188

  
157 189
        if pre_unit == 'kg/m3':
158
            if cur_unit == 'lb/ft3': convert_factor = 0.06242797            
190
            if cur_unit == 'lb/ft3': convert_factor = 0.06242797
159 191
        elif pre_unit == 'lb/ft3':
160
            if cur_unit == 'kg/m3': convert_factor =1 / 0.06242797
161
                    
192
            if cur_unit == 'kg/m3': convert_factor = 1 / 0.06242797
193

  
162 194
        return round(value * convert_factor, self._decimal)
163 195

  
164 196
    def convert_viscosity(self, value):
......
169 201
            return value
170 202

  
171 203
        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     
204
            if cur_unit == 'kg/m.sec':
205
                convert_factor = 0.001
206
            elif cur_unit == 'kg/m.h':
207
                convert_factor = 3.6
208
            elif cur_unit == 'lb/ft.sec':
209
                convert_factor = 0.000671969
175 210
        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  
211
            if cur_unit == 'cP':
212
                convert_factor = 1 / 0.001
213
            elif cur_unit == 'kg/m.h':
214
                convert_factor = 3600
215
            elif cur_unit == 'lb/ft.sec':
216
                convert_factor = 0.671969
179 217
        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  
218
            if cur_unit == 'cP':
219
                convert_factor = 1 / 3.6
220
            elif cur_unit == 'kg/m.sec':
221
                convert_factor = 1 / 3600
222
            elif cur_unit == 'lb/ft.sec':
223
                convert_factor = 0.000186658
183 224
        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  
187
                            
225
            if cur_unit == 'cP':
226
                convert_factor = 1 / 0.000671969
227
            elif cur_unit == 'kg/m.sec':
228
                convert_factor = 1 / 0.671969
229
            elif cur_unit == 'kg/m.h':
230
                convert_factor = 1 / 0.000186658
231

  
188 232
        return round(value * convert_factor, self._decimal)
189 233

  
190 234
    def convert_temperature(self, value):
......
193 237

  
194 238
        if pre_unit == cur_unit:
195 239
            return value
196
    
240

  
197 241
        if cur_unit == '℉':
198
            return round(1.8 * value + 32, self._decimal)     
242
            return round(1.8 * value + 32, self._decimal)
199 243
        elif cur_unit == '℃':
200
            return round((value - 32) / 1.8, self._decimal)       
244
            return round((value - 32) / 1.8, self._decimal)
201 245

  
202 246
    def convert_pipe_diameter(self, value):
203 247
        pre_unit = self.pre_units['Pipe_Diameter']
......
205 249

  
206 250
        if pre_unit == cur_unit:
207 251
            return value
208
        
252

  
209 253
        if pre_unit == 'in':
210
            if cur_unit == 'mm': convert_factor = 25.4                     
254
            if cur_unit == 'mm': convert_factor = 25.4
211 255
        elif pre_unit == 'mm':
212 256
            if cur_unit == 'in': convert_factor = 1 / 25.4
213 257

  
214
        return round(value * convert_factor, self._decimal)         
258
        return round(value * convert_factor, self._decimal)
215 259

  
216 260
    def convert_length(self, value):
217 261
        pre_unit = self.pre_units['Length']
......
221 265
            return value
222 266

  
223 267
        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                  
268
            if cur_unit == 'm':
269
                convert_factor = 0.0254
270
            elif cur_unit == 'ft':
271
                convert_factor = 0.083333
272
            elif cur_unit == 'yd':
273
                convert_factor = 0.0277778
274
            elif cur_unit == 'mile':
275
                convert_factor = 0.00001578283
276
            elif cur_unit == 'mm':
277
                convert_factor = 25.4
229 278
        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
279
            if cur_unit == 'in':
280
                convert_factor = 1 / 0.0254
281
            elif cur_unit == 'ft':
282
                convert_factor = 3.28084
283
            elif cur_unit == 'yd':
284
                convert_factor = 1.093613
285
            elif cur_unit == 'mile':
286
                convert_factor = 0.000621371
287
            elif cur_unit == 'mm':
288
                convert_factor = 1000
235 289
        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
290
            if cur_unit == 'in':
291
                convert_factor = 1 / 0.083333
292
            elif cur_unit == 'm':
293
                convert_factor = 1 / 3.28084
294
            elif cur_unit == 'yd':
295
                convert_factor = 0.33333
296
            elif cur_unit == 'mile':
297
                convert_factor = 0.000189394
298
            elif cur_unit == 'mm':
299
                convert_factor = 304.8
241 300
        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
301
            if cur_unit == 'in':
302
                convert_factor = 1 / 0.277778
303
            elif cur_unit == 'm':
304
                convert_factor = 1 / 1.093613
305
            elif cur_unit == 'ft':
306
                convert_factor = 1 / 0.33333
307
            elif cur_unit == 'mile':
308
                convert_factor = 0.000568182
309
            elif cur_unit == 'mm':
310
                convert_factor = 914.4
247 311
        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
312
            if cur_unit == 'in':
313
                convert_factor = 1 / 0.00001578283
314
            elif cur_unit == 'm':
315
                convert_factor = 1 / 0.000621371
316
            elif cur_unit == 'ft':
317
                convert_factor = 1 / 0.000189394
318
            elif cur_unit == 'yd':
319
                convert_factor = 1 / 0.000568182
320
            elif cur_unit == 'mm':
321
                convert_factor = 1609344
253 322
        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
323
            if cur_unit == 'in':
324
                convert_factor = 1 / 25.4
325
            elif cur_unit == 'm':
326
                convert_factor = 1 / 1000
327
            elif cur_unit == 'ft':
328
                convert_factor = 1 / 304.8
329
            elif cur_unit == 'yd':
330
                convert_factor = 1 / 914.4
331
            elif cur_unit == 'mile':
332
                convert_factor = 1 / 1609344
259 333

  
260
        return round(value * convert_factor, self._decimal)           
334
        return round(value * convert_factor, self._decimal)
261 335

  
262 336
    def convert_roughness(self, value):
263 337
        pre_unit = self.pre_units['Roughness']
......
267 341
            return value
268 342

  
269 343
        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
344
            if cur_unit == 'm':
345
                convert_factor = 0.0254
346
            elif cur_unit == 'ft':
347
                convert_factor = 0.083333
348
            elif cur_unit == 'mm':
349
                convert_factor = 25.4
273 350
        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
351
            if cur_unit == 'in':
352
                convert_factor = 1 / 0.0254
353
            elif cur_unit == 'ft':
354
                convert_factor = 3.28084
355
            elif cur_unit == 'mm':
356
                convert_factor = 1000
277 357
        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
358
            if cur_unit == 'in':
359
                convert_factor = 1 / 0.083333
360
            elif cur_unit == 'm':
361
                convert_factor = 1 / 3.28084
362
            elif cur_unit == 'mm':
363
                convert_factor = 304.8
281 364
        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             
365
            if cur_unit == 'in':
366
                convert_factor = 1 / 25.4
367
            elif cur_unit == 'm':
368
                convert_factor = 1 / 1000
369
            elif cur_unit == 'ft':
370
                convert_factor = 1 / 304.8
285 371

  
286
        return round(value * convert_factor, self._decimal)   
372
        return round(value * convert_factor, self._decimal)
287 373

  
288 374
    def convert_velocity(self, value):
289 375
        pre_unit = self.pre_units['Velocity']
......
293 379
            return value
294 380

  
295 381
        if pre_unit == 'm/s':
296
            if cur_unit == 'ft/s': convert_factor = 3.28084                     
382
            if cur_unit == 'ft/s': convert_factor = 3.28084
297 383
        elif pre_unit == 'ft/s':
298
            if cur_unit == 'm/s': convert_factor = 1 / 3.28084      
384
            if cur_unit == 'm/s': convert_factor = 1 / 3.28084
299 385

  
300
        return round(value * convert_factor, self._decimal)        
386
        return round(value * convert_factor, self._decimal)
301 387

  
302 388
    def convert_pressure(self, value):
303 389
        pre_unit = self.pre_units['Pressure']
......
307 393
            return value
308 394

  
309 395
        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     
396
            if cur_unit == 'psi':
397
                convert_factor = 14.22334
398
            elif cur_unit == 'atm':
399
                convert_factor = 0.9678411
400
            elif cur_unit == 'bar':
401
                convert_factor = 0.980665
402
            elif cur_unit == 'mmHg':
403
                convert_factor = 735.5591
404
            elif cur_unit == 'kPa':
405
                convert_factor = 98.0665
406
            elif cur_unit == 'MPa':
407
                convert_factor = 0.0980665
316 408
        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 
409
            if cur_unit == 'kg/cm2':
410
                convert_factor = 1 / 14.22334
411
            elif cur_unit == 'atm':
412
                convert_factor = 0.06804596
413
            elif cur_unit == 'bar':
414
                convert_factor = 0.06894757
415
            elif cur_unit == 'mmHg':
416
                convert_factor = 51.71492
417
            elif cur_unit == 'kPa':
418
                convert_factor = 6.894757
419
            elif cur_unit == 'MPa':
420
                convert_factor = 0.006894757
323 421
        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 
422
            if cur_unit == 'kg/cm2':
423
                convert_factor = 1 / 0.9678411
424
            elif cur_unit == 'psi':
425
                convert_factor = 1 / 0.06804596
426
            elif cur_unit == 'bar':
427
                convert_factor = 1.01325
428
            elif cur_unit == 'mmHg':
429
                convert_factor = 759.9998
430
            elif cur_unit == 'kPa':
431
                convert_factor = 101.325
432
            elif cur_unit == 'MPa':
433
                convert_factor = 0.101325
330 434
        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
435
            if cur_unit == 'kg/cm2':
436
                convert_factor = 1 / 0.980665
437
            elif cur_unit == 'psi':
438
                convert_factor = 1 / 0.06894757
439
            elif cur_unit == 'atm':
440
                convert_factor = 1 / 1.01325
441
            elif cur_unit == 'mmHg':
442
                convert_factor = 750.0615
443
            elif cur_unit == 'kPa':
444
                convert_factor = 100
445
            elif cur_unit == 'MPa':
446
                convert_factor = 0.1
337 447
        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
448
            if cur_unit == 'kg/cm2':
449
                convert_factor = 1 / 735.5591
450
            elif cur_unit == 'psi':
451
                convert_factor = 1 / 51.71492
452
            elif cur_unit == 'atm':
453
                convert_factor = 1 / 759.9998
454
            elif cur_unit == 'bar':
455
                convert_factor = 1 / 750.0615
456
            elif cur_unit == 'kPa':
457
                convert_factor = 0.1333224
458
            elif cur_unit == 'MPa':
459
                convert_factor = 0.0001333224
344 460
        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
461
            if cur_unit == 'kg/cm2':
462
                convert_factor = 1 / 98.0665
463
            elif cur_unit == 'psi':
464
                convert_factor = 1 / 6.894757
465
            elif cur_unit == 'atm':
466
                convert_factor = 1 / 101.325
467
            elif cur_unit == 'bar':
468
                convert_factor = 1 / 100
469
            elif cur_unit == 'mmHg':
470
                convert_factor = 1 / 0.1333224
471
            elif cur_unit == 'MPa':
472
                convert_factor = 1 / 1000
351 473
        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
    
474
            if cur_unit == 'kg/cm2':
475
                convert_factor = 1 / 98.0665 * 1000
476
            elif cur_unit == 'psi':
477
                convert_factor = 1 / 6.894757 * 1000
478
            elif cur_unit == 'atm':
479
                convert_factor = 1 / 101.325 * 1000
480
            elif cur_unit == 'bar':
481
                convert_factor = 1 / 100 * 1000
482
            elif cur_unit == 'mmHg':
483
                convert_factor = 1 / 0.1333224 * 1000
484
            elif cur_unit == 'kPa':
485
                convert_factor = 1  # 기존 소스에 없음
486

  
487
        return round(value * convert_factor, self._decimal)
488

  
361 489
    def convert_power(self, value):
362 490
        pre_unit = self.pre_units['Power']
363 491
        cur_unit = self.cur_units['Power']
......
366 494
            return value
367 495

  
368 496
        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                
497
            if cur_unit == 'kcal/h':
498
                convert_factor = 860.4207
499
            elif cur_unit == 'btu/h':
500
                convert_factor = 3414.425
501
            elif cur_unit == 'Hp':
502
                convert_factor = 1.359622
503
            elif cur_unit == 'kg.m/sec':
504
                convert_factor = 101.9716
505
            elif cur_unit == 'ft.lb/sec':
506
                convert_factor = 737.5621
374 507
        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     
508
            if cur_unit == 'kW':
509
                convert_factor = 1 / 860.4207
510
            elif cur_unit == 'btu/h':
511
                convert_factor = 3.96832
512
            elif cur_unit == 'Hp':
513
                convert_factor = 0.001580182
514
            elif cur_unit == 'kg.m/sec':
515
                convert_factor = 0.1185137
516
            elif cur_unit == 'ft.lb/sec':
517
                convert_factor = 0.857211
380 518
        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
519
            if cur_unit == 'kW':
520
                convert_factor = 1 / 3414.425
521
            elif cur_unit == 'kcal/h':
522
                convert_factor = 1 / 3.96832
523
            elif cur_unit == 'Hp':
524
                convert_factor = 0.000398199
525
            elif cur_unit == 'kg.m/sec':
526
                convert_factor = 0.02986495
527
            elif cur_unit == 'ft.lb/sec':
528
                convert_factor = 0.2160136
386 529
        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
530
            if cur_unit == 'kW':
531
                convert_factor = 11 / 1.359622
532
            elif cur_unit == 'kcal/h':
533
                convert_factor = 1 / 0.001580182
534
            elif cur_unit == 'btu/h':
535
                convert_factor = 1 / 0.000398199
536
            elif cur_unit == 'kg.m/sec':
537
                convert_factor = 75.00001
538
            elif cur_unit == 'ft.lb/sec':
539
                convert_factor = 542.4761
392 540
        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
541
            if cur_unit == 'kW':
542
                convert_factor = 1 / 101.9716
543
            elif cur_unit == 'kcal/h':
544
                convert_factor = 1 / 0.1185137
545
            elif cur_unit == 'btu/h':
546
                convert_factor = 1 / 0.02986495
547
            elif cur_unit == 'Hp':
548
                convert_factor = 1 / 75.00001
549
            elif cur_unit == 'ft.lb/sec':
550
                convert_factor = 7.233014
398 551
        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)    
552
            if cur_unit == 'kW':
553
                convert_factor = 1 / 737.5621
554
            elif cur_unit == 'kcal/h':
555
                convert_factor = 1 / 0.857211
556
            elif cur_unit == 'btu/h':
557
                convert_factor = 1 / 0.2160136
558
            elif cur_unit == 'Hp':
559
                convert_factor = 1 / 542.4761
560
            elif cur_unit == 'kg.m/sec':
561
                convert_factor = 1 / 7.233014
406 562

  
563
        return round(value * convert_factor, self._decimal)
407 564

  
408 565
    def convert_Nozzle(self):
409 566
        from App import App
......
414 571
            for item in items:
415 572
                for connector in item.connectors:
416 573
                    if connector.data.pressure:
417
                        connector.data.pressure= self.convert_pressure(connector.data.pressure)
574
                        connector.data.pressure = self.convert_pressure(connector.data.pressure)
418 575
                    if connector.data.pressure_drop:
419
                        connector.data.pressure_drop= self.convert_pressure(connector.data.pressure_drop)
576
                        connector.data.pressure_drop = self.convert_pressure(connector.data.pressure_drop)
420 577
                    if connector.data.elevation:
421
                        connector.data.elevation= self.convert_length(connector.data.elevation)                    
578
                        connector.data.elevation = self.convert_length(connector.data.elevation)
422 579
        except Exception as ex:
423 580
            from App import App
424 581
            from AppDocData import MessageType
425
            
426
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
582

  
583
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
584
                                                           sys.exc_info()[-1].tb_lineno)
427 585
            App.mainWnd().addMessage.emit(MessageType.Error, message)
428 586

  
429 587
    def getCurrentUnits(self):
......
436 594
        except Exception as ex:
437 595
            from App import App
438 596
            from AppDocData import MessageType
439
            
440
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
597

  
598
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
599
                                                           sys.exc_info()[-1].tb_lineno)
441 600
            App.mainWnd().addMessage.emit(MessageType.Error, message)
442 601

  
443 602
    def getPreviousUnits(self):
......
448 607
            for attr in activeDrawing.attrs:
449 608
                if attr[0] == 'Units':
450 609
                    self.pre_units = attr[1]
451
                    
610

  
452 611
        except Exception as ex:
453 612
            from App import App
454 613
            from AppDocData import MessageType
455
            
456
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
614

  
615
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
616
                                                           sys.exc_info()[-1].tb_lineno)
457 617
            App.mainWnd().addMessage.emit(MessageType.Error, message)
458 618

  
619

  
459 620
class Calculation:
460 621
    def __init__(self, hmb):
461
        self.initUnits()
462 622
        self._hmb = hmb
463
                    
623
        self.units = {}
624

  
625
        self.init_units()
626

  
627
        if self._hmb.phase_type == 'Liquid':
628
            if self.validation_check_Liquid():
629
                self.calculation_Liquid()
630

  
631
        '''    
464 632
        if self._hmb.phase_type == 'Vapor':
465
            self.calculation_Vapor()
633
            if self.validation_check_vapor():
634
                self.calculation_Vapor()
466 635
        elif self._hmb.phase_type == 'Liquid':
467 636
            if self.validation_check_Liquid():
468 637
                self.calculation_Liquid()
469 638
        elif self._hmb.phase_type == 'Mixed':
470 639
            self.calculation_Mixed()
471
    
640
        '''
472 641

  
473 642
    def get_equivalent_length(self):
474 643
        if self._hmb.equivalent_length_input:
......
476 645
        else:
477 646
            return self._hmb.equivalent_length_cal
478 647

  
648
    def validation_check_vapor(self):
649
        result = False
650

  
651
        if self._hmb.inside_pipe_size is None:
652
            message = 'You have to input the ID of stream <{}>.'.format(self._hmb.stream_no)
653
            App.mainWnd().addMessage.emit(MessageType.Information, message)
654
            return result
655

  
656
        if self._hmb.flowrate_mass is None:
657
            message = 'You have to input mass flowrate of stream <{}>.'.format(self._hmb.stream_no)
658
            App.mainWnd().addMessage.emit(MessageType.Information, message)
659
            return result
660

  
661
        if self._hmb.specific_heat_ratio is None:
662
            message = 'You have to input the specific heat ratio of stream <{}>.'.format(self._hmb.stream_no)
663
            App.mainWnd().addMessage.emit(MessageType.Information, message)
664
            return result
665

  
666
        if self._hmb.viscosity is None:
667
            message = 'You have to input the viscosity of stream <{}>.'.format(self._hmb.stream_no)
668
            App.mainWnd().addMessage.emit(MessageType.Information, message)
669
            return result
670

  
671
        if self._hmb.roughness is None:
672
            message = 'You have to input the roughness of stream <{}>.'.format(self._hmb.stream_no)
673
            App.mainWnd().addMessage.emit(MessageType.Information, message)
674
            return result
675

  
676
        return True
677

  
479 678
    def validation_check_Liquid(self):
480 679
        from App import App
481 680
        from AppDocData import MessageType
482
        
681

  
483 682
        result = False
484 683

  
485 684
        # 1.  Equivalent Length
......
493 692
            message = 'You have to input mass or volume flowrate of stream <{}>.'.format(self._hmb.stream_no)
494 693
            App.mainWnd().addMessage.emit(MessageType.Information, message)
495 694
            return result
496
        
695

  
497 696
        if self._hmb.density is None:
498 697
            message = 'You have to input the density of stream <{}>.'.format(self._hmb.stream_no)
499 698
            App.mainWnd().addMessage.emit(MessageType.Information, message)
......
515 714
            return result
516 715

  
517 716
        return True
518
        
519

  
520 717

  
521

  
522
    def initUnits(self):
718
    def init_units(self):
523 719
        try:
524
            activeDrawing = AppDocData.instance().activeDrawing
720
            app_doc_data = AppDocData.instance()
721
            self.units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
525 722

  
526
            for attr in activeDrawing.attrs:
723
            '''
724
            for attr in app_doc_data.attrs:
527 725
                if attr[0] == 'Units':
528
                    self.flowrate_mass_unit = attr[1]['Flowrate_Mass']                
726
                    self.flowrate_mass_unit = attr[1]['Flowrate_Mass']
529 727
                    self.flowrate_volume_unit = attr[1]['Flowrate_Volume']
530 728
                    self.density_unit = attr[1]['Density']
531
                    self.viscosity_unit = attr[1]['Viscosity']                
729
                    self.viscosity_unit = attr[1]['Viscosity']
532 730
                    self.velocity_unit = attr[1]['Velocity']
533 731
                    self.pressure_unit = attr[1]['Pressure']
534 732
                    self.length_unit = attr[1]['Length']
535
                    self.pipe_diameter_unit = attr[1]['Pipe_Diameter']                
536
                    self.roughness_unit = attr[1]['Roughness']                
733
                    self.pipe_diameter_unit = attr[1]['Pipe_Diameter']
734
                    self.roughness_unit = attr[1]['Roughness']
537 735
                    self.temperature_unit = attr[1]['Temperature']
736
            '''
538 737
        except Exception as ex:
539 738
            from App import App
540 739
            from AppDocData import MessageType
541
            
542
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
740

  
741
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
742
                                                           sys.exc_info()[-1].tb_lineno)
543 743
            App.mainWnd().addMessage.emit(MessageType.Error, message)
544 744

  
545 745
    def getBarometricPressure(self):
546
        
547
        if self.pressure_unit == 'kg/cm2':
746
        pressure_unit = self.units['Pressure']
747

  
748
        if pressure_unit == 'kg/cm2':
548 749
            barometric_pressure = 1.033
549
        elif self.pressure_unit == 'bar':
750
        elif pressure_unit == 'bar':
550 751
            barometric_pressure = 1.01325
551
        elif self.pressure_unit == 'psi':
752
        elif pressure_unit == 'psi':
552 753
            barometric_pressure = 14.7
553
        elif self.pressure_unit == 'mmHg':
754
        elif pressure_unit == 'mmHg':
554 755
            barometric_pressure = 760
555
        elif self.pressure_unit == 'kPa':
756
        elif pressure_unit == 'kPa':
556 757
            barometric_pressure = 101.325
557
        elif self.pressure_unit == 'MPa':
758
        elif pressure_unit == 'MPa':
558 759
            barometric_pressure = 0.101325
559 760

  
560 761
        return barometric_pressure
561 762

  
562
    def calculation_Vapor(self):  
563
        try:
564
            # (1) density 입력
565

  
566
            Ref_baro = self.getBarometricPressure()
567

  
568
            press2 = 100 # To쪽 Equipment의 Pressure
569

  
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
586

  
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
595

  
596
            # 'MW 가져오기
597
            mw = self._hmb.molecular_weight
598

  
599
            # 'Z 가져오기
600
            z = self._hmb.compress_factor
601

  
602
            # 밀도 계산
603
            density2 = press2 * mw / 0.08206 / temp / z / 1.033
604

  
605
            # '밀도 입력
606
            if self.density_unit == 'kg/m3':
607
                density2 = density2
608
            elif self.density_unit == 'lb/ft3':
609
                density2 = density2 * 0.062428
610

  
611

  
612

  
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
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
641

  
642
            # 3. static head 계산 
643
            # 'atm으로 계산된 dp
644
            stat_dp = (el2 - el1) * density2 / 1000 * 9.80665 / 101.325 
645

  
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
661

  
662

  
663
            # '(3) pressure drop 계산
664
            # 'vapor인 경우 압력강하를 계산해주고 넣어주는 모듈
665

  
666
            # '입력된 vapor의 압력과 밀도를 가지고 끊어서 계산하는 factor를 적용했을때 length가 얼마나 나오는지 판별하는 것.
667
            ida = self._hmb.inside_pipe_size
668
            if self.pipe_diameter_unit == 'in':
669
                ida = ida * 0.0254
670
            elif self.pipe_diameter_unit == 'mm':
671
                ida = ida / 1000
672

  
673
            # 'mass 가져오기 기준 kg/h
674
            mass = self._hmb.flowrate_mass
675
            if self.flowrate_mass_unit == 'kg/h':
676
                mass = mass
677
            elif self.flowrate_mass_unit == 'g/min':
678
                mass = mass * 60 / 1000
679
            elif self.flowrate_mass_unit == 'lb/h':
680
                mass = mass * 0.453592
681
            elif self.flowrate_mass_unit == 't/h':
682
                mass = mass * 1000
683
            
684
            # 'g 구하기 (kg/m2/s)
685
            g = mass / 3600 / (3.1415 * ida ** 2 / 4)
686

  
687
            # '속도 계산 (m/s)
688
            velocity = 4 * mass / density2 / 3.1415 / ida ** 2 / 3600
689

  
690
            # 'k 가져오기
691
            k = self._hmb.specific_heat_ratio
692

  
693
            # 'Mach Number 계산
694
            mach = velocity / ((k * 9.80665 * 847.28 * temp / mw) ** 0.5)
695

  
696
            # '부피유량 계산
697
            volume = mass / density2
698

  
699
            # '현재 volume은 m3/h임. 부피유량 단위에 맞춰 뿌려줌
700
            if self.flowrate_volume_unit == 'm3/h':
701
                volume = round(volume, 3)    
702
            elif self.flowrate_volume_unit == 'l/min':
703
                volume = round(volume / 60 * 1000, 3)
704
            elif self.flowrate_volume_unit == 'ft3/h':
705
                volume = round(volume * 35.3147, 3)
706
            elif self.flowrate_volume_unit == 'USgpm':
707
                volume = round(volume * 4.40287, 3)
708
            elif self.flowrate_volume_unit == 'BPSD':
709
                volume = round(volume * 150.955, 3)
710

  
711
            viscosity = self._hmb.viscosity
712
            # ' viscosity 유닛 변환 (모두 kg/m.s로 바꿀것임)
713
            if self.viscosity_unit == 'kg/m.sec':
714
                viscosity = viscosity
715
            elif self.viscosity_unit == 'cP':
716
                viscosity = viscosity * 0.001
717
            elif self.viscosity_unit == 'kg/m.h':
718
                viscosity = viscosity / 3600
719
            elif self.viscosity_unit == 'lb/ft.sec':
720
                viscosity = viscosity * 1.48816
721

  
722
            # 'density case에 따라 re계산
723
            if self.density_unit == 'kg/m3':
724
                reynolds = ida * velocity * density2 / viscosity
725
            elif self.density_unit == 'lb/ft3':
726
                reynolds = ida * velocity * (density2 * 16.0185) / viscosity
727

  
728
            rough = self._hmb.roughness
729
            # 'roughness 를 m로 바꿔줌
730
            if self.roughness_unit == 'm':
731
                rough = rough
732
            elif self.roughness_unit == 'ft':
733
                rough = rough * 0.3048
734
            elif self.roughness_unit == 'in':
735
                rough = rough * 0.0254
736
            elif self.roughness_unit == 'mm':
737
                rough = rough * 0.001
738

  
739
            # ' reynolds수에 따라 Fanning/Chen friction factor 계산
740
            if reynolds <= 2100:
741
                f = 4 * 16 / reynolds
742
            else:
743
                af = math.log(rough / ida / 3.7 + (6.7 / reynolds) ** 0.9) / math.log(10)
744
                f = (-2 * (math.log(rough / 3.7 / ida - 5.02 / reynolds * af) / math.log(10))) ** (-2)
745

  
746
            # '속도와 마하 수 입력
747
            if self.velocity_unit == 'm/s':
748
                self._hmb.velocity = round(velocity, 3)
749
            elif self.velocity_unit == 'ft/s':
750
                self._hmb.velocity = round(velocity * 3.28084, 3)
751

  
752
            self._hmb.reynolds = round(mach, 5)
753

  
754

  
755
            press1est = press2 / 0.95 #HY_Calc_sht.Cells(2, 1)
756
            density1est = press1est * mw / 0.08206 / temp / z / 1.033
757

  
758
            # ' 라인 길이 도출 (m)
759
            estlength = (((press1est ** 2 - press2 ** 2) * mw / g ** 2 / 0.08206 / 1.033 ** 2 / temp / z * 101325) - (2 * math.log(density1est / density2))) * ida / f
760

  
761
            # '라인 길이를 유닛에 맞춰서 변환
762
            if self.length_unit == 'm':
763
                estlength = estlength
764
            elif self.length_unit == 'in':
765
                estlength = estlength * 39.3701
766
            elif self.length_unit == 'ft':
767
                estlength = estlength * 3.28084
768
            elif self.length_unit == 'yd':
769
                estlength = estlength * 1.09361
770
            elif self.length_unit == 'mile':
771
                estlength = estlength * 0.000621371
772
            elif self.length_unit == 'mm':
773
                estlength = estlength * 1000
774
            
775
            equivalent_length = self.get_equivalent_length()
776
            if estlength > equivalent_length:
777
                # '주어진 길이를 가지고 압력 강하를 계산하는 모듈이 들어가야함 (safe)
778
                # ' length 여유 있음. 한번에 isothermal 식으로 계산
779

  
780

  
781
                # ' 끊은 결과 length가 여유가 있음. 그래서 단순 계산하는 모듈
782
                length = equivalent_length
783

  
784
                # 'length 를 m로 변환
785
                if self.length_unit == 'm':
786
                    length = length
787
                elif self.length_unit == 'in':
788
                    length = length * 0.0254
789
                elif self.length_unit == 'ft':
790
                    length = length * 0.3048
791
                elif self.length_unit == 'yd':
792
                    length = length * 0.9144
793
                elif self.length_unit == 'mile':
794
                    length = length * 1609.34
795
                elif self.length_unit == 'mm':
796
                    length = length * 0.001
797
                
798
                # 'Newton's Rule에 따라
799
                press1 = self.vap_discharge_1(press2, g, mw, temp, f, z, ida, length)
800

  
801
                line_drop_press = 0
802
                if self.pressure_unit == 'kg/cm2':
803
                    line_drop_press = press1 - press2
804
                elif self.pressure_unit == 'psi':
805
                    line_drop_press = (press1 - press2) / 1.033 * 14.7
806
                elif self.pressure_unit == 'atm':
807
                    line_drop_press = (press1 - press2) / 1.033
808
                elif self.pressure_unit == 'bar':
809
                    line_drop_press = (press1 - press2) / 1.033 * 1.013
810
                elif self.pressure_unit == 'mmHg':
811
                    line_drop_press = (press1 - press2) / 1.033 * 760
812
                elif self.pressure_unit == 'kPa':
813
                    line_drop_press = (press1 - press2) / 1.033 * 101.325
814
                elif self.pressure_unit == 'MPa':
815
                    line_drop_press = (press1 - press2) / 1.033 * 0.101325
816

  
817

  
818
                # 'Hole Calculation
819
                # 'cv와 pump가 다 없을때 (Hole Case)
820

  
821

  
822

  
823

  
824
            else:
825
                # '끊어서 계산하는 모듈이 들어가야함
826
                # 'length 여유 없음. 압력 재계산->밀도 재계산->re, f 재계산->압력 재계산 체계로 가야함
827
                dev = 1
828

  
829
        except Exception as ex:
830
            from App import App
831
            from AppDocData import MessageType
832
            
833
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
834
            App.mainWnd().addMessage.emit(MessageType.Error, message)
835

  
836
    def vap_discharge_1(self, p2, g, mw, temp, f, z, id, L_eq):
837
        R = 0.08206
838

  
839
        Tmp_Const = 101325 * mw / (1.033 ** 2 * (g ** 2) * R * temp * z)
840
        Tmp_Const2 = id / f
841

  
842
        if self.pressure_unit == 'kg/cm2':
843
            const_iteration = 5
844
        elif self.pressure_unit == 'psi':
845
            const_iteration = 75
846
        elif self.pressure_unit == 'atm':
847
            const_iteration = 5
848
        elif self.pressure_unit == 'bar':
849
            const_iteration = 5
850
        elif self.pressure_unit == 'mmHg':
851
            const_iteration = 3800
852
        elif self.pressure_unit == 'kPa':
853
            const_iteration = 506
854
        elif self.pressure_unit == 'MPa':
855
            const_iteration = 0.5
856

  
857
        x2 = p2 + const_iteration
858
        delta_x_past = 0    
859

  
860
        loop = True
861
        while loop:
862
            X = x2        
863
            f_x = (Tmp_Const2 * (Tmp_Const * (X ** 2 - p2 ** 2) - 2 * math.log(X / p2))) - L_eq        
864
            df_x = 2 * Tmp_Const2 * (Tmp_Const * X - 1 / X)        
865
            x2 = X - (f_x / df_x)    
866
            delta_x = x2 - X        
867
            if abs(delta_x_past) == abs(delta_x):
868
                break
869

  
870
            delta_x_past = delta_x                            
871

  
872
            if delta_x == 0 or x2 < 0:
873
                loop = False
874

  
875
        '''
876
        Do
877
            X = x2        
878
            f_x = (Tmp_Const2 * (Tmp_Const * (X ^ 2 - p2 ^ 2) - 2 * Log(X / p2))) - L_eq        
879
            df_x = 2 * Tmp_Const2 * (Tmp_Const * X - 1 / X)        
880
            x2 = X - (f_x / df_x)    
881
            delta_x = x2 - X        
882
            If Abs(delta_x_past) = Abs(delta_x) Then Exit Do        
883
            delta_x_past = delta_x                            
884
        Loop Until delta_x = 0 Or x2 < 0
885
        '''
886

  
887
        return x2
888

  
889 763
    def getLiquid_Drop_Method(self):
890 764
        appDocData = AppDocData.instance()
891
            
765

  
892 766
        # Calculation
893 767
        liquid_dp_method = appDocData.getConfigs('Calculation', 'Liquid_Drop_Method')
894 768

  
895
        if len(liquid_dp_method) == 1:                
769
        if len(liquid_dp_method) == 1:
896 770
            return liquid_dp_method[0].value
897 771
        else:
898 772
            return 'darcy'
899
    
773

  
900 774
    def calculation_Liquid(self):
901 775
        try:
902 776
            liquid_dp_method = self.getLiquid_Drop_Method()
......
905 779
                self.liquid_calc_darcy()
906 780
            elif liquid_dp_method == 'hagen':
907 781
                self.liquid_calc_hagen()
908
                
782

  
909 783
        except Exception as ex:
910
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
911
            App.mainWnd().addMessage.emit(MessageType.Error, message)      
784
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
785
                                                           sys.exc_info()[-1].tb_lineno)
786
            App.mainWnd().addMessage.emit(MessageType.Error, message)
912 787

  
913 788
    def liquid_calc_darcy(self):
914 789
        from App import App
......
917 792
        try:
918 793
            '''
919 794
            Incompressible Line 계산
920

  
795
    
921 796
            **********************************************************************************
922 797
            참고사항 :
923 798
            유닛의 기준 : 유량 (kg/h, m3/h), 밀도 (kg/m3), 지름 (m), 점도 (kg/m/s), 속도 (m/s), 압력강하 (kg/cm2/100m)
924 799
            **********************************************************************************
925 800
            '''
926 801

  
927
            # ********** 1. Flowrate 구하기 ***********        
802
            # ********** 1. Flowrate 구하기 ***********
928 803
            # (1)질량만 적혀있는경우
929
            if self._hmb.flowrate_mass and self._hmb.flowrate_volume is None: 
804
            if self._hmb.flowrate_mass and self._hmb.flowrate_volume is None:
930 805
                density = self._hmb.density
931
                
806

  
932 807
                # '질량유량을 kg/h로 변환.
933
                if self.flowrate_mass_unit == 'kg/h':
808
                flowrate_mass_unit = self.units['Flowrate_Mass']
809
                if flowrate_mass_unit == 'kg/h':
934 810
                    mass = self._hmb.flowrate_mass
935
                elif self.flowrate_mass_unit == 'g/min':
811
                elif flowrate_mass_unit == 'g/min':
936 812
                    mass = self._hmb.flowrate_mass * 60 / 1000
937
                elif self.flowrate_mass_unit == 'lb/h': 
813
                elif flowrate_mass_unit == 'lb/h':
938 814
                    mass = self._hmb.flowrate_mass * 0.453592
939
                elif self.flowrate_mass_unit == 't/h': 
815
                elif flowrate_mass_unit == 't/h':
940 816
                    mass = self._hmb.flowrate_mass * 1000
941 817

  
942 818
                # 'density case에 따라 volume rate (m3/h) 계산
943
                if self.density_unit == 'kg/m3':
819
                density_unit = self.units['Density']
820
                if density_unit == 'kg/m3':
944 821
                    volume = mass / density
945
                elif self.density_unit == 'lb/ft3':
822
                elif density_unit == 'lb/ft3':
946 823
                    volume = mass / (density * 16.0185)
947
                
824

  
948 825
                # '부피 유닛에 맞춰서 뿌려줌
949
                if self.flowrate_volume_unit == 'm3/h':
826
                flowrate_volume_unit = self.units['Flowrate_Volume']
827
                if flowrate_volume_unit == 'm3/h':
950 828
                    self._hmb.flowrate_volume = round(volume, 3)
951
                elif self.flowrate_volume_unit == 'l/min': 
829
                elif flowrate_volume_unit == 'l/min':
952 830
                    self._hmb.flowrate_volume = round(volume / 60 * 1000, 3)
953
                elif self.flowrate_volume_unit == 'ft3/h':
831
                elif flowrate_volume_unit == 'ft3/h':
954 832
                    self._hmb.flowrate_volume = round(volume * 35.3147, 3)
955
                elif self.flowrate_volume_unit == 'USgpm':
833
                elif flowrate_volume_unit == 'USgpm':
956 834
                    self._hmb.flowrate_volume = round(volume * 4.40287, 3)
957
                elif self.flowrate_volume_unit == 'BPSD':
958
                    self._hmb.flowrate_volume = round(volume * 150.955, 3) 
959
            
960
            elif self._hmb.flowrate_mass is None and self._hmb.flowrate_volume: # (2)부피만 적혀있는경우        
835
                elif flowrate_volume_unit == 'BPSD':
836
                    self._hmb.flowrate_volume = round(volume * 150.955, 3)
837

  
838
            elif self._hmb.flowrate_mass is None and self._hmb.flowrate_volume:  # (2)부피만 적혀있는경우
961 839
                density = self._hmb.density
962 840

  
963 841
                # '부피유량을 m3/h로 변환.
964
                if self.flowrate_volume_unit == 'm3/h':
842
                flowrate_volume_unit = self.units['Flowrate_Volume']
843
                if flowrate_volume_unit == 'm3/h':
965 844
                    volume = self._hmb.flowrate_volume
966
                elif self.flowrate_volume_unit == 'l/min': 
845
                elif flowrate_volume_unit == 'l/min':
967 846
                    volume = self._hmb.flowrate_volume * 60 / 1000
968
                elif self.flowrate_volume_unit == 'ft3/h':
847
                elif flowrate_volume_unit == 'ft3/h':
969 848
                    volume = self._hmb.flowrate_volume / 35.3147
970
                elif self.flowrate_volume_unit == 'USgpm':
849
                elif flowrate_volume_unit == 'USgpm':
971 850
                    volume = self._hmb.flowrate_volume / 4.40287
972
                elif self.flowrate_volume_unit == 'BPSD':
851
                elif flowrate_volume_unit == 'BPSD':
973 852
                    volume = self._hmb.flowrate_volume / 150.955
974 853

  
975 854
                # 'density case에 따라 mass rate (kg/h) 계산
976
                if self.density_unit == 'kg/m3':
855
                density_unit = self.units['Density']
856
                if density_unit == 'kg/m3':
977 857
                    mass = volume * density
978
                elif self.density_unit == 'lb/ft3':
858
                elif density_unit == 'lb/ft3':
979 859
                    mass = volume * (density * 16.0185)
980 860

  
981 861
                # '질량 유닛에 맞춰서 뿌려줌
982
                if self.flowrate_mass_unit == 'kg/h':
862
                flowrate_mass_unit = self.units['Flowrate_Mass']
863
                if flowrate_mass_unit == 'kg/h':
983 864
                    self._hmb.flowrate_mass = round(mass, 3)
984
                elif self.flowrate_mass_unit == 'g/min':
865
                elif flowrate_mass_unit == 'g/min':
985 866
                    self._hmb.flowrate_mass = round(mass / 60 * 1000, 3)
986
                elif self.flowrate_mass_unit == 'lb/h': 
867
                elif flowrate_mass_unit == 'lb/h':
987 868
                    self._hmb.flowrate_mass = round(mass * 2.20462, 3)
988
                elif self.flowrate_mass_unit == 't/h': 
869
                elif flowrate_mass_unit == 't/h':
989 870
                    self._hmb.flowrate_mass = round(mass * 1000, 3)
990 871
            else:
991 872
                # (5-3) 둘다 적힌 경우
992 873
                density = self._hmb.density
993 874

  
994 875
                # '질량유량을 kg/h로 변환.
995
                if self.flowrate_mass_unit == 'kg/h':
876
                flowrate_mass_unit = self.units['Flowrate_Mass']
877
                if flowrate_mass_unit == 'kg/h':
996 878
                    mass = self._hmb.flowrate_mass
997
                elif self.flowrate_mass_unit == 'g/min':
879
                elif flowrate_mass_unit == 'g/min':
998 880
                    mass = self._hmb.flowrate_mass * 60 / 1000
999
                elif self.flowrate_mass_unit == 'lb/h': 
881
                elif flowrate_mass_unit == 'lb/h':
1000 882
                    mass = self._hmb.flowrate_mass * 0.453592
1001
                elif self.flowrate_mass_unit == 't/h': 
883
                elif flowrate_mass_unit == 't/h':
1002 884
                    mass = self._hmb.flowrate_mass * 1000
1003 885

  
1004 886
                # 'density case에 따라 volume rate (m3/h) 계산
1005
                if self.density_unit == 'kg/m3':
887
                density_unit = self.units['Density']
888
                if density_unit == 'kg/m3':
1006 889
                    volume = mass / density
1007
                elif self.density_unit == 'lb/ft3':
890
                elif density_unit == 'lb/ft3':
1008 891
                    volume = mass / (density * 16.0185)
1009 892

  
1010 893
                # '부피 유닛에 맞춰서 뿌려줌
1011

  
1012
                if self.flowrate_volume_unit == 'm3/h':
894
                flowrate_volume_unit = self.units['Flowrate_Volume']
895
                if flowrate_volume_unit == 'm3/h':
1013 896
                    self._hmb.flowrate_volume = round(volume, 3)
1014
                elif self.flowrate_volume_unit == 'l/min': 
897
                elif flowrate_volume_unit == 'l/min':
1015 898
                    self._hmb.flowrate_volume = round(volume / 60 * 1000, 3)
1016
                elif self.flowrate_volume_unit == 'ft3/h':
899
                elif flowrate_volume_unit == 'ft3/h':
1017 900
                    self._hmb.flowrate_volume = round(volume * 35.3147, 3)
1018
                elif self.flowrate_volume_unit == 'USgpm':
901
                elif flowrate_volume_unit == 'USgpm':
1019 902
                    self._hmb.flowrate_volume = round(volume * 4.40287, 3)
1020
                elif self.flowrate_volume_unit == 'BPSD':
903
                elif flowrate_volume_unit == 'BPSD':
1021 904
                    self._hmb.flowrate_volume = round(volume * 150.955, 3)
1022 905

  
1023

  
1024
                
1025
                
1026

  
1027
            # ********** 2. Velocity 구하기 ***********        
906
            # ********** 2. Velocity 구하기 ***********
1028 907
            # '지름을 m로 변환
1029
            if self.pipe_diameter_unit == 'in':
908
            pipe_diameter_unit = self.units['Pipe_Diameter']
909
            if pipe_diameter_unit == 'in':
1030 910
                ida = self._hmb.inside_pipe_size * 0.0254
1031
            elif self.pipe_diameter_unit == 'mm':
911
            elif pipe_diameter_unit == 'mm':
1032 912
                ida = self._hmb.inside_pipe_size / 1000
1033 913

  
1034

  
1035 914
            # '속도 계산 (m/s)
1036 915
            velocity = 4 * volume / 3.1415 / ida ** 2 / 3600
1037
        
916

  
1038 917
            # '속도 유닛에 맞춰서 뿌려줌
1039
            if self.velocity_unit == 'm/s':
918
            velocity_unit = self.units['Velocity']
919
            if velocity_unit == 'm/s':
1040 920
                self._hmb.velocity = round(velocity, 3)
1041
            elif self.velocity_unit == 'ft/s':
921
            elif velocity_unit == 'ft/s':
1042 922
                self._hmb.velocity = round(velocity * 3.28084, 3)
1043 923

  
1044

  
1045 924
            # ********** 3. Reynolds 수 구하기 ***********
1046 925

  
1047 926
            # ' viscosity 유닛 변환 (모두 kg/m.s로 바꿀것임)
1048
            if self.viscosity_unit == 'kg/m.sec':
927
            viscosity_unit = self.units['Viscosity']
928
            if viscosity_unit == 'kg/m.sec':
1049 929
                viscosity = self._hmb.viscosity
1050
            elif self.viscosity_unit == 'cP':
930
            elif viscosity_unit == 'cP':
1051 931
                viscosity = self._hmb.viscosity * 0.001
1052
            elif self.viscosity_unit == 'kg/m.h':
932
            elif viscosity_unit == 'kg/m.h':
1053 933
                viscosity = self._hmb.viscosity / 3600
1054
            elif self.viscosity_unit == 'lb/ft.s':
934
            elif viscosity_unit == 'lb/ft.s':
1055 935
                viscosity = self._hmb.viscosity * 1.48816
1056 936

  
1057 937
            # 'density case에 따라 re계산
1058
            if self.density_unit == 'kg/m3':
938
            density_unit = self.units['Density']
939
            if density_unit == 'kg/m3':
1059 940
                reynolds = ida * velocity * density / viscosity
1060
            elif self.density_unit == 'lb/ft3':
941
            elif density_unit == 'lb/ft3':
1061 942
                reynolds = ida * velocity * (density * 16.0185) / viscosity
1062
                
943

  
1063 944
            # 'MACH 넘버 자리이므로 미입력 처리
1064 945
            self._hmb.reynolds = None
1065
            
946

  
1066 947
            # ********** 4. Friction Factor 구하기 ***********
1067 948
            # 'roughness 를 m로 바꿔줌
1068
            if self.roughness_unit == 'm':
949
            roughness_unit = self.units['Roughness']
950
            if roughness_unit == 'm':
1069 951
                rough = self._hmb.roughness
1070
            elif self.roughness_unit == 'ft':
952
            elif roughness_unit == 'ft':
1071 953
                rough = self._hmb.roughness * 0.3048
1072
            elif self.roughness_unit == 'in':
954
            elif roughness_unit == 'in':
1073 955
                rough = self._hmb.roughness * 0.0254
1074
            elif self.roughness_unit == 'mm':
956
            elif roughness_unit == 'mm':
1075 957
                rough = self._hmb.roughness * 0.001
1076 958

  
1077

  
1078 959
            # ' reynolds수에 따라 Fanning/Chen friction factor 계산
1079 960
            if reynolds <= 2100:
1080 961
                f = 4 * 16 / reynolds
......
1087 968

  
1088 969
            # ********** 5. pressure Drop 구하기 ***********
1089 970
            # '100m 당 압력강하를 kg/cm2 단위로 구한 후, 설정된 유닛에 맞춰서 conversion후 기입해줌.
1090
            if self.density_unit == 'kg/m3':
971
            density_unit = self.units['Density']
972
            if density_unit == 'kg/m3':
1091 973
                # 100m 당 압력강하
1092
                dp = f * density * (velocity ** 2) / 2 / ida / 9.8066 / 10000 * 100   
1093
            elif self.density_unit == 'lb/ft3':
974
                dp = f * density * (velocity ** 2) / 2 / ida / 9.8066 / 10000 * 100
975
            elif density_unit == 'lb/ft3':
1094 976
                # 100m 당 압력강하
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)