tespy.components.combustion package

tespy.components.combustion.base module

Module of class CombustionChamber.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/base.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.base.CombustionChamber(label, **kwargs)[source]

Bases: Component

The class CombustionChamber is parent class of all combustion components.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen, carbon monoxide, nDodecane

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamber flowsheet of the combustion chamber

Note

The fuel and the air components can be connected to either of the inlets.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Actual oxygen to stoichiometric oxygen ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

Note

For more information on the usage of the combustion chamber see the examples section on github or look for the combustion chamber tutorials at tespy.readthedocs.io.

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel.

>>> from tespy.components import Sink, Source, CombustionChamber
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.fluid_properties import T_sat_p
>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "temperature": "degC"
... })
>>> amb = Source('ambient air')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> comb = CombustionChamber('combustion chamber')
>>> amb_comb = Connection(amb, 'out1', comb, 'in1')
>>> sf_comb = Connection(sf, 'out1', comb, 'in2')
>>> comb_fg = Connection(comb, 'out1', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)

Specify the thermal input of the combustion chamber. At the given fluid compositions this determines the mass flow of the fuel. The outlet temperature of the flue gas determines the ratio of oxygen to fuel mass flow.

>>> comb.set_attr(ti=500000)
>>> amb_comb.set_attr(p=1, T=20, fluid={'Ar': 0.0129, 'N2': 0.7553,
... 'CO2': 0.0004, 'O2': 0.2314})
>>> sf_comb.set_attr(T=25, fluid={'CO2': 0.03, 'H2': 0.01, 'CH4': 0.96})
>>> comb_fg.set_attr(T=1200)
>>> nw.solve('design')
>>> round(comb.lamb.val, 3)
2.014
>>> comb.set_attr(lamb=2)
>>> comb_fg.set_attr(T=None)
>>> nw.solve('design')
>>> round(comb_fg.T.val, 1)
1206.6
bus_deriv(bus)[source]

Calculate the matrix of partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

val (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\dot{E} = LHV \cdot \dot{m}_{f}\]

calc_lambda()[source]

Calculate oxygen to stoichimetric oxygen ration

Returns:

lambda (float) – Oxygent to stoichiometric oxygen ratio.

\[ \begin{align}\begin{aligned}\lambda = \frac{\dot{m}_{f,m}}{\dot{m}_{O_2,m} \cdot \left(n_{C,fuel} + 0.25 \cdot n_{H,fuel}\right)}\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in inlets\end{split}\end{aligned}\end{align} \]

calc_lhv(f)[source]

Calculate the lower heating value of the combustion chamber’s fuel.

  • Source for fluids O2, H2O and CO2: [20]

  • Source for all other fluids: [21]

Parameters:

f (str) – Alias of the fuel.

Returns:

val (float) – Lower heating value of the combustion chambers fuel.

\[\begin{split}LHV = -\frac{\sum_i {\Delta H_f^0}_i - \sum_j {\Delta H_f^0}_j } {M_{fuel}}\\ \forall i \in \text{reation products},\\ \forall j \in \text{reation educts},\\ \Delta H_f^0: \text{molar formation enthalpy}\end{split}\]

calc_parameters()[source]

Postprocessing parameter calculation.

calc_ti()[source]

Calculate the thermal input of the combustion chamber.

Returns:

ti (float) – Thermal input.

\[ti = LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{fuel,in,i} \right) - \dot{m}_{out,1} \cdot x_{fuel,out,1} \right] \; \forall i \in [1,2]\]

combustion_pressure_structure_matrix(k)[source]

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equations.

\[\begin{split}0 = p_\mathrm{in,1} - p_\mathrm{out,1}\\ 0 = p_\mathrm{in,2} - p_\mathrm{out,1}\end{split}\]

convergence_check()[source]

Perform a convergence check.

Note

Manipulate enthalpies/pressure at inlet and outlet if not specified by user to match physically feasible constraints, keep fluid composition within feasible range and then propagates it towards the outlet.

energy_balance_dependents()[source]
energy_balance_func()[source]

