|
40 | 40 | "import numpy as np\n", |
41 | 41 | "import warnings\n", |
42 | 42 | "\n", |
43 | | - "with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n", |
| 43 | + "with warnings.catch_warnings():\n", |
| 44 | + " warnings.simplefilter(\"ignore\", category=DeprecationWarning)\n", |
44 | 45 | " # suppress warning about pyarrow as future required dependency\n", |
45 | 46 | " import pandas as pd\n", |
46 | 47 | "\n", |
|
891 | 892 | }, |
892 | 893 | { |
893 | 894 | "cell_type": "markdown", |
894 | | - "id": "7828a4e3", |
| 895 | + "id": "9f1a6f30", |
895 | 896 | "metadata": {}, |
896 | 897 | "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." |
898 | 899 | ] |
899 | 900 | }, |
900 | 901 | { |
901 | 902 | "cell_type": "code", |
902 | 903 | "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, |
903 | 1049 | "id": "be276930", |
904 | 1050 | "metadata": {}, |
905 | 1051 | "outputs": [ |
|
1094 | 1240 | "\n", |
1095 | 1241 | "# power flow batch calculation with automatic tap changing\n", |
1096 | 1242 | "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", |
1098 | 1244 | ")\n", |
1099 | 1245 | "\n", |
1100 | 1246 | "print(\"------node_4 batch result------\")\n", |
|
1116 | 1262 | }, |
1117 | 1263 | { |
1118 | 1264 | "cell_type": "code", |
1119 | | - "execution_count": 13, |
| 1265 | + "execution_count": 14, |
1120 | 1266 | "id": "21b01a77", |
1121 | 1267 | "metadata": {}, |
1122 | 1268 | "outputs": [ |
|
1259 | 1405 | }, |
1260 | 1406 | { |
1261 | 1407 | "cell_type": "code", |
1262 | | - "execution_count": 14, |
| 1408 | + "execution_count": 15, |
1263 | 1409 | "id": "c0314199", |
1264 | 1410 | "metadata": {}, |
1265 | 1411 | "outputs": [ |
|
1412 | 1558 | }, |
1413 | 1559 | { |
1414 | 1560 | "cell_type": "code", |
1415 | | - "execution_count": 15, |
| 1561 | + "execution_count": 16, |
1416 | 1562 | "id": "ac091392", |
1417 | 1563 | "metadata": {}, |
1418 | 1564 | "outputs": [], |
|
1437 | 1583 | }, |
1438 | 1584 | { |
1439 | 1585 | "cell_type": "code", |
1440 | | - "execution_count": 16, |
| 1586 | + "execution_count": 17, |
1441 | 1587 | "id": "9b66d16e", |
1442 | 1588 | "metadata": {}, |
1443 | 1589 | "outputs": [ |
|
1585 | 1731 | "name": "python", |
1586 | 1732 | "nbconvert_exporter": "python", |
1587 | 1733 | "pygments_lexer": "ipython3", |
1588 | | - "version": "3.12.2" |
| 1734 | + "version": "3.10.14" |
1589 | 1735 | }, |
1590 | 1736 | "vscode": { |
1591 | 1737 | "interpreter": { |
|
0 commit comments