프로젝트

일반

사용자정보

개정판 1b00446f

ID1b00446f0e412abdf56b959fcce0b1f11353c01a
상위 7c580b99
하위 671b5aff, 374bf908

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

issue #1058 : 계산 후 결과 표시

Change-Id: Iebd51d5d5ed779aee8c945dfa614c87542731c42

차이점 보기:

HYTOS/HYTOS/Commands/HydroCalculationCommand.py
24 24
        super(HydroCalculationCommand, self).__init__(imageViewer)
25 25
        self.name = 'HydroCalculation'
26 26

  
27
        self.units = {}
27 28
        self.loops = []
28 29

  
29 30
    def is_loop_start_item(self, item):
......
36 37

  
37 38
        return False
38 39

  
40
    def init_units(self):
41
        from AppDocData import AppDocData
42
        try:
43
            app_doc_data = AppDocData.instance()
44
            self.units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
45
        except Exception as ex:
46
            from App import App
47
            from AppDocData import MessageType
48
            message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
49
                                                           sys.exc_info()[-1].tb_lineno)
50
            App.mainWnd().addMessage.emit(MessageType.Error, message)
51

  
39 52
    def is_loop_end_item(self, item):
40 53
        """check given item is possible of end of loop"""
41 54

  
......
43 56

  
44 57
    def execute(self, param):
45 58
        """ execute hydro calculation """
46
        from AppDocData import AppDocData
59

  
47 60
        from SymbolSvgItem import SymbolSvgItem
48 61
        from EngineeringLoopItem import QEngineeringLoopItem
49 62

  
......
71 84
                    if item in loop.pressure_drops:
72 85
                        item.pressure_drop = loop.pressure_drops[item]
73 86

  
87
            self.init_units()
88
            self.loop_result()
89

  
90
        except Exception as ex:
91
            from App import App
92
            from AppDocData import MessageType
93

  
94
            message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
95
                                                           sys.exc_info()[-1].tb_lineno)
96
            App.mainWnd().addMessage.emit(MessageType.Error, message)
97

  
98
    def loop_result(self):
99
        self.loop_streams_hy()
100
        self.loop_pumps_hy()
101
        self.loop_comps_hy()
102
        self.loop_cv_hy()
103

  
104
        self.stream_input()  # static 및 end.p 값 입력
105

  
106
    def stream_input(self):
107
        from AppDocData import AppDocData
108
        try:
74 109
            """ update pressure drop and pressure of stream data """
75 110
            app_doc_data = AppDocData.instance()
76 111
            for hmb in app_doc_data.activeDrawing.hmbTable._hmbs:
......
80 115
                    indices = [index for index in range(len(matches[0].items)) if
81 116
                               str(matches[0].items[index].uid) == str(hmb.components_uid)]
82 117
                    if indices:
118
                        hmb.pressure_drop_static = matches[0].pressure_drops[matches[0].items[indices[0] - 1]]
119
                        hmb.pressure_pipe_end_point = matches[0].pressures[matches[0].items[indices[0] + 1]]
120

  
83 121
                        if hmb.phase_type == 'Vapor':
84 122
                            hmb.pressure_drop_friction = matches[0].pressure_drops[matches[0].items[indices[0]]]
85 123
                            hmb.density = matches[0].density_elevations[matches[0].items[indices[0]]]
86
                            hmb.pressure_drop = round(
87
                                matches[0].pressure_drops[matches[0].items[indices[0]]] / hmb.equivalent_length * 100,
88
                                3)
89
                        hmb.pressure_drop_static = matches[0].pressure_drops[matches[0].items[indices[0] - 1]]
90
                        hmb.pressure_pipe_end_point = matches[0].pressures[matches[0].items[indices[0] + 1]]
124
                            hmb.pressure_drop = matches[0].pressure_drops[matches[0].items[indices[0]]] / hmb.equivalent_length * 100
91 125

  
92 126
        except Exception as ex:
93 127
            from App import App
......
97 131
                                                           sys.exc_info()[-1].tb_lineno)
98 132
            App.mainWnd().addMessage.emit(MessageType.Error, message)
99 133

  
134
    def loop_comps_hy(self):
135
        if self.loops:
136
            for loop in self.loops:
137
                indices = [index for index in range(len(loop.items)) if
138
                           str(loop.items[index])[:3] == 'R_K' or str(loop.items[index])[:3] == 'L_K']
139
                attribute = {}
140
                if indices:
141
                    if len(indices) == 2:
142
                        tag_no = loop.items[indices[0]].parent.tag_no
