Skip to content

Commit 36d77f3

Browse files
author
WouterPeere
committed
Add maximum power to Building Load classes
1 parent 686ca5c commit 36d77f3

3 files changed

Lines changed: 148 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111

1212
- Add flow_rates as explicit argument in PressureDrop curve function.
1313
- Add function for cascading heat pumps.
14+
- Added _get_max_power functions to BuildingLoad classes.
1415
- Inlet and outlet water temperature (issue #271).
1516
- Added 'type' attribute to temperature profile plotting so also the inlet and outlet temperatures can be shown (issue
1617
#271).

GHEtool/VariableClasses/LoadData/Baseclasses/_HourlyDataBuilding.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _get_hourly_cop(self, power: np.ndarray = None) -> Union[float, np.ndarray]:
179179
if isinstance(self.cop, SCOP) and isinstance(self.eer, SEER) and isinstance(self.cop_dhw, SCOP):
180180
return self.cop.get_COP(0, power=np.nan_to_num(power))
181181
if isinstance(self.results, ResultsMonthly):
182-
raise TypeError('You cannot get an hourly EER values based on monthly temperature results.')
182+
raise TypeError('You cannot get an hourly COP values based on monthly temperature results.')
183183
if isinstance(self.results, tuple):
184184
temperature = self.results[1]
185185
else:
@@ -209,7 +209,7 @@ def _get_hourly_cop_dhw(self, power: np.ndarray = None) -> Union[float, np.ndarr
209209
if isinstance(self.cop, SCOP) and isinstance(self.eer, SEER) and isinstance(self.cop_dhw, SCOP):
210210
return self.cop_dhw.get_COP(0, power=np.nan_to_num(power))
211211
if isinstance(self.results, ResultsMonthly):
212-
raise TypeError('You cannot get an hourly EER values based on monthly temperature results.')
212+
raise TypeError('You cannot get an hourly COP values based on monthly temperature results.')
213213
if isinstance(self.results, tuple):
214214
temperature = self.results[1]
215215
else:
@@ -247,6 +247,64 @@ def _get_hourly_eer(self, power: np.ndarray = None) -> Union[float, np.ndarray]:
247247

248248
return self.eer.get_EER(temperature, power=np.nan_to_num(power), month_indices=self.month_indices)
249249

250+
def _get_max_power_heating(self) -> Union[float, np.ndarray]:
251+
"""
252+
This function returns the maximum power available in heating, taking into account the maximum power of the
253+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
254+
is simply returned.
255+
256+
Returns
257+
-------
258+
maximum heating power : float | np.ndarray
259+
Array with the maximum heating power
260+
"""
261+
if isinstance(self.cop, SCOP):
262+
return self.hourly_heating_load_simulation_period
263+
if isinstance(self.results, tuple):
264+
temperature = self.results[1]
265+
else:
266+
temperature = self.results.Tf
267+
return np.minimum(self.hourly_heating_load_simulation_period, self.cop._get_max_power(temperature))
268+
269+
def _get_max_power_dhw(self) -> Union[float, np.ndarray]:
270+
"""
271+
This function returns the maximum power available in dhw, taking into account the maximum power of the
272+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
273+
is simply returned.
274+
275+
Returns
276+
-------
277+
maximum dhw power : float | np.ndarray
278+
Array with the maximum dhw power
279+
"""
280+
if isinstance(self.cop_dhw, SCOP):
281+
return self.hourly_dhw_load_simulation_period
282+
if isinstance(self.results, tuple):
283+
temperature = self.results[1]
284+
else:
285+
temperature = self.results.Tf
286+
return np.minimum(self.hourly_dhw_load_simulation_period, self.cop_dhw._get_max_power(temperature))
287+
288+
def _get_max_power_cooling(self) -> Union[float, np.ndarray]:
289+
"""
290+
This function returns the maximum power available in cooling, taking into account the maximum power of the
291+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
292+
is simply returned.
293+
294+
Returns
295+
-------
296+
maximum cooling power : float | np.ndarray
297+
Array with the maximum cooling power
298+
"""
299+
if isinstance(self.eer, SEER):
300+
return self.hourly_cooling_load_simulation_period
301+
if isinstance(self.results, tuple):
302+
temperature = self.results[1]
303+
else:
304+
temperature = self.results.Tf
305+
return np.minimum(self.hourly_cooling_load_simulation_period, self.eer._get_max_power(temperature, month_indices=self.month_indices))
306+
307+
250308
@property
251309
def hourly_injection_load_simulation_period(self) -> np.ndarray:
252310
"""
@@ -258,6 +316,10 @@ def hourly_injection_load_simulation_period(self) -> np.ndarray:
258316
Hourly injection values [kWh/h] for the whole simulation period
259317
"""
260318
part_load = self.hourly_cooling_load_simulation_period
319+
if self._limit_to_max_heat_pump_power:
320+
return np.multiply(
321+
self._get_max_power_cooling(),
322+
self.conversion_factor_secondary_to_primary_cooling(self._get_hourly_eer(part_load)))
261323
return np.multiply(
262324
self.hourly_cooling_load_simulation_period,
263325
self.conversion_factor_secondary_to_primary_cooling(self._get_hourly_eer(part_load)))
@@ -285,6 +347,10 @@ def _hourly_extraction_load_heating_simulation_period(self) -> np.ndarray:
285347
Hourly extraction values [kWh/h] for the whole simulation period
286348
"""
287349
part_load = self.hourly_heating_load_simulation_period
350+
if self._limit_to_max_heat_pump_power:
351+
return np.multiply(
352+
self._get_max_power_heating(),
353+
self.conversion_factor_secondary_to_primary_heating(self._get_hourly_cop(part_load)))
288354
return np.multiply(
289355
self.hourly_heating_load_simulation_period,
290356
self.conversion_factor_secondary_to_primary_heating(self._get_hourly_cop(part_load)))
@@ -300,6 +366,9 @@ def _hourly_extraction_load_dhw_simulation_period(self) -> np.ndarray:
300366
Hourly extraction values [kWh/h] for the whole simulation period
301367
"""
302368
part_load_dhw = self.hourly_dhw_load_simulation_period
369+
if self._limit_to_max_heat_pump_power:
370+
return np.multiply( self._get_max_power_dhw(),
371+
self.conversion_factor_secondary_to_primary_heating(self._get_hourly_cop_dhw(part_load_dhw)))
303372
return np.multiply(
304373
self.hourly_dhw_load_simulation_period,
305374
self.conversion_factor_secondary_to_primary_heating(self._get_hourly_cop_dhw(part_load_dhw)))

GHEtool/VariableClasses/LoadData/Baseclasses/_LoadDataBuilding.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ def __init__(self,
4747
self._cop_dhw = None
4848
self._results = None
4949
self._results_fixed = (0, 17)
50-
self.exclude_DHW_from_peak: bool = False # by default, the DHW increase the peak load. Set to false,
50+
51+
# False by default, the DHW increase the peak load. Set to false,
5152
# if you only want the heating load to determine the peak in extraction
53+
self.exclude_DHW_from_peak: bool = False
54+
55+
self._limit_to_max_heat_pump_power: bool = False
5256

5357
# set variables
5458
self.cop = efficiency_heating
@@ -398,7 +402,7 @@ def _get_monthly_cop(self, peak: bool, power: np.ndarray = None) -> Union[float,
398402
elif peak:
399403
temperature = self.results.peak_extraction
400404
else:
401-
temperature = self.results.monthly_extraction
405+
temperature = self.results.baseload_temperature
402406

403407
return self.cop.get_COP(temperature, power=np.nan_to_num(power))
404408

@@ -424,7 +428,7 @@ def _get_monthly_cop_dhw(self, peak: bool, power: np.ndarray = None) -> Union[fl
424428
elif peak:
425429
temperature = self.results.peak_extraction
426430
else:
427-
temperature = self.results.monthly_extraction
431+
temperature = self.results.baseload_temperature
428432

429433
return self.cop_dhw.get_COP(temperature, power=np.nan_to_num(power))
430434

@@ -454,6 +458,63 @@ def _get_monthly_eer(self, peak: bool, power: np.ndarray = None) -> Union[float,
454458

455459
return self.eer.get_EER(temperature, power=np.nan_to_num(power), month_indices=self.month_indices)
456460

461+
def _get_max_power_heating_monthly(self) -> Union[float, np.ndarray]:
462+
"""
463+
This function returns the maximum power available in heating, taking into account the maximum power of the
464+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
465+
is simply returned.
466+
467+
Returns
468+
-------
469+
maximum heating power : float | np.ndarray
470+
Array with the maximum heating power
471+
"""
472+
if isinstance(self.cop, SCOP):
473+
return self.monthly_peak_heating_simulation_period
474+
if isinstance(self.results, tuple):
475+
temperature = self.results[1]
476+
else:
477+
temperature = self.results.Tf
478+
return np.minimum(self.monthly_peak_heating_simulation_period, self.cop._get_max_power(temperature))
479+
480+
def _get_max_power_dhw_monthly(self) -> Union[float, np.ndarray]:
481+
"""
482+
This function returns the maximum power available in dhw, taking into account the maximum power of the
483+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
484+
is simply returned.
485+
486+
Returns
487+
-------
488+
maximum dhw power : float | np.ndarray
489+
Array with the maximum dhw power
490+
"""
491+
if isinstance(self.cop_dhw, SCOP):
492+
return self.monthly_peak_dhw_simulation_period
493+
if isinstance(self.results, tuple):
494+
temperature = self.results[1]
495+
else:
496+
temperature = self.results.Tf
497+
return np.minimum(self.monthly_peak_dhw_simulation_period, self.cop_dhw._get_max_power(temperature))
498+
499+
def _get_max_power_cooling_monthly(self) -> Union[float, np.ndarray]:
500+
"""
501+
This function returns the maximum power available in cooling, taking into account the maximum power of the
502+
heat pump (when available). When the attribute '_limit_to_max_heat_pump_power' is False, the input array
503+
is simply returned.
504+
505+
Returns
506+
-------
507+
maximum cooling power : float | np.ndarray
508+
Array with the maximum cooling power
509+
"""
510+
if isinstance(self.eer, SEER):
511+
return self.monthly_peak_cooling_simulation_period
512+
if isinstance(self.results, tuple):
513+
temperature = self.results[1]
514+
else:
515+
temperature = self.results.Tf
516+
return np.minimum(self.monthly_peak_cooling_simulation_period, self.eer._get_max_power(temperature, month_indices=self.month_indices))
517+
457518
@staticmethod
458519
def conversion_factor_secondary_to_primary_heating(cop_value: Union[int, float, np.ndarray]) -> Union[
459520
float, np.ndarray]:
@@ -560,6 +621,10 @@ def monthly_peak_injection_simulation_period(self) -> np.ndarray:
560621
Peak injection for the whole simulation period
561622
"""
562623
part_load = self.monthly_peak_cooling_simulation_period
624+
if self._limit_to_max_heat_pump_power:
625+
return np.multiply(
626+
self._get_max_power_cooling_monthly(),
627+
self.conversion_factor_secondary_to_primary_cooling(self._get_monthly_eer(True,part_load)))
563628
return np.multiply(
564629
self.monthly_peak_cooling_simulation_period,
565630
self.conversion_factor_secondary_to_primary_cooling(self._get_monthly_eer(True, part_load)))
@@ -591,6 +656,10 @@ def _monthly_peak_extraction_heating_simulation_period(self) -> np.ndarray:
591656
Peak extraction for the whole simulation period
592657
"""
593658
part_load = self.monthly_peak_heating_simulation_period
659+
if self._limit_to_max_heat_pump_power:
660+
return np.multiply(
661+
self._get_max_power_heating_monthly(),
662+
self.conversion_factor_secondary_to_primary_heating(self._get_monthly_cop(True,part_load)))
594663
return np.multiply(
595664
self.monthly_peak_heating_simulation_period,
596665
self.conversion_factor_secondary_to_primary_heating(self._get_monthly_cop(True, part_load)))
@@ -606,6 +675,10 @@ def _monthly_peak_extraction_dhw_simulation_period(self) -> np.ndarray:
606675
Peak extraction for the whole simulation period
607676
"""
608677
part_load_dhw = self.monthly_peak_dhw_simulation_period
678+
if self._limit_to_max_heat_pump_power:
679+
return np.multiply(
680+
self._get_max_power_dhw_monthly(),
681+
self.conversion_factor_secondary_to_primary_heating(self._get_monthly_cop_dhw(True,part_load_dhw)))
609682
return np.multiply(
610683
self.monthly_peak_dhw_simulation_period,
611684
self.conversion_factor_secondary_to_primary_heating(self._get_monthly_cop_dhw(True, part_load_dhw)))

0 commit comments

Comments
 (0)