Update class_heatpump.py

initial clean up. comments translated, parameters pulled top the top
This commit is contained in:
NormannK 2024-09-20 12:29:02 +02:00 committed by Andreas
parent cbb5807a7b
commit ad24ab68fc

View File

@ -5,34 +5,36 @@ from pprint import pprint
class Waermepumpe: class Waermepumpe:
MAX_HEIZLEISTUNG = 5000 # Maximum heating power in watts
BASE_HEIZLEISTUNG = 235.0 # Base heating power value
TEMPERATURE_COEFFICIENT = -11.645 # Coefficient for temperature
COP_BASE = 3.0 # Base COP value
COP_COEFFICIENT = 0.1 # COP increase per degree
def __init__(self, max_heizleistung, prediction_hours): def __init__(self, max_heizleistung, prediction_hours):
self.max_heizleistung = max_heizleistung self.max_heizleistung = max_heizleistung
self.prediction_hours = prediction_hours self.prediction_hours = prediction_hours
def cop_berechnen(self, aussentemperatur): def cop_berechnen(self, aussentemperatur):
cop = 3.0 + (aussentemperatur-0) * 0.1 """Calculate the coefficient of performance (COP) based on outside temperature."""
cop = self.COP_BASE + (aussentemperatur * self.COP_COEFFICIENT)
return max(cop, 1) return max(cop, 1)
def heizleistung_berechnen(self, aussentemperatur): def heizleistung_berechnen(self, aussentemperatur):
#235.092 kWh + Temperatur * -11.645 """Calculate heating power based on outside temperature."""
heizleistung = (((235.0) + aussentemperatur*(-11.645))*1000)/24.0 heizleistung = ((self.BASE_HEIZLEISTUNG + aussentemperatur * self.TEMPERATURE_COEFFICIENT) * 1000) / 24.0
heizleistung = min(self.max_heizleistung,heizleistung) return min(self.max_heizleistung, heizleistung)
return heizleistung
def elektrische_leistung_berechnen(self, aussentemperatur): def elektrische_leistung_berechnen(self, aussentemperatur):
#heizleistung = self.heizleistung_berechnen(aussentemperatur) """Calculate electrical power based on outside temperature."""
#cop = self.cop_berechnen(aussentemperatur) return 1164 - 77.8 * aussentemperatur + 1.62 * aussentemperatur ** 2.0
return 1164 -77.8*aussentemperatur + 1.62*aussentemperatur**2.0
#1253.0*np.math.pow(aussentemperatur,-0.0682)
def simulate_24h(self, temperaturen): def simulate_24h(self, temperaturen):
"""Simulate power data for 24 hours based on provided temperatures."""
leistungsdaten = [] leistungsdaten = []
# Überprüfen, ob das Temperaturarray die richtige Größe hat
if len(temperaturen) != self.prediction_hours: if len(temperaturen) != self.prediction_hours:
raise ValueError("Das Temperaturarray muss genau "+str(self.prediction_hours)+" Einträge enthalten, einen für jede Stunde des Tages.") raise ValueError("The temperature array must contain exactly " + str(self.prediction_hours) + " entries, one for each hour of the day.")
for temp in temperaturen: for temp in temperaturen:
elektrische_leistung = self.elektrische_leistung_berechnen(temp) elektrische_leistung = self.elektrische_leistung_berechnen(temp)
@ -40,23 +42,21 @@ class Waermepumpe:
return leistungsdaten return leistungsdaten
# Example usage of the class
# Beispiel für die Verwendung der Klasse
if __name__ == '__main__': if __name__ == '__main__':
max_heizleistung = 5000 # 5 kW Heizleistung max_heizleistung = 5000 # 5 kW heating power
start_innentemperatur = 15 start_innentemperatur = 15 # Initial indoor temperature
isolationseffizienz = 0.8 isolationseffizienz = 0.8 # Insulation efficiency
gewuenschte_innentemperatur = 20 gewuenschte_innentemperatur = 20 # Desired indoor temperature
wp = Waermepumpe(max_heizleistung) wp = Waermepumpe(max_heizleistung, 24) # Initialize heat pump with prediction hours
print(wp.cop_berechnen(-10)," ",wp.cop_berechnen(0), " ", wp.cop_berechnen(10))
# 24 Stunden Außentemperaturen (Beispielwerte)
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]
# Berechnung der 24-Stunden-Leistungsdaten # Print COP for various outside temperatures
leistungsdaten = wp.simulate_24h(temperaturen) print(wp.cop_berechnen(-10), " ", wp.cop_berechnen(0), " ", wp.cop_berechnen(10))
print(leistungsdaten) # 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]
# Calculate the 24-hour power data
leistungsdaten = wp.simulate_24h(temperaturen)
print(leistungsdaten)