Self consumption predictor

* Inverter: Self consumption interpolator for better discharge_hour results
 * Small penalty when EV 100% and charge >0
 * Price Forceast (use mean of last 7 days instead of repeat)
 * Price Prediction as JSON simulation output, config fixed electricty fees configurable + MyPy & Ruff
This commit is contained in:
Andreas
2024-12-19 14:45:20 +01:00
committed by Dominique Lasserre
parent 1c75060d8a
commit 410a23e375
15 changed files with 1243 additions and 820 deletions

View File

@@ -1,3 +1,5 @@
from pathlib import Path
import numpy as np
import pytest
@@ -15,6 +17,9 @@ from akkudoktoreos.devices.battery import (
)
from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters
from akkudoktoreos.devices.inverter import Inverter, InverterParameters
from akkudoktoreos.prediction.self_consumption_probability import (
self_consumption_probability_interpolator,
)
start_hour = 1
@@ -35,8 +40,19 @@ def create_ems_instance() -> EnergieManagementSystem:
),
hours=config_eos.prediction_hours,
)
# 1h Load to Sub 1h Load Distribution -> SelfConsumptionRate
sc = self_consumption_probability_interpolator(
Path(__file__).parent.resolve()
/ ".."
/ "src"
/ "akkudoktoreos"
/ "data"
/ "regular_grid_interpolator.pkl"
)
akku.reset()
inverter = Inverter(InverterParameters(max_power_wh=10000), akku)
inverter = Inverter(sc, InverterParameters(max_power_wh=10000), akku)
# Household device (currently not used, set to None)
home_appliance = HomeAppliance(
@@ -306,21 +322,21 @@ def test_simulation(create_ems_instance):
# Verify the total balance
assert (
abs(result["Gesamtbilanz_Euro"] - 1.7880374129090917) < 1e-5
), "Total balance should be 1.7880374129090917."
abs(result["Gesamtbilanz_Euro"] - 1.958185274567674) < 1e-5
), "Total balance should be 1.958185274567674."
# Check total revenue and total costs
assert (
abs(result["Gesamteinnahmen_Euro"] - 1.3169784090909087) < 1e-5
), "Total revenue should be 1.3169784090909087."
abs(result["Gesamteinnahmen_Euro"] - 1.168863124510214) < 1e-5
), "Total revenue should be 1.168863124510214."
assert (
abs(result["Gesamtkosten_Euro"] - 3.1050158220000004) < 1e-5
), "Total costs should be 3.1050158220000004 ."
abs(result["Gesamtkosten_Euro"] - 3.127048399077888) < 1e-5
), "Total costs should be 3.127048399077888 ."
# Check the losses
assert (
abs(result["Gesamt_Verluste"] - 2615.222727272727) < 1e-5
), "Total losses should be 2615.222727272727 ."
abs(result["Gesamt_Verluste"] - 2871.5330639359036) < 1e-5
), "Total losses should be 2871.5330639359036 ."
# Check the values in 'akku_soc_pro_stunde'
assert (