exerpy.components

Component

class exerpy.components.component.Component(**kwargs)[source]

Bases: object

Base class for all ExerPy components.

This class serves as the parent class for all exergy analysis components. It provides the basic structure and methods for exergy analysis calculations including the calculation of exergetic efficiency and exergy balance.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments that will be assigned as attributes to the component.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

Notes

The exergetic efficiency is calculated as the ratio of exergy product to exergy fuel:

\[\varepsilon = \frac{\dot{E}_\mathrm{P}}{\dot{E}_\mathrm{F}}\]

The exergy balance for any component follows the principle:

\[\dot{E}_\mathrm{F} = \dot{E}_\mathrm{P} + \dot{E}_\mathrm{D}\]

See also

exerpy.components

Module containing all available components for exergy analysis

calc_epsilon()[source]

Calculate the exergetic efficiency of the component.

The exergetic efficiency is defined as the ratio of exergy product to exergy fuel. If the exergy fuel is zero, the function returns NaN to avoid division by zero.

Returns:

float or nan – Exergetic efficiency \(\varepsilon = \frac{\dot{E}_\mathrm{P}}{\dot{E}_\mathrm{F}}\) or NaN if \(\dot{E}_\mathrm{F} = 0\).

Notes

\[\begin{split}\varepsilon = \begin{cases} \frac{\dot{E}_\mathrm{P}}{\dot{E}_\mathrm{F}} & \mathrm{if } \dot{E}_\mathrm{F} \neq 0\\ \mathrm{NaN} & \mathrm{if } \dot{E}_\mathrm{F} = 0 \end{cases}\end{split}\]
calc_exergy_balance(T0: float, p0: float) None[source]

Calculate the exergy balance of the component.

This method should be implemented by child classes to perform specific exergy balance calculations.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Placeholder method for exergoeconomic balance.

This method is intentionally empty in the base class. In each child class (e.g. Pump, Turbine, HeatExchanger), you should override it with the logic that calculates the component’s exergoeconomic variables, e.g. C_F, C_P, C_D, r, and f.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.

exerpy.components.component.component_registry(cls)[source]

A decorator function to register components in the component registry. Registers the class using the class’s name as the key.

CombustionChamber

class exerpy.components.combustion.base.CombustionChamber(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of combustion chambers.

This class performs exergy and exergoeconomic analysis calculations for combustion chambers, considering both thermal and mechanical exergy flows, as well as chemical exergy flows. The exergy product is defined based on thermal and mechanical exergy differences, while the exergy fuel is based on chemical exergy differences.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

Notes

This component requires the calculation of both physical and chemical exergy.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Add auxiliary cost equations for the combustion chamber.

This method appends two rows to the cost matrix to enforce:

  1. F rule for mechanical exergy:

\[-\frac{1}{\dot{E}^{\mathrm{M}}_{\text{out}}}\,\dot{C}^{\mathrm{M}}_{\text{out}} + \frac{\dot m_{1}}{\dot m_{1} + \dot m_{2}} \frac{1}{\dot{E}^{\mathrm{M}}_{\text{in},1}}\,\dot{C}^{\mathrm{M}}_{\text{in},1} + \frac{\dot m_{2}}{\dot m_{1} + \dot m_{2}} \frac{1}{\dot{E}^{\mathrm{M}}_{\text{in},2}}\,\dot{C}^{\mathrm{M}}_{\text{in},2} = 0\]
  1. F rule for chemical exergy:

\[-\frac{1}{\dot{E}^{\mathrm{CH}}_{\text{out}}}\,\dot{C}^{\mathrm{CH}}_{\text{out}}{} + \frac{\dot m_{1}}{\dot m_{1} + \dot m_{2}} \frac{1}{\dot{E}^{\mathrm{CH}}_{\text{in},1}}\,\dot{C}^{\mathrm{CH}}_{\text{in},1} + \frac{\dot m_{2}}{\dot m_{1} + \dot m_{2}} \frac{1}{\dot{E}^{\mathrm{CH}}_{\text{in},2}}\,\dot{C}^{\mathrm{CH}}_{\text{in},2} = 0\]
Parameters:
  • A (numpy.ndarray) – Current cost matrix.

  • b (numpy.ndarray) – Current RHS vector.

  • counter (int) – Starting row index.

  • T0 (float) – Ambient temperature.

  • equations (dict or list) – Structure for equation labels.

  • chemical_exergy_enabled (bool) – Must be True to include chemical exergy mixing.

Returns:

  • A (numpy.ndarray) – Updated cost matrix.

  • b (numpy.ndarray) – Updated RHS vector.

  • counter (int) – Updated row index.

  • equations (dict or list) – Updated labels.

Raises:

ValueError – If chemical_exergy_enabled is False.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the combustion chamber.

\[\dot{E}_P = \dot{E}^{\mathrm{PH}}_{\text{out}} - \bigl(\dot{E}^{\mathrm{PH}}_{\text{in},1} + \dot{E}^{\mathrm{PH}}_{\text{in},2}\bigr)\]
\[\dot{E}_F = \dot{E}^{\mathrm{CH}}_{\text{in},1} + \dot{E}^{\mathrm{CH}}_{\text{in},2} - \dot{E}^{\mathrm{CH}}_{\text{out}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • p0 (float) – Ambient pressure (Pa).

  • split_physical_exergy (bool) – Whether to split thermal and mechanical exergy.

Raises:

ValueError – If fewer than two inlets or no outlets are defined.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the combustion chamber.

\[\dot{C}^{\mathrm{PH}}_{\text{in},1} + \dot{C}^{\mathrm{CH}}_{\text{in},1} + \dot{C}^{\mathrm{CH}}_{\text{in},2} + \dot{C}^{\mathrm{PH}}_{\text{in},2} - \dot{C}^{\mathrm{PH}}_{\text{out}} - \dot{C}^{\mathrm{CH}}_{\text{out}} + \dot{Z} = 0\]

This method computes cost coefficients and ratios:

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\text{out}} - \bigl(\dot{C}^{\mathrm{T}}_{\text{in},1} + \dot{C}^{\mathrm{T}}_{\text{in},2}\bigr)\]
\[\dot{C}_F = \dot{C}^{\mathrm{CH}}_{\text{in},1} + \dot{C}^{\mathrm{CH}}_{\text{in},2} - \dot{C}^{\mathrm{CH}}_{\text{out}} + \dot{C}^{\mathrm{M}}_{\text{in},1} + \dot{C}^{\mathrm{M}}_{\text{in},2} - \dot{C}^{\mathrm{M}}_{\text{out}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.

HeatExchanger

class exerpy.components.heat_exchanger.base.HeatExchanger(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of heat exchangers.

This class performs exergy and exergoeconomic analysis calculations for heat exchanger components, accounting for two inlet and two outlet streams across various temperature regimes, including above and below ambient temperature, and optional dissipative behavior.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Add auxiliary cost equations for the heat exchanger.

This method appends rows to the cost matrix to enforce:

Case 1: All streams above ambient temperature

F rule for thermal exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},1} = 0\]

Case 2: All streams below or equal to ambient temperature

F rule for thermal exergy of the cold stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},2} = 0\]

Case 3: Both stream crossing ambient temperature

P rule for thermal exergy of both outlets:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} = 0\]

Case 4: Only the hot inlet above ambient temperature

F rule for thermal exergy of the cold stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},2} = 0\]

Case 5: Only the cold inlet below ambient temperature

F rule for thermal exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},1} = 0\]

Case 6: Hot stream always above and cold stream always below ambiente temperature (dissipative case):

The dissipative is not handeld here!

For all cases, the mechanical and chemical exergy costs are handled as follows:

F rule for mechanical exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{M}}_{\mathrm{out},i}}\,\dot{C}^{\mathrm{M}}_{\mathrm{out},i} + \frac{1}{\dot{E}^{\mathrm{M}}_{\mathrm{in},i}}\,\dot{C}^{\mathrm{M}}_{\mathrm{in},i} = 0\]

F rule for chemical exergy on hot branch:

\[-\frac{1}{\dot{E}^{\mathrm{CH}}_{\mathrm{out},i}}\,\dot{C}^{\mathrm{CH}}_{\mathrm{out},i} + \frac{1}{\dot{E}^{\mathrm{CH}}_{\mathrm{in},i}}\,\dot{C}^{\mathrm{CH}}_{\mathrm{in},i} = 0\]
Parameters:
  • A (numpy.ndarray) – Current cost matrix.

  • b (numpy.ndarray) – Current RHS vector.

  • counter (int) – Starting row index for auxiliary equations.

  • T0 (float) – Ambient temperature (K).

  • equations (dict or list) – Structure for equation labels.

  • chemical_exergy_enabled (bool) – Must be True to include chemical exergy mixing.

Returns:

  • A (numpy.ndarray) – Updated cost matrix.

  • b (numpy.ndarray) – Updated RHS vector.

  • counter (int) – Updated row index after adding equations.

  • equations (dict or list) – Updated labels.

Raises:

ValueError – If required cost variable indices are missing.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the heat exchanger.

Case 1: All streams above ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},2} - \dot{E}^{\mathrm{T}}_{\mathrm{in},2}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in},2} - \dot{E}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out},2} - \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\]