Calculate the energy balance of the adiabatic combustion chamber.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & -\dot{m}_{out,2}\cdot\left( h_{out,1}-h_{out,1,ref} \right)\\ & + LHV_{fuel} \cdot\left(\sum_i\dot{m}_{in,i}\cdot x_{fuel,in,i}- \dot{m}_{out,1} \cdot x_{fuel} \right) \end{split}\\\end{split}\\\forall i \in \text{inlets}\end{aligned}\end{align} \]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the state of the water in the flue gas is forced to gaseous.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

entropy_balance()[source]

Calculate entropy balance of combustion chamber.

Note

The entropy balance makes the following parameter available:

  • T_mcomb: Thermodynamic temperature of heat of combustion

  • S_comb: Entropy production due to combustion

  • S_irr: Entropy production due to irreversibilty

The methodology for entropy analysis of combustion processes is derived from [22]. Similar to the energy balance of a combustion reaction, we need to define the same reference state for the entropy balance of the combustion. The temperature for the reference state is set to 25 °C and reference pressure is 1 bar. As the water in the flue gas may be liquid but the thermodynmic temperature of heat of combustion refers to the lower heating value, the water is forced to gas at the reference point by considering evaporation.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

\[\begin{split}T_\mathrm{m,comb}= \frac{\dot{m}_\mathrm{fuel} \cdot LHV} {\dot{S}_\mathrm{comb}}\\ \dot{S}_\mathrm{comb}= \dot{m}_\mathrm{fluegas} \cdot \left(s_\mathrm{fluegas}-s_\mathrm{fluegas,ref}\right) - \sum_{i=1}^2 \dot{m}_{\mathrm{in,}i} \cdot \left( s_{\mathrm{in,}i} - s_{\mathrm{in,ref,}i} \right)\\ \dot{S}_\mathrm{irr}= 0\\\end{split}\]
exergy_balance(T0)[source]

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]
get_parameters()[source]
static initialise_source(c, key)[source]

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]
lambda_dependents()[source]
lambda_func()[source]

Calculate the residual for specified lambda.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \frac{\dot{m}_{f,m}}{\dot{m}_{O_2,m} \cdot \left(n_{C,fuel} + 0.25 \cdot n_{H,fuel}\right)} - \lambda\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in inlets\end{split}\end{aligned}\end{align} \]

mass_flow_dependents()[source]
mass_flow_deriv(increment_filter, k, dependents=None)[source]

Calculate the partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the fluid equations.

mass_flow_func()[source]

Calculate the residual value for component’s mass flow balance.

Returns:

residual (list) – Vector with residual value for component’s mass flow balance.

\[0 = \dot{m}_{in,1} + \dot{m}_{in,2} - \dot{m}_{out,1}\]

static outlets()[source]
propagate_wrapper_to_target(branch)[source]
setup_reaction_parameters()[source]

Setup parameters for reaction (gas name aliases and LHV).

stoichiometry(fluid)[source]

Calculate the reaction balance for one fluid.

  • determine molar mass flows of fuel and oxygen

  • calculate mole number of carbon and hydrogen atoms in fuel

  • calculate molar oxygen flow for stoichiometric combustion

  • calculate residual value for the corresponding fluid

for excess fuel

  • calculate excess carbon and hydrogen in fuels

  • calculate excess fuel shares

General equations

\[ \begin{align}\begin{aligned}\begin{split}res = \sum_i \left(x_{fluid,i} \cdot \dot{m}_{i}\right) - \sum_j \left(x_{fluid,j} \cdot \dot{m}_{j}\right)\\ \forall i \in \text{combustion inlets}\\ \forall j \in text{flue gas outlet}\end{split}\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in \text{combustion inlets}\end{split}\\\dot{m}_{O_2,m,stoich}=\frac{\dot{m}_{H_m}}{4} + \dot{m}_{C_m}\\\lambda = \frac{\dot{m}_{O_2,m}}{\dot{m}_{O_2,m,stoich}}\end{aligned}\end{align} \]

Excess carbon and hydrogen

