mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 00:45:22 +00:00
min_soc (was killed by someone else, pls dont force push!)
This commit is contained in:
parent
a16490523d
commit
05c0f74b09
@ -228,6 +228,10 @@ def flask_optimize():
|
||||
parameter=parameter, start_hour=datetime.now().hour
|
||||
)
|
||||
|
||||
# Optional min SoC PV Battery
|
||||
if "min_soc_prozent" not in parameter:
|
||||
parameter["min_soc_prozent"] = None
|
||||
|
||||
return jsonify(result) # Return optimization results as JSON
|
||||
|
||||
|
||||
|
@ -270,6 +270,7 @@ class optimization_problem:
|
||||
kapazitaet_wh=parameter["pv_akku_cap"],
|
||||
hours=self.prediction_hours,
|
||||
start_soc_prozent=parameter["pv_soc"],
|
||||
min_soc_prozent=parameter["min_soc_prozent"],
|
||||
max_ladeleistung_w=5000,
|
||||
)
|
||||
akku.set_charge_per_hour(np.full(self.prediction_hours, 1))
|
||||
|
@ -341,7 +341,7 @@ parameter = {
|
||||
# Electricity price forecast (48 hours)
|
||||
"strompreis_euro_pro_wh": strompreis_euro_pro_wh,
|
||||
# Minimum SOC for electric car
|
||||
"eauto_min_soc": 70,
|
||||
"eauto_min_soc": 1000,
|
||||
# Electric car battery capacity (Wh)
|
||||
"eauto_cap": 60000,
|
||||
# Charging efficiency of the electric car
|
||||
@ -349,7 +349,7 @@ parameter = {
|
||||
# Charging power of the electric car (W)
|
||||
"eauto_charge_power": 11040,
|
||||
# Current SOC of the electric car (%)
|
||||
"eauto_soc": 54,
|
||||
"eauto_soc": 5,
|
||||
# Current PV power generation (W)
|
||||
"pvpowernow": 211.137503624,
|
||||
# Initial solution for the optimization
|
||||
@ -358,6 +358,8 @@ parameter = {
|
||||
"haushaltsgeraet_wh": 5000,
|
||||
# Duration of appliance usage (hours)
|
||||
"haushaltsgeraet_dauer": 2,
|
||||
# Minimum Soc PV Battery
|
||||
"min_soc_prozent": 15,
|
||||
}
|
||||
|
||||
# Initialize the optimization problem
|
||||
|
@ -17,7 +17,9 @@ def create_ems_instance():
|
||||
Fixture to create an EnergieManagementSystem instance with given test parameters.
|
||||
"""
|
||||
# Initialize the battery and the inverter
|
||||
akku = PVAkku(kapazitaet_wh=5000, start_soc_prozent=80, hours=48)
|
||||
akku = PVAkku(
|
||||
kapazitaet_wh=5000, start_soc_prozent=80, hours=48, min_soc_prozent=10
|
||||
)
|
||||
akku.reset()
|
||||
wechselrichter = Wechselrichter(10000, akku)
|
||||
|
||||
@ -30,7 +32,9 @@ def create_ems_instance():
|
||||
home_appliance.set_startzeitpunkt(2)
|
||||
|
||||
# Example initialization of electric car battery
|
||||
eauto = PVAkku(kapazitaet_wh=26400, start_soc_prozent=10, hours=48)
|
||||
eauto = PVAkku(
|
||||
kapazitaet_wh=26400, start_soc_prozent=10, hours=48, min_soc_prozent=10
|
||||
)
|
||||
|
||||
# Parameters based on previous example data
|
||||
pv_prognose_wh = [
|
||||
@ -286,33 +290,33 @@ def test_simulation(create_ems_instance):
|
||||
result["Netzbezug_Wh_pro_Stunde"][0] == 0.0
|
||||
), "The value at index 0 of 'Netzbezug_Wh_pro_Stunde' should be None."
|
||||
assert (
|
||||
result["Netzbezug_Wh_pro_Stunde"][1] == 21239.13
|
||||
), "The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be 21239.13."
|
||||
result["Netzbezug_Wh_pro_Stunde"][1] == 21679.13
|
||||
), "The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be21679.13."
|
||||
|
||||
# Verify the total balance
|
||||
assert (
|
||||
abs(result["Gesamtbilanz_Euro"] - 9.091642129454547) < 1e-5
|
||||
), "Total balance should be 9.091642129454547."
|
||||
abs(result["Gesamtbilanz_Euro"] - 9.302960148909092) < 1e-5
|
||||
), "Total balance should be 9.302960148909092."
|
||||
|
||||
# Check total revenue and total costs
|
||||
assert (
|
||||
abs(result["Gesamteinnahmen_Euro"] - 1.237432954545454) < 1e-5
|
||||
), "Total revenue should be 1.237432954545454."
|
||||
abs(result["Gesamteinnahmen_Euro"] - 1.3169784090909087) < 1e-5
|
||||
), "Total revenue should be 1.3169784090909087."
|
||||
assert (
|
||||
abs(result["Gesamtkosten_Euro"] - 10.329075084000001) < 1e-5
|
||||
), "Total costs should be 10.329075084000001 ."
|
||||
abs(result["Gesamtkosten_Euro"] - 10.619938558000001) < 1e-5
|
||||
), "Total costs should be 10.619938558000001 ."
|
||||
|
||||
# Check the losses
|
||||
assert (
|
||||
abs(result["Gesamt_Verluste"] - 6111.586363636363) < 1e-5
|
||||
), "Total losses should be 6111.586363636363."
|
||||
abs(result["Gesamt_Verluste"] - 5855.222727272727) < 1e-5
|
||||
), "Total losses should be 5855.222727272727."
|
||||
|
||||
# Check the values in 'akku_soc_pro_stunde'
|
||||
assert (
|
||||
result["akku_soc_pro_stunde"][-1] == 28.675
|
||||
), "The value at index -1 of 'akku_soc_pro_stunde' should be 28.675."
|
||||
assert (
|
||||
result["akku_soc_pro_stunde"][1] == 0.0
|
||||
result["akku_soc_pro_stunde"][1] == 10.0
|
||||
), "The value at index 1 of 'akku_soc_pro_stunde' should be 0.0."
|
||||
|
||||
# Check home appliances
|
||||
|
@ -1398,6 +1398,7 @@ def setup_opt_class():
|
||||
) # Yield the class and parameters for use in tests
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Expensive - Skipped per default")
|
||||
def test_optimierung_ems(setup_opt_class):
|
||||
opt_class, parameter, start_hour = setup_opt_class
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user