Beispiel #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
Beispiel #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
Beispiel #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"]))
Beispiel #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"])
Beispiel #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')