\[ \begin{align}\begin{aligned}\begin{split}\dot{m}_{H_{exc,m}} = \begin{cases} 0 & \lambda \geq 1\\ 4 \cdot \left( \dot{m}_{O_2,m,stoich} - \dot{m}_{O_2,m}\right) & \lambda < 1 \end{cases}\end{split}\\\begin{split}\dot{m}_{C_{exc,m}} = \begin{cases} 0 & \lambda \geq 1\\ \dot{m}_{O_2,m,stoich} - \dot{m}_{O_2,m} & \lambda < 1 \end{cases}\end{split}\end{aligned}\end{align} \]

Equation for fuels

\[ \begin{align}\begin{aligned}\begin{split}0 = res - \left(\dot{m}_{f,m} - \dot{m}_{f,exc,m}\right) \cdot M_{fuel}\\\end{split}\\\begin{split}\dot{m}_{f,exc,m} = \begin{cases} 0 & \lambda \geq 1\\ \dot{m}_{f,m} - \frac{\dot{m}_{O_2,m}} {n_{C,fuel} + 0.25 \cdot n_{H,fuel}} \end{cases}\end{split}\end{aligned}\end{align} \]

Equation for oxygen

\[\begin{split}0 = res - \begin{cases} -\frac{\dot{m}_{O_2,m} \cdot M_{O_2}}{\lambda} & \lambda \geq 1\\ - \dot{m}_{O_2,m} \cdot M_{O_2} & \lambda < 1 \end{cases}\end{split}\]

Equation for water

\[0 = res + \left( \dot{m}_{H_m} - \dot{m}_{H_{exc,m}} \right) \cdot 0.5 \cdot M_{H_2O}\]

Equation for carbondioxide

\[0 = res + \left( \dot{m}_{C_m} - \dot{m}_{C_{exc,m}} \right) \cdot M_{CO_2}\]

Equation for all other fluids

\[0 = res\]
Parameters:

fluid (str) – Fluid to calculate residual value for.

Returns:

residual (float) – Residual value for corresponding fluid.

stoichiometry_dependents()[source]
stoichiometry_deriv(increment_filter, k, dependents=None)[source]

Calculate partial derivatives of the reaction balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

stoichiometry_func()[source]

Collect residual values for all fluids in stoichiometry.

Returns:

residual (list) – Vector with residual values of equations.

ti_dependents()[source]
ti_deriv(increment_filter, k, dependents=None)[source]

Calculate partial derivatives of thermal input function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

ti_func()[source]

Calculate the residual for specified thermal input.

Returns:

residual (float) – Residual value of function.

\[0 = ti - \dot{m}_{fuel} \cdot LHV\]

tespy.components.combustion.diabatic module

Module of class DiabaticCombustionChamber.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/diabatic.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.diabatic.DiabaticCombustionChamber(label, **kwargs)[source]

Bases: CombustionChamber

The class CombustionChamber is parent class of all combustion components.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen, carbon monoxide, nDodecane

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamber flowsheet of the combustion chamber

Note

The fuel and the air components can be connected to either of the inlets. The pressure of inlet 2 is disconnected from the pressure of inlet 1. A warning is prompted, if the pressure at inlet 2 is lower than the pressure at inlet 1.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Actual oxygen to stoichiometric oxygen ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

  • eta (float, dict) – Combustion thermal efficiency, \(\eta\). Heat loss calculation based on share of thermal input.

  • pr (float, dict) – Pressure ratio of outlet 1 to inlet 1, \(pr\).

Note

For more information on the usage of the combustion chamber see the examples section on github or look for the combustion chamber tutorials at tespy.readthedocs.io.

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel.

>>> from tespy.components import Sink, Source, DiabaticCombustionChamber
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.fluid_properties import T_sat_p
>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "temperature": "degC"
... })
>>> amb = Source('ambient air')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> comb = DiabaticCombustionChamber('combustion chamber')
>>> amb_comb = Connection(amb, 'out1', comb, 'in1')
>>> sf_comb = Connection(sf, 'out1', comb, 'in2')
>>> comb_fg = Connection(comb, 'out1', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)