Case 2: All streams below or equal to ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},1} - \dot{E}^{\mathrm{T}}_{\mathrm{in},1}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},2} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in},1} - \dot{E}^{\mathrm{M}}_{\mathrm{out},1}\bigr)\]

Else

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{in},1}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},2}\]

Case 3: Both stream crossing ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},1} + \dot{E}^{\mathrm{T}}_{\mathrm{out},2}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2} - \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{out},1} + \dot{E}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},1} + \dot{E}^{\mathrm{T}}_{\mathrm{out},2}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]

Case 4: Only the hot inlet above ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},1}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\bigr) - \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{out},2} + \dot{E}^{\mathrm{M}}_{\mathrm{out},1}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\bigr) - \dot{E}^{\mathrm{PH}}_{\mathrm{out},2}\]

Case 5: Only the cold inlet below ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out},2}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) + \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{E}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out},2}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]

Case 6: Hot stream always above and cold stream always below ambiente temperature (dissipative case):

\[\dot{E}_{\mathrm{P}} = \mathrm{NaN}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) - \dot{E}^{\mathrm{PH}}_{\mathrm{out},2} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]

If dissipative is True, the component is treated as dissipative:

\[\dot{E}_{\mathrm{P}} = \mathrm{NaN}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) - \dot{E}^{\mathrm{PH}}_{\mathrm{out},2} + \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • p0 (float) – Ambient pressure (Pa).

  • split_physical_exergy (bool) – Whether to split thermal and mechanical exergy.

Raises:

ValueError – If required inlets or outlets are missing.

dis_eqs(A, b, counter, T0, equations, chemical_exergy_enabled=False, all_components=None)[source]

Construct cost equations for a dissipative HeatExchanger.

Distributes the heat exchanger’s extra cost difference (C_diff) to all other productive components (non-dissipative and non-CycleCloser) in proportion to their exergy destruction (E_D) and adds an overall cost balance row that enforces:

\[(\dot C_{\mathrm{in},1} - \dot C_{\mathrm{out},1}) + (\dot C_{\mathrm{in},2} - \dot C_{\mathrm{out},2}) - \dot C_{\mathrm{diff}} = -\,\dot Z_{\mathrm{costs}}\]

The equality equations enforce that specific costs are equal between inlet and outlet for each exergy component (thermal, mechanical, chemical) on both the hot and cold streams.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the cost matrix.

  • T0 (float) – Ambient temperature (K).

  • equations (dict) – Dictionary mapping row indices to equation labels.

  • chemical_exergy_enabled (bool, optional) – Flag indicating whether chemical exergy is considered.

  • all_components (list, optional) – Global list of all component objects; if not provided, defaults to [].

Returns:

tuple – Updated (A, b, counter, equations).

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the heat exchanger.

\[\dot{C}^{\mathrm{T}}_{\mathrm{in},1} + \dot{C}^{\mathrm{M}}_{\mathrm{in},1} + \dot{C}^{\mathrm{T}}_{\mathrm{in},2} + \dot{C}^{\mathrm{M}}_{\mathrm{in},2} - \dot{C}^{\mathrm{T}}_{\mathrm{out},1} - \dot{C}^{\mathrm{M}}_{\mathrm{out},1} - \dot{C}^{\mathrm{T}}_{\mathrm{out},2} - \dot{C}^{\mathrm{M}}_{\mathrm{out},2} + \dot{Z} = 0\]

In case the chemical exergy of the streams is know:

\[\dot{C}^{\mathrm{CH}}_{\mathrm{in},1} = \dot{C}^{\mathrm{CH}}_{\mathrm{out},1}\]
\[\dot{C}^{\mathrm{CH}}_{\mathrm{in},2} = \dot{C}^{\mathrm{CH}}_{\mathrm{out},2}\]

This method computes cost coefficients and ratios:

Case 1: All streams above ambient temperature

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\mathrm{out},2} - \dot{C}^{\mathrm{T}}_{\mathrm{in},2}\]
\[\dot{C}_F = \dot{C}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},1} + \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{in},2} - \dot{C}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Case 2: All streams below or equal to ambient temperature

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\mathrm{out},1} - \dot{C}^{\mathrm{T}}_{\mathrm{in},1}\]
\[\dot{C}_F = \dot{C}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},2} + \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{in},1} - \dot{C}^{\mathrm{M}}_{\mathrm{out},1}\bigr)\]

Case 3: Both stream crossing ambient temperature

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \dot{C}^{\mathrm{T}}_{\mathrm{out},2}\]
\[\dot{C}_F = \dot{C}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{C}^{\mathrm{PH}}_{\mathrm{in},2} - \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{out},1} + \dot{C}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Case 4: Only the hot inlet above ambient temperature

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\mathrm{out},1}\]
\[\dot{C}_F = \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{in},1} + \dot{C}^{\mathrm{PH}}_{\mathrm{in},2}\bigr) - \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{out},2} + \dot{C}^{\mathrm{M}}_{\mathrm{out},1}\bigr)\]

Case 5: Only the cold inlet below ambient temperature

\[\dot{C}_P = \dot{C}^{\mathrm{T}}_{\mathrm{out},2}\]
\[\dot{C}_F = \dot{C}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},1} + \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{C}^{\mathrm{M}}_{\mathrm{out},2}\bigr)\]

Case 6: Hot stream always above and cold stream always below ambient temperature (dissipative case):

\[\dot{C}_P = \mathrm{NaN}\]
\[\dot{C}_F = \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) - \dot{C}^{\mathrm{PH}}_{\mathrm{out},2} + \dot{C}^{\mathrm{PH}}_{\mathrm{in},2}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.

SimpleHeatExchanger

class exerpy.components.heat_exchanger.simple.SimpleHeatExchanger(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of simple heat exchangers.

This class performs exergy and exergoeconomic analysis calculations for heat exchanger components, accounting for one inlet and one outlet stream across various temperature regimes, including above and below ambient temperature, and optional dissipative behavior.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

This function must be implemented in the future.

The exergoeconomic analysis of SimpleHeatExchanger is not implemented yet.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the simple heat exchanger.

Heat release :math:dot{Q}<0

Case 1: Both streams above ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]

Case 2: Inlet above and outlet below ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} + \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]

Case 3: Both streams below ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\bigr) + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]

Heat injection :math:dot{Q}>0

Case 1: Both streams above ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]

Case 2: Inlet below and outlet above ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]

Case 3: Both streams below ambient temperature

If split_physical_exergy=True:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} - \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{out}} - \dot{E}^{\mathrm{M}}_{\mathrm{in}}\bigr)\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} - \dot{E}^{\mathrm{T}}_{\mathrm{out}}\]

Else:

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]

Fully dissipative or :math:dot{Q}=0

\[\dot{E}_{\mathrm{P}} = \mathrm{NaN}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • p0 (float) – Ambient pressure (Pa).

  • split_physical_exergy (bool) – Whether to split thermal and mechanical exergy.

Raises:

ValueError – If required inlet or outlet are missing.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the simple heat exchanger.

The general exergoeconomic balance equation is:

\[\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{Z} = 0\]

In case the chemical exergy of the streams is known:

\[\dot{C}^{\mathrm{CH}}_{\mathrm{in}} = \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

This method computes cost rates for product and fuel, and derives exergoeconomic indicators based on the operating conditions.

Heat release (\(\dot{Q} < 0\))

Case 1: Both streams above ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]

Case 2: Inlet above and outlet below ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} + \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Case 3: Both streams below ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \bigl(\dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\bigr) + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Heat injection (\(\dot{Q} > 0\))

Case 1: Both streams above ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} - \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]

Case 2: Inlet below and outlet above ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \dot{E}^{\mathrm{T}}_{\mathrm{in}}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{in}} - \dot{E}^{\mathrm{M}}_{\mathrm{out}}\bigr)\]

Case 3: Both streams below ambient temperature

\[\dot{E}_{\mathrm{P}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} - \dot{E}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{E}^{\mathrm{M}}_{\mathrm{out}} - \dot{E}^{\mathrm{M}}_{\mathrm{in}}\bigr)\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{T}}_{\mathrm{in}} - \dot{E}^{\mathrm{T}}_{\mathrm{out}}\]

Fully dissipative or \(\dot{Q} = 0\)

\[\dot{E}_{\mathrm{P}} = \mathrm{NaN}\]
\[\dot{E}_{\mathrm{F}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in}} - \dot{E}^{\mathrm{PH}}_{\mathrm{out}}\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Condenser

class exerpy.components.heat_exchanger.condenser.Condenser(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of condensers (only dissipative).

This class performs exergy and exergoeconomic analysis calculations for condenser components, accounting for two inlet and two outlet streams. This class should be used only for dissipative condensers. For non-dissipative condensers, use components that are modeled in ExerPy using the HeatExchanger class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • E_L (float) – Exergy loss of the component \(\dot{E}_\mathrm{L}\) in \(\mathrm{W}\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Add auxiliary cost equations for the condenser.

This method appends rows to the cost matrix to enforce:

Case 1: All streams above ambient temperature

F rule for thermal exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},1} = 0\]

Case 2: All streams below or equal to ambient temperature

