Exemplo n.º 1
0
    def __init__(self, initScript=None):
        super(ConvReactor, self).__init__(initScript)
        self.isoRxn = IsothermalConvReactor()
        self.AddUnitOperation(self.isoRxn, 'IsoRxn')
        self.isoRxn.containerUnitOp = self

        self.heater = Heater.Heater()
        self.AddUnitOperation(self.heater, 'RxnHeater')

        self.baln = Balance.BalanceOp()
        self.AddUnitOperation(self.baln, 'EneBalance')

        #Initialize with one energy In and Out as a default
        #The parameter QEXOTHERMIC_ISPOS_PAR will set the missing energy port
        self.baln.SetParameterValue(NUSTIN_PAR + Balance.S_ENE, 1)
        self.baln.SetParameterValue(NUSTOUT_PAR + Balance.S_ENE, 1)
        self.baln.SetParameterValue(Balance.BALANCETYPE_PAR,
                                    Balance.ENERGY_BALANCE)

        # to create an Energy Out port for export
        self.balEneSensor = Sensor.EnergySensor()
        self.AddUnitOperation(self.balEneSensor, 'BalEneSensor')
        self.eneSensor = Sensor.EnergySensor()
        self.AddUnitOperation(self.eneSensor, 'EneSensor')
        self.eneStream = Stream.Stream_Energy()
        self.AddUnitOperation(self.eneStream, 'EneStream')

        # connect the child unit ops
        self.ConnectPorts('IsoRxn', OUT_PORT + 'Q', 'EneBalance',
                          IN_PORT + 'Q0')
        self.ConnectPorts('RxnHeater', IN_PORT + 'Q', 'EneBalance',
                          OUT_PORT + 'Q0')
        self.ConnectPorts('IsoRxn', OUT_PORT, 'RxnHeater', IN_PORT)

        self.ConnectPorts('EneSensor', OUT_PORT, 'EneStream', IN_PORT)
        #
        self.ConnectPorts('BalEneSensor', SIG_PORT, 'EneSensor', SIG_PORT)

        # borrow child ports
        self.BorrowChildPort(self.eneStream.GetPort(OUT_PORT), OUT_PORT + 'Q')
        self.BorrowChildPort(self.isoRxn.GetPort(IN_PORT), IN_PORT)
        self.BorrowChildPort(self.heater.GetPort(OUT_PORT), OUT_PORT)
        self.BorrowChildPort(self.heater.GetPort(DELTAP_PORT), DELTAP_PORT)

        self.SetParameterValue(NURXN_PAR, 0)
        self.SetParameterValue(SIMULTANEOUSRXN_PAR, 1)
        self.SetParameterValue(QEXOTHERMIC_ISPOS_PAR, 1)