Specify the thermal input of the combustion chamber. At the given fluid compositions this determines the mass flow of the fuel. The outlet temperature of the flue gas determines the ratio of oxygen to fuel mass flow. In contrast to the simple combustion chamber, this component does allow for a pressure drop. Therefore the outlet pressure or the pressure ratio of the combustion chamber must be specified. Since the component is not adiabatic, an efficiency value eta can be supplied to account for heat loss to the ambient. First, we specify eta=1 and expect identical lambda or outlet temperature as in an adiabatic combustion chamber.

>>> comb.set_attr(ti=500000, pr=0.95, eta=1)
>>> amb_comb.set_attr(
...     p=1.2, T=20,
...     fluid={'Ar': 0.0129, 'N2': 0.7553, 'CO2': 0.0004, 'O2': 0.2314}
... )
>>> sf_comb.set_attr(
...     p=1.3, T=25, fluid={'CO2': 0.03, 'H2': 0.01, 'CH4': 0.96}
... )
>>> comb_fg.set_attr(T=1200)
>>> nw.solve('design')
>>> round(comb.lamb.val, 3)
2.014
>>> round(comb_fg.p.val, 2)
1.14

Instead of the pressure ration, we can also specify the outlet pressure. The pressure ratio is the ratio or pressure at the outlet to the pressure at the inlet 1 (ambient air inlet in this example).

>>> comb.set_attr(pr=None)
>>> comb_fg.set_attr(p=1)
>>> nw.solve('design')
>>> round(comb.pr.val, 3)
0.833

We can change lambda to a specific value and unset the flue gas temperature:

>>> comb.set_attr(lamb=2)
>>> comb_fg.set_attr(T=None)
>>> nw.solve('design')
>>> round(comb_fg.T.val, 1)
1206.5

Now, if we change the efficiency value, e.g. to 0.9, a total of 10 % of heat respective to the thermal input will be transferred to the ambient. Note, that the heat loss Qloss has a negative value as it is extracted from the system.

>>> eta = 0.9
>>> comb.set_attr(eta=eta)
>>> nw.solve('design')
>>> round(comb.Qloss.val, 0)
-50000.0
>>> round(comb.ti.val * comb.eta.val, 0)
450000.0
calc_parameters()[source]

Postprocessing parameter calculation.

energy_balance_func()[source]

Calculate the energy balance of the diabatic combustion chamber.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & -\dot{m}_{out,2}\cdot\left( h_{out,1}-h_{out,1,ref} \right)\\ & + LHV_{fuel} \cdot\left(\sum_i\dot{m}_{in,i}\cdot x_{fuel,in,i}- \dot{m}_{out,1} \cdot x_{fuel} \right) \cdot \eta \end{split}\\\end{split}\\\forall i \in \text{inlets}\end{aligned}\end{align} \]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the state of the water in the flue gas is fored to gaseous.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

exergy_balance(T0)[source]

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]
get_parameters()[source]

tespy.components.combustion.engine module

Module of class CombustionEngine.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/engine.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.engine.CombustionEngine(label, **kwargs)[source]

Bases: CombustionChamber

An internal combustion engine supplies power and heat cogeneration.

The combustion engine produces power and heat in cogeneration from fuel combustion. The combustion properties are identical to the combustion chamber. Thermal input and power output, heat output and heat losses are linked with an individual characteristic line for each property.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen, carbon monoxide, nDodecane

Inlets/Outlets

  • in1, in2 (cooling water), in3, in4 (air and fuel)

  • out1, out2 (cooling water), out3 (flue gas)

Power outlets

  • power

Image

flowsheet of the combustion engine flowsheet of the combustion engine

Note

