Coverage for pyrc \ heat_pump \ heat_pump.py: 29%
17 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-13 16:59 +0200
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-13 16:59 +0200
1# -------------------------------------------------------------------------------
2# Copyright (C) 2026 Joel Kimmich, Tim Jourdan
3# ------------------------------------------------------------------------------
4# License
5# This file is part of PyRC, distributed under GPL-3.0-or-later.
6# ------------------------------------------------------------------------------
8import numpy as np
11def carnot_heat_pump(source_temperature, supply_temperature):
12 """
13 Calculates the Carnot efficiency.
15 Parameters
16 ----------
17 source_temperature : float | np.ndarray | list
18 The temperature in Kelvin of the source.
19 supply_temperature : float | np.ndarray | list
20 The temperature in Kelvin of the supply water.
22 Returns
23 -------
24 float | np.ndarray :
25 The Carnot efficiency.
26 If its an array with
27 """
28 source_temperature = np.asarray(source_temperature)
29 supply_temperature = np.asarray(supply_temperature)
31 source_temperature = source_temperature.reshape(-1, 1)
32 supply_temperature = supply_temperature.reshape(1, -1)
34 result = supply_temperature.reshape(1, -1) / np.abs(
35 source_temperature.reshape(-1, 1) - supply_temperature.reshape(1, -1))
36 return np.squeeze(result)
39class COP:
40 def __init__(self):
41 self.exergetic_efficency = 0.45 # COP_real / COP_Carnot
42 self.overtemperature_delta = 3 # Is added to the supply temperature because of loss in heat transfer
44 def cop_change(self, new_temperature, old_temperature, supply_water_temperature):
45 """
46 Returns how much more Watt per Watt is created from a heat pump when the source temperature changes.
48 Returns each supply_water_temperature in a row (supply_temp x time_steps).
50 Parameters
51 ----------
52 new_temperature : float | int | np.ndarray | list
53 The new source temperature in Kelvin.
54 old_temperature : float | int | np.ndarray | list
55 The temperature in Kelvin to compare the new temperature with.
56 supply_water_temperature : float | int
57 The supply water temperature in Kelvin.
58 Used to calculate the carnot efficiency.
60 Returns
61 -------
62 float | np.ndarray:
63 The change of the COP with the new temeprature.
64 > 1 if the COP increases
65 < 1 if the COP decreases
66 = 1 if no change at all.
67 If it's an array with multiple dimensions each row is with a fixed supply water temperature.
68 """
69 supply = np.asarray(supply_water_temperature) + self.overtemperature_delta
70 cop_old = self.exergetic_efficency * carnot_heat_pump(supply, old_temperature)
71 cop_new = self.exergetic_efficency * carnot_heat_pump(supply, new_temperature)
73 return np.where((cop_old >= 0.4) & (cop_new <= 35), cop_new / cop_old, np.nan)