flexmeasures.data.models.planning.soc_projection
Projection of off-tick point-like SoC constraints onto scheduling ticks.
Module Attributes
Functions
- flexmeasures.data.models.planning.soc_projection.project_off_tick_soc_at_start(soc_at_start_time: datetime, soc_at_start: Quantity | float, soc_maxima: list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, soc_minima: list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, schedule_start: datetime, consumption_capacity: Series, production_capacity: Series, resolution: timedelta, soc_min: Quantity | float | None, soc_max: Quantity | float | None, charging_efficiency: Series | Quantity | float | None = None, discharging_efficiency: Series | Quantity | float | None = None) tuple[list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, list[dict[str, datetime | float]] | Series | Sensor | Quantity | None]
Project an off-tick starting state of charge onto the next scheduling tick.
When the starting SoC is known at a time
tbetween the schedule start and the next scheduling tickn(e.g. because thestate-of-chargefield resolved to a measurement taken att), the SoC is assumed to hold from the schedule start untilt(the device is not moving its stock before then), and the SoC atnis bounded by how much the device can (dis)charge betweentandn:an upper bound of
soc_at_startplus the energy chargeable betweentandn,a lower bound of
soc_at_startminus the energy dischargeable betweentandn.
Both bounds are clamped to the global
soc-min/soc-maxand merged into the givensoc-maxima/soc-minima(the stricter bound wins on collisions). Known SoC times on a scheduling tick, or outside the first scheduling interval, leave the bounds unchanged.Returns
(soc_maxima, soc_minima).
- flexmeasures.data.models.planning.soc_projection.project_off_tick_soc_constraints(soc_targets: list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, soc_maxima: list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, soc_minima: list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, consumption_capacity: Series, production_capacity: Series, resolution: timedelta, soc_min: Quantity | float | None, soc_max: Quantity | float | None, charging_efficiency: Series | Quantity | float | None = None, discharging_efficiency: Series | Quantity | float | None = None) tuple[list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, list[dict[str, datetime | float]] | Series | Sensor | Quantity | None, list[dict[str, datetime | float]] | Series | Sensor | Quantity | None]
Project off-tick point-like SoC constraints onto scheduling ticks.
The scheduler can only enforce constraints at its fixed scheduling resolution. Point-like
soc-targets,soc-minimaandsoc-maximathat fall between two scheduling ticks are therefore replaced by constraints on the previous and next tick that preserve reachability using the available charge and discharge capacity between the original event time and those ticks (seeSOC_PROJECTION_POLICIES).For an off-tick event with value
vat timet, between previous tickpand next tickn:soc-targetsbecome an exact targetvonn, plus bounds onpthat keep the target reachable att: a lower bound ofvminus the energy that can still be charged betweenpandt, and an upper bound ofvplus the energy that can still be discharged betweenpandt.soc-minimabecome lower bounds on both surrounding ticks: onp,vminus the energy that can be charged betweenpandt; onn,vminus the energy that can be discharged betweentandn.soc-maximabecome upper bounds on both surrounding ticks: onp,vplus the energy that can be discharged betweenpandt; onn,vplus the energy that can be charged betweentandn.
The reachable energy accounts for the (dis)charging efficiencies: charging at grid power P moves the stock at rate P * charging_efficiency (which can exceed 1, e.g. a heat pump’s COP), and discharging at grid power P moves the stock at rate P / discharging_efficiency.
If multiple projected bounds land on the same tick, the stricter lower or upper bound is kept. Projected bounds are clamped to the global
soc-min/soc-max.Returns
(soc_targets, soc_maxima, soc_minima)with projected list-based timed events. Non-list specifications such as sensors, series, fixed quantities, orNoneare returned unchanged unless projected bounds need to be added to a missing list.
Classes
- class flexmeasures.data.models.planning.soc_projection.SocProjectionRule(bound_type: Literal['min', 'max'], tick: Literal['previous', 'next'])
One projected bound for an off-tick point-like SoC event.
A rule only needs to state which bound lands on which surrounding scheduling tick; everything else follows from preserving reachability:
The capacity period runs from the tick to the event time (
previous) or from the event time to the tick (next).A bound is loosened by the energy the device can move through that period towards satisfying the original event: lower bounds by charging up to it (on the previous tick) or by discharging away from it (on the next tick), and upper bounds vice versa.
Lower bounds are loosened downwards, upper bounds upwards.