The fuel and the air components can be connected to either of the inlets.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Air to stoichiometric air ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

  • P (float, dict, "var") – Power output, \(P/\text{W}\).

  • Q1 (float, dict) – Heat output 1, \(\dot Q/\text{W}\).

  • Q2 (float, dict) – Heat output 2, \(\dot Q/\text{W}\).

  • Qloss (float, dict, "var") – Heat loss, \(\dot Q_{loss}/\text{W}\).

  • pr1 (float, dict, "var") – Pressure ratio heat outlet 1, \(pr/1\).

  • pr2 (float, dict, "var") – Pressure ratio heat outlet 2, \(pr/1\).

  • zeta1 (float, dict, "var") – Geometry independent friction coefficient heating loop 1, \(\zeta_1/\frac{1}{\text{m}^4}\).

  • zeta2 (float, dict, "var") – Geometry independent friction coefficient heating loop 2, \(\zeta_2/\frac{1}{\text{m}^4}\).

  • tiP_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking fuel input to power output.

  • Q1_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat output 1 to power output.

  • Q2_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat output 2 to power output.

  • Qloss_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat loss to power output.

  • eta_mech (float) – Value of internal efficiency of the combustion engine. This value is required to determine the (virtual) thermodynamic temperature of heat inside the combustion engine for the entropy balance calculation. Default value is 0.85.

Note

Parameters available through entropy balance are listed in the respective method:

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel. There are two cooling ports, the cooling water will flow through them in parallel.

>>> from tespy.components import (Sink, Source, CombustionEngine, Merge,
... Splitter)
>>> from tespy.connections import Connection, Ref
>>> from tespy.networks import Network
>>> import os
>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "temperature": "degC"
... })
>>> amb = Source('ambient')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> cw_in = Source('cooling water inlet')
>>> sp = Splitter('cooling water splitter', num_out=2)
>>> me = Merge('cooling water merge', num_in=2)
>>> cw_out = Sink('cooling water outlet')
>>> chp = CombustionEngine(label='internal combustion engine')
>>> amb_comb = Connection(amb, 'out1', chp, 'in3')
>>> sf_comb = Connection(sf, 'out1', chp, 'in4')
>>> comb_fg = Connection(chp, 'out3', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)
>>> cw_sp = Connection(cw_in, 'out1', sp, 'in1')
>>> sp_chp1 = Connection(sp, 'out1', chp, 'in1')
>>> sp_chp2 = Connection(sp, 'out2', chp, 'in2')
>>> chp1_me = Connection(chp, 'out1', me, 'in1')
>>> chp2_me = Connection(chp, 'out2', me, 'in2')
>>> me_cw = Connection(me, 'out1', cw_out, 'in1')
>>> nw.add_conns(cw_sp, sp_chp1, sp_chp2, chp1_me, chp2_me, me_cw)

The combustion engine produces a power output of 10 MW the oxygen to stoichiometric oxygen ratio is set to 1. Only pressure ratio 1 is set as we reconnect both cooling water streams. At the merge all pressure values will be identical automatically. Reference the mass flow at the splitter to be split in half.

>>> chp.set_attr(pr1=0.99, P=-10e6, lamb=1.0,
... design=['pr1'], offdesign=['zeta1'])
>>> amb_comb.set_attr(p=5, T=30, fluid={'Ar': 0.0129, 'N2': 0.7553,
... 'CO2': 0.0004, 'O2': 0.2314})
>>> sf_comb.set_attr(T=30, fluid={'CH4': 1})
>>> cw_sp.set_attr(p=3, T=60, m=50, fluid={'H2O': 1})
>>> sp_chp2.set_attr(m=Ref(sp_chp1, 1, 0))
>>> mode = 'design'
>>> nw.solve(mode=mode)
>>> nw.save('tmp.json')
>>> round(chp.ti.val, 0)
25300000.0
>>> round(chp.Q1.val, 0)
-4980000.0
>>> chp.set_attr(Q1=-4e6, P=None)
>>> mode = 'offdesign'
>>> nw.solve(mode=mode, init_path='tmp.json', design_path='tmp.json')
>>> round(chp.ti.val, 0)
17794554.0
>>> round(chp.P.val / chp.P.design, 3)
0.617
>>> chp.set_attr(P=chp.P.design * 0.75, Q1=None)
>>> mode = 'offdesign'
>>> nw.solve(mode=mode, init_path='tmp.json', design_path='tmp.json')
>>> round(chp.ti.val, 0)
20550000.0
>>> round(chp.P.val / chp.P.design, 3)
0.75
>>> os.remove('tmp.json')
Q1_char_dependents()[source]
Q1_char_func()[source]

