renamed haushaltsgeräte to home appliance (#196)

* * rename Haushaltsgeraete to home appliance
* renamed strafe to penalty (optimization problem)

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* removed penalty renaming

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* renamed one variable

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* * 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 <juergen.eckel@gmail.com>
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2024-11-26 00:53:16 +01:00 committed by GitHub
parent 5b58e6375d
commit 595b73359c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 174 additions and 107 deletions

View File

@ -9,6 +9,8 @@ repos:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- id: check-merge-conflict
exclude: '\.rst$' # Exclude .rst files
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.13.2 rev: 5.13.2
hooks: hooks:

View File

@ -496,27 +496,27 @@
"type": "object", "type": "object",
"title": "HTTPValidationError" "title": "HTTPValidationError"
}, },
"HaushaltsgeraetParameters": { "HomeApplianceParameters": {
"properties": { "properties": {
"verbrauch_wh": { "consumption_wh": {
"type": "integer", "type": "integer",
"exclusiveMinimum": 0.0, "exclusiveMinimum": 0.0,
"title": "Verbrauch Wh", "title": "Consumption Wh",
"description": "An integer representing the energy consumption of a household device in watt-hours." "description": "An integer representing the energy consumption of a household device in watt-hours."
}, },
"dauer_h": { "duration_h": {
"type": "integer", "type": "integer",
"exclusiveMinimum": 0.0, "exclusiveMinimum": 0.0,
"title": "Dauer H", "title": "Duration H",
"description": "An integer representing the usage duration of a household device in hours." "description": "An integer representing the usage duration of a household device in hours."
} }
}, },
"type": "object", "type": "object",
"required": [ "required": [
"verbrauch_wh", "consumption_wh",
"dauer_h" "duration_h"
], ],
"title": "HaushaltsgeraetParameters" "title": "HomeApplianceParameters"
}, },
"OptimizationParameters": { "OptimizationParameters": {
"properties": { "properties": {
@ -535,10 +535,10 @@
"eauto": { "eauto": {
"$ref": "#/components/schemas/EAutoParameters" "$ref": "#/components/schemas/EAutoParameters"
}, },
"spuelmaschine": { "dishwasher": {
"anyOf": [ "anyOf": [
{ {
"$ref": "#/components/schemas/HaushaltsgeraetParameters" "$ref": "#/components/schemas/HomeApplianceParameters"
}, },
{ {
"type": "null" "type": "null"
@ -624,7 +624,7 @@
"title": "Start Solution", "title": "Start Solution",
"description": "An array of binary values (0 or 1) representing a possible starting solution for the simulation." "description": "An array of binary values (0 or 1) representing a possible starting solution for the simulation."
}, },
"spuelstart": { "washingstart": {
"anyOf": [ "anyOf": [
{ {
"type": "integer" "type": "integer"
@ -633,7 +633,7 @@
"type": "null" "type": "null"
} }
], ],
"title": "Spuelstart", "title": "Washingstart",
"description": "Can be `null` or contain an object representing the start of washing (if applicable)." "description": "Can be `null` or contain an object representing the start of washing (if applicable)."
} }
}, },
@ -782,7 +782,7 @@
"title": "Gesamtkosten Euro", "title": "Gesamtkosten Euro",
"description": "The total costs in euros." "description": "The total costs in euros."
}, },
"Haushaltsgeraet_wh_pro_stunde": { "Home_appliance_wh_per_hour": {
"items": { "items": {
"anyOf": [ "anyOf": [
{ {
@ -794,7 +794,7 @@
] ]
}, },
"type": "array", "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." "description": "The energy consumption of a household appliance in watt-hours per hour."
}, },
"Kosten_Euro_pro_Stunde": { "Kosten_Euro_pro_Stunde": {
@ -882,7 +882,7 @@
"Gesamtbilanz_Euro", "Gesamtbilanz_Euro",
"Gesamteinnahmen_Euro", "Gesamteinnahmen_Euro",
"Gesamtkosten_Euro", "Gesamtkosten_Euro",
"Haushaltsgeraet_wh_pro_stunde", "Home_appliance_wh_per_hour",
"Kosten_Euro_pro_Stunde", "Kosten_Euro_pro_Stunde",
"Netzbezug_Wh_pro_Stunde", "Netzbezug_Wh_pro_Stunde",
"Netzeinspeisung_Wh_pro_Stunde", "Netzeinspeisung_Wh_pro_Stunde",

View File

@ -267,11 +267,11 @@ parameters = OptimizationParameters(
# Current SOC of the electric car (%) # Current SOC of the electric car (%)
"start_soc_prozent": 5, "start_soc_prozent": 5,
}, },
# "spuelmaschine": { # "dishwasher": {
# # Household appliance consumption (Wh) # # Household appliance consumption (Wh)
# "verbrauch_wh": 5000, # "consumption_wh": 5000,
# # Duration of appliance usage (hours) # # Duration of appliance usage (hours)
# "dauer_h": 0, # "duration_h": 0,
# }, # },
# Temperature forecast (48 hours) # Temperature forecast (48 hours)
"temperature_forecast": temperature_forecast, "temperature_forecast": temperature_forecast,

View File

@ -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

View File

@ -2,53 +2,53 @@ import numpy as np
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
class HaushaltsgeraetParameters(BaseModel): class HomeApplianceParameters(BaseModel):
verbrauch_wh: int = Field( consumption_wh: int = Field(
gt=0, gt=0,
description="An integer representing the energy consumption of a household device in watt-hours.", description="An integer representing the energy consumption of a household device in watt-hours.",
) )
dauer_h: int = Field( duration_h: int = Field(
gt=0, gt=0,
description="An integer representing the usage duration of a household device in hours.", description="An integer representing the usage duration of a household device in hours.",
) )
class Haushaltsgeraet: class HomeAppliance:
def __init__(self, parameters: HaushaltsgeraetParameters, hours=24): def __init__(self, parameters: HomeApplianceParameters, hours=None):
self.hours = hours # Total duration for which the planning is done self.hours = hours # Total duration for which the planning is done
self.verbrauch_wh = ( self.consumption_wh = (
parameters.verbrauch_wh # Total energy consumption of the device in kWh parameters.consumption_wh
) ) # Total energy consumption of the device in kWh
self.dauer_h = parameters.dauer_h # Duration of use in hours self.duration_h = parameters.duration_h # Duration of use in hours
self.lastkurve = np.zeros(self.hours) # Initialize the load curve with zeros 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. """Sets the start time of the device and generates the corresponding load curve.
:param start_hour: The hour at which the device should start. :param start_hour: The hour at which the device should start.
""" """
self.reset() self.reset()
# Check if the duration of use is within the available time frame # 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.") raise ValueError("The duration of use exceeds the available time frame.")
if start_hour < global_start_hour: if start_hour < global_start_hour:
raise ValueError("The start time is earlier than the available time frame.") raise ValueError("The start time is earlier than the available time frame.")
# Calculate power per hour based on total consumption and duration # 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 # 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): def reset(self):
"""Resets the load curve.""" """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.""" """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. """Returns the load for a specific hour.
:param hour: The hour for which the load is queried. :param hour: The hour for which the load is queried.
@ -57,8 +57,8 @@ class Haushaltsgeraet:
if hour < 0 or hour >= self.hours: if hour < 0 or hour >= self.hours:
raise ValueError("The specified hour is outside the available time frame.") 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.""" """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

View File

@ -125,15 +125,15 @@ if __name__ == "__main__":
start_innentemperatur = 15 # Initial indoor temperature start_innentemperatur = 15 # Initial indoor temperature
isolationseffizienz = 0.8 # Insulation efficiency isolationseffizienz = 0.8 # Insulation efficiency
gewuenschte_innentemperatur = 20 # Desired indoor temperature 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 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) # 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 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 # Calculate the 24-hour power data
leistungsdaten = wp.simulate_24h(temperaturen) leistungsdaten = hp.simulate_24h(temperaturen)
print(leistungsdaten) print(leistungsdaten)

View File

@ -8,7 +8,7 @@ from typing_extensions import Self
from akkudoktoreos.config import AppConfig from akkudoktoreos.config import AppConfig
from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters 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.devices.inverter import Wechselrichter, WechselrichterParameters
from akkudoktoreos.prediction.ems import ( from akkudoktoreos.prediction.ems import (
EnergieManagementSystem, EnergieManagementSystem,
@ -22,7 +22,7 @@ class OptimizationParameters(BaseModel):
pv_akku: PVAkkuParameters pv_akku: PVAkkuParameters
wechselrichter: WechselrichterParameters = WechselrichterParameters() wechselrichter: WechselrichterParameters = WechselrichterParameters()
eauto: EAutoParameters eauto: EAutoParameters
spuelmaschine: Optional[HaushaltsgeraetParameters] = None dishwasher: Optional[HomeApplianceParameters] = None
temperature_forecast: list[float] = Field( temperature_forecast: list[float] = Field(
"An array of floats representing the temperature forecast in degrees Celsius for different time intervals." "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.") Gesamteinnahmen_Euro: float = Field(description="The total revenues in euros.")
Gesamtkosten_Euro: float = Field(description="The total costs 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." description="The energy consumption of a household appliance in watt-hours per hour."
) )
Kosten_Euro_pro_Stunde: list[Optional[float]] = Field( 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.") # Gesamtbilanz_Euro: float = Field(description="The total simulated balance in euros.")
# Gesamteinnahmen_Euro: float = Field(description="The total simulated income in euros.") # Gesamteinnahmen_Euro: float = Field(description="The total simulated income in euros.")
# Gesamtkosten_Euro: float = Field(description="The total simulated costs 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." # 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( # Kosten_Euro_pro_Stunde: list[Optional[float]] = Field(
@ -158,7 +158,7 @@ class OptimizeResponse(BaseModel):
None, None,
description="An array of binary values (0 or 1) representing a possible starting solution for the simulation.", 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, None,
description="Can be `null` or contain an object representing the start of washing (if applicable).", 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 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 # 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) # Extract the appliance part (typically a single value for the start hour)
appliance_part = [individual[-1]] appliance_part = [individual[-1]]
@ -311,7 +311,7 @@ class optimization_problem:
] ]
# Add the start time of the household appliance if it's being optimized # 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()] individual_components += [self.toolbox.attr_int()]
return creator.Individual(individual_components) return creator.Individual(individual_components)
@ -333,12 +333,12 @@ class optimization_problem:
else None else None
) )
spuelstart_int = ( washingstart_int = (
individual[-1] 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 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: 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.""" """Set up the DEAP environment with fitness and individual creation rules."""
@ -410,11 +410,11 @@ class optimization_problem:
This is an internal function. This is an internal function.
""" """
ems.reset() 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 individual
) )
if self.opti_param.get("haushaltsgeraete", 0) > 0: if self.opti_param.get("home_appliance", 0) > 0:
ems.set_haushaltsgeraet_start(spuelstart_int, global_start_hour=start_hour) ems.set_home_appliance_start(washingstart_int, global_start_hour=start_hour)
ac, dc, discharge = self.decode_charge_discharge(discharge_hours_bin) 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)) eauto.set_charge_per_hour(np.full(self.prediction_hours, 1))
# Initialize household appliance if applicable # Initialize household appliance if applicable
spuelmaschine = ( dishwasher = (
Haushaltsgeraet( HomeAppliance(
parameters=parameters.spuelmaschine, parameters=parameters.dishwasher,
hours=self.prediction_hours, hours=self.prediction_hours,
) )
if parameters.spuelmaschine is not None if parameters.dishwasher is not None
else None else None
) )
@ -572,12 +572,12 @@ class optimization_problem:
self._config.eos, self._config.eos,
parameters.ems, parameters.ems,
eauto=eauto, eauto=eauto,
haushaltsgeraet=spuelmaschine, home_appliance=dishwasher,
wechselrichter=wr, wechselrichter=wr,
) )
# Setup the DEAP environment and optimization process # 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( self.toolbox.register(
"evaluate", "evaluate",
lambda ind: self.evaluate(ind, ems, parameters, start_hour, worst_case), 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 # Perform final evaluation on the best solution
o = self.evaluate_inner(start_solution, ems, start_hour) 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 start_solution
) )
if self.optimize_ev: if self.optimize_ev:
@ -622,7 +622,7 @@ class optimization_problem:
"Einnahmen_Euro_pro_Stunde", "Einnahmen_Euro_pro_Stunde",
"EAuto_SoC_pro_Stunde", "EAuto_SoC_pro_Stunde",
"Verluste_Pro_Stunde", "Verluste_Pro_Stunde",
"Haushaltsgeraet_wh_pro_stunde", "Home_appliance_wh_per_hour",
] ]
# Loop through each key in the list # Loop through each key in the list
@ -649,6 +649,6 @@ class optimization_problem:
"result": o, "result": o,
"eauto_obj": ems.eauto.to_dict(), "eauto_obj": ems.eauto.to_dict(),
"start_solution": start_solution, "start_solution": start_solution,
"spuelstart": spuelstart_int, "washingstart": washingstart_int,
# "simulation_data": o, # "simulation_data": o,
} }

View File

@ -7,7 +7,7 @@ from typing_extensions import Self
from akkudoktoreos.config import EOSConfig from akkudoktoreos.config import EOSConfig
from akkudoktoreos.devices.battery import PVAkku from akkudoktoreos.devices.battery import PVAkku
from akkudoktoreos.devices.generic import Haushaltsgeraet from akkudoktoreos.devices.generic import HomeAppliance
from akkudoktoreos.devices.inverter import Wechselrichter from akkudoktoreos.devices.inverter import Wechselrichter
@ -47,7 +47,7 @@ class EnergieManagementSystem:
config: EOSConfig, config: EOSConfig,
parameters: EnergieManagementSystemParameters, parameters: EnergieManagementSystemParameters,
eauto: Optional[PVAkku] = None, eauto: Optional[PVAkku] = None,
haushaltsgeraet: Optional[Haushaltsgeraet] = None, home_appliance: Optional[HomeAppliance] = None,
wechselrichter: Optional[Wechselrichter] = None, wechselrichter: Optional[Wechselrichter] = None,
): ):
self.akku = wechselrichter.akku self.akku = wechselrichter.akku
@ -60,7 +60,7 @@ class EnergieManagementSystem:
else np.full(len(self.gesamtlast), parameters.einspeiseverguetung_euro_pro_wh, float) else np.full(len(self.gesamtlast), parameters.einspeiseverguetung_euro_pro_wh, float)
) )
self.eauto = eauto self.eauto = eauto
self.haushaltsgeraet = haushaltsgeraet self.home_appliance = home_appliance
self.wechselrichter = wechselrichter self.wechselrichter = wechselrichter
self.ac_charge_hours = np.full(config.prediction_hours, 0) self.ac_charge_hours = np.full(config.prediction_hours, 0)
self.dc_charge_hours = np.full(config.prediction_hours, 1) 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: def set_ev_charge_hours(self, ds: List[int]) -> None:
self.ev_charge_hours = ds self.ev_charge_hours = ds
def set_haushaltsgeraet_start(self, ds: List[int], global_start_hour: int = 0) -> None: def set_home_appliance_start(self, ds: List[int], global_start_hour: int = 0) -> None:
self.haushaltsgeraet.set_startzeitpunkt(ds, global_start_hour=global_start_hour) self.home_appliance.set_starting_time(ds, global_start_hour=global_start_hour)
def reset(self) -> None: def reset(self) -> None:
self.eauto.reset() self.eauto.reset()
@ -114,7 +114,7 @@ class EnergieManagementSystem:
akku_soc_pro_stunde = np.full((total_hours), np.nan) akku_soc_pro_stunde = np.full((total_hours), np.nan)
eauto_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) 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 # Set initial state
akku_soc_pro_stunde[0] = self.akku.ladezustand_in_prozent() akku_soc_pro_stunde[0] = self.akku.ladezustand_in_prozent()
@ -127,10 +127,10 @@ class EnergieManagementSystem:
# Accumulate loads and PV generation # Accumulate loads and PV generation
verbrauch = self.gesamtlast[stunde] verbrauch = self.gesamtlast[stunde]
verluste_wh_pro_stunde[stunde_since_now] = 0.0 verluste_wh_pro_stunde[stunde_since_now] = 0.0
if self.haushaltsgeraet: if self.home_appliance:
ha_load = self.haushaltsgeraet.get_last_fuer_stunde(stunde) ha_load = self.home_appliance.get_load_for_hour(stunde)
verbrauch += ha_load 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 # E-Auto handling
if self.eauto and self.ev_charge_hours[stunde] > 0: if self.eauto and self.ev_charge_hours[stunde] > 0:
@ -193,7 +193,7 @@ class EnergieManagementSystem:
"Gesamtkosten_Euro": np.nansum(kosten_euro_pro_stunde), "Gesamtkosten_Euro": np.nansum(kosten_euro_pro_stunde),
"Verluste_Pro_Stunde": verluste_wh_pro_stunde, "Verluste_Pro_Stunde": verluste_wh_pro_stunde,
"Gesamt_Verluste": np.nansum(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 return out

View File

@ -112,7 +112,7 @@ def visualisiere_ergebnisse(
) )
plt.plot( plt.plot(
hours, hours,
ergebnisse["Haushaltsgeraet_wh_pro_stunde"], ergebnisse["Home_appliance_wh_per_hour"],
label="Household Device (Wh)", label="Household Device (Wh)",
marker="o", marker="o",
linestyle="--", linestyle="--",

View File

@ -3,7 +3,7 @@ import pytest
from akkudoktoreos.config import AppConfig from akkudoktoreos.config import AppConfig
from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters 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.devices.inverter import Wechselrichter, WechselrichterParameters
from akkudoktoreos.prediction.ems import ( from akkudoktoreos.prediction.ems import (
EnergieManagementSystem, EnergieManagementSystem,
@ -28,14 +28,14 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem:
wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku) wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku)
# Household device (currently not used, set to None) # Household device (currently not used, set to None)
home_appliance = Haushaltsgeraet( home_appliance = HomeAppliance(
HaushaltsgeraetParameters( HomeApplianceParameters(
verbrauch_wh=2000, consumption_wh=2000,
dauer_h=2, duration_h=2,
), ),
hours=prediction_hours, hours=prediction_hours,
) )
home_appliance.set_startzeitpunkt(2) home_appliance.set_starting_time(2)
# Example initialization of electric car battery # Example initialization of electric car battery
eauto = PVAkku( eauto = PVAkku(
@ -212,7 +212,7 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem:
gesamtlast=gesamtlast, gesamtlast=gesamtlast,
), ),
eauto=eauto, eauto=eauto,
haushaltsgeraet=home_appliance, home_appliance=home_appliance,
wechselrichter=wechselrichter, wechselrichter=wechselrichter,
) )
@ -270,7 +270,7 @@ def test_simulation(create_ems_instance):
"Gesamtkosten_Euro", "Gesamtkosten_Euro",
"Verluste_Pro_Stunde", "Verluste_Pro_Stunde",
"Gesamt_Verluste", "Gesamt_Verluste",
"Haushaltsgeraet_wh_pro_stunde", "Home_appliance_wh_per_hour",
] ]
for key in expected_keys: for key in expected_keys:
@ -338,18 +338,18 @@ def test_simulation(create_ems_instance):
# Check home appliances # Check home appliances
assert ( assert (
sum(ems.haushaltsgeraet.get_lastkurve()) == 2000 sum(ems.home_appliance.get_load_curve()) == 2000
), "The sum of 'ems.haushaltsgeraet.get_lastkurve()' should be 2000." ), "The sum of 'ems.home_appliance.get_load_curve()' should be 2000."
assert ( assert (
np.nansum( np.nansum(
np.where( np.where(
np.equal(result["Haushaltsgeraet_wh_pro_stunde"], None), np.equal(result["Home_appliance_wh_per_hour"], None),
np.nan, np.nan,
np.array(result["Haushaltsgeraet_wh_pro_stunde"]), np.array(result["Home_appliance_wh_per_hour"]),
) )
) )
== 2000 == 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.") print("All tests passed successfully.")

View File

@ -3,7 +3,7 @@ import pytest
from akkudoktoreos.config import AppConfig from akkudoktoreos.config import AppConfig
from akkudoktoreos.devices.battery import EAutoParameters, PVAkku, PVAkkuParameters 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.devices.inverter import Wechselrichter, WechselrichterParameters
from akkudoktoreos.prediction.ems import ( from akkudoktoreos.prediction.ems import (
EnergieManagementSystem, EnergieManagementSystem,
@ -28,14 +28,14 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem:
wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku) wechselrichter = Wechselrichter(WechselrichterParameters(max_leistung_wh=10000), akku)
# Household device (currently not used, set to None) # Household device (currently not used, set to None)
home_appliance = Haushaltsgeraet( home_appliance = HomeAppliance(
HaushaltsgeraetParameters( HomeApplianceParameters(
verbrauch_wh=2000, consumption_wh=2000,
dauer_h=2, duration_h=2,
), ),
hours=prediction_hours, hours=prediction_hours,
) )
home_appliance.set_startzeitpunkt(2) home_appliance.set_starting_time(2)
# Example initialization of electric car battery # Example initialization of electric car battery
eauto = PVAkku( eauto = PVAkku(
@ -117,7 +117,7 @@ def create_ems_instance(tmp_config: AppConfig) -> EnergieManagementSystem:
gesamtlast=gesamtlast, gesamtlast=gesamtlast,
), ),
eauto=eauto, eauto=eauto,
haushaltsgeraet=home_appliance, home_appliance=home_appliance,
wechselrichter=wechselrichter, wechselrichter=wechselrichter,
) )
@ -182,7 +182,7 @@ def test_simulation(create_ems_instance):
"Gesamtkosten_Euro", "Gesamtkosten_Euro",
"Verluste_Pro_Stunde", "Verluste_Pro_Stunde",
"Gesamt_Verluste", "Gesamt_Verluste",
"Haushaltsgeraet_wh_pro_stunde", "Home_appliance_wh_per_hour",
] ]
for key in expected_keys: for key in expected_keys:

View File

@ -37,9 +37,9 @@
"start_soc_prozent": 5, "start_soc_prozent": 5,
"min_soc_prozent": 80 "min_soc_prozent": 80
}, },
"spuelmaschine" :{ "dishwasher" :{
"verbrauch_wh": 5000, "consumption_wh": 5000,
"dauer_h": 2 "duration_h": 2
}, },
"temperature_forecast": [ "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, 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 22.7, 23.1, 23.1, 22.8, 21.8, 20.2, 19.1, 18.0, 17.4
], ],
"start_solution": null "start_solution": null
} }

View File

@ -475,7 +475,7 @@
0.0 0.0
], ],
"Gesamt_Verluste": 1859.6205371900821, "Gesamt_Verluste": 1859.6205371900821,
"Haushaltsgeraet_wh_pro_stunde": [ "Home_appliance_wh_per_hour": [
null, null,
null, null,
null, null,
@ -727,5 +727,5 @@
1, 1,
1 1
], ],
"spuelstart": null "washingstart": null
} }

View File

@ -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 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, "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 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": [ "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 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
} }

View File

@ -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 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, "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 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": [ "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 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
} }

View File

@ -90,7 +90,7 @@
100.08954545454549, 0.0 100.08954545454549, 0.0
], ],
"Gesamt_Verluste": 6563.160567638104, "Gesamt_Verluste": 6563.160567638104,
"Haushaltsgeraet_wh_pro_stunde": [ "Home_appliance_wh_per_hour": [
null, null,
null, null,
null, null,