Пример #1
0
    def AdjustOldCase(self, version):
        """
        fixup old versions
        """
        super(PumpWithCurve, self).AdjustOldCase(version)

        if version[0] < 12:
            newPort = self.GetPort(DELTAP_PORT)
            if not newPort:
                # Borrow the deltaP port
                self.BorrowChildPort(self.HPump.GetPort(DELTAP_PORT),
                                     DELTAP_PORT)

            newPort = self.GetPort(EFFICIENCY_PORT)
            if not newPort:
                # insert a signal stream between the 'LookupTable.SIG_PORT2' and IsenthalpicPump.EFFICIENCY_PORT
                # first break the old connection
                self.DisconnectPort('IsenthalpicPump', EFFICIENCY_PORT)
                # create the in-between signal stream and re-connect
                self.effStream = Stream.Stream_Signal()
                self.effStream.SetParameterValue(SIGTYPE_PAR, GENERIC_VAR)
                self.AddUnitOperation(self.effStream, 'EfficiencySig')
                effClone = Stream.ClonePort()
                self.effStream.AddObject(effClone, 'effClone')
                self.ConnectPorts('EfficiencySig', IN_PORT, 'LookupTable',
                                  SIG_PORT + '2')
                self.ConnectPorts('EfficiencySig', OUT_PORT, 'IsenthalpicPump',
                                  EFFICIENCY_PORT)
                self.BorrowChildPort(self.effStream.GetPort('effClone'),
                                     EFFICIENCY_PORT)

            newPort = self.GetPort(HEAD_PORT)
            if not newPort:
                # insert a signal stream between the 'CalcDelP.SIG_PORT0' and 'LookupTable.SIG_PORT1'
                # first break the old connection
                self.DisconnectPort('CalcDelP', SIG_PORT)
                # create the in-between signal stream and re-connect
                self.headStream = Stream.Stream_Signal()
                self.headStream.SetParameterValue(SIGTYPE_PAR, LENGTH_VAR)
                self.AddUnitOperation(self.headStream, 'HeadSig')
                headClone = Stream.ClonePort()
                self.headStream.AddObject(headClone, 'headClone')
                self.ConnectPorts('HeadSig', IN_PORT, 'LookupTable',
                                  SIG_PORT + '1')
                self.ConnectPorts('HeadSig', OUT_PORT, 'CalcDelP',
                                  SIG_PORT + '0')
                self.BorrowChildPort(self.headStream.GetPort('headClone'),
                                     HEAD_PORT)

        if version[0] < 61:
            prop = self.TotalQ.GetPort(IN_PORT).GetProperty()
            if prop.GetType().name == ENERGY_VAR:
                prop.SetTypeByName(WORK_VAR)
