프로젝트

일반

사용자정보

개정판 59bbfb9b

ID59bbfb9bebb2aea2ffa57d8964e7c9e836992c8f
상위 ac917e1b
하위 f27add86

백흠경이(가) 5년 이상 전에 추가함

issue #1202: update pressure_drop_static and pressure_pipe_end_point of stream line

Change-Id: I1205ad5fab0d41a5fb69255584e76edd7ccd7e73

차이점 보기:

HYTOS/HYTOS/Commands/HydroCalculationCommand.py
25 25
    
26 26
    def execute(self, param):
27 27
        """ execute hydro calculation """
28
        from EngineeringOriginItem import QEngineeringOriginItem
29
        from EngineeringGuidelineItem import QEngineeringGuidelineItem
28
        from AppDocData import AppDocData
30 29
        from SymbolSvgItem import SymbolSvgItem
31 30
        from EngineeringLoopItem import QEngineeringLoopItem
32 31

  
......
44 43

  
45 44
            for loop in self.loops:
46 45
                loop.calculate()
46

  
47
            """ update pressure drop and pressure of stream data """
48
            app_doc_data = AppDocData.instance()
49
            for hmb in app_doc_data.activeDrawing.hmbTable._hmbs:
50
                matches = [loop for loop in self.loops if [item for item in loop.items if str(item.uid) == str(hmb.components_uid)]]
51
                if matches:
52
                    indices = [index for index in range(len(matches[0].items)) if str(matches[0].items[index].uid) == str(hmb.components_uid)]
53
                    if indices:
54
                        hmb.pressure_drop_static = matches[0].pressure_drops[matches[0].items[indices[0] - 1]]
55
                        hmb.pressure_pipe_end_point = matches[0].pressures[matches[0].items[indices[0] + 1]]
56

  
47 57
        except Exception as ex:
48 58
            from App import App
49 59
            from AppDocData import MessageType
50 60

  
51
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
61
            message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
52 62
            App.mainWnd().addMessage.emit(MessageType.Error, message)            
53 63

  
54 64
    def make_loop(self, loop):
......
83 93
            from App import App
84 94
            from AppDocData import MessageType
85 95
            
86
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
96
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
87 97
            App.mainWnd().addMessage.emit(MessageType.Error, message)
88 98
        finally:
89 99
            loop.name = 'Loop{}'.format(len(self.loops) + 1)
HYTOS/HYTOS/HMBTable.py
8 8
'''
9 9
    @brief      HMB data
10 10
'''
11

  
12

  
11 13
class HMBData:
12 14
    def __init__(self, uid=None):
13
        self._uid                       = None
14
        self._components_uid            = None        
15
        self._stream_no                 = None
16
        self._phase_type                = None
17
        self._flowrate_mass             = None
18
        self._flowrate_volume           = None
19
        self._density                   = None
20
        self._viscosity                 = None
21
        self._temperature               = None
22
        self._molecular_weight          = None
23
        self._specific_heat_ratio       = None
24
        self._compress_factor           = None
25
        self._nominal_pipe_size         = None
26
        self._inside_pipe_size          = None
27
        self._schedule_no               = None
28
        self._straight_length           = None
29
        self._equivalent_length_input   = None
30
        self._fitting_length            = None
31
        self._fitting_K                 = None
32
        self._equivalent_length_cal     = None
33
        self._roughness                 = None
34
        self._limitation_velocity       = None
35
        self._limitation_pressure_drop  = None
36
        self._velocity                  = None
37
        self._reynolds                  = None
38
        self._friction_factor           = None
39
        self._pressure_drop             = None
40
        self._pressure_drop_friction    = None
41
        self._pressure_drop_static      = None
42
        self._pressure_pipe_end_point   = None
43
        self._power                     = None
44
        self.isDeleted                  = False
15
        self._uid = None
16
        self._components_uid = None
17
        self._stream_no = None
18
        self._phase_type = None
19
        self._flowrate_mass = None
20
        self._flowrate_volume = None
21
        self._density = None
22
        self._viscosity = None
23
        self._temperature = None
24
        self._molecular_weight = None
25
        self._specific_heat_ratio = None