F rule for thermal exergy of the cold stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},2} = 0\]

Case 3: Both stream crossing ambient temperature

P rule for thermal exergy of both outlets:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} = 0\]

Case 4: Only the hot inlet above ambient temperature

F rule for thermal exergy of the cold stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},2} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},2}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},2} = 0\]

Case 5: Only the cold inlet below ambient temperature

F rule for thermal exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{out},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{out},1} + \frac{1}{\dot{E}^{\mathrm{T}}_{\mathrm{in},1}}\,\dot{C}^{\mathrm{T}}_{\mathrm{in},1} = 0\]

Case 6: Hot stream always above and cold stream always below ambiente temperature (dissipative case):

The dissipative is not handeld here!

For all cases, the mechanical and chemical exergy costs are handled as follows:

F rule for mechanical exergy of the hot stream:

\[-\frac{1}{\dot{E}^{\mathrm{M}}_{\mathrm{out},i}}\,\dot{C}^{\mathrm{M}}_{\mathrm{out},i} + \frac{1}{\dot{E}^{\mathrm{M}}_{\mathrm{in},i}}\,\dot{C}^{\mathrm{M}}_{\mathrm{in},i} = 0\]

F rule for chemical exergy on hot branch:

\[-\frac{1}{\dot{E}^{\mathrm{CH}}_{\mathrm{out},i}}\,\dot{C}^{\mathrm{CH}}_{\mathrm{out},i} + \frac{1}{\dot{E}^{\mathrm{CH}}_{\mathrm{in},i}}\,\dot{C}^{\mathrm{CH}}_{\mathrm{in},i} = 0\]
Parameters:
  • A (numpy.ndarray) – Current cost matrix.

  • b (numpy.ndarray) – Current RHS vector.

  • counter (int) – Starting row index for auxiliary equations.

  • T0 (float) – Ambient temperature (K).

  • equations (dict or list) – Structure for equation labels.

  • chemical_exergy_enabled (bool) – Must be True to include chemical exergy mixing.

Returns:

  • A (numpy.ndarray) – Updated cost matrix.

  • b (numpy.ndarray) – Updated RHS vector.

  • counter (int) – Updated row index after adding equations.

  • equations (dict or list) – Updated labels.

Raises:

ValueError – If required cost variable indices are missing.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the condenser.

In order to distinguish between the exergetic destruction because of heat transfer and the exergetic loss (coldf stream leaving the system) the exergetic losses and destruction are calculated as follows:

\[\dot{E}_{\mathrm{L}} = \dot{E}^{\mathrm{PH}}_{\mathrm{out},2} - \dot{E}^{\mathrm{PH}}_{\mathrm{in},2}\]
\[\dot{E}_{\mathrm{D}} = \dot{E}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{E}^{\mathrm{PH}}_{\mathrm{out},1} - \dot{E}_{\mathrm{L}}\]

However, these value can only be accessed via the attributes E_L and E_D of the component. In the table of final results of the exergy analysis of the system, the exergy destruction of the condenser is counted as the exergy loss and the exergetic destruction due to heat transfer.

Parameters:
  • T0 (float) – Ambient temperature (K).

  • p0 (float) – Ambient pressure (Pa).

  • split_physical_exergy (bool) – Whether to split thermal and mechanical exergy.

Raises:

ValueError – If required inlets or outlets are missing.

dis_eqs(A, b, counter, T0, equations, chemical_exergy_enabled=False, all_components=None)[source]

Construct cost equations for a dissipative Condenser.

Distributes the condenser’s extra cost difference (C_diff) to all other productive components (non-dissipative and non-CycleCloser) in proportion to their exergy destruction (E_D) and adds an overall cost balance row that enforces:

\[(\dot C_{\mathrm{in},1} - \dot C_{\mathrm{out},1}) + (\dot C_{\mathrm{in},2} - \dot C_{\mathrm{out},2}) - \dot C_{\mathrm{diff}} = -\,\dot Z_{\mathrm{costs}}\]

The equality equations enforce that specific costs are equal between inlet and outlet for each exergy component (thermal, mechanical, chemical) on both the hot and cold streams.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the cost matrix.

  • T0 (float) – Ambient temperature (K).

  • equations (dict) – Dictionary mapping row indices to equation labels.

  • chemical_exergy_enabled (bool, optional) – Flag indicating whether chemical exergy is considered.

  • all_components (list, optional) – Global list of all component objects; if not provided, defaults to [].

Returns:

tuple – Updated (A, b, counter, equations).

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the condenser.

The condenser is always dissipative (no identifiable product), so:

\[\dot{C}_P = \mathrm{NaN}\]
\[\dot{C}_F = \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{in},1} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},1}\bigr) + \bigl(\dot{C}^{\mathrm{PH}}_{\mathrm{in},2} - \dot{C}^{\mathrm{PH}}_{\mathrm{out},2}\bigr)\]

Since \(\dot{E}_F\) and \(\dot{E}_P\) are not defined for a dissipative condenser, the specific costs \(c_F\), \(c_P\), the cost of exergy destruction \(\dot{C}_D\), the relative cost difference \(r\), and the exergoeconomic factor \(f\) are all NaN.

Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.

SteamGenerator

class exerpy.components.heat_exchanger.steam_generator.SteamGenerator(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of heat exchangers.

This class performs exergy and exergoeconomic analysis calculations for heat exchanger components, accounting for two inlet and two outlet streams across various temperature regimes, including above and below ambient temperature, and optional dissipative behavior.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

Notes

The component has several input and output streams as follows.

Inlet streams:

  • inl[0]: Feed water inlet (high pressure)

  • inl[1]: Steam inlet (intermediate pressure)

  • inl[2]: Heat inlet (providing the heat input Q)

  • inl[3]: Water injection (high pressure)

  • inl[4]: Water injection (intermediate pressure)

Outlet streams:

  • outl[0]: Superheated steam outlet (high pressure)

  • outl[1]: Superheated steam outlet (intermediate pressure)

  • outl[2]: Drain / Blow down outlet

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

This function must be implemented in the future.

The exergoeconomic analysis of SteamGenerator is not implemented yet.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the steam generator.

The exergy fuel is defined as follows.

If split_physical_exergy is True:

\[\dot{E}_{\mathrm{F}} = \bigl[\dot{E}^{\mathrm{T}}_{\mathrm{out,HP}} - \dot{E}^{\mathrm{T}}_{\mathrm{in,HP}}\bigr] + \bigl[\dot{E}^{\mathrm{T}}_{\mathrm{out,IP}} - \dot{E}^{\mathrm{T}}_{\mathrm{in,IP}}\bigr] - \dot{E}^{\mathrm{T}}_{\mathrm{w,HP}} - \dot{E}^{\mathrm{T}}_{\mathrm{w,IP}}\]

If split_physical_exergy is False:

\[\dot{E}_{\mathrm{F}} = \bigl[\dot{E}^{\mathrm{PH}}_{\mathrm{out,HP}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in,HP}}\bigr] + \bigl[\dot{E}^{\mathrm{PH}}_{\mathrm{out,IP}} - \dot{E}^{\mathrm{PH}}_{\mathrm{in,IP}}\bigr] - \dot{E}^{\mathrm{PH}}_{\mathrm{w,HP}} - \dot{E}^{\mathrm{PH}}_{\mathrm{w,IP}}\]

The exergy product is defined as:

\[\dot{E}_\mathrm{P} = \Bigl[ \dot E^{\mathrm{PH}}_{\mathrm{out,HP}} - \dot E^{\mathrm{PH}}_{\mathrm{in,HP}} \Bigr] + \Bigl[ \dot E^{\mathrm{PH}}_{\mathrm{out,IP}} - \dot E^{\mathrm{PH}}_{\mathrm{in,IP}} \Bigr] - \dot E^{\mathrm{PH}}_{\mathrm{w,HP}} - \dot E^{\mathrm{PH}}_{\mathrm{w,IP}}\]

where the subscripts HP and IP denote high and intermediate pressure streams, respectively, and w stands for water injection.

Parameters:
  • T0 (float) – Ambient temperature (K).

  • p0 (float) – Ambient pressure (Pa).

  • split_physical_exergy (bool) – Whether to split thermal and mechanical exergy.

Raises:

ValueError – If required inlets or outlets are missing.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

This function must be implemented in the future.

The exergoeconomic analysis of SteamGenerator is not implemented yet.

Turbine

class exerpy.components.turbomachinery.turbine.Turbine(**kwargs)[source]

Bases: Component

Class for exergy analysis of turbines.

This class performs exergy analysis calculations for turbines, with definitions of exergy product and fuel varying based on the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • P (float) – Power output of the turbine in \(\mathrm{W}\).

  • inl (dict) – Dictionary containing inlet stream data with temperature, mass flows, enthalpies, and specific exergies. Must have at least one inlet.

  • outl (dict) – Dictionary containing outlet streams data with temperature, mass flows, enthalpies, and specific exergies. Can have multiple outlets, their properties will be summed up in the calculations.

Notes

The exergy analysis considers three cases based on temperature relationships:

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} -P & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ -P + \dot{E}_\mathrm{out}^\mathrm{T} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ -P + \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{in}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out} \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \dot{E}_\mathrm{in}^\mathrm{PH} - \dot{E}_\mathrm{out}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_0 \geq T_\mathrm{in}, T_\mathrm{out} \end{cases}\end{split}\end{aligned}\end{align} \]
aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the turbine.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