143
                        suct_p = loop.pressures[loop.items[indices[0]]]
144
                        disc_p = loop.pressures[loop.items[indices[1]]]
145
                        diff_p = disc_p - suct_p
146

  
147
                        flowrate_mass = loop.items[indices[0] - 1].data.flowrate_mass
148
                        density = loop.density_elevations[loop.items[indices[0] - 1]]
149
                        hhp = self.comp_hydp_hy(flowrate_mass, density, round(diff_p, 3))
150

  
151
                        attribute['Tag_No'] = tag_no
152
                        attribute['Suct.P'] = suct_p
153
                        attribute['Disc.P'] = disc_p
154
                        attribute['Diff.P'] = diff_p
155
                        attribute['HHP'] = hhp
156

  
157
                        loop.items[indices[0]].parent.attribute = attribute
158

  
159
    def loop_cv_hy(self):
160
        if self.loops:
161
            for loop in self.loops:
162
                indices = [index for index in range(len(loop.items)) if str(loop.items[index])[:3] == 'CV_']
163
                attribute = {}
164
                if indices:
165
                    if len(indices) == 2:
166
                        tag_no = loop.items[indices[0]].parent.tag_no
167
                        suct_p = loop.pressures[loop.items[indices[0]]]
168
                        disc_p = loop.pressures[loop.items[indices[1]]]
169
                        diff_p = loop.pressure_drops[loop.items[indices[0]]]
170
                        dp_ratio = loop.extras[loop.items[indices[1]]] if not loop.extras[loop.items[indices[1]]] is None else 0
171

  
172
                        attribute['Tag_No'] = tag_no
173
                        attribute['Suct.P'] = suct_p
174
                        attribute['Disc.P'] = disc_p
175
                        attribute['Diff.P'] = diff_p
176
                        attribute['dP Ratio'] = dp_ratio
177

  
178
                        loop.items[indices[0]].parent.attribute = attribute
179

  
180
    def loop_pumps_hy(self):
181
        if self.loops:
182
            for loop in self.loops:
183
                indices = [index for index in range(len(loop.items)) if
184
                           str(loop.items[index])[:3] == 'R_P' or str(loop.items[index])[:3] == 'L_P' or str(
185
                               loop.items[index])[:3] == 'V_P']
186
                attribute = {}
187
                if indices:
188
                    if len(indices) == 2:
189
                        tag_no = loop.items[indices[0]].parent.tag_no
190
                        suct_p = loop.pressures[loop.items[indices[0]]]
191
                        disc_p = loop.pressures[loop.items[indices[1]]]
192
                        diff_p = disc_p - suct_p
193
                        vapr_p = loop.extras[loop.items[indices[0]]]
194

  
195
                        flowrate_mass = loop.items[indices[0] - 1].data.flowrate_mass
196
                        density = loop.density_elevations[loop.items[indices[0] - 1]]
197

  
198
                        npsha = self.npsha_cal_hy(suct_p, vapr_p, density)
199
                        head = self.pump_head_cal(diff_p, density)
200
                        hhp = self.pump_hydp_hy(flowrate_mass, density, head)
201

  
202
                        if len(loop.items[indices[0]].parent.attribute) == 0:
203
                            attribute['Tag_No'] = tag_no
204
                            attribute['Suct.P'] = suct_p
205
                            attribute['Disc.P'] = disc_p
206
                            attribute['Diff.P'] = diff_p
207
                            attribute['Head'] = head
208
                            attribute['NPSHa'] = npsha
209
                            attribute['Vap. P'] = vapr_p
210
                            attribute['HHP'] = hhp
211
                            loop.items[indices[0]].parent.attribute = attribute
212
                        elif tag_no != loop.items[indices[0]].parent.attribute['Tag_No']:
213
                            attribute['Tag_No'] = tag_no
214
                            attribute['Suct.P'] = suct_p
215
                            attribute['Disc.P'] = disc_p
216
                            attribute['Diff.P'] = diff_p
217
                            attribute['Head'] = head
218
                            attribute['NPSHa'] = npsha
219
                            attribute['Vap. P'] = vapr_p
220
                            attribute['HHP'] = hhp
221
                            loop.items[indices[0]].parent.attribute = attribute
222

  
223
    def get_barometric_pressure(self):
224
        pressure_unit = self.units['Pressure']
225
        if pressure_unit == 'kg/cm2':
226
            barometric_pressure = 1.033
227
        elif pressure_unit == 'bar':
