Gas Turbine_Error in fuel composition analysis #461
-
Hello,
Any help or suggestion for this problem would be much appreciated! Code: from tespy.networks import Network
from tespy.components import (
DiabaticCombustionChamber, Turbine, Source, Sink, Compressor
)
from tespy.connections import Connection, Ref, Bus
nw = Network(p_unit="bar", T_unit="C", h_unit="kJ / kg")
cp = Compressor("Compressor")
cc = DiabaticCombustionChamber("combustion chamber")
tu = Turbine("turbine")
air = Source("air source")
fuel = Source("fuel source")
fg = Sink("flue gas sink")
c2 = Connection(air, "out1", cc, "in1", label="2")
c3 = Connection(cc, "out1", fg, "in1", label="3")
c5 = Connection(fuel, "out1", cc, "in2", label="5")
nw.add_conns(c2, c3, c5)
cc.set_attr(pr=0.97, eta=1, lamb=1.5, ti=None) # or ti=132.778e6 W (LHV = 49.736 MJ/kg for natural gas)
c2.set_attr(
p=0.93194, T=13.5,
fluid={"Ar": 0.0129, "N2": 0.7553, "CO2": 0.0004, "O2": 0.2314}
) # fluid: air -> composition by mass fractions, m=122.415
c5.set_attr(m=0.0001, p=Ref(c2, 1.05, 0), T=13.5, fluid={"CH4": 0.96, "ETHANE": 0.04, "H2": 0}) # fluid: natural gas -> composition by mass fractions
nw.solve(mode="design")
#cc.set_attr(ti=None)
c5.set_attr(m=None)
c5.set_attr(m=1)
nw.solve(mode="design")
c5.set_attr(m=None)
c5.set_attr(m=2.66966)
nw.solve(mode="design")
cc.set_attr(lamb=None)
c3.set_attr(T=1306.85)
nw.solve(mode="design")
nw.print_results()
print(nw.results["Connection"])
nw.del_conns(c2, c3)
c1 = Connection(air, "out1", cp, "in1", label="1")
c2 = Connection(cp, "out1", cc, "in1", label="2")
c3 = Connection(cc, "out1", tu, "in1", label="3")
c4 = Connection(tu, "out1", fg, "in1", label="4")
nw.add_conns(c1, c2, c3, c4)
generator = Bus("generator")
generator.add_comps(
{"comp": tu, "char": 0.98, "base": "component"},
{"comp": cp, "char": 1, "base": "bus"},
)
nw.add_busses(generator)
cp.set_attr(eta_s=0.82, pr=21.1)
tu.set_attr(eta_s=0.87)
c1.set_attr(
m=None, p=0.93194, T=13.5,
fluid={"Ar": 0.0129, "N2": 0.7553, "CO2": 0.0004, "O2": 0.2314}
) # fluid: air -> composition by mass fractions, m=122.415
c3.set_attr(m=125.085)
c4.set_attr(p=Ref(c1, 1.03, 0))
c5.set_attr(p=None)
c5.set_attr(p=Ref(c2, 1.05, 0))
nw.solve("design")
c3.set_attr(m=None, T=1306.85) # or m=125.085
nw.solve("design")
nw.print_results()
# fuel composition analysis
hyd = np.linspace(0, 0.75, 16), # hydrogen volume (molar) fraction in fuel mixture
# Brayton cycle net power output
power = []
# Brayton cycle efficiency
eta = []
MW_CH4 = 16 # [g/mol]
MW_C2H6 = 30 # [g/mol]
MW_H2 = 2 # [g/mol]
for x_H2 in hyd:
x_NG = 1-x_H2 # natural gas volume (molar) fraction in fuel mixture
x_CH4 = 0.9782*x_NG # methane volume (molar) fraction in fuel mixture (for 96 mass% CH4 and 4 mass% C2H6 in natural gas)
x_C2H6 = 0.0218*x_NG # ethane volume (molar) fraction in fuel mixture (for 96 mass% CH4 and 4 mass% C2H6 in natural gas)
c5.set_attr(fluid={"CH4": (MW_CH4*x_CH4)/((MW_CH4*x_CH4)+(MW_C2H6*x_C2H6)+(MW_H2*x_H2)),
"ETHANE": (MW_C2H6*x_C2H6)/((MW_CH4*x_CH4)+(MW_C2H6*x_C2H6)+(MW_H2*x_H2)),
"H2": (MW_H2*x_H2)/((MW_CH4*x_CH4)+(MW_C2H6*x_C2H6)+(MW_H2*x_H2))}) # fluid: natural gas-hydrogen mixture -> composition by mass fractions
#c5.set_attr(fluid_balance=True)
#print(c5.fluid_data)
nw.solve('design')
power += [abs(generator.P.val) / 1e6] # [MWe]
eta += [(abs(generator.P.val) / cc.ti.val) * 100]
# reset to base fuel composition
c5.set_attr(fluid={"CH4": 0.96, "ETHANE": 0.04, "H2": 0})
# plotting
fig, ax = plt.subplots(2, 1, figsize=(16, 8), sharex='col')
ax = ax.flatten()
[a.grid() for a in ax]
i = 0
for key in hyd:
ax[i].scatter(hyd[key] * 100, eta[key], s=100, color="#1f567d")
ax[i + 1].scatter(hyd[key] * 100, power[key], s=100, color="#18a999")
i += 1
ax[0].set_ylabel('Efficiency (%)')
ax[1].set_ylabel('Net electric power output [MWe]')
ax[1].set_xlabel('Hydrogen volume fraction in fuel mixture (%)')
plt.tight_layout()
fig.savefig('Gas Turbine_fuel composition analysis.svg')
plt.close() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! The issue is, that you are passing an array to all the fluid mass fractions, that cannot work. You do not iterate over the values of the numpy array but over the values of the tuple (first is numpy array, there are no other values in there. hyd = np.linspace(0, 0.75, 16), # hydrogen volume (molar) fraction in fuel mixture
# ^ Due to this comma, python saves the numpy array in a tuple.
for x_H2 in hyd:
x_NG = 1-x_H2 # natural gas volume (molar) fraction in fuel mixture |
Beta Was this translation helpful? Give feedback.
Hi!
The issue is, that you are passing an array to all the fluid mass fractions, that cannot work. You do not iterate over the values of the numpy array but over the values of the tuple (first is numpy array, there are no other values in there.