|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": null, |
| 5 | + "execution_count": 2, |
6 | 6 | "id": "59d49e29", |
7 | 7 | "metadata": {}, |
8 | | - "outputs": [], |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stdout", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "\n", |
| 14 | + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", |
| 15 | + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" |
| 16 | + ] |
| 17 | + } |
| 18 | + ], |
9 | 19 | "source": [ |
10 | 20 | "!pip install pandas power-grid-model-ds[visualizer] --quiet" |
11 | 21 | ] |
|
33 | 43 | }, |
34 | 44 | { |
35 | 45 | "cell_type": "code", |
36 | | - "execution_count": null, |
| 46 | + "execution_count": 3, |
37 | 47 | "id": "cf475775", |
38 | 48 | "metadata": {}, |
39 | 49 | "outputs": [], |
|
65 | 75 | }, |
66 | 76 | { |
67 | 77 | "cell_type": "code", |
68 | | - "execution_count": null, |
| 78 | + "execution_count": 4, |
69 | 79 | "id": "37f4bd29", |
70 | 80 | "metadata": {}, |
71 | 81 | "outputs": [], |
|
118 | 128 | }, |
119 | 129 | { |
120 | 130 | "cell_type": "code", |
121 | | - "execution_count": null, |
| 131 | + "execution_count": 5, |
122 | 132 | "id": "78d0639e", |
123 | 133 | "metadata": {}, |
124 | 134 | "outputs": [], |
|
157 | 167 | "execution_count": null, |
158 | 168 | "id": "206be67b", |
159 | 169 | "metadata": {}, |
160 | | - "outputs": [], |
| 170 | + "outputs": [ |
| 171 | + { |
| 172 | + "name": "stdout", |
| 173 | + "output_type": "stream", |
| 174 | + "text": [ |
| 175 | + "None\n" |
| 176 | + ] |
| 177 | + } |
| 178 | + ], |
161 | 179 | "source": [ |
162 | 180 | "# Check the grid for capacity issues\n", |
163 | 181 | "# 1. Use the PowerGridModelInterface to calculate power flow\n", |
|
212 | 230 | "metadata": {}, |
213 | 231 | "outputs": [], |
214 | 232 | "source": [ |
| 233 | + "# Check the introduction workshop on adding a substation\n", |
| 234 | + "\n", |
215 | 235 | "def build_new_substation(grid: Grid, location: tuple[float, float]) -> NodeArray:\n", |
216 | 236 | " \"\"\"Build a new substation at the given location.\n", |
217 | 237 | " Return the new substation.\n", |
|
243 | 263 | "metadata": {}, |
244 | 264 | "outputs": [], |
245 | 265 | "source": [ |
| 266 | + "# Hint: The lines have been extended with extra properties in Step 1\n", |
| 267 | + "# Hint: The arrays in the grid have a filter option, https://power-grid-model-ds.readthedocs.io/en/stable/examples/model/array_examples.html#using-filters\n", |
| 268 | + "\n", |
246 | 269 | "def get_all_congested_routes(grid: Grid) -> list[NodeArray]:\n", |
247 | 270 | " \"\"\"Get all routes that originate from a given substation node.\"\"\"\n", |
248 | 271 | "\n", |
249 | 272 | "# %load solutions/advanced_5_1_get_all_congested_routes.py" |
250 | 273 | ] |
251 | 274 | }, |
| 275 | + { |
| 276 | + "cell_type": "markdown", |
| 277 | + "id": "ee84e60c", |
| 278 | + "metadata": {}, |
| 279 | + "source": [ |
| 280 | + "Next we will use the nodes x and y coordinates to find a suitable node to connect to the new substation. You will create a find_connection_point function that return the Node in a route which is closest to the new_substation." |
| 281 | + ] |
| 282 | + }, |
252 | 283 | { |
253 | 284 | "cell_type": "code", |
254 | 285 | "execution_count": null, |
|
260 | 291 | " \"\"\"Calculate the connection point for the new route.\n", |
261 | 292 | " This should be the geographically closest node to the new substation.\n", |
262 | 293 | " \"\"\"\n", |
| 294 | + " # Calculate the distance of each node in the route to the new_substation\n", |
| 295 | + " # Return the closest one\n", |
263 | 296 | "\n", |
264 | 297 | "# %load solutions/advanced_5_2_find_connection_point.py" |
265 | 298 | ] |
266 | 299 | }, |
| 300 | + { |
| 301 | + "cell_type": "markdown", |
| 302 | + "id": "a75e9b73", |
| 303 | + "metadata": {}, |
| 304 | + "source": [ |
| 305 | + "Finally we build a function that creates a new line between the connection point and the new substation. We will first create it with an open connection and optimize the opening in the next step." |
| 306 | + ] |
| 307 | + }, |
267 | 308 | { |
268 | 309 | "cell_type": "code", |
269 | 310 | "execution_count": null, |
270 | 311 | "id": "263818f6", |
271 | 312 | "metadata": {}, |
272 | 313 | "outputs": [], |
273 | 314 | "source": [ |
| 315 | + "# Hint: in the introduction you learned how to add a LineArray to the grid\n", |
| 316 | + "\n", |
274 | 317 | "def connect_to_route(grid: Grid, connection_point: NodeArray, new_substation: NodeArray) -> None:\n", |
275 | 318 | " \"\"\"Connect the new substation node to the connection point.\n", |
276 | 319 | " \"\"\"\n", |
|
325 | 368 | "# %load solutions/advanced_6_optimize_route_transfer.py" |
326 | 369 | ] |
327 | 370 | }, |
| 371 | + { |
| 372 | + "cell_type": "markdown", |
| 373 | + "id": "dbf3243e", |
| 374 | + "metadata": {}, |
| 375 | + "source": [ |
| 376 | + "Now we combine the functions you created to solve the issues in the network" |
| 377 | + ] |
| 378 | + }, |
328 | 379 | { |
329 | 380 | "cell_type": "code", |
330 | 381 | "execution_count": null, |
|
361 | 412 | "transfer_routes(grid=grid, new_substation=new_substation)" |
362 | 413 | ] |
363 | 414 | }, |
| 415 | + { |
| 416 | + "cell_type": "markdown", |
| 417 | + "id": "82546c38", |
| 418 | + "metadata": {}, |
| 419 | + "source": [ |
| 420 | + "Check we resolved all contingencies" |
| 421 | + ] |
| 422 | + }, |
364 | 423 | { |
365 | 424 | "cell_type": "code", |
366 | 425 | "execution_count": null, |
|
0 commit comments