simulate: more verbose validation

This commit is contained in:
Dominique Lasserre 2024-12-29 19:37:26 +01:00
parent 86d2173a4d
commit e8a47af04e

View File

@ -282,27 +282,36 @@ class EnergieManagementSystem(SingletonMixin, ConfigMixin, PredictionMixin, Pyda
last_wh_pro_stunde integral of last hour (end state) last_wh_pro_stunde integral of last hour (end state)
""" """
# Check for simulation integrity # Check for simulation integrity
if ( missing_data = []
self.load_energy_array is None
or self.pv_prediction_wh is None if self.load_energy_array is None:
or self.elect_price_hourly is None missing_data.append("Load Curve")
or self.ev_charge_hours is None if self.pv_prediction_wh is None:
or self.ac_charge_hours is None missing_data.append("PV Forecast")
or self.dc_charge_hours is None if self.elect_price_hourly is None:
or self.elect_revenue_per_hour_arr is None missing_data.append("Electricity Price")
): if self.ev_charge_hours is None:
error_msg = ( missing_data.append("EV Charge Hours")
f"Mandatory data missing - " if self.ac_charge_hours is None:
f"Load Curve: {self.load_energy_array}, " missing_data.append("AC Charge Hours")
f"PV Forecast: {self.pv_prediction_wh}, " if self.dc_charge_hours is None:
f"Electricity Price: {self.elect_price_hourly}, " missing_data.append("DC Charge Hours")
f"EV Charge Hours: {self.ev_charge_hours}, " if self.elect_revenue_per_hour_arr is None:
f"AC Charge Hours: {self.ac_charge_hours}, " missing_data.append("Feed-in Tariff")
f"DC Charge Hours: {self.dc_charge_hours}, "
f"Feed-in tariff: {self.elect_revenue_per_hour_arr}" if missing_data:
) error_msg = "Mandatory data missing - " + ", ".join(missing_data)
logger.error(error_msg) logger.error(error_msg)
raise ValueError(error_msg) raise ValueError(error_msg)
else:
# make mypy happy
assert self.load_energy_array is not None
assert self.pv_prediction_wh is not None
assert self.elect_price_hourly is not None
assert self.ev_charge_hours is not None
assert self.ac_charge_hours is not None
assert self.dc_charge_hours is not None
assert self.elect_revenue_per_hour_arr is not None
load_energy_array = self.load_energy_array load_energy_array = self.load_energy_array