mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
heatpump translated (#282)
This commit is contained in:
parent
bec24588e1
commit
c3aa567b4d
@ -3,10 +3,10 @@ from typing import List, Sequence
|
|||||||
|
|
||||||
|
|
||||||
class Heatpump:
|
class Heatpump:
|
||||||
MAX_HEATOUTPUT = 5000
|
MAX_HEAT_OUTPUT = 5000
|
||||||
"""Maximum heating power in watts"""
|
"""Maximum heating power in watts"""
|
||||||
|
|
||||||
BASE_HEATPOWER = 235.0
|
BASE_HEAT_POWER = 235.0
|
||||||
"""Base heating power value"""
|
"""Base heating power value"""
|
||||||
|
|
||||||
TEMPERATURE_COEFFICIENT = -11.645
|
TEMPERATURE_COEFFICIENT = -11.645
|
||||||
@ -32,7 +32,7 @@ class Heatpump:
|
|||||||
Returns:
|
Returns:
|
||||||
bool: True if in range
|
bool: True if in range
|
||||||
"""
|
"""
|
||||||
return temp_celsius > -100 and temp_celsius < 100
|
return -100 < temp_celsius < 100
|
||||||
|
|
||||||
def calculate_cop(self, outside_temperature_celsius: float) -> float:
|
def calculate_cop(self, outside_temperature_celsius: float) -> float:
|
||||||
"""Calculate the coefficient of performance (COP) based on outside temperature.
|
"""Calculate the coefficient of performance (COP) based on outside temperature.
|
||||||
@ -54,7 +54,10 @@ class Heatpump:
|
|||||||
cop = self.COP_BASE + (outside_temperature_celsius * self.COP_COEFFICIENT)
|
cop = self.COP_BASE + (outside_temperature_celsius * self.COP_COEFFICIENT)
|
||||||
return max(cop, 1)
|
return max(cop, 1)
|
||||||
else:
|
else:
|
||||||
err_msg = f"Outside temperature '{outside_temperature_celsius}' not in range (min: -100 Celsius, max: 100 Celsius) "
|
err_msg = (
|
||||||
|
f"Outside temperature '{outside_temperature_celsius}' not in range "
|
||||||
|
"(min: -100 Celsius, max: 100 Celsius)"
|
||||||
|
)
|
||||||
self.log.error(err_msg)
|
self.log.error(err_msg)
|
||||||
raise ValueError(err_msg)
|
raise ValueError(err_msg)
|
||||||
|
|
||||||
@ -74,12 +77,15 @@ class Heatpump:
|
|||||||
"""
|
"""
|
||||||
if self.__check_outside_temperature_range__(outside_temperature_celsius):
|
if self.__check_outside_temperature_range__(outside_temperature_celsius):
|
||||||
heat_output = (
|
heat_output = (
|
||||||
(self.BASE_HEATPOWER + outside_temperature_celsius * self.TEMPERATURE_COEFFICIENT)
|
(self.BASE_HEAT_POWER + outside_temperature_celsius * self.TEMPERATURE_COEFFICIENT)
|
||||||
* 1000
|
* 1000
|
||||||
) / 24.0
|
) / 24.0
|
||||||
return min(self.max_heat_output, heat_output)
|
return min(self.max_heat_output, heat_output)
|
||||||
else:
|
else:
|
||||||
err_msg = f"Outside temperature '{outside_temperature_celsius}' not in range (min: -100 Celsius, max: 100 Celsius) "
|
err_msg = (
|
||||||
|
f"Outside temperature '{outside_temperature_celsius}' not in range "
|
||||||
|
"(min: -100 Celsius, max: 100 Celsius)"
|
||||||
|
)
|
||||||
self.log.error(err_msg)
|
self.log.error(err_msg)
|
||||||
raise ValueError(err_msg)
|
raise ValueError(err_msg)
|
||||||
|
|
||||||
@ -100,7 +106,10 @@ class Heatpump:
|
|||||||
1164 - 77.8 * outside_temperature_celsius + 1.62 * outside_temperature_celsius**2.0
|
1164 - 77.8 * outside_temperature_celsius + 1.62 * outside_temperature_celsius**2.0
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
err_msg = f"Outside temperature '{outside_temperature_celsius}' not in range (min: -100 Celsius, max: 100 Celsius) "
|
err_msg = (
|
||||||
|
f"Outside temperature '{outside_temperature_celsius}' not in range "
|
||||||
|
"(min: -100 Celsius, max: 100 Celsius)"
|
||||||
|
)
|
||||||
self.log.error(err_msg)
|
self.log.error(err_msg)
|
||||||
raise ValueError(err_msg)
|
raise ValueError(err_msg)
|
||||||
|
|
||||||
@ -110,7 +119,8 @@ class Heatpump:
|
|||||||
|
|
||||||
if len(temperatures) != self.prediction_hours:
|
if len(temperatures) != self.prediction_hours:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"The temperature array must contain exactly {self.prediction_hours} entries, one for each hour of the day."
|
f"The temperature array must contain exactly {self.prediction_hours} entries, "
|
||||||
|
"one for each hour of the day."
|
||||||
)
|
)
|
||||||
|
|
||||||
for temp in temperatures:
|
for temp in temperatures:
|
||||||
@ -121,19 +131,21 @@ class Heatpump:
|
|||||||
|
|
||||||
# Example usage of the class
|
# Example usage of the class
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
max_heizleistung = 5000 # 5 kW heating power
|
max_heating_power = 5000 # 5 kW heating power
|
||||||
start_innentemperatur = 15 # Initial indoor temperature
|
initial_indoor_temperature = 15 # Initial indoor temperature
|
||||||
isolationseffizienz = 0.8 # Insulation efficiency
|
insulation_efficiency = 0.8 # Insulation efficiency
|
||||||
gewuenschte_innentemperatur = 20 # Desired indoor temperature
|
desired_indoor_temperature = 20 # Desired indoor temperature
|
||||||
hp = Heatpump(max_heizleistung, 24) # Initialize heat pump with prediction hours
|
hp = Heatpump(max_heating_power, 24) # Initialize heat pump with prediction hours
|
||||||
|
|
||||||
# Print COP for various outside temperatures
|
# Print COP for various outside temperatures
|
||||||
print(hp.calculate_cop(-10), " ", hp.calculate_cop(0), " ", hp.calculate_cop(10))
|
print(hp.calculate_cop(-10), " ", hp.calculate_cop(0), " ", hp.calculate_cop(10))
|
||||||
|
|
||||||
# 24 hours of outside temperatures (example values)
|
# 24 hours of outside temperatures (example values)
|
||||||
temperaturen = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -5, -2, 5, ] # fmt: skip
|
temperatures = [
|
||||||
|
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -5, -2, 5,
|
||||||
|
] # fmt: skip
|
||||||
|
|
||||||
# Calculate the 24-hour power data
|
# Calculate the 24-hour power data
|
||||||
leistungsdaten = hp.simulate_24h(temperaturen)
|
power_data = hp.simulate_24h(temperatures)
|
||||||
|
|
||||||
print(leistungsdaten)
|
print(power_data)
|
||||||
|
@ -5,13 +5,13 @@ from akkudoktoreos.devices.heatpump import Heatpump
|
|||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def hp_5kw_24h() -> Heatpump:
|
def hp_5kw_24h() -> Heatpump:
|
||||||
"""Heatpump with 5 kw heating power and 24 h prediction."""
|
"""Heatpump with 5 kW heating power and 24 h prediction."""
|
||||||
return Heatpump(5000, 24)
|
return Heatpump(5000, 24)
|
||||||
|
|
||||||
|
|
||||||
class TestHeatpump:
|
class TestHeatpump:
|
||||||
def test_cop(self, hp_5kw_24h: Heatpump):
|
def test_cop(self, hp_5kw_24h: Heatpump):
|
||||||
"""Testing calculate COP for variouse outside temperatures."""
|
"""Testing calculate COP for various outside temperatures."""
|
||||||
assert hp_5kw_24h.calculate_cop(-10) == 2.0
|
assert hp_5kw_24h.calculate_cop(-10) == 2.0
|
||||||
assert hp_5kw_24h.calculate_cop(0) == 3.0
|
assert hp_5kw_24h.calculate_cop(0) == 3.0
|
||||||
assert hp_5kw_24h.calculate_cop(10) == 4.0
|
assert hp_5kw_24h.calculate_cop(10) == 4.0
|
||||||
@ -24,7 +24,7 @@ class TestHeatpump:
|
|||||||
hp_5kw_24h.calculate_cop(out_temp_max)
|
hp_5kw_24h.calculate_cop(out_temp_max)
|
||||||
|
|
||||||
def test_heating_output(self, hp_5kw_24h: Heatpump):
|
def test_heating_output(self, hp_5kw_24h: Heatpump):
|
||||||
"""Testing calculate of heating output."""
|
"""Testing calculation of heating output."""
|
||||||
assert hp_5kw_24h.calculate_heating_output(-10.0) == 5000
|
assert hp_5kw_24h.calculate_heating_output(-10.0) == 5000
|
||||||
assert hp_5kw_24h.calculate_heating_output(0.0) == 5000
|
assert hp_5kw_24h.calculate_heating_output(0.0) == 5000
|
||||||
assert hp_5kw_24h.calculate_heating_output(10.0) == pytest.approx(4939.583)
|
assert hp_5kw_24h.calculate_heating_output(10.0) == pytest.approx(4939.583)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user