exerpy 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
exerpy/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.1"
1
+ __version__ = "0.0.2"
2
2
 
3
3
  import importlib.resources
4
4
  import os
@@ -16,12 +16,6 @@ class CombustionChamber(Component):
16
16
  The exergy product is defined based on thermal and mechanical exergy differences,
17
17
  while the exergy fuel is based on chemical exergy differences.
18
18
 
19
- Parameters
20
- ----------
21
- **kwargs : dict
22
- Arbitrary keyword arguments passed to parent class.
23
- Optional parameter 'Z_costs' (float): Investment cost rate of the component in currency/h.
24
-
25
19
  Attributes
26
20
  ----------
27
21
  E_F : float
@@ -38,34 +32,39 @@ class CombustionChamber(Component):
38
32
  Dictionary containing outlet stream data with mass flows and specific exergies.
39
33
  Z_costs : float
40
34
  Investment cost rate of the component in currency/h.
35
+ C_P : float
36
+ Cost of product stream :math:`\dot{C}_P` in currency/h.
37
+ C_F : float
38
+ Cost of fuel stream :math:`\dot{C}_F` in currency/h.
39
+ C_D : float
40
+ Cost of exergy destruction :math:`\dot{C}_D` in currency/h.
41
+ c_P : float
42
+ Specific cost of product stream (currency per unit exergy).
43
+ c_F : float
44
+ Specific cost of fuel stream (currency per unit exergy).
45
+ r : float
46
+ Relative cost difference, :math:`(c_P - c_F)/c_F`.
47
+ f : float
48
+ Exergoeconomic factor, :math:`\dot{Z}/(\dot{Z} + \dot{C}_D)`.
49
+ Ex_C_col : dict
50
+ Custom cost coefficients collection passed via `kwargs`.
41
51
 
42
52
  Notes
43
53
  -----
44
- The exergy analysis considers the following definitions:
45
-
46
- .. math::
47
- \dot{E}_\mathrm{P} &= \sum_{out} \dot{m}_{out} \cdot e^\mathrm{T}_{out}
48
- + \sum_{out} \dot{m}_{out} \cdot e^\mathrm{M}_{out}
49
- - \sum_{in} \dot{m}_{in} \cdot e^\mathrm{T}_{in}
50
- - \sum_{in} \dot{m}_{in} \cdot e^\mathrm{M}_{in}
51
-
52
- .. math::
53
- \dot{E}_\mathrm{F} &= \sum_{in} \dot{m}_{in} \cdot e^\mathrm{CH}_{in}
54
- - \sum_{out} \dot{m}_{out} \cdot e^\mathrm{CH}_{out}
55
-
56
- The exergetic efficiency is calculated as:
57
-
58
- .. math::
59
- \varepsilon = \frac{\dot{E}_\mathrm{P}}{\dot{E}_\mathrm{F}}
60
-
61
- The exergy destruction follows from the exergy balance:
62
-
63
- .. math::
64
- \dot{E}_\mathrm{D} = \dot{E}_\mathrm{F} - \dot{E}_\mathrm{P}
54
+ This component requires the calculation of both physical and chemical exergy.
65
55
  """
66
56
 
67
57
  def __init__(self, **kwargs):
68
- r"""Initialize combustion chamber component with given parameters."""
58
+ r"""
59
+ Initialize the combustion chamber component.
60
+
61
+ Parameters
62
+ ----------
63
+ **kwargs : dict
64
+ Arbitrary keyword arguments. Recognized keys:
65
+ - Ex_C_col (dict): custom cost coefficients, default {}
66
+ - Z_costs (float): investment cost rate (currency/h), default 0.0
67
+ """
69
68
  super().__init__(**kwargs)
70
69
  # Initialize additional attributes if necessary
71
70
  self.Ex_C_col = kwargs.get('Ex_C_col', {})
@@ -73,23 +72,31 @@ class CombustionChamber(Component):
73
72
 
74
73
  def calc_exergy_balance(self, T0: float, p0: float, split_physical_exergy) -> None:
75
74
  r"""
