Example #1
0
def read_devicefile(filename):
    devFile = open(filename, 'r')
    discardHeader = devFile.readline()
    Comps = {}
    i = 0
    begId = 2
    for line in devFile:
        dev = line.split(',')
        if dev[1] == "TURBINE":
            Comps[dev[0]] = turbine.Turbine(dev[0], int(dev[begId]),
                                            int(dev[begId + 1]))
        elif dev[1] == "BOILER":
            Comps[dev[0]] = boiler.Boiler(dev[0], int(dev[begId]),
                                          int(dev[begId + 1]))
        elif dev[1] == "CONDENSER":
            Comps[dev[0]] = condenser.Condenser(dev[0], int(dev[begId]),
                                                int(dev[begId + 1]))
        elif dev[1] == "PUMP":
            Comps[dev[0]] = pump.Pump(dev[0], int(dev[begId]),
                                      int(dev[begId + 1]))

        i = i + 1

    DevNum = i
    return Comps, DevNum
Example #2
0
def read_jsonfile(filename):
    """ rankine cycle in json file"""

    # 1 read json file to dict
    with open(filename, 'r') as f:
        rkcyc = json.loads(f.read())

    # print(rkcyc)
    name = rkcyc["name"]
    dictnodes = rkcyc["nodes"]
    dictcomps = rkcyc["comps"]

    # 2 convert dict nodes to the object nodes
    countNodes = len(dictnodes)
    nodes = [None for i in range(countNodes)]
    for curjnode in dictnodes:
        i = int(curjnode['id'])
        nodes[i] = node.Node(curjnode['name'], i)
        nodes[i].p = curjnode['p']
        nodes[i].t = curjnode['t']
        nodes[i].x = curjnode['x']

        if nodes[i].p != None and nodes[i].t != None:
            nodes[i].pt()
        elif nodes[i].p != None and nodes[i].x != None:
            nodes[i].px()
        elif nodes[i].t != None and nodes[i].x != None:
            nodes[i].tx()

    #print(nodes[1])

    # 3 convert dict Comps to the object Comps
    DevNum = len(dictcomps)
    Comps = {}
    for curdev in dictcomps:
        if curdev['type'] == "TURBINE":
            Comps[curdev['name']] = turbine.Turbine(curdev['name'],
                                                    curdev['inNode'],
                                                    curdev['exNode'])
        elif curdev['type'] == "BOILER":
            Comps[curdev['name']] = boiler.Boiler(curdev['name'],
                                                  curdev['inNode'],
                                                  curdev['exNode'])
        elif curdev['type'] == "CONDENSER":
            Comps[curdev['name']] = condenser.Condenser(
                curdev['name'], curdev['inNode'], curdev['exNode'])
        elif curdev['type'] == "PUMP":
            Comps[curdev['name']] = pump.Pump(curdev['name'], curdev['inNode'],
                                              curdev['exNode'])

    return name, nodes, countNodes, Comps, DevNum
Example #3
0
def RankineCycle():
    condenserOverCool = 0.1
    condenserPressure = 0.006
    desiredQuality = 0.9

    table = []

    for boilerPressure in [1, 1.5, 2]:
        nodes = []
        for i in range(4):
            nodes.append(Node.Node())

        nodes[0].p = boilerPressure

        nodes[1].p = condenserPressure
        nodes[1].x = desiredQuality

        nodes[2].p = condenserPressure
        nodes[2].x = 0

        nodes[3].p = boilerPressure

        #  simulate
        nodes[1].px()
        t = turbine.Turbine(nodes[0], nodes[1])
        t.simulate()
        nodes[0] = t.inletNode

        nodes[2].px()
        c = condenser.Condenser(nodes[1], nodes[2])
        c.simulate(condenserOverCool)
        nodes[2] = c.exitNode

        p = pump.Pump(nodes[2], nodes[3])
        p.simulate()
        nodes[3] = p.exitNode

        b = boiler.Boiler(nodes[3], nodes[0])
        b.simulate()

        efficiency = (t.workExtracted - p.workRequired) / (b.heatAdded)

        table.append([boilerPressure, efficiency])

    print(tabulate(table, headers=["Boiler Pressure", "Efficiency"]))
Example #4
0
def main():
    condenserOverCool = 0.1
    condenserPressure = 0.006

    desiredQuality = 0.9

    table = []

    for boilerPressure in [1, 1.5, 2]:
        turbineEntropy = iapws.IAPWS97(P=condenserPressure, x=desiredQuality).s

        turbineInletTemperature = iapws.IAPWS97(P=boilerPressure,
                                                s=turbineEntropy).T

        condenserExitState = iapws.IAPWS97(x=0, P=condenserPressure)
        condenserExitState = iapws.IAPWS97(h=condenserExitState.h -
                                           condenserOverCool,
                                           P=condenserPressure)

        p = pump.Pump(condenserExitState)
        p.simulate(boilerPressure)

        b = boiler.Boiler(p.exitState)
        b.simulate(turbineInletTemperature)

        boilerSaturationTemp = iapws.IAPWS97(P=boilerPressure, x=0.5).T
        degreeOfSuperheat = turbineInletTemperature - boilerSaturationTemp

        t = turbine.Turbine(b.exitState)
        t.simulate(condenserPressure)

        c = condenser.Condenser(t.exitState)
        c.simulate(condenserExitState.T)

        efficiency = (t.workExtracted - p.workRequired) / (b.heatAdded)

        table.append([boilerPressure, degreeOfSuperheat, efficiency])

    print tabulate(
        table,
        headers=["Boiler Pressure", "Degree of Superheat", "Efficiency"])
