Apply isort and ruff code style

This commit is contained in:
Michael Osthege
2024-10-03 11:05:44 +02:00
committed by Andreas
parent 05a3c1a5bb
commit a4d178d250
23 changed files with 1787 additions and 866 deletions

View File

@@ -1,4 +1,3 @@
class Heatpump:
MAX_HEIZLEISTUNG = 5000 # Maximum heating power in watts
BASE_HEIZLEISTUNG = 235.0 # Base heating power value
@@ -17,20 +16,27 @@ class Heatpump:
def heizleistung_berechnen(self, aussentemperatur):
"""Calculate heating power based on outside temperature."""
heizleistung = ((self.BASE_HEIZLEISTUNG + aussentemperatur * self.TEMPERATURE_COEFFICIENT) * 1000) / 24.0
heizleistung = (
(self.BASE_HEIZLEISTUNG + aussentemperatur * self.TEMPERATURE_COEFFICIENT)
* 1000
) / 24.0
return min(self.max_heizleistung, heizleistung)
def elektrische_leistung_berechnen(self, aussentemperatur):
"""Calculate electrical power based on outside temperature."""
return 1164 - 77.8 * aussentemperatur + 1.62 * aussentemperatur ** 2.0
return 1164 - 77.8 * aussentemperatur + 1.62 * aussentemperatur**2.0
def simulate_24h(self, temperaturen):
"""Simulate power data for 24 hours based on provided temperatures."""
leistungsdaten = []
if len(temperaturen) != self.prediction_hours:
raise ValueError("The temperature array must contain exactly " + str(self.prediction_hours) + " entries, one for each hour of the day.")
raise ValueError(
"The temperature array must contain exactly "
+ str(self.prediction_hours)
+ " entries, one for each hour of the day."
)
for temp in temperaturen:
elektrische_leistung = self.elektrische_leistung_berechnen(temp)
leistungsdaten.append(elektrische_leistung)
@@ -38,7 +44,7 @@ class Heatpump:
# Example usage of the class
if __name__ == '__main__':
if __name__ == "__main__":
max_heizleistung = 5000 # 5 kW heating power
start_innentemperatur = 15 # Initial indoor temperature
isolationseffizienz = 0.8 # Insulation efficiency
@@ -49,7 +55,32 @@ if __name__ == '__main__':
print(wp.cop_berechnen(-10), " ", wp.cop_berechnen(0), " ", wp.cop_berechnen(10))
# 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]
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)