Calculate the relation of heat output 1 and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{m}_1 \cdot \left(h_{out,1} - h_{in,1} \right) \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & - LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{Q1}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Q1_dependents()[source]
Q1_func()[source]

Calculate residual value of primary heat loop function.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_1 \cdot \left(h_{out,1} + h_{in,1} \right) + \dot{Q}_1\]

Q2_char_dependents()[source]
Q2_char_func()[source]

Calculate the relation of heat output 2 and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{m}_2 \cdot \left(h_{out,2} - h_{in,2} \right) \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & - LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{Q2}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Q2_dependents()[source]
Q2_func()[source]

Calculate residual value of secondary heat loop function.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_2 \cdot \left(h_{out,2} - h_{in,2} \right) + \dot{Q}_2\]

Qloss_char_dependents()[source]
Qloss_char_func()[source]

Calculate the relation of heat loss and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{Q}_{loss} \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & + LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{QLOSS}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

bus_deriv(bus)[source]

Calculate the matrix of partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

residual (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\begin{split}\dot{E} = \begin{cases} LHV \cdot \dot{m}_{f} & \text{key = 'TI'}\\ P & \text{key = 'P'}\\ -\dot{m}_1 \cdot \left( h_{1,out} - h_{1,in} \right) -\dot{m}_2 \cdot \left( h_{2,out} - h_{2,in} \right) & \text{key = 'Q'}\\ -\dot{m}_1 \cdot \left( h_{1,out} - h_{1,in} \right) & \text{key = 'Q1'}\\ -\dot{m}_2 \cdot \left( h_{2,out} - h_{2,in} \right) & \text{key = 'Q2'}\\ \dot{Q}_{loss} & \text{key = 'Qloss'} \end{cases}\end{split}\]

calc_P()[source]

Calculate the power output of the combustion engine.

Returns:

P (float) – Power output.

\[P = -\frac{LHV \cdot \dot{m}_{f}} {f_{TI}\left(\frac{P}{P_{ref}}\right)}\]

calc_Qloss()[source]

Calculate the heat loss of the combustion engine.

Returns:

Qloss (float) – Heat loss.

\[\dot{Q}_{loss} = -\frac{LHV \cdot \dot{m}_{f} \cdot f_{QLOSS}\left(\frac{P}{P_{ref}}\right)} {f_{TI}\left(\frac{P}{P_{ref}}\right)}\]

calc_parameters()[source]

Postprocessing parameter calculation.

check_parameter_bounds()[source]

Check parameter value limits.

energy_balance_dependents()[source]
energy_balance_deriv(increment_filter, k, dependents=None)[source]

Calculate partial derivatives of energy balance function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

energy_balance_func()[source]

Calculate the energy balance of the combustion engine.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & - \sum_j \dot{m}_{out,3} \cdot \left( h_{out,3} - h_{out,3,ref} \right)\\ & + LHV_{fuel} \cdot \left(\sum_i \left(\dot{m}_{in,i} \cdot x_{fuel,i} \right)- \dot{m}_{out,3} \cdot x_{fuel,3} \right)\\ & - \dot{Q}_1 - \dot{Q}_2 - P - \dot{Q}_{loss}\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the necessary enthalpy difference for evaporation is added.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_connector_balance_func()[source]
energy_connector_dependents()[source]
entropy_balance()[source]

Calculate entropy balance of combustion engine.

For the entropy balance of a combustion engine two additional parameters need to be specified:

  • virtual inner temperature T_v_inner that is used to determine the entropy of heat transferred from the hot side.

  • mechanical efficiency eta_mech describing the ratio of power output P to reversible power of the motor [23]. It is used to determine the irreversibilty inside the motor.

    \[P_\mathrm{irr,inner}=\left(1 - \frac{1}{\eta_\mathrm{mech}} \right) \cdot P\]

The default values are:

  • T_v_inner: flue gas temperature (result of calculation)

  • eta_mech: 0.85

Note

