From 595b73359c1064bae5dc05d7ad07b87ced580939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Tue, 26 Nov 2024 00:53:16 +0100 Subject: [PATCH] =?UTF-8?q?renamed=20haushaltsger=C3=A4te=20to=20home=20ap?= =?UTF-8?q?pliance=20(#196)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * * rename Haushaltsgeraete to home appliance * renamed strafe to penalty (optimization problem) Signed-off-by: Jürgen Eckel * removed penalty renaming Signed-off-by: Jürgen Eckel * renamed one variable Signed-off-by: Jürgen Eckel * * renamed variable names and methods of the home appliance class * renamed missed method names * fixed renamed variable * renamed object * adjusted to latest repo changes * renamed file to class_home_applianc.py * renamed method --------- Signed-off-by: Jürgen Eckel Signed-off-by: Jürgen Eckel --- .pre-commit-config.yaml | 2 + docs/akkudoktoreos/openapi.json | 30 +++++----- single_test_optimization.py | 6 +- src/akkudoktoreos/class_home_appliance.py | 64 ++++++++++++++++++++++ src/akkudoktoreos/devices/generic.py | 42 +++++++------- src/akkudoktoreos/devices/heatpump.py | 6 +- src/akkudoktoreos/optimization/genetic.py | 44 +++++++-------- src/akkudoktoreos/prediction/ems.py | 20 +++---- src/akkudoktoreos/visualize.py | 2 +- tests/test_class_ems.py | 26 ++++----- tests/test_class_ems_2.py | 16 +++--- tests/testdata/optimize_input_2.json | 8 +-- tests/testdata/optimize_result_1.json | 4 +- tests/testdata/optimize_result_2.json | 5 +- tests/testdata/optimize_result_2_full.json | 4 +- tests/testdata/visualize_input_1.json | 2 +- 16 files changed, 174 insertions(+), 107 deletions(-) create mode 100644 src/akkudoktoreos/class_home_appliance.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2ed1c2..c857455 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,8 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace + - id: check-merge-conflict + exclude: '\.rst$' # Exclude .rst files - repo: https://github.com/PyCQA/isort rev: 5.13.2 hooks: diff --git a/docs/akkudoktoreos/openapi.json b/docs/akkudoktoreos/openapi.json index ec23edd..58b12cf 100644 --- a/docs/akkudoktoreos/openapi.json +++ b/docs/akkudoktoreos/openapi.json @@ -496,27 +496,27 @@ "type": "object", "title": "HTTPValidationError" }, - "HaushaltsgeraetParameters": { + "HomeApplianceParameters": { "properties": { - "verbrauch_wh": { + "consumption_wh": { "type": "integer", "exclusiveMinimum": 0.0, - "title": "Verbrauch Wh", + "title": "Consumption Wh", "description": "An integer representing the energy consumption of a household device in watt-hours." }, - "dauer_h": { + "duration_h": { "type": "integer", "exclusiveMinimum": 0.0, - "title": "Dauer H", + "title": "Duration H", "description": "An integer representing the usage duration of a household device in hours." } }, "type": "object", "required": [ - "verbrauch_wh", - "dauer_h" + "consumption_wh", + "duration_h" ], - "title": "HaushaltsgeraetParameters" + "title": "HomeApplianceParameters" }, "OptimizationParameters": { "properties": { @@ -535,10 +535,10 @@ "eauto": { "$ref": "#/components/schemas/EAutoParameters" }, - "spuelmaschine": { + "dishwasher": { "anyOf": [ { - "$ref": "#/components/schemas/HaushaltsgeraetParameters" + "$ref": "#/components/schemas/HomeApplianceParameters" }, { "type": "null" @@ -624,7 +624,7 @@ "title": "Start Solution", "description": "An array of binary values (0 or 1) representing a possible starting solution for the simulation." }, - "spuelstart": { + "washingstart": { "anyOf": [ { "type": "integer" @@ -633,7 +633,7 @@ "type": "null" } ], - "title": "Spuelstart", + "title": "Washingstart", "description": "Can be `null` or contain an object representing the start of washing (if applicable)." } }, @@ -782,7 +782,7 @@ "title": "Gesamtkosten Euro", "description": "The total costs in euros." }, - "Haushaltsgeraet_wh_pro_stunde": { + "Home_appliance_wh_per_hour": { "items": { "anyOf": [ { @@ -794,7 +794,7 @@ ] }, "type": "array", - "title": "Haushaltsgeraet Wh Pro Stunde", + "title": "Home Appliance Wh Per Hour", "description": "The energy consumption of a household appliance in watt-hours per hour." }, "Kosten_Euro_pro_Stunde": { @@ -882,7 +882,7 @@ "Gesamtbilanz_Euro", "Gesamteinnahmen_Euro", "Gesamtkosten_Euro", - "Haushaltsgeraet_wh_pro_stunde", + "Home_appliance_wh_per_hour", "Kosten_Euro_pro_Stunde", "Netzbezug_Wh_pro_Stunde", "Netzeinspeisung_Wh_pro_Stunde", diff --git a/single_test_optimization.py b/single_test_optimization.py index d45aa75..e209aef 100644 --- a/single_test_optimization.py +++ b/single_test_optimization.py @@ -267,11 +267,11 @@ parameters = OptimizationParameters( # Current SOC of the electric car (%) "start_soc_prozent": 5, }, - # "spuelmaschine": { + # "dishwasher": { # # Household appliance consumption (Wh) - # "verbrauch_wh": 5000, + # "consumption_wh": 5000, # # Duration of appliance usage (hours) - # "dauer_h": 0, + # "duration_h": 0, # }, # Temperature forecast (48 hours) "temperature_forecast": temperature_forecast, diff --git a/src/akkudoktoreos/class_home_appliance.py b/src/akkudoktoreos/class_home_appliance.py new file mode 100644 index 0000000..68ff157 --- /dev/null +++ b/src/akkudoktoreos/class_home_appliance.py @@ -0,0 +1,64 @@ +import numpy as np +from pydantic import BaseModel, Field + + +class HomeApplianceParameters(BaseModel): + consumption_wh: int = Field( + gt=0, + description="An integer representing the energy consumption of a household device in watt-hours.", + ) + duration_h: int = Field( + gt=0, + description="An integer representing the usage duration of a household device in hours.", + ) + + +class HomeAppliance: + def __init__(self, parameters: HomeApplianceParameters, hours=None): + self.hours = hours # Total duration for which the planning is done + self.consumption_wh = ( + parameters.consumption_wh + ) # Total energy consumption of the device in kWh + self.duration_h = parameters.duration_h # Duration of use in hours + self.load_curve = np.zeros(self.hours) # Initialize the load curve with zeros + + def set_starting_time(self, start_hour, global_start_hour=0): + """Sets the start time of the device and generates the corresponding load curve. + + :param start_hour: The hour at which the device should start. + """ + self.reset() + # Check if the duration of use is within the available time frame + if start_hour + self.duration_h > self.hours: + raise ValueError("The duration of use exceeds the available time frame.") + if start_hour < global_start_hour: + raise ValueError("The start time is earlier than the available time frame.") + + # Calculate power per hour based on total consumption and duration + power_per_hour = self.consumption_wh / self.duration_h # Convert to watt-hours + + # Set the power for the duration of use in the load curve array + self.load_curve[start_hour : start_hour + self.duration_h] = power_per_hour + + def reset(self): + """Resets the load curve.""" + self.load_curve = np.zeros(self.hours) + + def get_load_curve(self): + """Returns the current load curve.""" + return self.load_curve + + def get_load_for_hour(self, hour): + """Returns the load for a specific hour. + + :param hour: The hour for which the load is queried. + :return: The load in watts for the specified hour. + """ + if hour < 0 or hour >= self.hours: + raise ValueError("The specified hour is outside the available time frame.") + + return self.load_curve[hour] + + def get_latest_starting_point(self): + """Returns the latest possible start time at which the device can still run completely.""" + return self.hours - self.duration_h diff --git a/src/akkudoktoreos/devices/generic.py b/src/akkudoktoreos/devices/generic.py index e52b7a8..68ff157 100644 --- a/src/akkudoktoreos/devices/generic.py +++ b/src/akkudoktoreos/devices/generic.py @@ -2,53 +2,53 @@ import numpy as np from pydantic import BaseModel, Field -class HaushaltsgeraetParameters(BaseModel): - verbrauch_wh: int = Field( +class HomeApplianceParameters(BaseModel): + consumption_wh: int = Field( gt=0, description="An integer representing the energy consumption of a household device in watt-hours.", ) - dauer_h: int = Field( + duration_h: int = Field( gt=0, description="An integer representing the usage duration of a household device in hours.", ) -class Haushaltsgeraet: - def __init__(self, parameters: HaushaltsgeraetParameters, hours=24): +class HomeAppliance: + def __init__(self, parameters: HomeApplianceParameters, hours=None): self.hours = hours # Total duration for which the planning is done - self.verbrauch_wh = ( - parameters.verbrauch_wh # Total energy consumption of the device in kWh - ) - self.dauer_h = parameters.dauer_h # Duration of use in hours - self.lastkurve = np.zeros(self.hours) # Initialize the load curve with zeros + self.consumption_wh = ( + parameters.consumption_wh + ) # Total energy consumption of the device in kWh + self.duration_h = parameters.duration_h # Duration of use in hours + self.load_curve = np.zeros(self.hours) # Initialize the load curve with zeros - def set_startzeitpunkt(self, start_hour, global_start_hour=0): + def set_starting_time(self, start_hour, global_start_hour=0): """Sets the start time of the device and generates the corresponding load curve. :param start_hour: The hour at which the device should start. """ self.reset() # Check if the duration of use is within the available time frame - if start_hour + self.dauer_h > self.hours: + if start_hour + self.duration_h > self.hours: raise ValueError("The duration of use exceeds the available time frame.") if start_hour < global_start_hour: raise ValueError("The start time is earlier than the available time frame.") # Calculate power per hour based on total consumption and duration - leistung_pro_stunde = self.verbrauch_wh / self.dauer_h # Convert to watt-hours + power_per_hour = self.consumption_wh / self.duration_h # Convert to watt-hours # Set the power for the duration of use in the load curve array - self.lastkurve[start_hour : start_hour + self.dauer_h] = leistung_pro_stunde + self.load_curve[start_hour : start_hour + self.duration_h] = power_per_hour def reset(self): """Resets the load curve.""" - self.lastkurve = np.zeros(self.hours) + self.load_curve = np.zeros(self.hours) - def get_lastkurve(self): + def get_load_curve(self): """Returns the current load curve.""" - return self.lastkurve + return self.load_curve - def get_last_fuer_stunde(self, hour): + def get_load_for_hour(self, hour): """Returns the load for a specific hour. :param hour: The hour for which the load is queried. @@ -57,8 +57,8 @@ class Haushaltsgeraet: if hour < 0 or hour >= self.hours: raise ValueError("The specified hour is outside the available time frame.") - return self.lastkurve[hour] + return self.load_curve[hour] - def spaetestmoeglicher_startzeitpunkt(self): + def get_latest_starting_point(self): """Returns the latest possible start time at which the device can still run completely.""" - return self.hours - self.dauer_h + return self.hours - self.duration_h diff --git a/src/akkudoktoreos/devices/heatpump.py b/src/akkudoktoreos/devices/heatpump.py index bc506e5..a5215a7 100644 --- a/src/akkudoktoreos/devices/heatpump.py +++ b/src/akkudoktoreos/devices/heatpump.py @@ -125,15 +125,15 @@ if __name__ == "__main__": start_innentemperatur = 15 # Initial indoor temperature isolationseffizienz = 0.8 # Insulation efficiency gewuenschte_innentemperatur = 20 # Desired indoor temperature - wp = Heatpump(max_heizleistung, 24) # Initialize heat pump with prediction hours + hp = Heatpump(max_heizleistung, 24) # Initialize heat pump with prediction hours # Print COP for various outside temperatures - print(wp.calculate_cop(-10), " ", wp.calculate_cop(0), " ", wp.calculate_cop(10)) + print(hp.calculate_cop(-10), " ", hp.calculate_cop(0), " ", hp.calculate_cop(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, ] # fmt: skip # Calculate the 24-hour power data - leistungsdaten = wp.simulate_24h(temperaturen) + leistungsdaten = hp.simulate_24h(temperaturen) print(leistungsdaten) diff --git a/src/akkudoktoreos/optimization/genetic.py b/src/akkudoktoreos/optimization/genetic.py index 9f65924..fb6b943 100644 --- a/src/akkudoktoreos/optimization/genetic.py +++ b/src/akkudoktoreos/optimization/genetic.py @@ -8,7 +8,7 @@ from typing_extensions import Self from akkudoktoreos.config import AppConfig from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters -from akkudoktoreos.devices.generic import Haushaltsgeraet, HaushaltsgeraetParameters +from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters from akkudoktoreos.devices.inverter import Wechselrichter, WechselrichterParameters from akkudoktoreos.prediction.ems import ( EnergieManagementSystem, @@ -22,7 +22,7 @@ class OptimizationParameters(BaseModel): pv_akku: PVAkkuParameters wechselrichter: WechselrichterParameters = WechselrichterParameters() eauto: EAutoParameters - spuelmaschine: Optional[HaushaltsgeraetParameters] = None + dishwasher: Optional[HomeApplianceParameters] = None temperature_forecast: list[float] = Field( "An array of floats representing the temperature forecast in degrees Celsius for different time intervals." ) @@ -86,7 +86,7 @@ class SimulationResult(BaseModel): ) Gesamteinnahmen_Euro: float = Field(description="The total revenues in euros.") Gesamtkosten_Euro: float = Field(description="The total costs in euros.") - Haushaltsgeraet_wh_pro_stunde: list[Optional[float]] = Field( + Home_appliance_wh_per_hour: list[Optional[float]] = Field( description="The energy consumption of a household appliance in watt-hours per hour." ) Kosten_Euro_pro_Stunde: list[Optional[float]] = Field( @@ -120,7 +120,7 @@ class SimulationResult(BaseModel): # Gesamtbilanz_Euro: float = Field(description="The total simulated balance in euros.") # Gesamteinnahmen_Euro: float = Field(description="The total simulated income in euros.") # Gesamtkosten_Euro: float = Field(description="The total simulated costs in euros.") -# Haushaltsgeraet_wh_pro_stunde: list[Optional[float]] = Field( +# Home_appliance_wh_per_hour: list[Optional[float]] = Field( # description="An array of floats representing the simulated energy consumption of a household appliance in watt-hours per hour." # ) # Kosten_Euro_pro_Stunde: list[Optional[float]] = Field( @@ -158,7 +158,7 @@ class OptimizeResponse(BaseModel): None, description="An array of binary values (0 or 1) representing a possible starting solution for the simulation.", ) - spuelstart: Optional[int] = Field( + washingstart: Optional[int] = Field( None, description="Can be `null` or contain an object representing the start of washing (if applicable).", ) @@ -285,7 +285,7 @@ class optimization_problem: individual[self.prediction_hours : self.prediction_hours * 2] = ev_charge_part_mutated # Step 3: Mutate appliance start times if household appliances are part of the optimization - if self.opti_param["haushaltsgeraete"] > 0: + if self.opti_param["home_appliance"] > 0: # Extract the appliance part (typically a single value for the start hour) appliance_part = [individual[-1]] @@ -311,7 +311,7 @@ class optimization_problem: ] # Add the start time of the household appliance if it's being optimized - if self.opti_param["haushaltsgeraete"] > 0: + if self.opti_param["home_appliance"] > 0: individual_components += [self.toolbox.attr_int()] return creator.Individual(individual_components) @@ -333,12 +333,12 @@ class optimization_problem: else None ) - spuelstart_int = ( + washingstart_int = ( individual[-1] - if self.opti_param and self.opti_param.get("haushaltsgeraete", 0) > 0 + if self.opti_param and self.opti_param.get("home_appliance", 0) > 0 else None ) - return discharge_hours_bin, eautocharge_hours_float, spuelstart_int + return discharge_hours_bin, eautocharge_hours_float, washingstart_int def setup_deap_environment(self, opti_param: dict[str, Any], start_hour: int) -> None: """Set up the DEAP environment with fitness and individual creation rules.""" @@ -410,11 +410,11 @@ class optimization_problem: This is an internal function. """ ems.reset() - discharge_hours_bin, eautocharge_hours_index, spuelstart_int = self.split_individual( + discharge_hours_bin, eautocharge_hours_index, washingstart_int = self.split_individual( individual ) - if self.opti_param.get("haushaltsgeraete", 0) > 0: - ems.set_haushaltsgeraet_start(spuelstart_int, global_start_hour=start_hour) + if self.opti_param.get("home_appliance", 0) > 0: + ems.set_home_appliance_start(washingstart_int, global_start_hour=start_hour) ac, dc, discharge = self.decode_charge_discharge(discharge_hours_bin) @@ -557,12 +557,12 @@ class optimization_problem: eauto.set_charge_per_hour(np.full(self.prediction_hours, 1)) # Initialize household appliance if applicable - spuelmaschine = ( - Haushaltsgeraet( - parameters=parameters.spuelmaschine, + dishwasher = ( + HomeAppliance( + parameters=parameters.dishwasher, hours=self.prediction_hours, ) - if parameters.spuelmaschine is not None + if parameters.dishwasher is not None else None ) @@ -572,12 +572,12 @@ class optimization_problem: self._config.eos, parameters.ems, eauto=eauto, - haushaltsgeraet=spuelmaschine, + home_appliance=dishwasher, wechselrichter=wr, ) # Setup the DEAP environment and optimization process - self.setup_deap_environment({"haushaltsgeraete": 1 if spuelmaschine else 0}, start_hour) + self.setup_deap_environment({"home_appliance": 1 if dishwasher else 0}, start_hour) self.toolbox.register( "evaluate", lambda ind: self.evaluate(ind, ems, parameters, start_hour, worst_case), @@ -586,7 +586,7 @@ class optimization_problem: # Perform final evaluation on the best solution o = self.evaluate_inner(start_solution, ems, start_hour) - discharge_hours_bin, eautocharge_hours_float, spuelstart_int = self.split_individual( + discharge_hours_bin, eautocharge_hours_float, washingstart_int = self.split_individual( start_solution ) if self.optimize_ev: @@ -622,7 +622,7 @@ class optimization_problem: "Einnahmen_Euro_pro_Stunde", "EAuto_SoC_pro_Stunde", "Verluste_Pro_Stunde", - "Haushaltsgeraet_wh_pro_stunde", + "Home_appliance_wh_per_hour", ] # Loop through each key in the list @@ -649,6 +649,6 @@ class optimization_problem: "result": o, "eauto_obj": ems.eauto.to_dict(), "start_solution": start_solution, - "spuelstart": spuelstart_int, + "washingstart": washingstart_int, # "simulation_data": o, } diff --git a/src/akkudoktoreos/prediction/ems.py b/src/akkudoktoreos/prediction/ems.py index f155e03..3882e0d 100644 --- a/src/akkudoktoreos/prediction/ems.py +++ b/src/akkudoktoreos/prediction/ems.py @@ -7,7 +7,7 @@ from typing_extensions import Self from akkudoktoreos.config import EOSConfig from akkudoktoreos.devices.battery import PVAkku -from akkudoktoreos.devices.generic import Haushaltsgeraet +from akkudoktoreos.devices.generic import HomeAppliance from akkudoktoreos.devices.inverter import Wechselrichter @@ -47,7 +47,7 @@ class EnergieManagementSystem: config: EOSConfig, parameters: EnergieManagementSystemParameters, eauto: Optional[PVAkku] = None, - haushaltsgeraet: Optional[Haushaltsgeraet] = None, + home_appliance: Optional[HomeAppliance] = None, wechselrichter: Optional[Wechselrichter] = None, ): self.akku = wechselrichter.akku @@ -60,7 +60,7 @@ class EnergieManagementSystem: else np.full(len(self.gesamtlast), parameters.einspeiseverguetung_euro_pro_wh, float) ) self.eauto = eauto - self.haushaltsgeraet = haushaltsgeraet + self.home_appliance = home_appliance self.wechselrichter = wechselrichter self.ac_charge_hours = np.full(config.prediction_hours, 0) self.dc_charge_hours = np.full(config.prediction_hours, 1) @@ -78,8 +78,8 @@ class EnergieManagementSystem: def set_ev_charge_hours(self, ds: List[int]) -> None: self.ev_charge_hours = ds - def set_haushaltsgeraet_start(self, ds: List[int], global_start_hour: int = 0) -> None: - self.haushaltsgeraet.set_startzeitpunkt(ds, global_start_hour=global_start_hour) + def set_home_appliance_start(self, ds: List[int], global_start_hour: int = 0) -> None: + self.home_appliance.set_starting_time(ds, global_start_hour=global_start_hour) def reset(self) -> None: self.eauto.reset() @@ -114,7 +114,7 @@ class EnergieManagementSystem: akku_soc_pro_stunde = np.full((total_hours), np.nan) eauto_soc_pro_stunde = np.full((total_hours), np.nan) verluste_wh_pro_stunde = np.full((total_hours), np.nan) - haushaltsgeraet_wh_pro_stunde = np.full((total_hours), np.nan) + home_appliance_wh_per_hour = np.full((total_hours), np.nan) # Set initial state akku_soc_pro_stunde[0] = self.akku.ladezustand_in_prozent() @@ -127,10 +127,10 @@ class EnergieManagementSystem: # Accumulate loads and PV generation verbrauch = self.gesamtlast[stunde] verluste_wh_pro_stunde[stunde_since_now] = 0.0 - if self.haushaltsgeraet: - ha_load = self.haushaltsgeraet.get_last_fuer_stunde(stunde) + if self.home_appliance: + ha_load = self.home_appliance.get_load_for_hour(stunde) verbrauch += ha_load - haushaltsgeraet_wh_pro_stunde[stunde_since_now] = ha_load + home_appliance_wh_per_hour[stunde_since_now] = ha_load # E-Auto handling if self.eauto and self.ev_charge_hours[stunde] > 0: @@ -193,7 +193,7 @@ class EnergieManagementSystem: "Gesamtkosten_Euro": np.nansum(kosten_euro_pro_stunde), "Verluste_Pro_Stunde": verluste_wh_pro_stunde, "Gesamt_Verluste": np.nansum(verluste_wh_pro_stunde), - "Haushaltsgeraet_wh_pro_stunde": haushaltsgeraet_wh_pro_stunde, + "Home_appliance_wh_per_hour": home_appliance_wh_per_hour, } return out diff --git a/src/akkudoktoreos/visualize.py b/src/akkudoktoreos/visualize.py index 01af1bf..781ea18 100644 --- a/src/akkudoktoreos/visualize.py +++ b/src/akkudoktoreos/visualize.py @@ -112,7 +112,7 @@ def visualisiere_ergebnisse( ) plt.plot( hours, - ergebnisse["Haushaltsgeraet_wh_pro_stunde"], + ergebnisse["Home_appliance_wh_per_hour"], label="Household Device (Wh)", marker="o", linestyle="--", diff --git a/tests/test_class_ems.py b/tests/test_class_ems.py index 42b88ed..69a084e 100644 --- a/tests/test_class_ems.py +++ b/tests/test_class_ems.py @@ -3,7 +3,7 @@ import pytest from akkudoktoreos.config import AppConfig from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters -from akkudoktoreos.devices.generic import Haushaltsgeraet, HaushaltsgeraetParameters +from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters from akkudoktoreos.devices.inverter import Wechselrichter, WechselrichterParameters from akkudoktoreos.prediction.ems import ( EnergieManagementSystem, @@ -28,14 +28,14 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem: wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku) # Household device (currently not used, set to None) - home_appliance = Haushaltsgeraet( - HaushaltsgeraetParameters( - verbrauch_wh=2000, - dauer_h=2, + home_appliance = HomeAppliance( + HomeApplianceParameters( + consumption_wh=2000, + duration_h=2, ), hours=prediction_hours, ) - home_appliance.set_startzeitpunkt(2) + home_appliance.set_starting_time(2) # Example initialization of electric car battery eauto = PVAkku( @@ -212,7 +212,7 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem: gesamtlast=gesamtlast, ), eauto=eauto, - haushaltsgeraet=home_appliance, + home_appliance=home_appliance, wechselrichter=wechselrichter, ) @@ -270,7 +270,7 @@ def test_simulation(create_ems_instance): "Gesamtkosten_Euro", "Verluste_Pro_Stunde", "Gesamt_Verluste", - "Haushaltsgeraet_wh_pro_stunde", + "Home_appliance_wh_per_hour", ] for key in expected_keys: @@ -338,18 +338,18 @@ def test_simulation(create_ems_instance): # Check home appliances assert ( - sum(ems.haushaltsgeraet.get_lastkurve()) == 2000 - ), "The sum of 'ems.haushaltsgeraet.get_lastkurve()' should be 2000." + sum(ems.home_appliance.get_load_curve()) == 2000 + ), "The sum of 'ems.home_appliance.get_load_curve()' should be 2000." assert ( np.nansum( np.where( - np.equal(result["Haushaltsgeraet_wh_pro_stunde"], None), + np.equal(result["Home_appliance_wh_per_hour"], None), np.nan, - np.array(result["Haushaltsgeraet_wh_pro_stunde"]), + np.array(result["Home_appliance_wh_per_hour"]), ) ) == 2000 - ), "The sum of 'Haushaltsgeraet_wh_pro_stunde' should be 2000." + ), "The sum of 'Home_appliance_wh_per_hour' should be 2000." print("All tests passed successfully.") diff --git a/tests/test_class_ems_2.py b/tests/test_class_ems_2.py index 09bf664..e048efd 100644 --- a/tests/test_class_ems_2.py +++ b/tests/test_class_ems_2.py @@ -3,7 +3,7 @@ import pytest from akkudoktoreos.config import AppConfig from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters -from akkudoktoreos.devices.generic import Haushaltsgeraet, HaushaltsgeraetParameters +from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters from akkudoktoreos.devices.inverter import Wechselrichter, WechselrichterParameters from akkudoktoreos.prediction.ems import ( EnergieManagementSystem, @@ -28,14 +28,14 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem: wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku) # Household device (currently not used, set to None) - home_appliance = Haushaltsgeraet( - HaushaltsgeraetParameters( - verbrauch_wh=2000, - dauer_h=2, + home_appliance = HomeAppliance( + HomeApplianceParameters( + consumption_wh=2000, + duration_h=2, ), hours=prediction_hours, ) - home_appliance.set_startzeitpunkt(2) + home_appliance.set_starting_time(2) # Example initialization of electric car battery eauto = PVAkku( @@ -117,7 +117,7 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem: gesamtlast=gesamtlast, ), eauto=eauto, - haushaltsgeraet=home_appliance, + home_appliance=home_appliance, wechselrichter=wechselrichter, ) @@ -182,7 +182,7 @@ def test_simulation(create_ems_instance): "Gesamtkosten_Euro", "Verluste_Pro_Stunde", "Gesamt_Verluste", - "Haushaltsgeraet_wh_pro_stunde", + "Home_appliance_wh_per_hour", ] for key in expected_keys: diff --git a/tests/testdata/optimize_input_2.json b/tests/testdata/optimize_input_2.json index 1fcafd6..9a715d6 100644 --- a/tests/testdata/optimize_input_2.json +++ b/tests/testdata/optimize_input_2.json @@ -37,9 +37,9 @@ "start_soc_prozent": 5, "min_soc_prozent": 80 }, - "spuelmaschine" :{ - "verbrauch_wh": 5000, - "dauer_h": 2 + "dishwasher" :{ + "consumption_wh": 5000, + "duration_h": 2 }, "temperature_forecast": [ 18.3, 17.8, 16.9, 16.2, 15.6, 15.1, 14.6, 14.2, 14.3, 14.8, 15.7, 16.7, 17.4, @@ -48,4 +48,4 @@ 22.7, 23.1, 23.1, 22.8, 21.8, 20.2, 19.1, 18.0, 17.4 ], "start_solution": null -} \ No newline at end of file +} diff --git a/tests/testdata/optimize_result_1.json b/tests/testdata/optimize_result_1.json index 0e3871d..1586f06 100644 --- a/tests/testdata/optimize_result_1.json +++ b/tests/testdata/optimize_result_1.json @@ -475,7 +475,7 @@ 0.0 ], "Gesamt_Verluste": 1859.6205371900821, - "Haushaltsgeraet_wh_pro_stunde": [ + "Home_appliance_wh_per_hour": [ null, null, null, @@ -727,5 +727,5 @@ 1, 1 ], - "spuelstart": null + "washingstart": null } \ No newline at end of file diff --git a/tests/testdata/optimize_result_2.json b/tests/testdata/optimize_result_2.json index cb01b54..e7ff510 100644 --- a/tests/testdata/optimize_result_2.json +++ b/tests/testdata/optimize_result_2.json @@ -40,7 +40,8 @@ 957.818181818182, 447.0, 1152.0, 843.0, 846.7933884297522, 345.0, 276.0, 309.0, 0.0, 0.0, 0.0, 0.0, 124.41545454545451, 141.38119834710756, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 69.12409090909085, 0.0, 78.55010330578523, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.08954545454549, 80.85954545454547 ], "Gesamt_Verluste": 5771.031508264463, - "Haushaltsgeraet_wh_pro_stunde": [ + + "Home_appliance_wh_per_hour": [ 0.0, 0.0, 0.0, 2500.0, 2500.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, @@ -62,5 +63,5 @@ "start_solution": [ 0, 0, 4, 3, 1, 3, 1, 5, 6, 4, 1, 3, 6, 4, 6, 0, 6, 6, 0, 0, 3, 4, 1, 3, 2, 4, 4, 2, 3, 2, 1, 0, 2, 4, 1, 0, 6, 6, 2, 0, 4, 3, 3, 2, 6, 4, 1, 1, 0, 1, 5, 1, 2, 4, 6, 6, 5, 0, 2, 1, 6, 5, 6, 3, 2, 6, 6, 1, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13 ], - "spuelstart": 13 + "washingstart": 13 } \ No newline at end of file diff --git a/tests/testdata/optimize_result_2_full.json b/tests/testdata/optimize_result_2_full.json index ca0adc0..dd265c9 100644 --- a/tests/testdata/optimize_result_2_full.json +++ b/tests/testdata/optimize_result_2_full.json @@ -40,7 +40,7 @@ 957.818181818182, 2.817272727272737, 672.0, 1152.0, 1152.0, 660.994834710744, 276.0, 276.0, 33.0, 0.0, 0.0, 0.0, 0.0, 0.0, 70.41409090909087, 118.37045454545455, 94.68272727272722, 83.01681818181817, 75.86045454545456, 66.66681818181814, 69.12409090909085, 109.0704545454546, 109.96227272727276, 47.952272727272714, 15.439199999999985, 53.855999999999995, 159.6443999999999, 21.032399999999996, 710.3921528925632, 0.0, 0.0, 0.0, 0.0, 35.132727272727266, 77.27590909090907, 134.59227272727276, 100.08954545454549, 80.85954545454547 ], "Gesamt_Verluste": 7416.064896694217, - "Haushaltsgeraet_wh_pro_stunde": [ + "Home_appliance_wh_per_hour": [ 0.0, 0.0, 0.0, 2500.0, 2500.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, @@ -62,5 +62,5 @@ "start_solution": [ 3, 2, 6, 3, 5, 4, 1, 5, 4, 6, 1, 1, 2, 6, 6, 6, 6, 6, 1, 2, 2, 6, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 6, 2, 2, 2, 6, 1, 1, 1, 1, 1, 0, 5, 3, 1, 1, 2, 0, 1, 0, 6, 2, 0, 6, 6, 6, 5, 2, 2, 3, 6, 1, 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13 ], - "spuelstart": 13 + "washingstart": 13 } \ No newline at end of file diff --git a/tests/testdata/visualize_input_1.json b/tests/testdata/visualize_input_1.json index de0222c..1f5ecf4 100644 --- a/tests/testdata/visualize_input_1.json +++ b/tests/testdata/visualize_input_1.json @@ -90,7 +90,7 @@ 100.08954545454549, 0.0 ], "Gesamt_Verluste": 6563.160567638104, - "Haushaltsgeraet_wh_pro_stunde": [ + "Home_appliance_wh_per_hour": [ null, null, null,