@@ -152,15 +152,15 @@ def electricity_heat_production(self, enduse_option: EndUseOptions, availability
152
152
153
153
return ElectricityProduced , HeatExtracted , HeatProduced , HeatExtractedTowardsElectricity
154
154
155
- def annual_electricity_pumping_power (self , plant_lifetime : int , enduse_option : EndUseOptions , HeatExtracted : np .ndarray ,
156
- timestepsperyear : np . ndarray , utilization_factor : float , PumpingPower : np .ndarray ,
155
+ def annual_electricity_pumping_power (self , plant_lifetime : int ,enduse_option : EndUseOptions , HeatExtracted : np .ndarray ,
156
+ time_steps_per_year : int , utilization_factor : float , PumpingPower : np .ndarray ,
157
157
ElectricityProduced : np .ndarray , NetElectricityProduced : np .ndarray , HeatProduced : np .ndarray ) -> tuple :
158
158
"""
159
159
Calculate annual electricity/heat production
160
160
:param plant_lifetime: plant lifetime
161
161
:param enduse_option: end-use option
162
162
:param HeatExtracted: heat extracted
163
- :param timestepsperyear: timesteps per year
163
+ :param time_steps_per_year: time steps per year
164
164
:param utilization_factor: utilization factor
165
165
:param PumpingPower: pumping power
166
166
:param ElectricityProduced: electricity produced
@@ -176,12 +176,20 @@ def annual_electricity_pumping_power(self, plant_lifetime: int, enduse_option: E
176
176
NetkWhProduced = np .zeros (plant_lifetime )
177
177
HeatkWhProduced = np .zeros (plant_lifetime )
178
178
179
+ def integrate_slice (series : np .ndarray , _i : int ) -> np .float64 :
180
+ _slice = series [(0 + _i * time_steps_per_year ):((_i + 1 ) * time_steps_per_year ) + 1 ]
181
+
182
+ # Note that len(_slice) - 1 may be less than time_steps_per_year for the last slice.
183
+
184
+ return np .trapz (
185
+ _slice ,
186
+ dx = 1. / (len (_slice ) - 1 ) * 365. * 24.
187
+ ) * 1000. * utilization_factor
188
+
179
189
for i in range (0 , plant_lifetime ):
180
- heat_extracted_slice = HeatExtracted [(0 + i * timestepsperyear ):((i + 1 ) * timestepsperyear ) + 1 ]
181
- HeatkWhExtracted [i ] = np .trapz (heat_extracted_slice ,
182
- dx = 1. / (len (heat_extracted_slice )- 1 ) * 365. * 24. ) * 1000. * utilization_factor
183
- PumpingkWh [i ] = np .trapz (PumpingPower [(0 + i * timestepsperyear ):((i + 1 ) * timestepsperyear ) + 1 ],
184
- dx = 1. / timestepsperyear * 365. * 24. ) * 1000. * utilization_factor
190
+ HeatkWhExtracted [i ] = integrate_slice (HeatExtracted , i )
191
+ PumpingkWh [i ] = integrate_slice (PumpingPower , i )
192
+
185
193
186
194
if enduse_option in [EndUseOptions .ELECTRICITY , EndUseOptions .COGENERATION_TOPPING_EXTRA_HEAT ,
187
195
EndUseOptions .COGENERATION_TOPPING_EXTRA_ELECTRICITY ,
@@ -193,16 +201,14 @@ def annual_electricity_pumping_power(self, plant_lifetime: int, enduse_option: E
193
201
TotalkWhProduced = np .zeros (plant_lifetime )
194
202
NetkWhProduced = np .zeros (plant_lifetime )
195
203
for i in range (0 , plant_lifetime ):
196
- TotalkWhProduced [i ] = np .trapz (ElectricityProduced [(0 + i * timestepsperyear ):((i + 1 ) * timestepsperyear ) + 1 ],
197
- dx = 1. / timestepsperyear * 365. * 24. ) * 1000. * utilization_factor
198
- NetkWhProduced [i ] = np .trapz (NetElectricityProduced [(0 + i * timestepsperyear ):((i + 1 ) * timestepsperyear ) + 1 ],
199
- dx = 1. / timestepsperyear * 365. * 24. ) * 1000. * utilization_factor
204
+ TotalkWhProduced [i ] = integrate_slice (ElectricityProduced , i )
205
+ NetkWhProduced [i ] = integrate_slice (NetElectricityProduced , i )
206
+
200
207
if enduse_option is not EndUseOptions .ELECTRICITY :
201
208
# all those end-use options have a direct-use component
202
209
HeatkWhProduced = np .zeros (plant_lifetime )
203
210
for i in range (0 , plant_lifetime ):
204
- HeatkWhProduced [i ] = np .trapz (HeatProduced [(0 + i * timestepsperyear ):((i + 1 ) * timestepsperyear ) + 1 ],
205
- dx = 1. / timestepsperyear * 365. * 24. ) * 1000. * utilization_factor
211
+ HeatkWhProduced [i ] = integrate_slice (HeatProduced , i )
206
212
207
213
return HeatkWhExtracted , PumpingkWh , TotalkWhProduced , NetkWhProduced , HeatkWhProduced
208
214
0 commit comments