Exemplo n.º 2
0
    def __init__(self, initScript=None):
        super(EquilibriumReactor, self).__init__(initScript)
        self.itnRxn = InternalEqmReactor()
        self.AddUnitOperation(self.itnRxn, 'itnRxn')
        self.itnRxn.containerUnitOp = self

        self.baln = Balance.BalanceOp()
        self.AddUnitOperation(self.baln, 'EneBalance')

        self.baln.SetParameterValue(NUSTIN_PAR + Balance.S_ENE, 1)
        self.baln.SetParameterValue(Balance.BALANCETYPE_PAR,
                                    Balance.ENERGY_BALANCE)

        # to create an Energy Out port for export
        self.balEneSensor = Sensor.EnergySensor()
        self.AddUnitOperation(self.balEneSensor, 'BalEneSensor')
        self.eneSensor = Sensor.EnergySensor()
        self.AddUnitOperation(self.eneSensor, 'EneSensor')
        self.eneStream = Stream.Stream_Energy()
        self.AddUnitOperation(self.eneStream, 'EneStream')

        # connect the child unit ops
        self.ConnectPorts('itnRxn', OUT_PORT + 'Q', 'EneBalance',
                          IN_PORT + 'Q0')
        self.ConnectPorts('EneSensor', OUT_PORT, 'EneStream', IN_PORT)
        self.ConnectPorts('BalEneSensor', SIG_PORT, 'EneSensor', SIG_PORT)

        # borrow child ports
        self.BorrowChildPort(self.eneStream.GetPort(OUT_PORT), OUT_PORT + 'Q')
        self.BorrowChildPort(self.itnRxn.GetPort(IN_PORT), IN_PORT)
        self.BorrowChildPort(self.itnRxn.GetPort(OUT_PORT), OUT_PORT)
        self.BorrowChildPort(self.itnRxn.GetPort(DELTAP_PORT), DELTAP_PORT)

        self.SetParameterValue(NURXN_PAR, 0)
        self.SetParameterValue(CALCOPTION_PAR,
                               1)  #use table to correlate constant
        self.SetParameterValue(CONSTBASIS_PAR,
                               1)  #use partial pressure to calculate constant
        self.SetParameterValue(
            BASISPUNIT_PAR,
            'atm')  #VMG pressure unit when partial pressure as basis
        self.SetParameterValue(QEXOTHERMIC_ISPOS_PAR, 1)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def __init__(self, initScript=None):
        """Init pump - build it from Idealpump,
        Heater and Set operations
        """
        super(Pump, self).__init__(initScript)

        # the isentropic compressor
        self.ideal = IdealPump()
        self.AddUnitOperation(self.ideal, 'Ideal')

        # a heater to add the waste heat to the outlet
        self.waste = Heater.Heater()
        self.AddUnitOperation(self.waste, 'Waste')
        self.waste.GetPort(DELTAP_PORT).SetValue(0.0, FIXED_V)

        # connect them
        self.ConnectPorts('Ideal', OUT_PORT, 'Waste', IN_PORT)

        # energy sensors (needed for signals)
        self.idealQ = Sensor.EnergySensor()
        self.AddUnitOperation(self.idealQ, 'IdealQ')
        self.ConnectPorts('Ideal', IN_PORT + 'Q', 'IdealQ', OUT_PORT)

        self.wasteQ = Sensor.EnergySensor()
        self.AddUnitOperation(self.wasteQ, 'WasteQ')
        self.ConnectPorts('Waste', IN_PORT + 'Q', 'WasteQ', OUT_PORT)

        self.totalQ = Sensor.EnergySensor()
        self.AddUnitOperation(self.totalQ, 'TotalQ')

        # create a signal stream for the efficiency
        self.effStream = Stream.Stream_Signal()
        self.effStream.SetParameterValue(SIGTYPE_PAR, GENERIC_VAR)
        self.AddUnitOperation(self.effStream, 'EfficiencySig')

        #set relation between ideal and total Q
        self.set = Set.Set()
        self.AddUnitOperation(self.set, 'Set')
        self.set.SetParameterValue(SIGTYPE_PAR, ENERGY_VAR)
        self.set.GetPort(Set.ADD_PORT).SetValue(0.0, FIXED_V)
        self.ConnectPorts('TotalQ', SIG_PORT, 'Set', SIG_PORT + '0')
        self.ConnectPorts('IdealQ', SIG_PORT, 'Set', SIG_PORT + '1')
        self.ConnectPorts('EfficiencySig', OUT_PORT, 'Set', Set.MULT_PORT)

        # energy stream balance
        self.mix = Balance.BalanceOp()
        self.AddUnitOperation(self.mix, 'Mix')
        self.mix.SetParameterValue(NUSTIN_PAR + Balance.S_ENE, 1)
        self.mix.SetParameterValue(NUSTOUT_PAR + Balance.S_ENE, 2)
        self.mix.SetParameterValue(Balance.BALANCETYPE_PAR,
                                   Balance.ENERGY_BALANCE)

        # connect the mixer ports
        self.ConnectPorts('IdealQ', IN_PORT, 'Mix', OUT_PORT + 'Q0')
        self.ConnectPorts('WasteQ', IN_PORT, 'Mix', OUT_PORT + 'Q1')
        self.ConnectPorts('TotalQ', OUT_PORT, 'Mix', IN_PORT + 'Q0')

        # export the flow ports
        self.BorrowChildPort(self.ideal.GetPort(IN_PORT), IN_PORT)
        self.BorrowChildPort(self.waste.GetPort(OUT_PORT), OUT_PORT)
        self.BorrowChildPort(self.totalQ.GetPort(IN_PORT), IN_PORT + 'Q')
        self.BorrowChildPort(self.effStream.GetPort(IN_PORT), EFFICIENCY_PORT)
        self.BorrowChildPort(self.ideal.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)