mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-06-28 08:56:54 +00:00
Lastprognose entkoppelt, an den Optimierer wird jetzt nur das Array
übergeben. So sind unterschiedliche / eigenen Prognosen möglich
This commit is contained in:
parent
5e842d5ee4
commit
b5ff38fb03
@ -76,13 +76,40 @@ def flask_strompreis():
|
||||
return jsonify(specific_date_prices.tolist())
|
||||
|
||||
|
||||
@app.route('/gesamtlast', methods=['GET'])
|
||||
def flask_gesamtlast():
|
||||
if request.method == 'GET':
|
||||
year_energy = float(request.args.get("year_energy"))
|
||||
date_now,date = get_start_enddate(prediction_hours,startdate=datetime.now().date())
|
||||
###############
|
||||
# Load Forecast
|
||||
###############
|
||||
lf = LoadForecast(filepath=r'load_profiles.npz', year_energy=year_energy)
|
||||
#leistung_haushalt = lf.get_daily_stats(date)[0,...] # Datum anpassen
|
||||
leistung_haushalt = lf.get_stats_for_date_range(date_now,date)[0] # Nur Erwartungswert!
|
||||
|
||||
gesamtlast = Gesamtlast(prediction_hours=prediction_hours)
|
||||
gesamtlast.hinzufuegen("Haushalt", leistung_haushalt)
|
||||
|
||||
# ###############
|
||||
# # WP
|
||||
# ##############
|
||||
# leistung_wp = wp.simulate_24h(temperature_forecast)
|
||||
# gesamtlast.hinzufuegen("Heatpump", leistung_wp)
|
||||
|
||||
last = gesamtlast.gesamtlast_berechnen()
|
||||
print(last)
|
||||
#print(specific_date_prices)
|
||||
return jsonify(last.tolist())
|
||||
|
||||
|
||||
@app.route('/optimize', methods=['POST'])
|
||||
def flask_optimize():
|
||||
if request.method == 'POST':
|
||||
parameter = request.json
|
||||
|
||||
# Erforderliche Parameter prüfen
|
||||
erforderliche_parameter = [ 'strompreis_euro_pro_wh','pv_akku_cap', 'year_energy',"einspeiseverguetung_euro_pro_wh", 'max_heizleistung', 'pv_forecast_url', 'eauto_min_soc', "eauto_cap","eauto_charge_efficiency","eauto_charge_power","eauto_soc","pv_soc","start_solution","pvpowernow","haushaltsgeraet_dauer","haushaltsgeraet_wh"]
|
||||
erforderliche_parameter = [ 'strompreis_euro_pro_wh', "gesamtlast",'pv_akku_cap', "einspeiseverguetung_euro_pro_wh", 'pv_forecast_url', 'eauto_min_soc', "eauto_cap","eauto_charge_efficiency","eauto_charge_power","eauto_soc","pv_soc","start_solution","pvpowernow","haushaltsgeraet_dauer","haushaltsgeraet_wh"]
|
||||
for p in erforderliche_parameter:
|
||||
if p not in parameter:
|
||||
return jsonify({"error": f"Fehlender Parameter: {p}"}), 400
|
||||
|
@ -51,7 +51,7 @@ class EnergieManagementSystem:
|
||||
eauto_soc_pro_stunde = []
|
||||
verluste_wh_pro_stunde = []
|
||||
haushaltsgeraet_wh_pro_stunde = []
|
||||
lastkurve_wh = self.gesamtlast.gesamtlast_berechnen()
|
||||
lastkurve_wh = self.gesamtlast
|
||||
|
||||
|
||||
assert len(lastkurve_wh) == len(self.pv_prognose_wh) == len(self.strompreis_euro_pro_wh), f"Arraygrößen stimmen nicht überein: Lastkurve = {len(lastkurve_wh)}, PV-Prognose = {len(self.pv_prognose_wh)}, Strompreis = {len(self.strompreis_euro_pro_wh)}"
|
||||
|
@ -4,6 +4,7 @@ from modules.class_load import *
|
||||
from modules.class_ems import *
|
||||
from modules.class_pv_forecast import *
|
||||
from modules.class_akku import *
|
||||
|
||||
from modules.class_heatpump import *
|
||||
from modules.class_load_container import *
|
||||
from modules.class_inverter import *
|
||||
@ -173,13 +174,9 @@ class optimization_problem:
|
||||
#print("Start_date:",date_now)
|
||||
|
||||
akku_size = parameter['pv_akku_cap'] # Wh
|
||||
year_energy = parameter['year_energy'] #2000*1000 #Wh
|
||||
|
||||
einspeiseverguetung_euro_pro_wh = np.full(self.prediction_hours, parameter["einspeiseverguetung_euro_pro_wh"]) #= # € / Wh 7/(1000.0*100.0)
|
||||
|
||||
max_heizleistung = parameter['max_heizleistung'] #1000 # 5 kW Heizleistung
|
||||
wp = Waermepumpe(max_heizleistung,self.prediction_hours)
|
||||
|
||||
pv_forecast_url = parameter['pv_forecast_url'] #"https://api.akkudoktor.net/forecast?lat=50.8588&lon=7.3747&power=5000&azimuth=-10&tilt=7&powerInvertor=10000&horizont=20,27,22,20&power=4800&azimuth=-90&tilt=7&powerInvertor=10000&horizont=30,30,30,50&power=1400&azimuth=-40&tilt=60&powerInvertor=2000&horizont=60,30,0,30&power=1600&azimuth=5&tilt=45&powerInvertor=1400&horizont=45,25,30,60&past_days=5&cellCoEff=-0.36&inverterEfficiency=0.8&albedo=0.25&timezone=Europe%2FBerlin&hourly=relativehumidity_2m%2Cwindspeed_10m"
|
||||
|
||||
akku = PVAkku(kapazitaet_wh=akku_size,hours=self.prediction_hours,start_soc_prozent=parameter["pv_soc"], max_ladeleistung_w=5000)
|
||||
@ -191,7 +188,6 @@ class optimization_problem:
|
||||
eauto.set_charge_per_hour(laden_moeglich)
|
||||
min_soc_eauto = parameter['eauto_min_soc']
|
||||
start_params = parameter['start_solution']
|
||||
gesamtlast = Gesamtlast(prediction_hours=self.prediction_hours)
|
||||
|
||||
###############
|
||||
# spuelmaschine
|
||||
@ -204,18 +200,12 @@ class optimization_problem:
|
||||
spuelmaschine = None
|
||||
|
||||
|
||||
###############
|
||||
# Load Forecast
|
||||
###############
|
||||
lf = LoadForecast(filepath=r'load_profiles.npz', year_energy=year_energy)
|
||||
#leistung_haushalt = lf.get_daily_stats(date)[0,...] # Datum anpassen
|
||||
|
||||
leistung_haushalt = lf.get_stats_for_date_range(date_now,date)[0] # Nur Erwartungswert!
|
||||
|
||||
|
||||
|
||||
|
||||
gesamtlast.hinzufuegen("Haushalt", leistung_haushalt)
|
||||
|
||||
|
||||
|
||||
###############
|
||||
# PV Forecast
|
||||
@ -240,15 +230,10 @@ class optimization_problem:
|
||||
print(specific_date_prices)
|
||||
#print("https://api.akkudoktor.net/prices?start="+date_now+"&end="+date)
|
||||
|
||||
###############
|
||||
# WP
|
||||
##############
|
||||
leistung_wp = wp.simulate_24h(temperature_forecast)
|
||||
gesamtlast.hinzufuegen("Heatpump", leistung_wp)
|
||||
|
||||
wr = Wechselrichter(5000, akku)
|
||||
|
||||
ems = EnergieManagementSystem(gesamtlast = gesamtlast, pv_prognose_wh=pv_forecast, strompreis_euro_pro_wh=specific_date_prices, einspeiseverguetung_euro_pro_wh=einspeiseverguetung_euro_pro_wh, eauto=eauto, haushaltsgeraet=spuelmaschine,wechselrichter=wr)
|
||||
ems = EnergieManagementSystem(gesamtlast = parameter["gesamtlast"], pv_prognose_wh=pv_forecast, strompreis_euro_pro_wh=specific_date_prices, einspeiseverguetung_euro_pro_wh=einspeiseverguetung_euro_pro_wh, eauto=eauto, haushaltsgeraet=spuelmaschine,wechselrichter=wr)
|
||||
o = ems.simuliere(start_hour)
|
||||
|
||||
###############
|
||||
@ -281,7 +266,7 @@ class optimization_problem:
|
||||
|
||||
print(parameter)
|
||||
print(best_solution)
|
||||
visualisiere_ergebnisse(gesamtlast, pv_forecast, specific_date_prices, o,best_solution[0::2],best_solution[1::2] , temperature_forecast, start_hour, self.prediction_hours,einspeiseverguetung_euro_pro_wh,extra_data=extra_data)
|
||||
visualisiere_ergebnisse(parameter["gesamtlast"], pv_forecast, specific_date_prices, o,best_solution[0::2],best_solution[1::2] , temperature_forecast, start_hour, self.prediction_hours,einspeiseverguetung_euro_pro_wh,extra_data=extra_data)
|
||||
os.system("cp visualisierungsergebnisse.pdf ~/")
|
||||
|
||||
# 'Eigenverbrauch_Wh_pro_Stunde': eigenverbrauch_wh_pro_stunde,
|
||||
|
@ -22,13 +22,13 @@ def visualisiere_ergebnisse(gesamtlast, pv_forecast, strompreise, ergebnisse, d
|
||||
plt.subplot(3, 3, 1)
|
||||
stunden = np.arange(0, prediction_hours)
|
||||
|
||||
|
||||
gesamtlast_array = np.array(gesamtlast)
|
||||
# Einzellasten plotten
|
||||
for name, last_array in gesamtlast.lasten.items():
|
||||
plt.plot(stunden, last_array, label=f'{name} (Wh)', marker='o')
|
||||
#for name, last_array in gesamtlast.lasten.items():
|
||||
plt.plot(stunden, gesamtlast_array, label=f'Last (Wh)', marker='o')
|
||||
|
||||
# Gesamtlast berechnen und plotten
|
||||
gesamtlast_array = gesamtlast.gesamtlast_berechnen()
|
||||
gesamtlast_array = np.array(gesamtlast)
|
||||
plt.plot(stunden, gesamtlast_array, label='Gesamtlast (Wh)', marker='o', linewidth=2, linestyle='--')
|
||||
plt.xlabel('Stunde')
|
||||
plt.ylabel('Last (Wh)')
|
||||
|
Loading…
x
Reference in New Issue
Block a user