Пример #2
0
    def __init__(self, initScript=None):
        # A pump
        # with pump curves, do not preserve entropy
        super(PumpWithCurve, self).__init__(initScript)

        self.HPump = Pump()
        self.HPump.SetParameterValue(ISENTROPIC_PAR, 1)
        self.AddUnitOperation(self.HPump, 'IsenthalpicPump')

        # Inlet P sensor
        self.InPSensor = Sensor.PropertySensor()
        self.AddUnitOperation(self.InPSensor, 'InPSensor')
        self.InPSensor.SetParameterValue(SIGTYPE_PAR, P_VAR)

        # Outlet P sensor
        self.OutPSensor = Sensor.PropertySensor()
        self.AddUnitOperation(self.OutPSensor, 'OutPSensor')
        self.OutPSensor.SetParameterValue(SIGTYPE_PAR, P_VAR)

        # A set to set the delP between the inlet and outlet P
        self.SetP = Set.Set()
        self.AddUnitOperation(self.SetP, 'SetP')
        self.SetP.SetParameterValue(SIGTYPE_PAR, P_VAR)
        self.SetP.GetPort(Set.MULT_PORT).SetValue(1.0, FIXED_V)

        # A table lookup unit
        # with 3 series: mass flow, head, efficiency
        self.LookupTable = LookupTable()
        self.AddUnitOperation(self.LookupTable, 'LookupTable')
        self.LookupTable.SetParameterValue(
            NUMBSERIES_PAR,
            4)  # 4 series: mass flow, head, efficiency and power
        self.LookupTable.SetParameterValue(EXTRAPOLATE_PAR + str(2),
                                           0)  # do not extrapolate efficiency
        self.LookupTable.SetParameterValue(SERIESTYPE_PAR + str(0),
                                           VOLFLOW_VAR)
        self.LookupTable.SetParameterValue(SERIESTYPE_PAR + str(1), LENGTH_VAR)
        self.LookupTable.SetParameterValue(SERIESTYPE_PAR + str(3),
                                           ENERGY_VAR)  # actually power

        self.LookupTable.SetParameterValue(
            TABLETAGTYPE_PAR, GENERIC_VAR)  # i do not yet has a RPM

        # A flow sensor
        self.FlowSensor = Sensor.PropertySensor()
        self.AddUnitOperation(self.FlowSensor, 'FlowSensor')
        self.FlowSensor.SetParameterValue(SIGTYPE_PAR, VOLFLOW_VAR)

        # An equation unit to convert the head to delP
        # delP = MW * 0.00981 * head / molarVol
        # Note cannot back out mass density from head and delta pressure
        self.CalcDelP = EquationUnit()
        self.AddUnitOperation(self.CalcDelP, 'CalcDelP')
        self.CalcDelP.SetParameterValue(NUMBSIG_PAR, 4)
        self.CalcDelP.SetParameterValue(TRANSFORM_EQT_PAR + str(0),
                                        'x[1]*x[3]/0.00981/x[2]')
        self.CalcDelP.SetParameterValue(TRANSFORM_EQT_PAR + str(1),
                                        'x[0]*x[2]*0.00981/x[3]')
        # x[0] = head
        # x[1] = delta pressure
        # x[2] = molecular weight
        # x[3] = molarVol

        # A molarVol sensor for calculating delP from head
        self.MolarVolSensor = Sensor.PropertySensor()
        self.AddUnitOperation(self.MolarVolSensor, 'MolarVolSensor')
        self.MolarVolSensor.SetParameterValue(SIGTYPE_PAR, molarV_VAR)

        # A MW sensor for calculating delP from head
        self.MWSensor = Sensor.PropertySensor()
        self.AddUnitOperation(self.MWSensor, 'MWSensor')
        self.MWSensor.SetParameterValue(SIGTYPE_PAR, MOLE_WT)

        # An energy sensor for setting the Q from the lookup table
        self.TotalQ = Sensor.EnergySensor()
        self.AddUnitOperation(self.TotalQ, 'TotalQ')

        # Connect them all
        self.ConnectPorts('FlowSensor', OUT_PORT, 'MolarVolSensor', IN_PORT)
        self.ConnectPorts('MolarVolSensor', OUT_PORT, 'MWSensor', IN_PORT)
        self.ConnectPorts('MWSensor', OUT_PORT, 'InPSensor', IN_PORT)
        self.ConnectPorts('InPSensor', OUT_PORT, 'IsenthalpicPump', IN_PORT)
        #        self.ConnectPorts('IsenthalpicPump', EFFICIENCY_PORT, 'LookupTable', SIG_PORT + '2')
        self.ConnectPorts('IsenthalpicPump', IN_PORT + 'Q', 'TotalQ', OUT_PORT)
        self.ConnectPorts('IsenthalpicPump', OUT_PORT, 'OutPSensor', IN_PORT)

        self.ConnectPorts('InPSensor', SIG_PORT, 'SetP', SIG_PORT + '0')
        self.ConnectPorts('OutPSensor', SIG_PORT, 'SetP', SIG_PORT + '1')
        self.ConnectPorts('FlowSensor', SIG_PORT, 'LookupTable',
                          SIG_PORT + '0')

        self.ConnectPorts('TotalQ', SIG_PORT, 'LookupTable', SIG_PORT + '3')
        #        self.ConnectPorts('CalcDelP', SIG_PORT + '0', 'LookupTable', SIG_PORT + '1')
        self.ConnectPorts('CalcDelP', SIG_PORT + '1', 'SetP', Set.ADD_PORT)
        self.ConnectPorts('CalcDelP', SIG_PORT + '2', 'MWSensor', SIG_PORT)
        self.ConnectPorts('CalcDelP', SIG_PORT + '3', 'MolarVolSensor',
                          SIG_PORT)

        self.BorrowChildPort(self.TotalQ.GetPort(IN_PORT), IN_PORT + 'Q')
        self.BorrowChildPort(self.OutPSensor.GetPort(OUT_PORT), OUT_PORT)
        self.BorrowChildPort(self.FlowSensor.GetPort(IN_PORT), IN_PORT)
        self.BorrowChildPort(self.LookupTable.GetPort(SPEC_TAG_PORT),
                             PUMPSPEED_PORT)
        self.BorrowChildPort(self.HPump.GetPort(DELTAP_PORT), DELTAP_PORT)

        #Change the type of the energy port such that it is in Work units and scaling
        self.TotalQ.GetPort(IN_PORT).GetProperty().SetTypeByName(WORK_VAR)

        # clone and borrow the lookuptable's efficiency port
        self.effStream = Stream.Stream_Signal()
        self.effStream.SetParameterValue(SIGTYPE_PAR, GENERIC_VAR)
        self.AddUnitOperation(self.effStream, 'EfficiencySig')
        effClone = Stream.ClonePort()
        self.effStream.AddObject(effClone, 'effClone')
        self.ConnectPorts('EfficiencySig', IN_PORT, 'LookupTable',
                          SIG_PORT + '2')
        self.ConnectPorts('EfficiencySig', OUT_PORT, 'IsenthalpicPump',
                          EFFICIENCY_PORT)
        self.BorrowChildPort(self.effStream.GetPort('effClone'),
                             EFFICIENCY_PORT)

        # clone and borrow the lookuptable's head port
        self.headStream = Stream.Stream_Signal()
        self.headStream.SetParameterValue(SIGTYPE_PAR, LENGTH_VAR)
        self.AddUnitOperation(self.headStream, 'HeadSig')
        headClone = Stream.ClonePort()
        self.headStream.AddObject(headClone, 'headClone')
        self.ConnectPorts('HeadSig', IN_PORT, 'LookupTable', SIG_PORT + '1')
        self.ConnectPorts('HeadSig', OUT_PORT, 'CalcDelP', SIG_PORT + '0')
        self.BorrowChildPort(self.headStream.GetPort('headClone'), HEAD_PORT)

        # parameters
        #default: no pump curve
        self.SetParameterValue(NUMBTABLE_PAR, 0)