diff --git a/src/tespy/components/combustion/base.py b/src/tespy/components/combustion/base.py index 3dba17f5f..810820225 100644 --- a/src/tespy/components/combustion/base.py +++ b/src/tespy/components/combustion/base.py @@ -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) @@ -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) @@ -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. @@ -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 = ( -( @@ -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 ) diff --git a/src/tespy/networks/network.py b/src/tespy/networks/network.py index 9069b3a67..777388835 100644 --- a/src/tespy/networks/network.py +++ b/src/tespy/networks/network.py @@ -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: @@ -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(): diff --git a/src/tespy/tools/__init__.py b/src/tespy/tools/__init__.py index d1cf85187..054326185 100644 --- a/src/tespy/tools/__init__.py +++ b/src/tespy/tools/__init__.py @@ -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 diff --git a/src/tespy/tools/global_vars.py b/src/tespy/tools/global_vars.py index 730ded359..0f8e8190e 100644 --- a/src/tespy/tools/global_vars.py +++ b/src/tespy/tools/global_vars.py @@ -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() \ No newline at end of file