mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-09-19 18:21:14 +00:00
translation of battery.py v3 (#262)
This commit is contained in:
@@ -13,10 +13,10 @@ from akkudoktoreos.core.coreabc import (
|
||||
)
|
||||
from akkudoktoreos.core.ems import EnergieManagementSystemParameters, SimulationResult
|
||||
from akkudoktoreos.devices.battery import (
|
||||
EAutoParameters,
|
||||
EAutoResult,
|
||||
PVAkku,
|
||||
PVAkkuParameters,
|
||||
Battery,
|
||||
ElectricVehicleParameters,
|
||||
ElectricVehicleResult,
|
||||
SolarPanelBatteryParameters,
|
||||
)
|
||||
from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters
|
||||
from akkudoktoreos.devices.inverter import Inverter, InverterParameters
|
||||
@@ -26,9 +26,9 @@ from akkudoktoreos.visualize import visualisiere_ergebnisse
|
||||
|
||||
class OptimizationParameters(BaseModel):
|
||||
ems: EnergieManagementSystemParameters
|
||||
pv_akku: PVAkkuParameters
|
||||
pv_akku: SolarPanelBatteryParameters
|
||||
inverter: InverterParameters = InverterParameters()
|
||||
eauto: Optional[EAutoParameters]
|
||||
eauto: Optional[ElectricVehicleParameters]
|
||||
dishwasher: Optional[HomeApplianceParameters] = None
|
||||
temperature_forecast: Optional[list[float]] = Field(
|
||||
default=None,
|
||||
@@ -68,7 +68,7 @@ class OptimizeResponse(BaseModel):
|
||||
)
|
||||
eautocharge_hours_float: Optional[list[float]] = Field(description="TBD")
|
||||
result: SimulationResult
|
||||
eauto_obj: Optional[EAutoResult]
|
||||
eauto_obj: Optional[ElectricVehicleResult]
|
||||
start_solution: Optional[list[float]] = Field(
|
||||
default=None,
|
||||
description="An array of binary values (0 or 1) representing a possible starting solution for the simulation.",
|
||||
@@ -92,8 +92,8 @@ class OptimizeResponse(BaseModel):
|
||||
mode="before",
|
||||
)
|
||||
def convert_eauto(cls, field: Any) -> Any:
|
||||
if isinstance(field, PVAkku):
|
||||
return EAutoResult(**field.to_dict())
|
||||
if isinstance(field, Battery):
|
||||
return ElectricVehicleResult(**field.to_dict())
|
||||
return field
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ class optimization_problem(ConfigMixin, DevicesMixin, EnergyManagementSystemMixi
|
||||
)
|
||||
|
||||
# Penalty for not meeting the minimum SOC (State of Charge) requirement
|
||||
# if parameters.eauto_min_soc_prozent - ems.eauto.ladezustand_in_prozent() <= 0.0 and self.optimize_ev:
|
||||
# if parameters.eauto_min_soc_prozent - ems.eauto.current_soc_percentage() <= 0.0 and self.optimize_ev:
|
||||
# gesamtbilanz += sum(
|
||||
# self.config.optimization_penalty for ladeleistung in eautocharge_hours_float if ladeleistung != 0.0
|
||||
# )
|
||||
@@ -375,7 +375,7 @@ class optimization_problem(ConfigMixin, DevicesMixin, EnergyManagementSystemMixi
|
||||
individual.extra_data = ( # type: ignore[attr-defined]
|
||||
o["Gesamtbilanz_Euro"],
|
||||
o["Gesamt_Verluste"],
|
||||
parameters.eauto.min_soc_prozent - self.ems.eauto.ladezustand_in_prozent()
|
||||
parameters.eauto.min_soc_percentage - self.ems.eauto.current_soc_percentage()
|
||||
if parameters.eauto and self.ems.eauto
|
||||
else 0,
|
||||
)
|
||||
@@ -383,16 +383,16 @@ class optimization_problem(ConfigMixin, DevicesMixin, EnergyManagementSystemMixi
|
||||
# Adjust total balance with battery value and penalties for unmet SOC
|
||||
|
||||
restwert_akku = (
|
||||
self.ems.akku.aktueller_energieinhalt() * parameters.ems.preis_euro_pro_wh_akku
|
||||
self.ems.akku.current_energy_content() * parameters.ems.preis_euro_pro_wh_akku
|
||||
)
|
||||
# print(ems.akku.aktueller_energieinhalt()," * ", parameters.ems.preis_euro_pro_wh_akku , " ", restwert_akku, " ", gesamtbilanz)
|
||||
# print(ems.akku.current_energy_content()," * ", parameters.ems.preis_euro_pro_wh_akku , " ", restwert_akku, " ", gesamtbilanz)
|
||||
gesamtbilanz += -restwert_akku
|
||||
# print(gesamtbilanz)
|
||||
if self.optimize_ev:
|
||||
gesamtbilanz += max(
|
||||
0,
|
||||
(
|
||||
parameters.eauto.min_soc_prozent - self.ems.eauto.ladezustand_in_prozent()
|
||||
parameters.eauto.min_soc_percentage - self.ems.eauto.current_soc_percentage()
|
||||
if parameters.eauto and self.ems.eauto
|
||||
else 0
|
||||
)
|
||||
@@ -458,21 +458,21 @@ class optimization_problem(ConfigMixin, DevicesMixin, EnergyManagementSystemMixi
|
||||
)
|
||||
|
||||
# Initialize PV and EV batteries
|
||||
akku = PVAkku(
|
||||
akku = Battery(
|
||||
parameters.pv_akku,
|
||||
hours=self.config.prediction_hours,
|
||||
)
|
||||
akku.set_charge_per_hour(np.full(self.config.prediction_hours, 1))
|
||||
|
||||
eauto: Optional[PVAkku] = None
|
||||
eauto: Optional[Battery] = None
|
||||
if parameters.eauto:
|
||||
eauto = PVAkku(
|
||||
eauto = Battery(
|
||||
parameters.eauto,
|
||||
hours=self.config.prediction_hours,
|
||||
)
|
||||
eauto.set_charge_per_hour(np.full(self.config.prediction_hours, 1))
|
||||
self.optimize_ev = (
|
||||
parameters.eauto.min_soc_prozent - parameters.eauto.start_soc_prozent >= 0
|
||||
parameters.eauto.min_soc_percentage - parameters.eauto.initial_soc_percentage >= 0
|
||||
)
|
||||
else:
|
||||
self.optimize_ev = False
|
||||
|
Reference in New Issue
Block a user