76
- Calculate the exergy balance of the combustion chamber.
75
+ Compute the exergy balance of the combustion chamber.
76
+
77
+ .. math::
78
+ \dot{E}_P = \dot{E}^{\mathrm{PH}}_{\text{out}}
79
+ - \bigl(\dot{E}^{\mathrm{PH}}_{\text{in},1}
80
+ + \dot{E}^{\mathrm{PH}}_{\text{in},2}\bigr)
77
81
 
78
- Performs exergy balance calculations considering both physical and chemical
79
- exergy flows. The exergy product is based on physical exergy differences,
80
- while the exergy fuel is based on chemical exergy differences.
82
+ .. math::
83
+ \dot{E}_F = \dot{E}^{\mathrm{CH}}_{\text{in},1}
84
+ + \dot{E}^{\mathrm{CH}}_{\text{in},2}
85
+ - \dot{E}^{\mathrm{CH}}_{\text{out}}
81
86
 
82
87
  Parameters
83
88
  ----------
84
89
  T0 : float
85
- Ambient temperature in :math:`\mathrm{K}`.
90
+ Ambient temperature (K).
86
91
  p0 : float
87
- Ambient pressure in :math:`\mathrm{Pa}`.
92
+ Ambient pressure (Pa).
93
+ split_physical_exergy : bool
94
+ Whether to split thermal and mechanical exergy.
88
95
 
89
96
  Raises
90
97
  ------
91
98
  ValueError
92
- If the required inlet and outlet streams are not properly defined.
99
+ If fewer than two inlets or no outlets are defined.
93
100
  """
94
101
  # Check for necessary inlet and outlet data
95
102
  if not hasattr(self, 'inl') or not hasattr(self, 'outl') or len(self.inl) < 2 or len(self.outl) < 1:
@@ -130,52 +137,61 @@ class CombustionChamber(Component):
130
137
 
131
138
 
132
139
  def aux_eqs(self, A, b, counter, T0, equations, chemical_exergy_enabled):
133
- """
134
- Auxiliary equations for the combustion chamber.
135
-
136
- This function adds rows to the cost matrix A and the right-hand-side vector b to enforce
137
- the following auxiliary cost relations:
138
-
139
- (1) For mechanical exergy:
140
- - When all streams have non-zero mechanical exergy:
141
- c_M(outlet)/E_M(outlet) = weighted average of inlet specific mechanical exergy costs
142
- - When pressure can only decrease: c_M(outlet) is directly set
143
-
144
- (2) For chemical exergy:
145
- - When all streams have non-zero chemical exergy:
146
- c_CH(outlet)/E_CH(outlet) = weighted average of inlet specific chemical exergy costs
147
- - When an inlet has zero chemical exergy: its specific cost is directly set
148
-
140
+ r"""
141
+ Add auxiliary cost equations for the combustion chamber.
142
+
143
+ This method appends two rows to the cost matrix to enforce:
144
+
145
+ 1. F rule for mechanical exergy:
146
+
147
+ .. math::
148
+ -\frac{1}{\dot{E}^{\mathrm{M}}_{\text{out}}}\,\dot{C}^{\mathrm{M}}_{\text{out}}
149
+ + \frac{\dot m_{1}}{\dot m_{1} + \dot m_{2}}
150
+ \frac{1}{\dot{E}^{\mathrm{M}}_{\text{in},1}}\,\dot{C}^{\mathrm{M}}_{\text{in},1}
151
+ + \frac{\dot m_{2}}{\dot m_{1} + \dot m_{2}}
152
+ \frac{1}{\dot{E}^{\mathrm{M}}_{\text{in},2}}\,\dot{C}^{\mathrm{M}}_{\text{in},2}
153
+ = 0
154
+
155
+ 2. F rule for chemical exergy:
156
+
157
+ .. math::
158
+ -\frac{1}{\dot{E}^{\mathrm{CH}}_{\text{out}}}\,\dot{C}^{\mathrm{CH}}_{\text{out}}{}
159
+ + \frac{\dot m_{1}}{\dot m_{1} + \dot m_{2}}
160
+ \frac{1}{\dot{E}^{\mathrm{CH}}_{\text{in},1}}\,\dot{C}^{\mathrm{CH}}_{\text{in},1}
161
+ + \frac{\dot m_{2}}{\dot m_{1} + \dot m_{2}}
162
+ \frac{1}{\dot{E}^{\mathrm{CH}}_{\text{in},2}}\,\dot{C}^{\mathrm{CH}}_{\text{in},2}
163
+ = 0
164
+
149
165
  Parameters
150
166
  ----------
151
167
  A : numpy.ndarray
152
- The current cost matrix.
168
+ Current cost matrix.
153
169
  b : numpy.ndarray
154
- The current right-hand-side vector.
170
+ Current RHS vector.
155
171
  counter : int
156
- The current row index in the matrix.
172
+ Starting row index.
157
173
  T0 : float
158
174
  Ambient temperature.
159
175
  equations : dict or list
160
- Data structure for storing equation labels.
176
+ Structure for equation labels.
161
177
  chemical_exergy_enabled : bool
162
- Flag indicating whether chemical exergy is enabled.
163
-
178
+ Must be True to include chemical exergy mixing.
179
+
164
180
  Returns
165
181
  -------
166
182
  A : numpy.ndarray
167
- The updated cost matrix.
183
+ Updated cost matrix.
168
184
  b : numpy.ndarray
169
- The updated right-hand-side vector.
185
+ Updated RHS vector.
170
186
  counter : int
171
- The updated row index (counter + 2).
187
+ Updated row index.
172
188
  equations : dict or list
173
- Updated structure with equation labels.
174
-
189
+ Updated labels.
190
+
175
191
  Raises
176
192
  ------
177
193
  ValueError
178
- If chemical exergy is not enabled, which is mandatory for combustion chambers.
194
+ If chemical_exergy_enabled is False.
179
195
  """