228
            barometric_pressure = 1.01325
229
        elif pressure_unit == 'psi':
230
            barometric_pressure = 14.7
231
        elif pressure_unit == 'mmHg':
232
            barometric_pressure = 760
233
        elif pressure_unit == 'kPa':
234
            barometric_pressure = 101.325
235
        elif pressure_unit == 'MPa':
236
            barometric_pressure = 0.101325
237

  
238
        return barometric_pressure
239

  
240
    def pump_head_cal(self, header, density):
241
        density_unit = self.units['Density']
242
        if density_unit == 'kg/m3':
243
            sg = density / 1000
244
        elif density_unit == 'lb/ft3':
245
            sg = density * 16.0185 / 1000
246

  
247
        pressure_unit = self.units['Pressure']
248
        if pressure_unit == 'kg/cm2':
249
            header = header
250
        elif pressure_unit == 'psi':
251
            header = header / 14.7 * 1.033
252
        elif pressure_unit == 'bar':
253
            header = header / 1.013 * 1.033
254
        elif pressure_unit == 'mmHg':
255
            header = header / 760 * 1.033
256
        elif pressure_unit == 'kPa':
257
            header = header / 101.325 * 1.033
258
        elif pressure_unit == 'MPa':
259
            header = header / 0.101325 * 1.033
260

  
261
        # 현재 head는 kg/cm2으로 통일되어있음
262
        header = header * 10 / sg
263

  
264
        # 현재 head는 m로 표시되어있음
265
        length_unit = self.units['Length']
266
        if length_unit == 'm':
267
            header = header
268
        elif length_unit == 'in':
269
            header = header * 39.3701
270
        elif length_unit == 'ft':
271
            header = header * 3.28084
272
        elif length_unit == 'yd':
273
            header = header * 1.09361
274
        elif length_unit == 'mile':
275
            header = header * 0.000621371
276
        elif length_unit == 'mm':
277
            header = header * 1000
278

  
279
        return header
280

  
281
    def npsha_cal_hy(self, suct_p, vapo_p, density):
282
        ref_baro = self.get_barometric_pressure()
283

  
284
        density_unit = self.units['Density']
285
        if density_unit == 'kg/m3':
286
            sg = density / 1000
287
        elif density_unit == 'lb/ft3':
288
            sg = density * 16.0185 / 1000
289

  
290
        npsha = suct_p - vapo_p
291

  
292
        pressure_unit = self.units['Pressure']
293
        if pressure_unit == 'kg/cm2':
294
            npsha = npsha
295
        elif pressure_unit == 'psi':
296
            npsha = npsha / 14.7 * 1.033
297
        elif pressure_unit == 'bar':
298
            npsha = npsha / 1.013 * 1.033
299
        elif pressure_unit == 'mmHg':
300
            npsha = npsha / 760 * 1.033
301
        elif pressure_unit == 'kPa':
302
            npsha = npsha / 101.325 * 1.033
303
        elif pressure_unit == 'MPa':
304
            npsha = npsha / 0.101325 * 1.033
305

  
306
        npsha = npsha + ref_baro
307
        # 현재 npsha는 kg/cm2으로 통일되어있음
308

  
309
        npsha = npsha * 10 / sg
310
        # 현재 npsha는 딱 m로 표시되어있음
311

  
312
        length_unit = self.units['Length']
313
        if length_unit == 'm':
314
            npsha = npsha
315
        elif length_unit == 'in':
316
            npsha = npsha * 39.3701
317
        elif length_unit == 'ft':
318
            npsha = npsha * 3.28084
319
        elif length_unit == 'yd':
320
            npsha = npsha * 1.09361
321
        elif length_unit == 'mile':
322
            npsha = npsha * 0.000621371
323
        elif length_unit == 'mm':
324
            npsha = npsha * 1000
325

  
326
        return npsha
327

  
328
    def pump_hydp_hy(self, flowrate_mass, density, head):
329
        hydp_den = density
330

  
331
        # 질량유량은 모두 kg/min으로 맞춰야 함
332
        flowrate_mass_unit = self.units['Flowrate_Mass']
333
        if flowrate_mass_unit == 'kg/h':
334
            mass_4_hydp = flowrate_mass / 60
335
        elif flowrate_mass_unit == 'g/min':
336
            mass_4_hydp = flowrate_mass / 1000
337
        elif flowrate_mass_unit == 'lb/h':
338
            mass_4_hydp = flowrate_mass / 60 * 2.20462
339
        elif flowrate_mass_unit == 't/h':
