mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 00:45:22 +00:00
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:
parent
12679b6ab1
commit
2a163569bc
@ -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:
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
|
64
src/akkudoktoreos/class_home_appliance.py
Normal file
64
src/akkudoktoreos/class_home_appliance.py
Normal 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
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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="--",
|
||||
|
@ -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.")
|
||||
|
@ -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:
|
||||
|
8
tests/testdata/optimize_input_2.json
vendored
8
tests/testdata/optimize_input_2.json
vendored
@ -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
|
||||
}
|
||||
}
|
||||
|
4
tests/testdata/optimize_result_1.json
vendored
4
tests/testdata/optimize_result_1.json
vendored
@ -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
|
||||
}
|
5
tests/testdata/optimize_result_2.json
vendored
5
tests/testdata/optimize_result_2.json
vendored
@ -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
|
||||
}
|
4
tests/testdata/optimize_result_2_full.json
vendored
4
tests/testdata/optimize_result_2_full.json
vendored
@ -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
|
||||
}
|
2
tests/testdata/visualize_input_1.json
vendored
2
tests/testdata/visualize_input_1.json
vendored
@ -90,7 +90,7 @@
|
||||
100.08954545454549, 0.0
|
||||
],
|
||||
"Gesamt_Verluste": 6563.160567638104,
|
||||
"Haushaltsgeraet_wh_pro_stunde": [
|
||||
"Home_appliance_wh_per_hour": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user