26
        self._compress_factor = None
27
        self._nominal_pipe_size = None
28
        self._inside_pipe_size = None
29
        self._schedule_no = None
30
        self._straight_length = None
31
        self._equivalent_length_input = None
32
        self._fitting_length = None
33
        self._fitting_K = None
34
        self._equivalent_length_cal = None
35
        self._roughness = None
36
        self._limitation_velocity = None
37
        self._limitation_pressure_drop = None
38
        self._velocity = None
39
        self._reynolds = None
40
        self._friction_factor = None
41
        self._pressure_drop = None
42
        self._pressure_drop_friction = None
43
        self._pressure_drop_static = None
44
        self._pressure_pipe_end_point = None
45
        self._power = None
46
        self.isDeleted = False
45 47

  
46 48
    '''
47 49
        @author humkyung
48 50
        @date   2018.07.12
49 51
    '''
52

  
50 53
    @property
51 54
    def uid(self):
52 55
        return self._uid
......
55 58
        @author humkyung
56 59
        @date   2018.07.12
57 60
    '''
61

  
58 62
    @uid.setter
59 63
    def uid(self, value):
60 64
        self._uid = value
61 65

  
62

  
63 66
    '''
64 67
        @author humkyung
65 68
        @date   2018.07.12
66 69
    '''
70

  
67 71
    @property
68 72
    def components_uid(self):
69 73
        return self._components_uid
......
72 76
        @author humkyung
73 77
        @date   2018.07.12
74 78
    '''
79

  
75 80
    @components_uid.setter
76 81
    def components_uid(self, value):
77 82
        self._components_uid = value
......
80 85
        @author humkyung
81 86
        @date   2018.07.12
82 87
    '''
88

  
83 89
    @property
84 90
    def stream_no(self):
85 91
        return self._stream_no
......
88 94
        @author humkyung
89 95
        @date   2018.07.12
90 96
    '''
97

  
91 98
    @stream_no.setter
92 99
    def stream_no(self, value):
93 100
        if value:
......
101 108
    def phase_type(self, value):
102 109
        if value:
103 110
            self._phase_type = value
104
    
111

  
105 112
    @property
106 113
    def flowrate_mass(self):
107 114
        return self._flowrate_mass
......
207 214
    def equivalent_length_input(self, value):
208 215
        self._equivalent_length_input = float(value) if value else None
209 216

  
210

  
211 217
    @property
212 218
    def fitting_length(self):
213 219
        return self._fitting_length
......
216 222
    def fitting_length(self, value):
217 223
        self._fitting_length = float(value) if value else None
218 224

  
219

  
220 225
    @property
221 226
    def fitting_K(self):
222 227
        return self._fitting_K
......
303 308

  
304 309
    @pressure_drop_static.setter
305 310
    def pressure_drop_static(self, value):
306
        self._pressure_drop_static = float(value) if value else None
311
        self._pressure_drop_static = float(value) if value is not None else None
307 312

  
308 313
    @property
309 314
    def pressure_pipe_end_point(self):
......
311 316

  
312 317
    @pressure_pipe_end_point.setter
313 318
    def pressure_pipe_end_point(self, value):
314
        self._pressure_pipe_end_point = float(value) if value else None
319
        self._pressure_pipe_end_point = float(value) if value is not None else None
315 320

  
316 321
    @property
317 322
    def power(self):
......
319 324

  
320 325
    @power.setter
321 326
    def power(self, value):
322
        self._power = float(value) if value else None
327
        self._power = float(value) if value is not None else None
323 328

  
324 329
    def fromRow(row):
325 330
        hmb = HMBData()
......
357 362

  
358 363
        return hmb
359 364

  
365

  
360 366
class HMBTable:
361 367
    '''
362 368
        @brief  constructor
363 369
        @author humkyung
364 370
        @date   2018.07.12
365 371
    '''
372

  
366 373
    def __init__(self):
367 374
        self._hmbs = None
368 375

  
......
370 377
    def new_data():
371 378
        # 새로운 HMB 데이타를 생성한다.
372 379
        hmb = HMBData()
373
        
380

  
374 381
        hmb.isDeleted = False
375 382
        return hmb
