Skip to content

Commit 06e8374

Browse files
committed
Update the examples
Signed-off-by: GitHub Actions Bot <[email protected]>
1 parent 1c1ed7c commit 06e8374

File tree

1 file changed

+155
-9
lines changed

1 file changed

+155
-9
lines changed

examples/Transformer Examples.ipynb

Lines changed: 155 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"import numpy as np\n",
4141
"import warnings\n",
4242
"\n",
43-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
43+
"with warnings.catch_warnings():\n",
44+
" warnings.simplefilter(\"ignore\", category=DeprecationWarning)\n",
4445
" # suppress warning about pyarrow as future required dependency\n",
4546
" import pandas as pd\n",
4647
"\n",
@@ -891,15 +892,160 @@
891892
},
892893
{
893894
"cell_type": "markdown",
894-
"id": "7828a4e3",
895+
"id": "9f1a6f30",
895896
"metadata": {},
896897
"source": [
897-
"**NOTE:** the tap positions obtained using the `any_valid_tap` strategy may depend on the initial tap position of the transformers."
898+
"You could also opt for fast_any_tap that takes advantage of binary search instead of linear search internally."
898899
]
899900
},
900901
{
901902
"cell_type": "code",
902903
"execution_count": 12,
904+
"id": "1fa08adb",
905+
"metadata": {},
906+
"outputs": [
907+
{
908+
"name": "stdout",
909+
"output_type": "stream",
910+
"text": [
911+
"------node result------\n"
912+
]
913+
},
914+
{
915+
"data": {
916+
"text/html": [
917+
"<div>\n",
918+
"<style scoped>\n",
919+
" .dataframe tbody tr th:only-of-type {\n",
920+
" vertical-align: middle;\n",
921+
" }\n",
922+
"\n",
923+
" .dataframe tbody tr th {\n",
924+
" vertical-align: top;\n",
925+
" }\n",
926+
"\n",
927+
" .dataframe thead th {\n",
928+
" text-align: right;\n",
929+
" }\n",
930+
"</style>\n",
931+
"<table border=\"1\" class=\"dataframe\">\n",
932+
" <thead>\n",
933+
" <tr style=\"text-align: right;\">\n",
934+
" <th></th>\n",
935+
" <th>id</th>\n",
936+
" <th>u</th>\n",
937+
" </tr>\n",
938+
" </thead>\n",
939+
" <tbody>\n",
940+
" <tr>\n",
941+
" <th>0</th>\n",
942+
" <td>2</td>\n",
943+
" <td>9999.994675</td>\n",
944+
" </tr>\n",
945+
" <tr>\n",
946+
" <th>1</th>\n",
947+
" <td>4</td>\n",
948+
" <td>401.932237</td>\n",
949+
" </tr>\n",
950+
" <tr>\n",
951+
" <th>2</th>\n",
952+
" <td>6</td>\n",
953+
" <td>346.203709</td>\n",
954+
" </tr>\n",
955+
" </tbody>\n",
956+
"</table>\n",
957+
"</div>"
958+
],
959+
"text/plain": [
960+
" id u\n",
961+
"0 2 9999.994675\n",
962+
"1 4 401.932237\n",
963+
"2 6 346.203709"
964+
]
965+
},
966+
"metadata": {},
967+
"output_type": "display_data"
968+
},
969+
{
970+
"name": "stdout",
971+
"output_type": "stream",
972+
"text": [
973+
"\n",
974+
"------tap regulator result------\n",
975+
"\n",
976+
"----------fast_any_tap----------\n"
977+
]
978+
},
979+
{
980+
"data": {
981+
"text/html": [
982+
"<div>\n",
983+
"<style scoped>\n",
984+
" .dataframe tbody tr th:only-of-type {\n",
985+
" vertical-align: middle;\n",
986+
" }\n",
987+
"\n",
988+
" .dataframe tbody tr th {\n",
989+
" vertical-align: top;\n",
990+
" }\n",
991+
"\n",
992+
" .dataframe thead th {\n",
993+
" text-align: right;\n",
994+
" }\n",
995+
"</style>\n",
996+
"<table border=\"1\" class=\"dataframe\">\n",
997+
" <thead>\n",
998+
" <tr style=\"text-align: right;\">\n",
999+
" <th></th>\n",
1000+
" <th>id</th>\n",
1001+
" <th>energized</th>\n",
1002+
" <th>tap_pos</th>\n",
1003+
" </tr>\n",
1004+
" </thead>\n",
1005+
" <tbody>\n",
1006+
" <tr>\n",
1007+
" <th>0</th>\n",
1008+
" <td>8</td>\n",
1009+
" <td>1</td>\n",
1010+
" <td>-1</td>\n",
1011+
" </tr>\n",
1012+
" </tbody>\n",
1013+
"</table>\n",
1014+
"</div>"
1015+
],
1016+
"text/plain": [
1017+
" id energized tap_pos\n",
1018+
"0 8 1 -1"
1019+
]
1020+
},
1021+
"metadata": {},
1022+
"output_type": "display_data"
1023+
}
1024+
],
1025+
"source": [
1026+
"# one-time power flow calculation with automatic tap changing\n",
1027+
"output_data6f = model5.calculate_power_flow(tap_changing_strategy=TapChangingStrategy.fast_any_tap)\n",
1028+
"\n",
1029+
"# the node at the control side of the transformer now has a voltage within the specified voltage band\n",
1030+
"print(\"------node result------\")\n",
1031+
"display(pd.DataFrame(output_data6f[ComponentType.node])[[\"id\", \"u\"]])\n",
1032+
"\n",
1033+
"print(\"\\n------tap regulator result------\")\n",
1034+
"print(\"\\n----------fast_any_tap----------\")\n",
1035+
"display(pd.DataFrame(output_data6f[ComponentType.transformer_tap_regulator]))"
1036+
]
1037+
},
1038+
{
1039+
"cell_type": "markdown",
1040+
"id": "7828a4e3",
1041+
"metadata": {},
1042+
"source": [
1043+
"**NOTE:** the tap positions obtained using the `any_valid_tap` and `fast_any_tap` strategy may depend on the initial tap position of the transformers."
1044+
]
1045+
},
1046+
{
1047+
"cell_type": "code",
1048+
"execution_count": 13,
9031049
"id": "be276930",
9041050
"metadata": {},
9051051
"outputs": [
@@ -1094,7 +1240,7 @@
10941240
"\n",
10951241
"# power flow batch calculation with automatic tap changing\n",
10961242
"output_data = model5.calculate_power_flow(\n",
1097-
" update_data=update_data, tap_changing_strategy=TapChangingStrategy.any_valid_tap\n",
1243+
" update_data=update_data, tap_changing_strategy=TapChangingStrategy.fast_any_tap\n",
10981244
")\n",
10991245
"\n",
11001246
"print(\"------node_4 batch result------\")\n",
@@ -1116,7 +1262,7 @@
11161262
},
11171263
{
11181264
"cell_type": "code",
1119-
"execution_count": 13,
1265+
"execution_count": 14,
11201266
"id": "21b01a77",
11211267
"metadata": {},
11221268
"outputs": [
@@ -1259,7 +1405,7 @@
12591405
},
12601406
{
12611407
"cell_type": "code",
1262-
"execution_count": 14,
1408+
"execution_count": 15,
12631409
"id": "c0314199",
12641410
"metadata": {},
12651411
"outputs": [
@@ -1412,7 +1558,7 @@
14121558
},
14131559
{
14141560
"cell_type": "code",
1415-
"execution_count": 15,
1561+
"execution_count": 16,
14161562
"id": "ac091392",
14171563
"metadata": {},
14181564
"outputs": [],
@@ -1437,7 +1583,7 @@
14371583
},
14381584
{
14391585
"cell_type": "code",
1440-
"execution_count": 16,
1586+
"execution_count": 17,
14411587
"id": "9b66d16e",
14421588
"metadata": {},
14431589
"outputs": [
@@ -1585,7 +1731,7 @@
15851731
"name": "python",
15861732
"nbconvert_exporter": "python",
15871733
"pygments_lexer": "ipython3",
1588-
"version": "3.12.2"
1734+
"version": "3.10.14"
15891735
},
15901736
"vscode": {
15911737
"interpreter": {

0 commit comments

Comments
 (0)