soc_schedule = {
flex_model_d["state_of_charge"]: convert_units(
integrate_time_series(
series=ems_schedule[d],
initial_stock=soc_at_start[d],
stock_delta=device_constraints[d]["stock delta"]
* resolution
/ timedelta(hours=1),
up_efficiency=device_constraints[d]["derivative up efficiency"],
down_efficiency=device_constraints[d]["derivative down efficiency"],
storage_efficiency=device_constraints[d]["efficiency"]
.astype(float)
.fillna(1),
),
from_unit="MWh",
to_unit=flex_model_d["state_of_charge"].unit,
)
for d, flex_model_d in enumerate(flex_model)
if isinstance(flex_model_d.get("state_of_charge", None), Sensor)
}
In
flexmeasures/data/models/planning/storage.pywe have the below bit of code that converts the state-of-charge schedule to the unit of the sensor where the schedule needs to be recorded. Theconvert_unitsmethod accepts acapacityargument with which theMWhvalues can be converted into%values. The capacity needs to be read from the flex-model for the given device, specifically, from thesoc-maxfield."60 kWh") than use that.soc-maxfield is aQuantityField, so it cannot contain a sensor reference (e.g.{"sensor": 50})STATE_OF_CHARGEfield metadata documented inflexmeasures/data/schemas/scheduling/metadata.py