376 383

  
......
379 386
        @author     yeonjin
380 387
        @date       2019.08.19
381 388
    '''
389

  
382 390
    def deleteByUID(self, uid):
383 391
        hmbs = self._hmbs
384
        if hmbs is not None:     
392
        if hmbs is not None:
385 393
            for hmb in hmbs:
386 394
                if str(hmb.components_uid) == str(uid):
387 395
                    hmb.isDeleted = True
388 396
                    break
389 397

  
390

  
391 398
    def add(self, components_uid, stream_no):
392 399
        import uuid
393 400

  
394 401
        hmb = HMBData()
395
        hmb.uid = str(uuid.uuid4())        
402
        hmb.uid = str(uuid.uuid4())
396 403
        hmb.components_uid = components_uid
397 404
        hmb.stream_no = stream_no
398 405
        hmb.isDeleted = False
......
400 407
        self.append(hmb)
401 408

  
402 409
    def updateByUID(self, components_uid, values):
403
        try:            
410
        try:
404 411
            for hmb in self._hmbs:
405 412
                if hmb.components_uid == components_uid:
406 413
                    if 'Phase_Type' in values:
......
410 417
                    if 'Flowrate_Volume' in values:
411 418
                        hmb.flowrate_volume = values['Flowrate_Volume']
412 419
                    if 'Viscosity' in values:
413
                        hmb.viscosity = values['Viscosity']                
414
                    if 'Density' in values:                    
415
                        hmb.density = values['Density']                
416
                    if 'Temperature' in values:                    
420
                        hmb.viscosity = values['Viscosity']
421
                    if 'Density' in values:
422
                        hmb.density = values['Density']
423
                    if 'Temperature' in values:
417 424
                        hmb.temperature = values['Temperature']
418
                    if 'Molecular_Weight' in values:                    
425
                    if 'Molecular_Weight' in values:
419 426
                        hmb.molecular_weight = values['Molecular_Weight']
420 427
                    if 'Specific_Heat_Ratio' in values:
421 428
                        hmb.specific_heat_ratio = values['Specific_Heat_Ratio']
......
455 462
                        hmb.pressure_drop_friction = values['Pressure_Drop_Friction']
456 463
                    if 'Pressure_Drop_Static' in values:
457 464
                        hmb.pressure_drop_static = values['Pressure_Drop_Static']
458
                    if 'Pressure_Pipe_End_Point' in values:                    
465
                    if 'Pressure_Pipe_End_Point' in values:
459 466
                        hmb.pressure_pipe_end_point = values['Pressure_Pipe_End_Point']
460 467
                    if 'Power' in values:
461 468
                        hmb.power = values['Power']
......
464 471
        except Exception as ex:
465 472
            from App import App
466 473
            from AppDocData import MessageType
467
            
468
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
474

  
475
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
476
                                                           sys.exc_info()[-1].tb_lineno)
469 477
            App.mainWnd().addMessage.emit(MessageType.Error, message)
478

  
470 479
    '''
471 480
        @brief      load hmb data from database
472 481
        @author     humkyung
473 482
        @date       2018.07.12
474 483
    '''
484

  
475 485
    def load_data_by_drawing(self, drawing):
476 486
        from App import App
477 487
        from AppDocData import AppDocData
......
532 542

  
533 543
                    # Roll back any change if something goes wrong
534 544
                    conn.rollback()
535
                    
536
                    message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
545

  
546
                    message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
547
                                                                  sys.exc_info()[-1].tb_lineno)
537 548
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
538 549

  
539 550
        return self._hmbs
540
        
551

  
541 552
    '''
542 553
        @brief      save hmb data 
543 554
        @author     humkyung
544 555
        @date       2018.07.12
