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