180
196
  # For the combustion chamber, chemical exergy is mandatory.
181
197
  if not chemical_exergy_enabled:
@@ -213,25 +229,34 @@ class CombustionChamber(Component):
213
229
  return [A, b, counter + 2, equations]
214
230
 
215
231
  def exergoeconomic_balance(self, T0):
216
- """
217
- Perform exergoeconomic balance calculations for the combustion chamber.
218
-
219
- This method calculates various exergoeconomic parameters including:
220
- - Cost rates of product (C_P) and fuel (C_F)
221
- - Specific cost of product (c_P) and fuel (c_F)
222
- - Cost rate of exergy destruction (C_D)
223
- - Relative cost difference (r)
224
- - Exergoeconomic factor (f)
225
-
232
+ r"""
233
+ Perform exergoeconomic cost balance for the combustion chamber.
234
+
235
+ .. math::
236
+ \dot{C}^{\mathrm{PH}}_{\text{in},1} + \dot{C}^{\mathrm{CH}}_{\text{in},1}
237
+ + \dot{C}^{\mathrm{CH}}_{\text{in},2} + \dot{C}^{\mathrm{PH}}_{\text{in},2}
238
+ - \dot{C}^{\mathrm{PH}}_{\text{out}} - \dot{C}^{\mathrm{CH}}_{\text{out}}
239
+ + \dot{Z} = 0
240
+
241
+ This method computes cost coefficients and ratios:
242
+
243
+ .. math::
244
+ \dot{C}_P = \dot{C}^{\mathrm{T}}_{\text{out}}
245
+ - \bigl(\dot{C}^{\mathrm{T}}_{\text{in},1}
246
+ + \dot{C}^{\mathrm{T}}_{\text{in},2}\bigr)
247
+
248
+ .. math::
249
+ \dot{C}_F = \dot{C}^{\mathrm{CH}}_{\text{in},1}
250
+ + \dot{C}^{\mathrm{CH}}_{\text{in},2}
251
+ - \dot{C}^{\mathrm{CH}}_{\text{out}}
252
+ + \dot{C}^{\mathrm{M}}_{\text{in},1}
253
+ + \dot{C}^{\mathrm{M}}_{\text{in},2}
254
+ - \dot{C}^{\mathrm{M}}_{\text{out}}
255
+
226
256
  Parameters
227
257
  ----------
228
258
  T0 : float
229
- Ambient temperature
230
-
231
- Notes
232
- -----
233
- The exergoeconomic balance considers thermal (T), chemical (CH),
234
- and mechanical (M) exergy components for the inlet and outlet streams.
259
+ Ambient temperature (K).
235
260
  """
236
261
  self.C_P = self.outl[0]["C_T"] - (
237
262
  self.inl[0]["C_T"] + self.inl[1]["C_T"]