For each material outlet (when inlet and first outlet are above ambient temperature T0):

  1. 1/E_T_in * C_T_in - 1/E_T_out * C_T_out = 0 - F-principle: specific thermal exergy costs equalized between inlet and each outlet

  2. 1/E_M_in * C_M_in - 1/E_M_out * C_M_out = 0 - F-principle: specific mechanical exergy costs equalized between inlet and each outlet

  3. 1/E_CH_in * C_CH_in - 1/E_CH_out * C_CH_out = 0 (if chemical_exergy_enabled) - F-principle: specific chemical exergy costs equalized between inlet and each outlet

For power outlets (with both source and target components):

  1. 1/E_ref * C_ref - 1/E_out * C_out = 0 - P-principle: specific power exergy costs equalized across all power outlets

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index after adding all auxiliary equations.

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the turbine.

Performs exergy balance calculations considering the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the turbine.

The general exergoeconomic balance equation is:

\[\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{Z} = 0\]

In case the chemical exergy of the streams is known:

\[\dot{C}^{\mathrm{CH}}_{\mathrm{in}} = \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

This method computes cost rates for product and fuel, and derives exergoeconomic indicators. The turbine may have multiple power outputs and multiple material outlets. The product cost includes the total cost of all power streams, while material outlet costs are summed accordingly.

Case 1: Inlet and outlet above ambient temperature

Both inlet and first material outlet satisfy \(T \geq T_0\):

\[\dot{C}_{\mathrm{P}} = \sum \dot{C}^{\mathrm{TOT}}_{\mathrm{power,out}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{PH}}_{\mathrm{in}} - \sum \dot{C}^{\mathrm{PH}}_{\mathrm{material,out}}\]

Case 2: Inlet above and outlet at or below ambient temperature

Inlet satisfies \(T > T_0\) and first material outlet \(T \leq T_0\):

\[\dot{C}_{\mathrm{P}} = \sum \dot{C}^{\mathrm{TOT}}_{\mathrm{power,out}} + \sum \dot{C}^{\mathrm{T}}_{\mathrm{material,out}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{T}}_{\mathrm{in}} + \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{in}} - \sum \dot{C}^{\mathrm{M}}_{\mathrm{material,out}}\bigr)\]

Case 3: Both inlet and outlet at or below ambient temperature

Both inlet and first material outlet satisfy \(T \leq T_0\):

\[\dot{C}_{\mathrm{P}} = \sum \dot{C}^{\mathrm{TOT}}_{\mathrm{power,out}} + \bigl(\sum \dot{C}^{\mathrm{T}}_{\mathrm{material,out}} - \dot{C}^{\mathrm{T}}_{\mathrm{in}}\bigr)\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \sum \dot{C}^{\mathrm{M}}_{\mathrm{material,out}}\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Compressor

class exerpy.components.turbomachinery.compressor.Compressor(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of compressors.

This class performs exergy and exergoeconomic analysis calculations for compressors, considering thermal, mechanical, and physical exergy flows. The exergy product and fuel are calculated based on temperature relationships between inlet, outlet, and ambient conditions.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class. Optional parameter ‘Z_costs’ (float): Investment cost rate of the component in currency/h.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • P (float) – Power input to the compressor in \(\mathrm{W}\).

  • inl (dict) – Dictionary containing inlet stream data with temperature, mass flows, enthalpies, and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with temperature, mass flows, enthalpies, and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

Notes

The exergy analysis considers three cases based on temperature relationships:

Case 1 - Both temperatures above ambient (\(T_\mathrm{in}, T_\mathrm{out} > T_0\)):

\[\begin{split}\dot{E}_\mathrm{P} &= \dot{m} \cdot (e_\mathrm{out}^\mathrm{PH} - e_\mathrm{in}^\mathrm{PH})\\ \dot{E}_\mathrm{F} &= |\dot{W}|\end{split}\]

Case 2 - Inlet below, outlet above ambient (\(T_\mathrm{in} < T_0 < T_\mathrm{out}\)):

\[\begin{split}\dot{E}_\mathrm{P} &= \dot{m} \cdot e_\mathrm{out}^\mathrm{T} + \dot{m} \cdot (e_\mathrm{out}^\mathrm{M} - e_\mathrm{in}^\mathrm{M})\\ \dot{E}_\mathrm{F} &= |\dot{W}| + \dot{m} \cdot e_\mathrm{in}^\mathrm{T}\end{split}\]

Case 3 - Both temperatures below ambient (\(T_\mathrm{in}, T_\mathrm{out} \leq T_0\)):

\[\begin{split}\dot{E}_\mathrm{P} &= \dot{m} \cdot (e_\mathrm{out}^\mathrm{M} - e_\mathrm{in}^\mathrm{M})\\ \dot{E}_\mathrm{F} &= |\dot{W}| + \dot{m} \cdot (e_\mathrm{in}^\mathrm{T} - e_\mathrm{out}^\mathrm{T})\end{split}\]

For all valid cases, the exergy destruction is:

\[\dot{E}_\mathrm{D} = \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P}\]
where:
  • \(\dot{W}\): Power input

  • \(e^\mathrm{T}\): Thermal exergy

  • \(e^\mathrm{M}\): Mechanical exergy

  • \(e^\mathrm{PH}\): Physical exergy

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the compressor.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

  1. Chemical exergy cost equation (if enabled): 1/E_CH_in * C_CH_in - 1/E_CH_out * C_CH_out = 0 - F-principle: specific chemical exergy costs equalized between inlet/outlet

  2. Thermal/Mechanical exergy cost equations (based on temperature conditions):

    Case 1 (T_in > T0, T_out > T0): 1/dET * C_T_out - 1/dET * C_T_in - 1/dEM * C_M_out + 1/dEM * C_M_in = 0 - P-principle: relates inlet/outlet thermal and mechanical exergy costs

    Case 2 (T_in ≤ T0, T_out > T0): 1/E_T_out * C_T_out - 1/dEM * C_M_out + 1/dEM * C_M_in = 0 - P-principle: relates outlet thermal and inlet/outlet mechanical exergy costs

    Case 3 (T_in ≤ T0, T_out ≤ T0): 1/E_T_out * C_T_out - 1/E_T_in * C_T_in = 0 - F-principle: specific thermal exergy costs equalized between inlet/outlet

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index (increased by 2 if chemical exergy is enabled, or by 1 otherwise).

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the compressor.

Performs exergy balance calculations considering the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the compressor.

The general exergoeconomic balance equation is:

\[\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{Z} = 0\]

In case the chemical exergy of the streams is known:

\[\dot{C}^{\mathrm{CH}}_{\mathrm{in}} = \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

This method computes cost rates for product and fuel, and derives exergoeconomic indicators. The compressor consumes power (fuel) to increase the exergy of the working fluid (product).

Case 1: Both inlet and outlet above ambient temperature

Both inlet and outlet satisfy \(T \geq T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{PH}}_{\mathrm{out}} - \dot{C}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}}\]

Case 2: Inlet at or below and outlet above ambient temperature

Inlet satisfies \(T \leq T_0\) and outlet \(T > T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{in}}\bigr)\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}} + \dot{C}^{\mathrm{T}}_{\mathrm{in}}\]

Case 3: Both inlet and outlet at or below ambient temperature

Both inlet and outlet satisfy \(T \leq T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{in}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}} + \bigl(\dot{C}^{\mathrm{T}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}}\bigr)\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Raises:

ValueError – If no inlet power stream is found.

Pump

class exerpy.components.turbomachinery.pump.Pump(**kwargs)[source]

Bases: Component

Class for exergy analysis of pumps.

This class performs exergy analysis calculations for pumps, with definitions of exergy product and fuel varying based on the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • P (float) – Power input to the pump in \(\mathrm{W}\).

  • inl (dict) – Dictionary containing inlet stream data with temperature, mass flows, enthalpies, and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with temperature, mass flows, enthalpies, and specific exergies.

Notes

The exergy analysis considers three cases based on temperature relationships:

Case 1 - Both temperatures above ambient (\(T_\mathrm{in}, T_\mathrm{out} > T_0\)):

\[\begin{split}\dot{E}_\mathrm{P} &= \dot{m} \cdot (e_\mathrm{out}^\mathrm{PH} - e_\mathrm{in}^\mathrm{PH})\\ \dot{E}_\mathrm{F} &= |\dot{W}|\end{split}\]

Case 2 - Inlet below, outlet above ambient (\(T_\mathrm{in} < T_0 < T_\mathrm{out}\)):

\[\begin{split}\dot{E}_\mathrm{P} &= |\dot{W}| + (e_\mathrm{out}^\mathrm{PH} - e_\mathrm{in}^\mathrm{M})\\ \dot{E}_\mathrm{F} &= e_\mathrm{in}^\mathrm{M} + e_\mathrm{in}^\mathrm{PH}\end{split}\]

Case 3 - Both temperatures below ambient (\(T_\mathrm{in}, T_\mathrm{out} \leq T_0\)):