545 556
    '''
557

  
546 558
    def saveData(self):
547 559
        import uuid
548 560
        from App import App
......
561 573

  
562 574
                for data in self._hmbs:
563 575
                    if data.isDeleted == False:
564
                        cols = ['UID', 'Components_UID', 'Stream_No', 'Phase_Type', 'Flowrate_Mass', 'Flowrate_Volume', 'Density', 'Viscosity',
565
                                'Temperature', 'Molecular_Weight', 'Specific_Heat_Ratio', 'Compress_Factor', 'Nominal_Pipe_Size', 'Inside_Pipe_Size',
566
                                'Schedule_No', 'Straight_Length', 'Equivalent_Length_Input', 'Fitting_Length', 'Fitting_K', 'Equivalent_Length_Cal', 'Roughness', 'Limitation_Velocity', 'Limitation_Pressure_Drop',
567
                                'Velocity', 'Reynolds', 'Friction_Factor', 'Pressure_Drop', 'Pressure_Drop_Friction', 'Pressure_Drop_Static', 'Pressure_Pipe_End_Point', 'Power']
568
                        values = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
569
                        param = (str(data.uid), str(data.components_uid), data.stream_no, data.phase_type, data.flowrate_mass, data.flowrate_volume, data.density,
570
                                    data.viscosity, data.temperature, data.molecular_weight, data.specific_heat_ratio, data.compress_factor, data.nominal_pipe_size,
571
                                    data.inside_pipe_size, data.schedule_no, data.straight_length, data.equivalent_length_input, data.fitting_length, data.fitting_K, data.equivalent_length_cal, data.roughness, data.limitation_velocity,
572
                                    data.limitation_pressure_drop, data.velocity, data.reynolds, data.friction_factor, data.pressure_drop, data.pressure_drop_friction,
573
                                    data.pressure_drop_static, data.pressure_pipe_end_point, data.power)
574

  
575
                        sql = 'insert or replace into HMB({}) values({})'.format(','.join(cols), ','.join(values))                  
576
                        cols = ['UID', 'Components_UID', 'Stream_No', 'Phase_Type', 'Flowrate_Mass', 'Flowrate_Volume',
577
                                'Density', 'Viscosity',
578
                                'Temperature', 'Molecular_Weight', 'Specific_Heat_Ratio', 'Compress_Factor',
579
                                'Nominal_Pipe_Size', 'Inside_Pipe_Size',
580
                                'Schedule_No', 'Straight_Length', 'Equivalent_Length_Input', 'Fitting_Length',
581
                                'Fitting_K', 'Equivalent_Length_Cal', 'Roughness', 'Limitation_Velocity',
582
                                'Limitation_Pressure_Drop',
583
                                'Velocity', 'Reynolds', 'Friction_Factor', 'Pressure_Drop', 'Pressure_Drop_Friction',
584
                                'Pressure_Drop_Static', 'Pressure_Pipe_End_Point', 'Power']
585
                        values = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
586
                                  '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
587
                        param = (
588
                        str(data.uid), str(data.components_uid), data.stream_no, data.phase_type, data.flowrate_mass,
589
                        data.flowrate_volume, data.density,
590
                        data.viscosity, data.temperature, data.molecular_weight, data.specific_heat_ratio,
591
                        data.compress_factor, data.nominal_pipe_size,
592
                        data.inside_pipe_size, data.schedule_no, data.straight_length, data.equivalent_length_input,
593
                        data.fitting_length, data.fitting_K, data.equivalent_length_cal, data.roughness,
594
                        data.limitation_velocity,
595
                        data.limitation_pressure_drop, data.velocity, data.reynolds, data.friction_factor,
596
                        data.pressure_drop, data.pressure_drop_friction,
597
                        data.pressure_drop_static, data.pressure_pipe_end_point, data.power)
598

  
599
                        sql = 'insert or replace into HMB({}) values({})'.format(','.join(cols), ','.join(values))
576 600
                        cursor.execute(sql, param)
577 601
                    else:
578 602
                        sql = "delete from HMB where uid=?"
......
587 611

  
588 612
                # Roll back any change if something goes wrong
589 613
                conn.rollback()
590
                
591
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
614

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

  
594 619
    '''
......
596 621
        @author     humkyung
597 622
        @date       2018.07.12
598 623
    '''
624

  
599 625
    def streamNos(self):
600 626
        return set([hmb.stream_no for hmb in self._hmbs if hmb.isDeleted == False]) if self._hmbs is not None else {}
601 627

  
......
604 630
        @author     humkyung
605 631
        @date       2018.07.12
606 632
    '''
