-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
Description
In flexmeasures/data/models/planning/storage.py we 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. The convert_units method accepts a capacity argument with which the MWh values can be converted into % values. The capacity needs to be read from the flex-model for the given device, specifically, from the soc-max field.
- If the field contains a constant unit (e.g.
"60 kWh") than use that. - Note that the
soc-maxfield is aQuantityField, so it cannot contain a sensor reference (e.g.{"sensor": 50}) - If the field is missing or zero, the conversion cannot happen. However, do not crash the scheduler, just don't save the state-of-charge schedule.
- Add test coverage
- Update the
STATE_OF_CHARGEfield metadata documented inflexmeasures/data/schemas/scheduling/metadata.py - Run all precommit hooks before committing
- Make sure all tests pass
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)
}
Reactions are currently unavailable