\[\begin{split}\dot{E}_\mathrm{P} &= e_\mathrm{out}^\mathrm{M} - e_\mathrm{in}^\mathrm{M}\\ \dot{E}_\mathrm{F} &= e_\mathrm{in}^\mathrm{PH} - e_\mathrm{out}^\mathrm{PH}\end{split}\]

For all valid cases, the exergy destruction is:

\[\dot{E}_\mathrm{D} = \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P}\]
where:
  • \(\dot{W}\): Power input

  • \(e^\mathrm{PH}\): Physical exergy

  • \(e^\mathrm{M}\): Mechanical exergy

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the pump.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

  1. Chemical exergy cost equation (if enabled): 1/E_CH_in * C_CH_in - 1/E_CH_out * C_CH_out = 0 - F-principle: specific chemical exergy costs equalized between inlet/outlet

  2. Thermal/Mechanical exergy cost equations (based on temperature conditions):

    Case 1 (T_in > T0, T_out > T0): 1/dET * C_T_out - 1/dET * C_T_in - 1/dEM * C_M_out + 1/dEM * C_M_in = 0 - P-principle: relates inlet/outlet thermal and mechanical exergy costs

    Case 2 (T_in ≤ T0, T_out > T0): 1/E_T_out * C_T_out - 1/dEM * C_M_out + 1/dEM * C_M_in = 0 - P-principle: relates outlet thermal and inlet/outlet mechanical exergy costs

    Case 3 (T_in ≤ T0, T_out ≤ T0): 1/E_T_out * C_T_out - 1/E_T_in * C_T_in = 0 - F-principle: specific thermal exergy costs equalized between inlet/outlet

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index (increased by 2 if chemical exergy is enabled, or by 1 otherwise).

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the pump.

Performs exergy balance calculations considering the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the pump.

The general exergoeconomic balance equation is:

\[\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{Z} = 0\]

In case the chemical exergy of the streams is known:

\[\dot{C}^{\mathrm{CH}}_{\mathrm{in}} = \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

This method computes cost rates for product and fuel, and derives exergoeconomic indicators. The pump consumes power (fuel) to increase the exergy of the working fluid (product).

Case 1: Both inlet and outlet above ambient temperature

Both inlet and outlet satisfy \(T \geq T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{PH}}_{\mathrm{out}} - \dot{C}^{\mathrm{PH}}_{\mathrm{in}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}}\]

Case 2: Inlet at or below and outlet above ambient temperature

Inlet satisfies \(T \leq T_0\) and outlet \(T > T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{T}}_{\mathrm{out}} + \bigl(\dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{in}}\bigr)\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}} + \dot{C}^{\mathrm{T}}_{\mathrm{in}}\]

Case 3: Both inlet and outlet at or below ambient temperature

Both inlet and outlet satisfy \(T \leq T_0\):

\[\dot{C}_{\mathrm{P}} = \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{M}}_{\mathrm{in}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}^{\mathrm{TOT}}_{\mathrm{power,in}} + \bigl(\dot{C}^{\mathrm{T}}_{\mathrm{in}} - \dot{C}^{\mathrm{T}}_{\mathrm{out}}\bigr)\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Raises:

ValueError – If no inlet power stream is found.

Deaerator

class exerpy.components.nodes.deaerator.Deaerator(**kwargs)[source]

Bases: Component

Class for exergy analysis of deaerators.

This class performs exergy analysis calculations for deaerators with multiple inlet streams and one outlet stream. The exergy product and fuel definitions vary based on the temperature relationships between inlet streams, outlet stream, and ambient conditions.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet streams data with temperature, mass flows, and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with temperature, mass flows, and specific exergies.

Notes

The exergy analysis accounts for physical exergy only. The equations for exergy product and fuel are defined based on temperature relationships:

\[\begin{split}\displaystyle \dot E_{P} = \begin{cases} \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{out}}^{\mathrm{PH}} -e_{\mathrm{in},i}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{in},i}<T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}\ge T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{out}}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{in},i}<T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}<T_{0},\\[8pt] \displaystyle \text{not defined (nan)}, \quad \text{if }T_{\mathrm{out}}=T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{out}}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{in},i}>T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}\ge T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{out}}^{\mathrm{PH}} -e_{\mathrm{in},i}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{in},i}>T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}<T_{0}. \end{cases}\end{split}\]
\[\begin{split}\displaystyle \dot E_{F} = \begin{cases} \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{in},i}^{\mathrm{PH}} -e_{\mathrm{out}}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{out}}>T_{0}\text{ and }T_{\mathrm{in},i}>T_{\mathrm{out}},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}>T_{0}\text{ and }T_{\mathrm{in},i}<T_{\mathrm{out}} \text{ and }T_{\mathrm{in},i}<T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}=T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}<T_{0}\text{ and }T_{\mathrm{in},i}>T_{\mathrm{out}},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{in},i}^{\mathrm{PH}} -e_{\mathrm{out}}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{out}}<T_{0}\text{ and }T_{\mathrm{in},i}<T_{\mathrm{out}}. \end{cases}\end{split}\]
aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the deaerator.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

  1. Mixing equation for chemical exergy costs (if enabled):

  • The outlet’s specific chemical exergy cost is calculated as a mass-weighted average of the inlet streams’ specific chemical exergy costs

  • This enforces proper chemical exergy cost distribution through the deaerator

  1. Mixing equation for mechanical exergy costs:

  • The outlet’s specific mechanical exergy cost is calculated as a mass-weighted average of the inlet streams’ specific mechanical exergy costs

  • This ensures mechanical exergy costs are properly conserved in the mixing process

Both equations implement the proportionality rule for mixing processes where the outlet’s specific costs should reflect the contribution of each inlet stream.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature (provided for consistency; not used in this function).

  • equations (dict) – Dictionary for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index (increased by 2 if chemical exergy is enabled, or by 1 otherwise).

  • equations (dict) – Updated dictionary with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the deaerator.

Performs exergy balance calculations considering the temperature relationships between inlet streams, outlet stream, and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

Raises:

ValueError – If the required inlet and outlet streams are not properly defined.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the deaerator (mixing component).

The deaerator is a mixing component where multiple streams combine. The general exergoeconomic balance equation is:

\[\sum_{\mathrm{in}} \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right) - \sum_{\mathrm{out}} \left(\dot{C}^{\mathrm{T}}_{\mathrm{out}} + \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\right) + \dot{Z} = 0\]

The product is defined as the outlet stream. The fuel consists of all inlet streams, with specific treatment depending on temperature levels. The cost balance is closed using:

\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{F}} + \dot{Z}\]

Case 1: Outlet above ambient temperature

When \(T_{\mathrm{out}} > T_0\):

For cold inlets (\(T_{\mathrm{in}} < T_{\mathrm{out}}\)):

\[\dot{C}_{\mathrm{F,cold}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\]

For hot inlets (\(T_{\mathrm{in}} \geq T_{\mathrm{out}}\)):

\[\dot{C}_{\mathrm{F,hot}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right)\]

Total fuel cost:

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,cold}} + \sum \dot{C}_{\mathrm{F,hot}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

Case 2: Outlet at ambient temperature (dissipative)

When \(|T_{\mathrm{out}} - T_0| < 10^{-6}\):

\[\dot{C}_{\mathrm{F}} = \sum_{\mathrm{in}} \dot{C}^{\mathrm{TOT}}_{\mathrm{in}}\]

Case 3: Outlet below ambient temperature

When \(T_{\mathrm{out}} < T_0\):

For hot inlets (\(T_{\mathrm{in}} > T_{\mathrm{out}}\)):

\[\dot{C}_{\mathrm{F,hot}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\]

For cold inlets (\(T_{\mathrm{in}} \leq T_{\mathrm{out}}\)):

\[\dot{C}_{\mathrm{F,cold}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right)\]

Total fuel cost:

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,hot}} + \sum \dot{C}_{\mathrm{F,cold}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Notes

The deaerator treats thermal, mechanical, and chemical exergy components differently depending on whether inlets are “hot” or “cold” relative to the outlet temperature. The distinction ensures proper cost allocation for streams that provide heating versus those being heated.

Future development may include merging profits from dissipative components.

Mixer

class exerpy.components.nodes.mixer.Mixer(**kwargs)[source]

Bases: Component

Class for exergy analysis of mixers.

This class performs exergy analysis calculations for mixers with multiple inlet streams and generally one outlet stream (multiple outlets are possible). The exergy product and fuel definitions vary based on the temperature relationships between inlet streams, outlet streams, and ambient conditions.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet streams data with temperature, mass flows, and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with temperature, mass flows, and specific exergies.

Notes

The exergy analysis accounts for physical exergy only. The equations for exergy product and fuel are defined based on temperature relationships:

\[\begin{split}\displaystyle \dot E_{P} = \begin{cases} \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{out}}^{\mathrm{PH}} -e_{\mathrm{in},i}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{in},i}<T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}\ge T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{out}}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{in},i}<T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}<T_{0},\\[8pt] \displaystyle \text{not defined (nan)}, \quad \text{if }T_{\mathrm{out}}=T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{out}}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{in},i}>T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}\ge T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{out}}^{\mathrm{PH}} -e_{\mathrm{in},i}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{in},i}>T_{\mathrm{out}}\text{ and }T_{\mathrm{in},i}<T_{0}. \end{cases}\end{split}\]
\[\begin{split}\displaystyle \dot E_{F} = \begin{cases} \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{in},i}^{\mathrm{PH}} -e_{\mathrm{out}}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{out}}>T_{0}\text{ and }T_{\mathrm{in},i}>T_{\mathrm{out}},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}>T_{0}\text{ and }T_{\mathrm{in},i}<T_{\mathrm{out}} \text{ and }T_{\mathrm{in},i}<T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}=T_{0},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,e_{\mathrm{in},i}^{\mathrm{PH}}, \quad \text{if }T_{\mathrm{out}}<T_{0}\text{ and }T_{\mathrm{in},i}>T_{\mathrm{out}},\\[8pt] \displaystyle \sum_{i}\dot m_{i}\,\bigl(e_{\mathrm{in},i}^{\mathrm{PH}} -e_{\mathrm{out}}^{\mathrm{PH}}\bigr), \quad \text{if }T_{\mathrm{out}}<T_{0}\text{ and }T_{\mathrm{in},i}<T_{\mathrm{out}}. \end{cases}\end{split}\]
aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the mixer.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

  1. Mixing equation for chemical exergy costs (if enabled):

  • The outlet’s specific chemical exergy cost is calculated as a mass-weighted average of the inlet streams’ specific chemical exergy costs

  • This enforces proper chemical exergy cost distribution through the deaerator

  1. Mixing equation for mechanical exergy costs:

  • The outlet’s specific mechanical exergy cost is calculated as a mass-weighted average of the inlet streams’ specific mechanical exergy costs

  • This ensures mechanical exergy costs are properly conserved in the mixing process

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature (provided for consistency; not used in this function).

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index (increased by 2 if chemical exergy is enabled, or by 1 otherwise).

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the mixer.