633

  
607 634
    def dataOfStreamNo(self, streamNo):
608
        return [hmb for hmb in self._hmbs if hmb.streamNo == streamNo and hmb.isDeleted == False] if self._hmbs is not None else None
635
        return [hmb for hmb in self._hmbs if
636
                hmb.streamNo == streamNo and hmb.isDeleted == False] if self._hmbs is not None else None
609 637

  
610 638
    '''
611 639
        @brief      append hmb data
612 640
        @author     humkyung
613 641
        @date       2018.07.12
614 642
    '''
643

  
615 644
    def append(self, hmbData):
616 645
        if self._hmbs is None:
617 646
            self._hmbs = []
......
623 652
        @author     humkyung
624 653
        @date       2018.07.12
625 654
    '''
655

  
626 656
    def reset(self):
627 657
        if self._hmbs is not None:
628 658
            del self._hmbs
......
633 663
        """ get hmb data has given stream no """
634 664

  
635 665
        matches = [data for data in self._hmbs if data._components_uid == component_uid]
636
        return matches[0] if matches else None
666
        return matches[0] if matches else None
HYTOS/HYTOS/MainWindow.py
654 654
        from HydroCalculationCommand  import HydroCalculationCommand
655 655

  
656 656
        try:
657
            appDocData = AppDocData.instance()
658
            if appDocData.activeDrawing is None:
657
            app_doc_data = AppDocData.instance()
658
            if app_doc_data.activeDrawing is None:
659 659
                self.showImageSelectionMessageBox()
660 660
                return
661 661
           
662
            hmbs = appDocData.activeDrawing.hmbTable._hmbs
662
            hmbs = app_doc_data.activeDrawing.hmbTable._hmbs
663 663
            if hmbs is not None:            
664 664
                try:
665 665
                    self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) if not hasattr(self, 'progress') else self.progress
......
692 692
                    self.progress.setValue(self.progress.maximum())
693 693
                    self.progress.hide()
694 694
        except Exception as ex:
695
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
695
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
696 696
            self.addMessage.emit(MessageType.Error, message)
697 697

  
698 698
    def display_loops(self, loops):        
......
1075 1075
            drawing = AppDocData.instance().activeDrawing
1076 1076
            if drawing:
1077 1077
                components_uid = stream_line.uid
1078
                stream_no = self.getNextStreamNo(drawing)
1078
                stream_no = self.get_next_stream_no(drawing)
1079 1079
                stream_line.stream_no = stream_no
1080 1080
                drawing.hmbTable.add(components_uid, stream_no)
1081 1081
        except Exception as ex:
1082
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1082
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1083 1083
            self.addMessage.emit(MessageType.Error, message)
1084 1084

  
1085
    def getNextStreamNo(self, drawing):
1085
    def get_next_stream_no(self, drawing):
1086 1086

  
1087 1087
        if len(list(drawing.hmbTable.streamNos())) == 0:
1088 1088
            return 1
HYTOS/HYTOS/Shapes/EngineeringLoopItem.py
155 155
                    break
156 156

  
157 157
            if acv:
158
                pf = (self.total_device_loss if self.total_device_loss else 0) + (
159
                    self.line_total_friction_loss if self.line_total_friction_loss else 0)
158
                pf = (self.total_device_loss if self.total_device_loss else 0) + \
159
                     (self.line_total_friction_loss if self.line_total_friction_loss else 0)
160 160
                method = 'bd'  # TODO:
161 161
                if method == 'bd':
162 162
                    self.bd_cal(pf, acv)
......
300 300
                self.suction_find_line(i)
301 301
                self.suction_static_cal(i)  # static P를 계산해줌
302 302

  
303
                # 라인이 liqiud 인지 vapor인지 판별
303
                # 라인이 liquid 인지 vapor인지 판별
304 304
                if self.items[i].data.phase_type == 'Liquid' or self.items[i].data.phase_type == 'Mixed':
305 305
                    # liquid 인 경우 stream 데이타로부터 del.P를 입력해줌.
306 306
                    self.pressure_drops[self.items[i]] = self.items[i].data.pressure_drop_friction

내보내기 Unified diff

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