Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/tespy/components/combustion/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def setup_reaction_parameters(self):
self.fuel_list = []
all_fluids = set([f for c in self.inl + self.outl for f in c.fluid.val])
for f in all_fluids:
if fluidalias_in_list(f, combustion_gases):
if fluidalias_in_list(f, combustion_gases.fluids.keys()):
self.fuel_list += [f]

self.fuel_list = set(self.fuel_list)
Expand All @@ -248,7 +248,7 @@ def setup_reaction_parameters(self):
"Your network's fluids do not contain any fuels, that are "
f"available for the component {self.label} of type "
f"{self.__class__.__name__}. Available fuels are: "
f"{', '.join(combustion_gases)}."
f"{', '.join(combustion_gases.fluids.keys())}."
)
logger.error(msg)
raise TESPyComponentError(msg)
Expand Down Expand Up @@ -283,8 +283,16 @@ def setup_reaction_parameters(self):
self.fuels[f][el] = structure[el]
else:
self.fuels[f][el] = 0
self.fuels[f]['LHV'] = self.calc_lhv(f)

if f not in combustion_gases.fluids.keys():
self.fuels[f]['LHV'] = self.calc_lhv(f)
continue

if combustion_gases.fluids[f]['LHV'] is None:
self.fuels[f]['LHV'] = self.calc_lhv(f)
continue

self.fuels[f]['LHV'] = combustion_gases.fluids[f]['LHV']

def calc_lhv(self, f):
r"""
Calculate the lower heating value of the combustion chamber's fuel.
Expand Down Expand Up @@ -313,19 +321,13 @@ def calc_lhv(self, f):
"""
inl, _ = self._get_combustion_connections()
hf = {}
hf['hydrogen'] = 0
hf['methane'] = -74.6
hf['ethane'] = -84.0
hf['propane'] = -103.8
hf['butane'] = -125.7
hf['nDodecane'] = -289.4
hf['CO'] = -110.5

hf[self.o2] = 0
hf[self.co2] = -393.51
# water (gaseous)
hf[self.h2o] = -241.826

key = set(list(hf.keys())).intersection(FLUID_ALIASES.get_fluid(f))
key = set(list(combustion_gases.fluids.keys())).intersection(FLUID_ALIASES.get_fluid(f))

val = (
-(
Expand All @@ -335,7 +337,7 @@ def calc_lhv(self, f):
(
self.fuels[f]['C'] + self.fuels[f]['H'] / 4
- self.fuels[f]['O'] / 2
) * hf[self.o2] + hf[list(key)[0]]
) * hf[self.o2] + combustion_gases.fluids[list(key)[0]]['hf']
)
) / inl[0].fluid.wrapper[f]._molar_mass * 1000
)
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/networks/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from tespy.tools.global_vars import fluid_property_data as fpd
from tespy.tools.units import SI_UNITS
from tespy.tools.units import Units
from tespy.tools.global_vars import combustion_gases

# Only require cupy if Cuda shall be used
try:
Expand Down Expand Up @@ -179,6 +180,7 @@ def set_defaults(self):
self.design_path = None
self.iterinfo = True
self.units = Units()
self.combustion_gases = combustion_gases

msg = 'Default unit specifications:\n'
for prop, unit in self.units.default.items():
Expand Down
1 change: 1 addition & 0 deletions src/tespy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
from .helpers import UserDefinedEquation # noqa: F401
from .optimization import OptimizationProblem # noqa: F401
from .units import Units # noqa: F401
from .global_vars import combustion_gases
49 changes: 45 additions & 4 deletions src/tespy/tools/global_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,49 @@ def get_fluid(self, fluid):

FLUID_ALIASES = FluidAliases()

class COMBUSTION_GASES:
def __init__(self):
self.fluids={
'hydrogen': {'hf':0,
'LHV':None
},
'methane': {'hf':-74.6,
'LHV':None
},
'ethane': {'hf':-84.0,
'LHV':None
},
'propane':{'hf':-103.8,
'LHV':None
},
'butane':{'hf':-125.7,
'LHV':None
},
'nDodecane':{'hf':-289.4,
'LHV':None
},

'Dichloroethane':{'hf':-1.2979E+02,
'LHV':None
},
'CO':{'hf': -110.5,
'LHV':None
},
}
def add_fluid(self, fluid, hf= None, LHV=None):
"""Add a new fluid to the possible combustion gases.

Parameters
----------
fluid : str
name of the fluid. Must be a valid fluid within the fluid property backend.
hf: float
specific enthalpy of formation at standard conditions in kJ/mol
LHV: float
lower heating value of the fuel in J/mol
"""
self.fluids[fluid] = {'hf':hf,
'LHV':LHV
}

combustion_gases = [
'methane', 'ethane', 'propane', 'butane', 'hydrogen', 'nDodecane',
'CO'
]
combustion_gases = COMBUSTION_GASES()
Loading