Performs exergy balance calculations considering the temperature relationships between inlet streams, outlet stream(s), and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

Raises:

ValueError – If the required inlet and outlet streams are not properly defined.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the mixer.

The mixer is a component where multiple streams combine. The general exergoeconomic balance equation is:

\[\sum_{\mathrm{in}} \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right) - \sum_{\mathrm{out}} \left(\dot{C}^{\mathrm{T}}_{\mathrm{out}} + \dot{C}^{\mathrm{M}}_{\mathrm{out}} + \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\right) + \dot{Z} = 0\]

The product is defined as the outlet stream. The fuel consists of all inlet streams, with treatment depending on temperature levels and whether chemical exergy is enabled. The cost balance is closed using:

\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{F}} + \dot{Z}\]

Case 1: Outlet above ambient temperature

When \(T_{\mathrm{out}} > T_0\):

For cold inlets (\(T_{\mathrm{in}} < T_{\mathrm{out}}\)):

Without chemical exergy:

\[\dot{C}_{\mathrm{F,cold}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}}\]

With chemical exergy enabled:

\[\dot{C}_{\mathrm{F,cold}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\]

For hot inlets (\(T_{\mathrm{in}} \geq T_{\mathrm{out}}\)):

Without chemical exergy:

\[\dot{C}_{\mathrm{F,hot}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}}\right)\]

With chemical exergy enabled:

\[\dot{C}_{\mathrm{F,hot}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right)\]

Total fuel cost (without chemical exergy):

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,cold}} + \sum \dot{C}_{\mathrm{F,hot}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}}\]

Total fuel cost (with chemical exergy):

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,cold}} + \sum \dot{C}_{\mathrm{F,hot}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

Case 2: Outlet at ambient temperature (dissipative)

When \(|T_{\mathrm{out}} - T_0| < 10^{-6}\):

\[\dot{C}_{\mathrm{F}} = \sum_{\mathrm{in}} \dot{C}^{\mathrm{TOT}}_{\mathrm{in}}\]

Case 3: Outlet below ambient temperature

When \(T_{\mathrm{out}} < T_0\):

For hot inlets (\(T_{\mathrm{in}} > T_{\mathrm{out}}\)):

Without chemical exergy:

\[\dot{C}_{\mathrm{F,hot}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}}\]

With chemical exergy enabled:

\[\dot{C}_{\mathrm{F,hot}} = \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\]

For cold inlets (\(T_{\mathrm{in}} \leq T_{\mathrm{out}}\)):

Without chemical exergy:

\[\dot{C}_{\mathrm{F,cold}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}}\right)\]

With chemical exergy enabled:

\[\dot{C}_{\mathrm{F,cold}} = -\dot{m}_{\mathrm{in}} \cdot c^{\mathrm{T}}_{\mathrm{in}} \cdot e^{\mathrm{T}}_{\mathrm{in}} + \left(\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} + \dot{C}^{\mathrm{CH}}_{\mathrm{in}}\right)\]

Total fuel cost (without chemical exergy):

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,hot}} + \sum \dot{C}_{\mathrm{F,cold}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}}\]

Total fuel cost (with chemical exergy):

\[\dot{C}_{\mathrm{F}} = \sum \dot{C}_{\mathrm{F,hot}} + \sum \dot{C}_{\mathrm{F,cold}} - \dot{C}^{\mathrm{M}}_{\mathrm{out}} - \dot{C}^{\mathrm{CH}}_{\mathrm{out}}\]

Calculated exergoeconomic indicators:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]
\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]
\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]
\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]
\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Notes

The mixer treats thermal, mechanical, and chemical exergy components differently depending on whether inlets are “hot” or “cold” relative to the outlet temperature. The distinction ensures proper cost allocation for streams that provide heating versus those being heated.

Future development may include merging profits from dissipative components.

Generator

class exerpy.components.power_machines.generator.Generator(**kwargs)[source]

Bases: Component

Class for exergy analysis of generators.

This class performs exergy analysis calculations for generators, converting mechanical or thermal energy flow into electrical energy. The exergy product is defined as the electrical power output, while the exergy fuel is the input energy flow.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with energy flow.

  • outl (dict) – Dictionary containing outlet stream data with energy flow.

Notes

The exergy analysis for a generator is straightforward as electrical energy is pure exergy. The equations are:

\[ \begin{align}\begin{aligned}\dot{E}_\mathrm{P} & = \dot{W}_\mathrm{el}\\\dot{E}_\mathrm{F} & = \dot{W}_\mathrm{in}\\\dot{E}_\mathrm{D} & = \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P}\end{aligned}\end{align} \]
where:
  • \(\dot{W}_\mathrm{el}\): Electrical power output

  • \(\dot{W}_\mathrm{in}\): Input power

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the generator.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the auxiliary cost relations for the generator. Since the generator converts mechanical or thermal energy to electrical energy, the auxiliary equations typically enforce:

  • No additional auxiliary equations are needed for generators as electrical energy is pure exergy and the cost balance equations are sufficient.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (dict) – Dictionary for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index.

  • equations (dict) – Updated dictionary with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the generator.

Calculates the exergy product (electrical power output), exergy fuel (input power), and the resulting exergy destruction and efficiency.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the generator (power-producing component).

The generator is a power-producing component (e.g., electrical generator, turbine) where mechanical/electrical work is extracted from a flowing stream. The general exergoeconomic balance equation is:

\[\dot{C}_{\mathrm{in}}^{\mathrm{TOT}} - \dot{C}_{\mathrm{out}}^{\mathrm{TOT}} - \dot{C}_{\mathrm{P}} + \dot{Z} = 0\]

For a generator, the product is the power output (electrical or mechanical), and the fuel is the exergy decrease in the working fluid:

\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{out}}^{\mathrm{TOT}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}_{\mathrm{in}}^{\mathrm{TOT}}\]

Calculated exergoeconomic indicators:

Specific cost of fuel:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]

Specific cost of product:

\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]

Cost rate of exergy destruction:

\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]

Relative cost difference:

\[r = \frac{\dot{C}_{\mathrm{P}} - \dot{C}_{\mathrm{F}}}{\dot{C}_{\mathrm{F}}}\]

Exergoeconomic factor:

\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Raises:

ValueError – If E_P or E_F is zero, preventing computation of specific costs.

Notes

Unlike other components, the generator does not add Z_costs to close the cost balance in the C_P calculation. The cost balance is determined by the total exergy costs of inlet and outlet streams.

The relative cost difference r is calculated using total cost rates (C_P and C_F) rather than specific costs (c_P and c_F), which is mathematically equivalent for this component type.

The exergy destruction E_D must be computed prior to calling this method.

Motor

class exerpy.components.power_machines.motor.Motor(**kwargs)[source]

Class for exergy analysis of motors.

This class performs exergy analysis calculations for motors, converting electrical energy into mechanical energy. The exergy product is defined as the mechanical power output, while the exergy fuel is the electrical power input.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments passed to parent class.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with energy flow.

  • outl (dict) – Dictionary containing outlet stream data with energy flow.

Notes

The exergy analysis for a motor is straightforward as both electrical and mechanical energy are pure exergy. The equations are:

