Skip to content

Commit fa14f39

Browse files
Adjust dx for slice size for all integrations in SurfacePlant.annual_electricity_pumping_power. FIXME TODO WIP marked for remaining integrations to adjust.
1 parent 66c9fe5 commit fa14f39

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed

src/geophires_x/SurfacePlant.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ def electricity_heat_production(self, enduse_option: EndUseOptions, availability
152152

153153
return ElectricityProduced, HeatExtracted, HeatProduced, HeatExtractedTowardsElectricity
154154

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,
157157
ElectricityProduced: np.ndarray, NetElectricityProduced: np.ndarray, HeatProduced: np.ndarray) -> tuple:
158158
"""
159159
Calculate annual electricity/heat production
160160
:param plant_lifetime: plant lifetime
161161
:param enduse_option: end-use option
162162
:param HeatExtracted: heat extracted
163-
:param timestepsperyear: timesteps per year
163+
:param time_steps_per_year: time steps per year
164164
:param utilization_factor: utilization factor
165165
:param PumpingPower: pumping power
166166
:param ElectricityProduced: electricity produced
@@ -176,12 +176,20 @@ def annual_electricity_pumping_power(self, plant_lifetime: int, enduse_option: E
176176
NetkWhProduced = np.zeros(plant_lifetime)
177177
HeatkWhProduced = np.zeros(plant_lifetime)
178178

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+
179189
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+
185193

186194
if enduse_option in [EndUseOptions.ELECTRICITY, EndUseOptions.COGENERATION_TOPPING_EXTRA_HEAT,
187195
EndUseOptions.COGENERATION_TOPPING_EXTRA_ELECTRICITY,
@@ -193,16 +201,14 @@ def annual_electricity_pumping_power(self, plant_lifetime: int, enduse_option: E
193201
TotalkWhProduced = np.zeros(plant_lifetime)
194202
NetkWhProduced = np.zeros(plant_lifetime)
195203
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+
200207
if enduse_option is not EndUseOptions.ELECTRICITY:
201208
# all those end-use options have a direct-use component
202209
HeatkWhProduced = np.zeros(plant_lifetime)
203210
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)
206212

207213
return HeatkWhExtracted, PumpingkWh, TotalkWhProduced, NetkWhProduced, HeatkWhProduced
208214

src/geophires_x/SurfacePlantAGS.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ def Calculate(self, model: Model) -> None:
739739
# useful direct-use heat provided to application [MWth]
740740
self.HeatProduced.value = self.HeatExtracted.value * self.enduseefficiencyfactor.value
741741
for i in range(0, self.plant_lifetime.value):
742+
# FIXME TODO WIP adjust dx for slice size
742743
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[
743744
(i * model.economics.timestepsperyear.value):((
744745
i + 1) * model.economics.timestepsperyear.value) + 1],
@@ -754,6 +755,7 @@ def Calculate(self, model: Model) -> None:
754755
if self.End_use is not EndUseOptions.ELECTRICITY:
755756
self.HeatkWhProduced.value = np.zeros(self.plant_lifetime.value)
756757
for i in range(0, self.plant_lifetime.value):
758+
# FIXME TODO WIP adjust dx for slice size
757759
self.HeatkWhProduced.value[i] = np.trapz(self.HeatProduced.value[
758760
(0 + i * model.economics.timestepsperyear.value):((
759761
i + 1) * model.economics.timestepsperyear.value) + 1],

src/geophires_x/SurfacePlantAbsorptionChiller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def Calculate(self, model: Model) -> None:
115115
self.PumpingkWh.value = np.zeros(self.plant_lifetime.value)
116116

117117
for i in range(0, self.plant_lifetime.value):
118+
# FIXME TODO WIP adjust dx for slice size
118119
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[
119120
(0 + i * model.economics.timestepsperyear.value):((
120121
i + 1) * model.economics.timestepsperyear.value) + 1],
@@ -126,13 +127,15 @@ def Calculate(self, model: Model) -> None:
126127

127128
self.HeatkWhProduced.value = np.zeros(self.plant_lifetime.value)
128129
for i in range(0, self.plant_lifetime.value):
130+
# FIXME TODO WIP adjust dx for slice size
129131
self.HeatkWhProduced.value[i] = np.trapz(self.HeatProduced.value[
130132
(0 + i * model.economics.timestepsperyear.value):((
131133
i + 1) * model.economics.timestepsperyear.value) + 1],
132134
dx=1. / model.economics.timestepsperyear.value * 365. * 24.) * 1000. * self.utilization_factor.value
133135

134136
self.cooling_kWh_Produced.value = np.zeros(self.plant_lifetime.value)
135137
for i in range(0, self.plant_lifetime.value):
138+
# FIXME TODO WIP adjust dx for slice size
136139
self.cooling_kWh_Produced.value[i] = np.trapz(self.cooling_produced.value[
137140
(0 + i * model.economics.timestepsperyear.value):((
138141
i + 1) * model.economics.timestepsperyear.value) + 1],

src/geophires_x/SurfacePlantDistrictHeating.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def Calculate(self, model: Model) -> None:
217217

218218
for i in range(0, self.plant_lifetime.value):
219219
if self.plant_type.value == PlantType.DISTRICT_HEATING: # for district heating, we have a util_factor_array
220+
# FIXME TODO WIP adjust dx for slice size
220221
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[
221222
(0 + i * model.economics.timestepsperyear.value):((
222223
i + 1) * model.economics.timestepsperyear.value) + 1],
@@ -228,6 +229,7 @@ def Calculate(self, model: Model) -> None:
228229
dx=1. / model.economics.timestepsperyear.value * 365. * 24.) * 1000. * \
229230
self.util_factor_array.value[i]
230231
else:
232+
# FIXME TODO WIP adjust dx for slice size
231233
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[
232234
(0 + i * model.economics.timestepsperyear.value):((
233235
i + 1) * model.economics.timestepsperyear.value) + 1],

src/geophires_x/SurfacePlantHeatPump.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,18 @@ def Calculate(self, model: Model) -> None:
116116
self.PumpingkWh.value = np.zeros(self.plant_lifetime.value)
117117

118118
for i in range(0, self.plant_lifetime.value):
119+
# FIXME TODO WIP adjust dx for slice size
119120
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[(0 + i * model.economics.timestepsperyear.value):((i + 1) * model.economics.timestepsperyear.value) + 1],dx=1. / model.economics.timestepsperyear.value * 365. * 24.) * 1000. * self.utilization_factor.value
120121
self.PumpingkWh.value[i] = np.trapz(model.wellbores.PumpingPower.value[(0 + i * model.economics.timestepsperyear.value):((i + 1) * model.economics.timestepsperyear.value) + 1],dx=1. / model.economics.timestepsperyear.value * 365. * 24.) * 1000. * self.utilization_factor.value
121122

122123
self.HeatkWhProduced.value = np.zeros(self.plant_lifetime.value)
123124
for i in range(0, self.plant_lifetime.value):
125+
# FIXME TODO WIP adjust dx for slice size
124126
self.HeatkWhProduced.value[i] = np.trapz(self.HeatProduced.value[(0+i*model.economics.timestepsperyear.value):((i+1)*model.economics.timestepsperyear.value)+1],dx = 1./model.economics.timestepsperyear.value*365.*24.)*1000.*self.utilization_factor.value
125127

126128
self.heat_pump_electricity_kwh_used.value = np.zeros(self.plant_lifetime.value)
127129
for i in range(0, self.plant_lifetime.value):
130+
# FIXME TODO WIP adjust dx for slice size
128131
self.heat_pump_electricity_kwh_used.value[i] = np.trapz(self.heat_pump_electricity_used.value[(0 + i * model.economics.timestepsperyear.value):((i + 1) * model.economics.timestepsperyear.value) + 1], dx =1. / model.economics.timestepsperyear.value * 365. * 24.) * 1000. * self.utilization_factor.value
129132

130133
# calculate reservoir heat content

src/geophires_x/SurfacePlantIndustrialHeat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def Calculate(self, model: Model) -> None:
7878
self.PumpingkWh.value = np.zeros(self.plant_lifetime.value)
7979

8080
for i in range(0, self.plant_lifetime.value):
81+
# FIXME TODO WIP adjust dx for slice size
8182
self.HeatkWhExtracted.value[i] = np.trapz(self.HeatExtracted.value[
8283
(0 + i * model.economics.timestepsperyear.value):((
8384
i + 1) * model.economics.timestepsperyear.value) + 1],
@@ -89,6 +90,7 @@ def Calculate(self, model: Model) -> None:
8990

9091
self.HeatkWhProduced.value = np.zeros(self.plant_lifetime.value)
9192
for i in range(0, self.plant_lifetime.value):
93+
# FIXME TODO WIP adjust dx for slice size
9294
self.HeatkWhProduced.value[i] = np.trapz(self.HeatProduced.value[
9395
(0 + i * model.economics.timestepsperyear.value):((
9496
i + 1) * model.economics.timestepsperyear.value) + 1],

0 commit comments

Comments
 (0)