340
            mass_4_hydp = flowrate_mass / 60 * 1000
341

  
342
        density_unit = self.units['Density']
343
        if density_unit == 'kg/m3':
344
            sg = hydp_den / 1000
345
            q = mass_4_hydp / hydp_den
346
        elif density_unit == 'lb/ft3':
347
            sg = hydp_den * 16.0185 / 1000
348
            q = mass_4_hydp / hydp_den * 2.20462 / 3.28 ** 3
349

  
350
        # 현재 hydp는 kW 임
351
        hydp = 0.163 * sg * q * head
352

  
353
        # 현재는 압력의 단위로 표시되어있음
354
        power_unit = self.units['Power']
355
        if power_unit == 'kW':
356
            hydp = hydp
357
        elif power_unit == 'kcal/h':
358
            hydp = hydp * 860.421
359
        elif power_unit == 'btu/h':
360
            hydp = hydp * 3412.14
361
        elif power_unit == 'Hp':
362
            hydp = hydp * 1.34041
363
        elif power_unit == 'kg.m/sec':
364
            hydp = hydp * 737.562 / 3.28 / 2.20462
365
        elif power_unit == 'ft.lb/sec':
366
            hydp = hydp * 737.562
367

  
368
        return hydp
369

  
370
    def comp_hydp_hy(self, flowrate_mass, density, diff_p):
371
        hydp_den = density
372

  
373
        # 질량유량은 모두 kg/min으로 맞춰야 함
374
        flowrate_mass_unit = self.units['Flowrate_Mass']
375
        if flowrate_mass_unit == 'kg/h':
376
            mass_4_hydp = flowrate_mass / 60
377
        elif flowrate_mass_unit == 'g/min':
378
            mass_4_hydp = flowrate_mass / 1000
379
        elif flowrate_mass_unit == 'lb/h':
380
            mass_4_hydp = flowrate_mass / 60 * 2.20462
381
        elif flowrate_mass_unit == 't/h':
382
            mass_4_hydp = flowrate_mass / 60 * 1000
383

  
384
        density_unit = self.units['Density']
385
        if density_unit == 'kg/m3':
386
            com_q = mass_4_hydp / hydp_den
387
        elif density_unit == 'lb/ft3':
388
            com_q = mass_4_hydp / hydp_den * 2.20462 / 3.28 ** 3
389

  
390
        density_unit = self.units['Density']
391
        if density_unit == 'kg/m3':
392
            com_sg = density / 1000
393
        elif density_unit == 'lb/ft3':
394
            com_sg = density * 16.0185 / 1000
395

  
396
        com_head = diff_p
397

  
398
        # 현재는 압력의 단위로 표시되어 있음
399
        pressure_unit = self.units['Pressure']
400
        if pressure_unit == 'kg/cm2':
401
            com_head = com_head
402
        elif pressure_unit == 'psi':
403
            com_head = com_head / 14.7 * 1.033
404
        elif pressure_unit == 'bar':
405
            com_head = com_head / 1.013 * 1.033
406
        elif pressure_unit == 'mmHg':
407
            com_head = com_head / 760 * 1.033
408
        elif pressure_unit == 'kPa':
409
            com_head = com_head / 101.325 * 1.033
410
        elif pressure_unit == 'MPa':
411
            com_head = com_head / 0.101325 * 1.033
412

  
413
        # 현재 head는 kg/cm2으로 통일되어있음
414
        com_head = com_head * 10 / com_sg
415

  
416
        hydp = 0.163 * com_sg * com_q * com_head
417
        # 현재 hydp는 kW 임
418

  
419
        # 현재는 압력의 단위로 표시되어있음
420
        power_unit = self.units['Power']
421
        if power_unit == 'kW':
422
            hydp = hydp
423
        elif power_unit == 'kcal/h':
424
            hydp = hydp * 860.421
425
        elif power_unit == 'btu/h':
426
            hydp = hydp * 3412.14
427
        elif power_unit == 'Hp':
428
            hydp = hydp * 1.34041
429
        elif power_unit == 'kg.m/sec':
430
            hydp = hydp * 737.562 / 3.28 / 2.20462
431
        elif power_unit == 'ft.lb/sec':
432
            hydp = hydp * 737.562
433

  
434
        return hydp
435

  
436
    def loop_streams_hy(self):
437
        pass
438

  
100 439
    def make_loop(self, loop):
101 440
        """ make a loop """
102 441
        from EngineeringConnectorItem import QEngineeringConnectorItem

내보내기 Unified diff

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