\[ \begin{align}\begin{aligned}\dot{E}_\mathrm{P} & = \dot{W}_\mathrm{mech}\\\dot{E}_\mathrm{F} & = \dot{W}_\mathrm{el}\\\dot{E}_\mathrm{D} & = \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P}\end{aligned}\end{align} \]
where:
  • \(\dot{W}_\mathrm{mech}\): Mechanical power output

  • \(\dot{W}_\mathrm{el}\): Electrical power input

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the motor.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the auxiliary cost relations for the motor. Since the motor converts mechanical or thermal energy to electrical energy, the auxiliary equations typically enforce:

  • No additional auxiliary equations are needed for motors as electrical energy is pure exergy and the cost balance equations are sufficient.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (dict) – Dictionary for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index.

  • equations (dict) – Updated dictionary with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the motor.

Calculates the exergy product (mechanical power output), exergy fuel (electrical power input), and the resulting exergy destruction and efficiency.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the motor (power-consuming component).

The motor is a power-consuming component (e.g., electric motor, pump motor) where mechanical/electrical work is consumed to drive a process. The general exergoeconomic balance equation is:

\[\dot{C}_{\mathrm{in}}^{\mathrm{TOT}} - \dot{C}_{\mathrm{out}}^{\mathrm{TOT}} + \dot{C}_{\mathrm{W}} + \dot{Z} = 0\]

For a motor, the fuel is the input stream (typically electrical power), and the product is the output stream (mechanical work or driven fluid):

\[\dot{C}_{\mathrm{F}} = \dot{C}_{\mathrm{in}}^{\mathrm{TOT}}\]
\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{out}}^{\mathrm{TOT}}\]

Calculated exergoeconomic indicators:

Specific cost of fuel:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]

Specific cost of product:

\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]

Cost rate of exergy destruction:

\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]

Relative cost difference:

\[r = \frac{\dot{C}_{\mathrm{P}} - \dot{C}_{\mathrm{F}}}{\dot{C}_{\mathrm{F}}}\]

Exergoeconomic factor:

\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float) – Cost rate of product (currency/time).

  • C_F (float) – Cost rate of fuel (currency/time).

  • c_P (float) – Specific cost of product (currency/energy).

  • c_F (float) – Specific cost of fuel (currency/energy).

  • C_D (float) – Cost rate of exergy destruction (currency/time).

  • r (float) – Relative cost difference (dimensionless).

  • f (float) – Exergoeconomic factor (dimensionless).

Raises:

ValueError – If E_P or E_F is zero, preventing computation of specific costs.

Notes

The motor is a power-consuming component, opposite in function to a generator. Unlike heat exchangers or pumps, the motor does not add Z_costs to close the cost balance in the C_P calculation. The cost balance is determined by the total exergy costs of inlet and outlet streams.

The relative cost difference r is calculated using total cost rates (C_P and C_F) rather than specific costs (c_P and c_F), which is mathematically equivalent for this component type.

The exergy destruction E_D must be computed prior to calling this method.

For motors coupled with pumps or compressors, the fuel is typically the electrical energy consumed, and the product is the mechanical work delivered to the driven equipment.

Valve

class exerpy.components.piping.valve.Valve(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of valves.

This class performs exergy and exergoeconomic analysis calculations for valve components, accounting for one inlet and one outlet streams across various temperature regimes, including above and below ambient temperature.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

Notes

The exergy analysis accounts for physical, thermal, and mechanical exergy based on temperature relationships:

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \text{not defined (nan)} & T_\mathrm{in}, T_\mathrm{out} > T_0\\ \dot{m} \cdot e_\mathrm{out}^\mathrm{T} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{m} \cdot (e_\mathrm{out}^\mathrm{T} - e_\mathrm{in}^\mathrm{T}) & T_0 \geq T_\mathrm{in}, T_\mathrm{out} \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \dot{m} \cdot (e_\mathrm{in}^\mathrm{PH} - e_\mathrm{out}^\mathrm{PH}) & T_\mathrm{in}, T_\mathrm{out} > T_0\\ \dot{m} \cdot (e_\mathrm{in}^\mathrm{T} + e_\mathrm{in}^\mathrm{M} - e_\mathrm{out}^\mathrm{M}) & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{m} \cdot (e_\mathrm{in}^\mathrm{M} - e_\mathrm{out}^\mathrm{M}) & T_0 \geq T_\mathrm{in}, T_\mathrm{out} \end{cases}\end{split}\end{aligned}\end{align} \]

For all cases, except when \(T_\mathrm{out} > T_\mathrm{in}\), the exergy destruction is calculated as:

\[\begin{split}\dot{E}_\mathrm{D} = \begin{cases} \dot{E}_\mathrm{F} & \text{if } \dot{E}_\mathrm{P} = \text{nan}\\ \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P} & \mathrm{otherwise} \end{cases}\end{split}\]
Where:
  • \(e^\mathrm{T}\): Thermal exergy

  • \(e^\mathrm{PH}\): Physical exergy

  • \(e^\mathrm{M}\): Mechanical exergy

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the valve.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce the following auxiliary cost relations:

For (T_in > T0 and T_out > T0) or (T_in <= T0 and T_out > T0):
  • Valve is treated as dissipative (warning issued)

For T_out <= T0: (1) 1/E_M_in * C_M_in - 1/E_M_out * C_M_out = 0

  • F-principle: specific mechanical exergy costs equalized between inlet/outlet

  • If E_M is zero for either stream, appropriate fallback coefficients are used

When chemical_exergy_enabled is True: (2) 1/E_CH_in * C_CH_in - 1/E_CH_out * C_CH_out = 0

  • F-principle: specific chemical exergy costs equalized between inlet/outlet

  • If E_CH is zero for either stream, appropriate fallback coefficients are used

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature.

  • equations (dict) – Dictionary for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index.

  • equations (dict) – Updated dictionary with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Calculate the exergy balance of the valve.

Performs exergy balance calculations considering the temperature relationships between inlet stream, outlet stream, and ambient conditions.

Parameters:
  • T0 (float) – Ambient temperature in \(\mathrm{K}\).

  • p0 (float) – Ambient pressure in \(\mathrm{Pa}\).

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

Raises:

ValueError – If the required inlet and outlet streams are not properly defined.

dis_eqs(A, b, counter, T0, equations, chemical_exergy_enabled=False, all_components=None)[source]

Constructs the cost equations for a dissipative Valve in ExerPy, distributing the valve’s extra cost difference (C_diff) to all other productive components (non-dissipative and non-CycleCloser) in proportion to their exergy destruction (E_D) and adding an extra overall cost balance row that enforces:

\[(\dot C_{\mathrm{in},T} - \dot C_{\mathrm{out},T}) + (\dot C_{\mathrm{in},M} - \dot C_{\mathrm{out},M}) - \dot C_{\mathrm{diff}} = -\,\dot Z_{\mathrm{costs}}\]

In this formulation, the unknown cost variable in the “dissipative” column (i.e. C_diff) is solved for, ensuring the valve’s cost balance.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the cost matrix.

  • T0 (float) – Ambient temperature (not explicitly used here).

  • equations (dict) – Dictionary mapping row indices to equation labels.

  • chemical_exergy_enabled (bool, optional) – Flag indicating whether chemical exergy is considered. (Ignored here.)

  • all_components (list, optional) – Global list of all component objects; if not provided, defaults to [].

Returns:

tuple – Updated (A, b, counter, equations).

Notes

  • It is assumed that each inlet/outlet stream’s CostVar_index dictionary has keys: “T” (thermal), “M” (mechanical), and “dissipative” (the extra unknown).

  • self.Z_costs is the known cost rate (in currency/s) for the valve.

exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the valve (throttling component).

The valve is a throttling device that reduces pressure without doing work. Unlike other components, a valve can be either dissipative (purely destructive) or productive depending on temperature conditions and whether physical exergy is split into thermal and mechanical components.

Dissipative Valve (E_P is NaN):

When the valve has no identifiable product (Cases 1, 4, or Cases 2-3 without split), the entire exergy loss is considered destruction. The cost of fuel is the decrease in physical exergy cost:

\[\dot{C}_{\mathrm{F}} = \dot{C}_{\mathrm{in}}^{\mathrm{PH}} - \dot{C}_{\mathrm{out}}^{\mathrm{PH}}\]
\[\dot{C}_{\mathrm{P}} = \text{NaN (no product)}\]

Productive Valve (E_P has a value):

When physical exergy is split (split_physical_exergy=True) and specific temperature conditions are met, the valve can have a product:

Case 2 (Inlet above T0, outlet below T0):

The product is the thermal exergy at the outlet (cooling capacity), and the fuel is the thermal exergy decrease plus the mechanical exergy loss:

\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{out}}^{\mathrm{T}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}_{\mathrm{in}}^{\mathrm{T}} + (\dot{C}_{\mathrm{in}}^{\mathrm{M}} - \dot{C}_{\mathrm{out}}^{\mathrm{M}})\]

Case 3 (Both inlet and outlet below T0):

The product is the increase in thermal exergy (cooling capacity increase), and the fuel is the mechanical exergy loss:

\[\dot{C}_{\mathrm{P}} = \dot{C}_{\mathrm{out}}^{\mathrm{T}} - \dot{C}_{\mathrm{in}}^{\mathrm{T}}\]
\[\dot{C}_{\mathrm{F}} = \dot{C}_{\mathrm{in}}^{\mathrm{M}} - \dot{C}_{\mathrm{out}}^{\mathrm{M}}\]