The entropy balance makes the following parameter available:

  • T_mcomb: Thermodynamic temperature of heat of combustion

  • S_comb: Entropy production due to combustion

  • T_mQ1: Thermodynamic temperature of heat at cold side of heater 1

  • S_Q11: Entropy transport at hot side of heater 1

  • S_Q12: Entropy transport at cold side of heater 1

  • S_Q1irr: Entropy production due to heat transfer at heater 1

  • S_irr1: Entropy production due to pressure losses at heater 1

  • T_mQ2: Thermodynamic temperature of heat at cold side of heater 2

  • S_Q21: Entropy transport at hot side of heater 2

  • S_Q22: Entropy transport at cold side of heater 2

  • S_Q2irr: Entropy production due to heat transfer at heater 2

  • S_irr2: Entropy production due to pressure losses at heater 2

  • S_irr_i: Entropy production due to internal irreversibilty

  • S_Qloss: Entropy transport with heat loss to ambient

  • S_Qcomb: Virtual entropy transport of heat to revert combustion gases to reference state

  • S_irr: Total entropy production due to irreversibilty

The methodology for entropy analysis of combustion processes is derived from [22]. Similar to the energy balance of a combustion reaction, we need to define the same reference state for the entropy balance of the combustion. The temperature for the reference state is set to 25 °C and reference pressure is 1 bar. As the water in the flue gas may be liquid but the thermodynmic temperature of heat of combustion refers to the lower heating value, the water is forced to gas at the reference point by considering evaporation.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

\[\begin{split}\begin{split} T_\mathrm{m,comb}= & \frac{\dot{m}_\mathrm{fuel} \cdot LHV} {\dot{S}_\mathrm{comb}}\\ \dot{S}_\mathrm{comb} =&\dot{S}_\mathrm{Q,comb}-\left( \dot{S}_\mathrm{Q,11} + \dot{S}_\mathrm{Q,21} + \dot{S}_\mathrm{Q,loss} +\dot{S}_\mathrm{irr,i}\right)\\ \dot{S}_\mathrm{Q,comb}= & \dot{m}_\mathrm{fluegas} \cdot \left(s_\mathrm{fluegas}-s_\mathrm{fluegas,ref}\right)\\ & - \sum_{i=3}^4 \dot{m}_{\mathrm{in,}i} \cdot \left( s_{\mathrm{in,}i} - s_{\mathrm{in,ref,}i} \right)\\ \dot{S}_\mathrm{Q,11}= & \frac{\dot{Q}_1}{T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{Q,21}= & \frac{\dot{Q}_2}{T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{Q,loss}= & \frac{\dot{Q}_\mathrm{loss}} {T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{irr,i}= & \frac{\left(1 - \frac{1}{\eta_\mathrm{mech}}\right) \cdot P}{T_\mathrm{v,inner}}\\ T_\mathrm{Q,12} = &\frac{-\dot{Q}_1}{\dot{m}_1 \cdot \left( s_\mathrm{out,1} - s_\mathrm{in,1}\right)}\\ T_\mathrm{Q,22} = &\frac{-\dot{Q}_2}{\dot{m}_2 \cdot \left( s_\mathrm{out,2} - s_\mathrm{in,2}\right)}\\ \dot{S}_\mathrm{irr} = &\sum \dot{S}_\mathrm{irr}\\ \end{split}\\\end{split}\]
exergy_balance(T0)[source]

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]
get_parameters()[source]
get_variables()[source]
static initialise_source(c, key)[source]

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]
static outlets()[source]
static poweroutlets()[source]
propagate_wrapper_to_target(branch)[source]
tiP_char_dependents()[source]
tiP_char_func()[source]

Calculate the relation of output power and thermal input.

Returns:

residual (float) – Residual value of equation.

\[0 = P \cdot f_{TI}\left(\frac{P}{P_{design}}\right)+ LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \; \forall i \in [3,4]\]

variable_equality_structure_matrix(k, **kwargs)[source]

Create pairwise linear relationship between two variables var for all inlets and the respective outlets. This usually is applied to mass flow, pressure, enthalpy and fluid composition.

\[var_\text{in,i} = var_\text{out,i}\]
Parameters:
  • k (int) – equation number in systems of equations

  • variable (str) – Connection variable name, e.g. h.