Skip to content

Commit f71976c

Browse files
committed
Improve power manager documentation for ShiftingMartyoshka algorithm
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent afd91e2 commit f71976c

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

src/frequenz/sdk/microgrid/__init__.py

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -201,35 +201,39 @@
201201
202202
*Example 1*: Battery bounds available for use: -100kW to 100kW
203203
204-
| Actor | Priority | System Bounds | Requested Bounds | Requested | Adjusted | Aggregate |
205-
| | | | | Power | Power | Power |
206-
|-------|----------|-----------------|------------------|-----------|--------------|-----------|
207-
| A | 3 | -100kW .. 100kW | None | 20kW | 20kW | 20kW |
208-
| B | 2 | -120kW .. 80kW | None | 50kW | 50kW | 70kW |
209-
| C | 1 | -170kW .. 30kW | None | 50kW | 30kW | 100kW |
210-
| | | | | | target power | 100kW |
211-
212-
Actor A proposes a power of `20kW`, but no bounds. In this case, actor B sees
213-
bounds shifted by A's proposal. Actor B proposes a power of `50kW` on this
214-
shifted range, and if this is applied on to the original bounds (aka shift the
215-
bounds back to the original range), it would be `20kW + 50kW = 70kW`.
216-
217-
So Actor C sees bounds shifted by `70kW` from the original bounds, and sets
218-
`50kW` on this shifted range, but it can't exceed `30kW`, so its request gets
219-
limited to 30kW. Shifting this back by `70kW`, the target power is calculated
220-
to be `100kW`.
204+
| Actor | Priority | Available Bounds | Requested Bounds | Requested Power | Adjusted Power | Aggregate Power |
205+
|------:|---------:|-----------------:|-----------------:|----------------:|---------------:|----------------:|
206+
| A | 3 | -100kW .. 100kW | None | 20kW | 20kW | 20kW |
207+
| B | 2 | -120kW .. 80kW | None | 50kW | 50kW | 70kW |
208+
| C | 1 | -170kW .. 30kW | None | 50kW | 30kW | 100kW |
209+
| | | | | | target power | 100kW |
210+
211+
1. Actor A sees the full system: Available Bounds = `-100kW .. 100kW`. It
212+
proposes a power of `20kW`, but no bounds.
213+
214+
2. This becomes the operating point for actor B, so actor B sees bounds shifted
215+
by A's proposal = `-120kW .. 80kW`. It can operate only in this range.
216+
217+
3. Actor B proposes a power of `50kW` on this shifted range, and if this is
218+
applied on to the original bounds (aka shift the bounds back to the original
219+
range), it would be `20kW + 50kW = 70kW`.
220+
221+
4. So Actor C sees bounds shifted by `70kW` from the original bounds, and sets
222+
`50kW` on this shifted range, but it can't exceed `30kW`, so its request gets
223+
limited to 30kW.
224+
225+
5. Shifting this back by `70kW`, the target power is calculated to be `100kW`.
221226
222227
Irrespective of what any actor sets, the final power won't exceed the available
223228
battery bounds.
224229
225230
*Example 2*:
226231
227-
| Actor | Priority | System Bounds | Requested Bounds | Requested | Adjusted | Aggregate |
228-
| | | | | Power | Power | Power |
229-
|-------|----------|-----------------|------------------|-----------|--------------|-----------|
230-
| A | 3 | -100kW .. 100kW | None | 20kW | 20kW | 20kW |
231-
| B | 2 | -120kW .. 80kW | None | -20kW | -20kW | 0kW |
232-
| | | | | | target power | 0kW |
232+
| Actor | Priority | Available Bounds | Requested Bounds | Requested Power | Adjusted Power | Aggregate Power |
233+
|------:|---------:|-----------------:|-----------------:|----------------:|---------------:|----------------:|
234+
| A | 3 | -100kW .. 100kW | None | 20kW | 20kW | 20kW |
235+
| B | 2 | -120kW .. 80kW | None | -20kW | -20kW | 0kW |
236+
| | | | | | target power | 0kW |
233237
234238
Actors with exactly opposite requests cancel each other out.
235239
@@ -241,39 +245,39 @@
241245
242246
*Example 1*: Battery bounds available for use: -100kW to 100kW
243247
244-
| Actor | Priority | System Bounds | Requested Bounds | Requested | Adjusted | Aggregate |
245-
| | | | | Power | Power | Power |
246-
|-------|----------|-----------------|------------------|-----------|--------------|-----------|
247-
| A | 3 | -100kW .. 100kW | -20kW .. 100kW | 50kW | 40kW | 50kW |
248-
| B | 2 | -70kW .. 50kW | -90kW .. 0kW | -10kW | -10kW | 40kW |
249-
| C | 1 | -60kW .. 10kW | None | -20kW | -20kW | 20kW |
250-
| | | | | | target power | 20kW |
248+
| Actor | Priority | Available Bounds | Requested Bounds | Requested Power | Adjusted Power | Aggregate Power |
249+
|------:|---------:|-----------------:|-----------------:|----------------:|---------------:|----------------:|
250+
| A | 3 | -100kW .. 100kW | -20kW .. 100kW | 50kW | 50kW | 50kW |
251+
| B | 2 | -70kW .. 50kW | -90kW .. 0kW | -10kW | -10kW | 40kW |
252+
| C | 1 | -60kW .. 10kW | None | -20kW | -20kW | 20kW |
253+
| | | | | | target power | 20kW |
251254
252-
Actor A with the highest priority has the entire battery bounds available to it.
253-
It sets limited bounds of -20kW .. 100kW, and proposes a power of 50kW.
255+
1. Actor A with the highest priority has the entire battery bounds available to
256+
it. It sets limited bounds of `-20kW .. 100kW`, and proposes a power of
257+
`50kW`.
254258
255-
Actor B sees Actor A's limit of -20kW..100kW shifted by 50kW as -70kW..50kW, and
256-
can only propose powers within this range, which will get added (shifted back)
257-
to Actor A's proposed power.
259+
2. Actor B's operating point is now `50kW`. So, Actor B sees Actor A's limit of
260+
`-20kW..100kW` shifted by `50kW` as `-70kW..50kW`, and can only operate
261+
within this range.
258262
259-
Actor B tries to limit the bounds of actor C to -90kW .. 0kW, but it can only
260-
operate in the -70kW .. 50kW range because of bounds set by actor A, so its
261-
requested bounds get restricted to -70kW .. 0kW.
263+
3. Actor B tries to limit the bounds of actor C to `-90kW .. 0kW`, but it
264+
doesn't have access to that full range and can only operate in the
265+
`-70kW .. 50kW` range, so its specified bounds get restricted to
266+
`-70kW .. 0kW`.
262267
263-
Actor C sees this as -60kW .. 10kW, because it gets shifted by Actor B's
264-
proposed power of -10kW.
268+
4. Actor C sees this as `-60kW .. 10kW`, because it gets shifted by Actor B's
269+
proposed power of `-10kW`.
265270
266-
Actor C proposes a power within its bounds and the proposals of all the actors
267-
are added to get the target power.
271+
5. Actor C proposes a power within its bounds and the proposals of all the actors
272+
are added to get the target power.
268273
269274
*Example 2*:
270275
271-
| Actor | Priority | System Bounds | Requested Bounds | Requested | Adjusted | Aggregate |
272-
| | | | | Power | Power | Power |
273-
|-------|----------|-----------------|------------------|-----------|--------------|-----------|
274-
| A | 3 | -100kW .. 100kW | -20kW .. 100kW | 50kW | 50kW | 50kW |
275-
| B | 2 | -70kW .. 50kW | -90kW .. 0kW | -90kW | -70kW | -20kW |
276-
| | | | | | target power | -20kW |
276+
| Actor | Priority | Available Bounds | Requested Bounds | Requested Power | Adjusted Power | Aggregate Power |
277+
|------:|---------:|-----------------:|-----------------:|----------------:|---------------:|----------------:|
278+
| A | 3 | -100kW .. 100kW | -20kW .. 100kW | 50kW | 50kW | 50kW |
279+
| B | 2 | -70kW .. 50kW | -90kW .. 0kW | -90kW | -70kW | -20kW |
280+
| | | | | | target power | -20kW |
277281
278282
When an actor requests a power that's outside its available bounds, the closest
279283
available power is used.
@@ -282,19 +286,18 @@
282286
283287
Battery bounds available for use: -100kW to 100kW
284288
285-
| Priority | System Bounds | Requested Bounds | Requested | Adjusted | Aggregate |
286-
| | | | Power | Power | Power |
287-
|----------|-------------------|------------------|-----------|--------------|-----------|
288-
| 7 | -100 kW .. 100 kW | None | 10 kW | 10 kW | 10 kW |
289-
| 6 | -110 kW .. 90 kW | -110 kW .. 80 kW | 10 kW | 10 kW | 20 kW |
290-
| 5 | -120 kW .. 70 kW | -100 kW .. 80 kW | 80 kW | 70 kW | 90 kW |
291-
| 4 | -170 kW .. 0 kW | None | -120 kW | -120 kW | -30 kW |
292-
| 3 | -50 kW .. 120 kW | None | 60 kW | 60 kW | 30 kW |
293-
| 2 | -110 kW .. 60 kW | -40 kW .. 30 kW | 20 kW | 20 kW | 50 kW |
294-
| 1 | -60 kW .. 10 kW | -50 kW .. 40 kW | 25 kW | 10 kW | 60 kW |
295-
| 0 | -60 kW .. 0 kW | None | 12 kW | 0 kW | 60 kW |
296-
| -1 | -60 kW .. 0 kW | -40 kW .. -10 kW | -10 kW | -10 kW | 50 kW |
297-
| | | | | Target Power | 50 kW |
289+
| Priority | Available Bounds | Requested Bounds | Requested Power | Adjusted Power | Aggregate Power |
290+
|---------:|------------------:|-----------------:|----------------:|---------------:|----------------:|
291+
| 7 | -100 kW .. 100 kW | None | 10 kW | 10 kW | 10 kW |
292+
| 6 | -110 kW .. 90 kW | -110 kW .. 80 kW | 10 kW | 10 kW | 20 kW |
293+
| 5 | -120 kW .. 70 kW | -100 kW .. 80 kW | 80 kW | 70 kW | 90 kW |
294+
| 4 | -170 kW .. 0 kW | None | -120 kW | -120 kW | -30 kW |
295+
| 3 | -50 kW .. 120 kW | None | 60 kW | 60 kW | 30 kW |
296+
| 2 | -110 kW .. 60 kW | -40 kW .. 30 kW | 20 kW | 20 kW | 50 kW |
297+
| 1 | -60 kW .. 10 kW | -50 kW .. 40 kW | 25 kW | 10 kW | 60 kW |
298+
| 0 | -60 kW .. 0 kW | None | 12 kW | 0 kW | 60 kW |
299+
| -1 | -60 kW .. 0 kW | -40 kW .. -10 kW | -10 kW | -10 kW | 50 kW |
300+
| | | | | Target Power | 50 kW |
298301
299302
## Withdrawing power proposals
300303
@@ -311,7 +314,7 @@
311314
| Batteries | Zero |
312315
| PV | Max production (Min power according to PSC) |
313316
| EV Chargers | Max consumption (Max power according to PSC) |
314-
""" # noqa: D205, D400
317+
""" # noqa: D205, D400, E501
315318

316319
from datetime import timedelta
317320

0 commit comments

Comments
 (0)