Calculated exergoeconomic indicators:

Specific cost of fuel:

\[c_{\mathrm{F}} = \frac{\dot{C}_{\mathrm{F}}}{\dot{E}_{\mathrm{F}}}\]

Specific cost of product:

\[c_{\mathrm{P}} = \frac{\dot{C}_{\mathrm{P}}}{\dot{E}_{\mathrm{P}}}\]

Cost rate of exergy destruction:

\[\dot{C}_{\mathrm{D}} = c_{\mathrm{F}} \cdot \dot{E}_{\mathrm{D}}\]

Relative cost difference:

\[r = \frac{c_{\mathrm{P}} - c_{\mathrm{F}}}{c_{\mathrm{F}}}\]

Exergoeconomic factor:

\[f = \frac{\dot{Z}}{\dot{Z} + \dot{C}_{\mathrm{D}}}\]
Parameters:
  • T0 (float) – Ambient temperature (K).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations. Default is False.

  • Attributes Set

  • ————–

  • C_P (float or NaN) – Cost rate of product (currency/time). NaN for dissipative valves.

  • C_F (float or NaN) – Cost rate of fuel (currency/time).

  • c_P (float or NaN) – Specific cost of product (currency/energy). NaN for dissipative valves.

  • c_F (float or NaN) – Specific cost of fuel (currency/energy).

  • C_D (float or NaN) – Cost rate of exergy destruction (currency/time).

  • r (float or NaN) – Relative cost difference (dimensionless). NaN for dissipative valves.

  • f (float or NaN) – Exergoeconomic factor (dimensionless).

Notes

The valve is unique among components because:

1. It typically has no capital cost (Z_costs ≈ 0), making the exergoeconomic factor f close to zero.

2. It can be dissipative (no product) or productive (identifiable product) depending on the analysis approach and temperature conditions.

3. For dissipative valves, many exergoeconomic parameters are NaN since there is no identifiable product.

4. The relative cost difference r is calculated using specific costs (c_P and c_F) rather than total cost rates, unlike generator and motor components.

5. The method handles NaN values throughout to accommodate both dissipative and productive valve configurations.

The exergy destruction E_D and product/fuel definitions E_P and E_F must be computed prior to calling this method (via exergy_balance).

For refrigeration cycles (Case 2) or cryogenic applications (Case 3), the productive valve approach may be more appropriate. For typical throttling applications, the dissipative approach is standard.

Storage

class exerpy.components.nodes.storage.Storage(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of a storage.

This class performs exergy and exergoeconomic analysis calculations for storage components, accounting for one inlet and one outlet stream.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the storage.

Parameters:
  • T0 (float) – Ambient temperature in Kelvin.

  • p0 (float) – Ambient pressure in Pascal.

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

Notes

The exergy analysis considers the cases where the storage is either charged or discharged.

Case 1 (Charging):

\[\dot{E}_\mathrm{F} = \dot{E}_\mathrm{in}^\mathrm{PH} - \dot{E}_\mathrm{out}^\mathrm{PH}\]
\[\dot{E}_\mathrm{P} = (\dot{m}_\mathrm{in} - \dot{m}_\mathrm{out}) \cdot e_\mathrm{out}^\mathrm{PH}\]

Case 2 (Discharging):

\[\dot{E}_\mathrm{F} = (\dot{m}_\mathrm{out} - \dot{m}_\mathrm{in}) \cdot e_\mathrm{out}^\mathrm{PH}\]
\[\dot{E}_\mathrm{P} = \dot{E}_\mathrm{out}^\mathrm{PH} - \dot{E}_\mathrm{in}^\mathrm{PH}\]
exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

This class has not been implemented yet!

Flash Tank

class exerpy.components.nodes.flash_tank.FlashTank(**kwargs)[source]

Bases: Component

Class for exergy and exergoeconomic analysis of flash tank.

This class performs exergy and exergoeconomic analysis calculations for flash tank components, accounting for two inlet and two outlet streams.

Variables:
  • E_F (float) – Exergy fuel of the component \(\dot{E}_\mathrm{F}\) in \(\mathrm{W}\).

  • E_P (float) – Exergy product of the component \(\dot{E}_\mathrm{P}\) in \(\mathrm{W}\).

  • E_D (float) – Exergy destruction of the component \(\dot{E}_\mathrm{D}\) in \(\mathrm{W}\).

  • epsilon (float) – Exergetic efficiency of the component \(\varepsilon\) in \(-\).

  • inl (dict) – Dictionary containing inlet stream data with mass flows and specific exergies.

  • outl (dict) – Dictionary containing outlet stream data with mass flows and specific exergies.

  • Z_costs (float) – Investment cost rate of the component in currency/h.

  • C_P (float) – Cost of product stream \(\dot{C}_P\) in currency/h.

  • C_F (float) – Cost of fuel stream \(\dot{C}_F\) in currency/h.

  • C_D (float) – Cost of exergy destruction \(\dot{C}_D\) in currency/h.

  • c_P (float) – Specific cost of product stream (currency per unit exergy).

  • c_F (float) – Specific cost of fuel stream (currency per unit exergy).

  • r (float) – Relative cost difference, \((c_P - c_F)/c_F\).

  • f (float) – Exergoeconomic factor, \(\dot{Z}/(\dot{Z} + \dot{C}_D)\).

  • Ex_C_col (dict) – Custom cost coefficients collection passed via kwargs.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the flash tank.

This function adds rows to the cost matrix A and the right-hand-side vector b to enforce equality of specific exergy costs between the single inlet stream and each outlet stream. Thermal and mechanical costs are always equated; chemical costs are equated only if enabled.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature (not used).

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index after adding equations.

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

Compute the exergy balance of the flash tank.

Parameters:
  • T0 (float) – Ambient temperature in Kelvin.

  • p0 (float) – Ambient pressure in Pascal.

  • split_physical_exergy (bool) – Flag indicating whether physical exergy is split into thermal and mechanical components.

Raises:

ValueError – If the number of inlet or outlet streams is less than two.

Notes

The definition of exergy fuel and product for this component has not been validated yet. For now, the exergy fuel is defined as the inlet streams exergy, and the exergy product is defined as the sum of the outlet streams’ exergies (i). The exergy destruction is calculated as the difference between the exergy fuel and product. .. math:

\dot{E}_\mathrm{F} = \dot{E}_{in}^\mathrm{PH}
\[\dot{E}_\mathrm{P} = \sum_{i=1}^{m} \dot{E}_i^\mathrm{PH}\]
exergoeconomic_balance(T0, chemical_exergy_enabled=False)[source]

Perform exergoeconomic cost balance for the flash tank.

The general cost balance is:

\[\dot{C}^{\mathrm{T}}_{\mathrm{in}} + \dot{C}^{\mathrm{M}}_{\mathrm{in}} - \sum_{i=1}^{n} \dot{C}^{\mathrm{T}}_{\mathrm{out},i} - \sum_{i=1}^{n} \dot{C}^{\mathrm{M}}_{\mathrm{out},i} + \dot{Z} = 0\]
Parameters:
  • T0 (float) – Ambient temperature

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.

Cycle Closer

class exerpy.components.helpers.cycle_closer.CycleCloser(**kwargs)[source]

Bases: Component

Component for closing cycles. This component is not considered in exergy analysis, but it is used in exergoeconomic analysis.

aux_eqs(A, b, counter, T0, equations, chemical_exergy_enabled)[source]

Auxiliary equations for the cycle closer.

This function adds two rows to the cost matrix A and the right-hand side vector b to enforce the following auxiliary cost relations:

  1. 1/E_M_in * C_M_in - 1/E_M_out * C_M_out = 0

  2. 1/E_T_in * C_T_in - 1/E_T_out * C_T_out = 0

These equations ensure that the specific mechanical and thermal costs are equalized between the inlet and outlet of the cycle closer. Chemical exergy is not considered for the cycle closer.

Parameters:
  • A (numpy.ndarray) – The current cost matrix.

  • b (numpy.ndarray) – The current right-hand-side vector.

  • counter (int) – The current row index in the matrix.

  • T0 (float) – Ambient temperature (not used in this component).

  • equations (list or dict) – Data structure for storing equation labels.

  • chemical_exergy_enabled (bool) – Flag indicating whether chemical exergy auxiliary equations should be added. This flag is ignored for CycleCloser.

Returns:

  • A (numpy.ndarray) – The updated cost matrix.

  • b (numpy.ndarray) – The updated right-hand-side vector.

  • counter (int) – The updated row index (increased by 2).

  • equations (list or dict) – Updated structure with equation labels.

calc_exergy_balance(T0: float, p0: float, split_physical_exergy) None[source]

The CycleCloser component does not have an exergy balance calculation.

exergoeconomic_balance(T0, chemical_exergy_enabled=False) None[source]

Exergoeconomic balance for the CycleCloser is not defined.

This component does not generate or consume exergy, so all cost terms are undefined.

Parameters:
  • T0 (float) – Ambient temperature (unused).

  • chemical_exergy_enabled (bool, optional) – If True, chemical exergy is considered in the calculations.