Example #5
0
def RankineCycle():
    boilerPressure = 8.0
    condenserPressure = 0.008
    Wcycledot = 100.00

    # 1 init nodes
    nodes = []
    for i in range(4):
        nodes.append(node.Node())

    nodes[0].p = boilerPressure
    nodes[0].x = 1

    nodes[1].p = condenserPressure

    nodes[2].p = condenserPressure
    nodes[2].x = 0

    nodes[3].p = boilerPressure

    nodes[0].px()
    nodes[2].px()

    # 2 connect device
    t = turbine.Turbine(0, 1)
    p = pump.Pump(2, 3)
    b = boiler.Boiler(3, 0)

    # 3 simulate
    t.simulate(nodes)
    p.simulate(nodes)

    bwr = p.workRequired / t.workExtracted
    mdot = Wcycledot * 1000.0* 3600.0 / (t.workExtracted - p.workRequired)

    b.simulate(nodes, mdot)                  # in MW
    efficiency = (t.workExtracted - p.workRequired) / \
        (b.heatAdded)                # in MW

   # 4 condenser
    nodew = []
    for i in range(2):
        nodew.append(node.Node())

    nodew[0].t = 15
    nodew[0].x = 0
    nodew[1].t = 35
    nodew[1].x = 0
    nodew[0].tx()
    nodew[1].tx()

    c = condenser.Condenser(1, 2, 0, 1)
    c.simulate(nodes, nodew, mdot)

    print("Boiler Pressure: ", boilerPressure, "MPa")
    print("Condenser Pressure: ", condenserPressure, "MPa")
    print("The net power output of the cycle: ", Wcycledot, "MW")
    print("Cooling water enters the condenser T", nodew[0].t, "°C")
    print("Cooling water exits  the condenser T", nodew[1].t, "°C")
    print(" \n --------------------------------------------------")
    print("Efficiency: ", '%.2f' % (efficiency * 100), "%")
    print("The back work ratio: ", '%.2f' % (bwr * 100), "%")
    print("The mass flow rate: ",  '%.2f' % mdot, "%")
    print('The rate of heat transfer as the fluid passes the boiler: ',
          '%.2f' % b.Qindot, 'MW')
    print('The rate of heat transfer from the condensing steam: ',
          '%.2f' % c.Qoutdot, 'MW')
    print('The mass flow rate of the condenser cooling water: ', '%.2f' %
          c.mcwdot, 'kg/h')
    def __init__(self, th_order, el_order, peak_th_power, maxr_th_power,
                 global_radiation):
        """
        Constructor class for supply system

        :param th_order: Thermal priority of system
        :param el_order: Electrical priority of system
        :param peak_th_power: Peak thermal power
        :param maxr_th_power: Thermal power according to maximum rectangle method
        :param global_radiation: Hourly global radiation values
        :return:
        """
        self.th_order = th_order
        self.el_order = el_order
        self.total_annuity = 0
        self.total_emissions = 0
        self.total_pef = 0
        self.peak_th_power = peak_th_power
        self.maxr_th_power = maxr_th_power
        self.global_radiation = global_radiation
        # ---------------------------------------------------------------------
        # CHP
        # If CHP is present, it will check for a peak load device. If peak load
        # device is present, CHP is sized according to maximum rectangle
        # method. Otherwise it is sized according to peak thermal load.
        if 'CHP' in th_order and 'ElHe' not in th_order and 'B' not in th_order:
            self.OnOffCHP = CHP.OnOffCHP(
                database.get_chp_capacity(self.peak_th_power))
        if 'CHP' in th_order and ('ElHe' in th_order or 'B' in th_order):
            self.OnOffCHP = CHP.OnOffCHP(
                database.get_chp_capacity(self.maxr_th_power))

        # ---------------------------------------------------------------------
        # Boiler
        # If boiler is present, dimension it to peak thermal demand
        if 'B' in th_order:
            self.B = boiler.Boiler(database.get_b_capacity(self.peak_th_power))

        # ---------------------------------------------------------------------
        # Electric Resistance Heater
        # If electric heater is present, dimension it to peak thermal demand
        if 'ElHe' in th_order:
            self.ElHe = electricheater.ElectricHeater(
                'Electric Heater Model',
                database.get_elhe_capacity(self.peak_th_power))

        # ---------------------------------------------------------------------
        # Thermal Storage
        # If thermal storage is present, dimension it according to CHP
        # capacity.
        if 'ThSt' in th_order:
            self.ThSt = thermalstorage.ThermalStorage(
                database.get_thst_capacity(3 * self.OnOffCHP.th_capacity))

        # ---------------------------------------------------------------------
        # Solar Thermal
        # If Solar thermal is present, dimension according to roof area
        if 'SolTh' in th_order:
            self.SolTh = solarthermal.SolarThermal(
                'Buderus SKS 5.0-s',
                database.get_solth_capacity(database.SolTh_available_area),
                self.global_radiation)

        # ---------------------------------------------------------------------
        # Photovoltaics
        # If PV is present, dimension according to roof area
        if 'PV' in el_order:
            self.PV = photovoltaics.Photovoltaics(
                'Buderus aleo s19',
                database.get_pv_capacity(database.PV_available_area),
                self.global_radiation)

        # ---------------------------------------------------------------------
        # Electrical Storage
        # Dimension logic to be implemented
        if 'ElSt' in el_order:
            self.ElSt = electricalstorage.ElectricalStorage(
                'Model', database.ElSt_capacity, 1)

        # ---------------------------------------------------------------------
        # HeatPump

        # ---------------------------------------------------------------------
        # Electrical Grid
        # Initialising electrical grid
        self.ElGrid = electricalgrid.ElectricalGrid()
        return