diff --git a/matpowercaseframes/constants.py b/matpowercaseframes/constants.py
index e7f6dfa..7fe3012 100644
--- a/matpowercaseframes/constants.py
+++ b/matpowercaseframes/constants.py
@@ -117,8 +117,8 @@
"map": ["IFNUM", "BRANCHIDX"],
"lims": ["IFNUM", "LOWER", "UPPER"],
},
- "gencost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST", "COST"],
- "dclinecost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST", "COST"],
+ "gencost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST"],
+ "dclinecost": ["MODEL", "STARTUP", "SHUTDOWN", "NCOST"],
"bus_name": ["BUS_NAME"],
"branch_name": ["BRANCH_NAME"],
"gen_name": ["GEN_NAME"],
diff --git a/matpowercaseframes/core.py b/matpowercaseframes/core.py
index c4f7ddf..c75569b 100644
--- a/matpowercaseframes/core.py
+++ b/matpowercaseframes/core.py
@@ -4,6 +4,7 @@
import copy
import os
+import warnings
import numpy as np
import pandas as pd
@@ -209,9 +210,8 @@ def _get_path(path):
if os.path.isfile(path_added_matpower_m):
return path_added_matpower_m
- # Create detailed error message
- error_msg = f"Could not find file or directory '{path}'."
- raise FileNotFoundError(error_msg)
+ message = f"Can't find data at {os.path.abspath(path)}"
+ raise FileNotFoundError(message)
def _read_matpower(self, filepath, allow_any_keys=False):
"""
@@ -433,6 +433,8 @@ def _get_dataframe(self, attribute, data, n_cols=None, columns_template=None):
)
columns = columns_template[:n_cols]
+
+ # special case for gencost and dclinecost
if n_cols > len(columns):
if attribute not in ("gencost", "dclinecost"):
msg = (
@@ -440,10 +442,31 @@ def _get_dataframe(self, attribute, data, n_cols=None, columns_template=None):
f" than the expected number."
)
raise IndexError(msg)
- columns = columns[:-1] + [
- "{}_{}".format(columns[-1], i)
- for i in range(n_cols - len(columns), -1, -1)
- ]
+ NCOST = n_cols - len(columns)
+ # Warning if mixed models exist
+ gencost_models = data[:, 0]
+ first_row_model = int(gencost_models[0]) # TODO: support mixed models
+ unique_models = np.unique(gencost_models).astype(int)
+
+ if len(unique_models) > 1:
+ warnings.warn(
+ f"Mixed cost models detected in {attribute}: "
+ f"{unique_models.tolist()}. "
+ f"Using model type {first_row_model} from first row. "
+ "Mixed models are not fully supported.",
+ UserWarning,
+ stacklevel=2,
+ )
+
+ if first_row_model == 1: # PW_LINEAR
+ ncost_cols = [
+ f"{prefix}{i}"
+ for i in range(1, (NCOST // 2) + 1)
+ for prefix in ("X", "Y")
+ ]
+ columns = columns + ncost_cols
+ else: # POLYNOMIAL
+ columns = columns + [f"C{i}" for i in range(NCOST - 1, -1, -1)]
return pd.DataFrame(data, columns=columns)
diff --git a/matpowercaseframes/utils.py b/matpowercaseframes/utils.py
index e7761fd..ddff57b 100644
--- a/matpowercaseframes/utils.py
+++ b/matpowercaseframes/utils.py
@@ -1,7 +1,11 @@
def int_else_float_except_string(s):
try:
f = float(s.replace(",", "."))
- i = int(f)
- return i if i == f else f
+ if f.is_integer():
+ try:
+ return int(f)
+ except (OverflowError, ValueError):
+ return f
+ return f
except ValueError:
return s
diff --git a/notebooks/compare_load.ipynb b/notebooks/compare_load.ipynb
index 5d38f39..ee12a74 100644
--- a/notebooks/compare_load.ipynb
+++ b/notebooks/compare_load.ipynb
@@ -418,7 +418,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.4"
+ "version": "3.14.2"
}
},
"nbformat": 4,
diff --git a/notebooks/load_case_RTS_GMLC.ipynb b/notebooks/load_case_RTS_GMLC.ipynb
new file mode 100644
index 0000000..61c3648
--- /dev/null
+++ b/notebooks/load_case_RTS_GMLC.ipynb
@@ -0,0 +1,766 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "91c6ca79",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%load_ext autoreload\n",
+ "%autoreload 2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "7b85f966",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import warnings\n",
+ "\n",
+ "from matpower import start_instance\n",
+ "\n",
+ "from matpowercaseframes import CaseFrames"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "42a980d8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "m = start_instance()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "ebf38c59",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "CASE_NAME = \"case_RTS_GMLC.m\"\n",
+ "# NOTE: \"case_RTS_GMLC.m\" currently error without load_case_engine\n",
+ "cf_RTS_GMLC = CaseFrames(CASE_NAME)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "e3b7a6da",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " MODEL | \n",
+ " STARTUP | \n",
+ " SHUTDOWN | \n",
+ " NCOST | \n",
+ " X1 | \n",
+ " Y1 | \n",
+ " X2 | \n",
+ " Y2 | \n",
+ " X3 | \n",
+ " Y3 | \n",
+ " X4 | \n",
+ " Y4 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " 1 | \n",
+ " 51.7470 | \n",
+ " 51.7470 | \n",
+ " 4 | \n",
+ " 8 | \n",
+ " 1085.77625 | \n",
+ " 12.00000 | \n",
+ " 1477.23196 | \n",
+ " 16.00000 | \n",
+ " 1869.51562 | \n",
+ " 20.0 | \n",
+ " 2298.06357 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 1 | \n",
+ " 51.7470 | \n",
+ " 51.7470 | \n",
+ " 4 | \n",
+ " 8 | \n",
+ " 1085.77625 | \n",
+ " 12.00000 | \n",
+ " 1477.23196 | \n",
+ " 16.00000 | \n",
+ " 1869.51562 | \n",
+ " 20.0 | \n",
+ " 2298.06357 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1 | \n",
+ " 11172.0143 | \n",
+ " 11172.0143 | \n",
+ " 4 | \n",
+ " 30 | \n",
+ " 841.57942 | \n",
+ " 45.33333 | \n",
+ " 1059.17805 | \n",
+ " 60.66667 | \n",
+ " 1319.40176 | \n",
+ " 76.0 | \n",
+ " 1596.51343 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1 | \n",
+ " 11172.0143 | \n",
+ " 11172.0143 | \n",
+ " 4 | \n",
+ " 30 | \n",
+ " 841.57942 | \n",
+ " 45.33333 | \n",
+ " 1059.17805 | \n",
+ " 60.66667 | \n",
+ " 1319.40176 | \n",
+ " 76.0 | \n",
+ " 1596.51343 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 1 | \n",
+ " 51.7470 | \n",
+ " 51.7470 | \n",
+ " 4 | \n",
+ " 8 | \n",
+ " 1212.03893 | \n",
+ " 12.00000 | \n",
+ " 1567.93410 | \n",
+ " 16.00000 | \n",
+ " 1946.59795 | \n",
+ " 20.0 | \n",
+ " 2344.92565 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " MODEL STARTUP SHUTDOWN NCOST X1 Y1 X2 Y2 \\\n",
+ "1 1 51.7470 51.7470 4 8 1085.77625 12.00000 1477.23196 \n",
+ "2 1 51.7470 51.7470 4 8 1085.77625 12.00000 1477.23196 \n",
+ "3 1 11172.0143 11172.0143 4 30 841.57942 45.33333 1059.17805 \n",
+ "4 1 11172.0143 11172.0143 4 30 841.57942 45.33333 1059.17805 \n",
+ "5 1 51.7470 51.7470 4 8 1212.03893 12.00000 1567.93410 \n",
+ "\n",
+ " X3 Y3 X4 Y4 \n",
+ "1 16.00000 1869.51562 20.0 2298.06357 \n",
+ "2 16.00000 1869.51562 20.0 2298.06357 \n",
+ "3 60.66667 1319.40176 76.0 1596.51343 \n",
+ "4 60.66667 1319.40176 76.0 1596.51343 \n",
+ "5 16.00000 1946.59795 20.0 2344.92565 "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "CASE_NAME = \"case_RTS_GMLC.m\"\n",
+ "# NOTE: \"case_RTS_GMLC.m\" currently error without load_case_engine\n",
+ "cf_RTS_GMLC = CaseFrames(CASE_NAME, load_case_engine=m)\n",
+ "with warnings.catch_warnings():\n",
+ " warnings.filterwarnings(\n",
+ " \"ignore\", category=RuntimeWarning, message=\".*invalid value.*\"\n",
+ " )\n",
+ " cf_RTS_GMLC.infer_numpy()\n",
+ "cf_RTS_GMLC.gencost.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "7281da34",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 8.1, 12-Jul-2025\n",
+ "Power Flow -- AC-polar-power formulation\n",
+ "\n",
+ "Newton's method converged in 4 iterations.\n",
+ "PF successful\n",
+ "\n",
+ "Converged in 0.10 seconds\n",
+ "================================================================================\n",
+ "| System Summary |\n",
+ "================================================================================\n",
+ "\n",
+ "How many? How much? P (MW) Q (MVAr)\n",
+ "--------------------- ------------------- ------------- -----------------\n",
+ "Buses 73 Total Gen Capacity 14549.8 -1615.0 to 4406.0\n",
+ "Generators 158 On-line Capacity 9076.0 -1615.0 to 4406.0\n",
+ "Committed Gens 96 Generation (actual) 8704.0 1718.7\n",
+ "Loads 51 Load 8550.0 1740.0\n",
+ " Fixed 51 Fixed 8550.0 1740.0\n",
+ " Dispatchable 0 Dispatchable -0.0 of -0.0 -0.0\n",
+ "Shunts 3 Shunt (inj) -0.0 -316.1\n",
+ "Branches 120 Losses (I^2 * Z) 153.97 1442.60\n",
+ "Transformers 16 Branch Charging (inj) - 1780.0\n",
+ "Inter-ties 5 Total Inter-tie Flow 331.2 25.0\n",
+ "Areas 3\n",
+ "\n",
+ " Minimum Maximum\n",
+ " ------------------------- --------------------------------\n",
+ "Voltage Magnitude 0.951 p.u. @ bus 308 1.050 p.u. @ bus 121\n",
+ "Voltage Angle -30.66 deg @ bus 307 16.52 deg @ bus 122\n",
+ "P Losses (I^2*R) - 9.42 MW @ line 312-323\n",
+ "Q Losses (I^2*X) - 76.11 MVAr @ line 312-323\n",
+ "\n",
+ "================================================================================\n",
+ "| Bus Data |\n",
+ "================================================================================\n",
+ " Bus Voltage Generation Load\n",
+ " # Mag(pu) Ang(deg) P (MW) Q (MVAr) P (MW) Q (MVAr)\n",
+ "----- ------- -------- -------- -------- -------- --------\n",
+ " 101 1.047 -8.575 168.00 10.68 108.00 22.00\n",
+ " 102 1.047 -8.634 168.00 4.66 97.00 20.00\n",
+ " 103 1.011 -7.980 - - 180.00 37.00\n",
+ " 104 1.017 -10.745 - - 74.00 15.00\n",
+ " 105 1.035 -10.928 - - 71.00 14.00\n",
+ " 106 1.032 -13.157 - - 136.00 28.00\n",
+ " 107 1.050 -3.989 355.00 49.51 125.00 25.00\n",
+ " 108 1.017 -9.342 - - 171.00 35.00\n",
+ " 109 1.027 -8.460 - - 175.00 36.00\n",
+ " 110 1.050 -10.203 - - 195.00 40.00\n",
+ " 111 1.027 -4.083 - - - -\n",
+ " 112 1.020 -2.396 - - - -\n",
+ " 113 1.035 0.000* 220.00 76.07 265.00 54.00\n",
+ " 114 1.044 -2.552 0.00 103.20 194.00 39.00\n",
+ " 115 1.043 5.977 165.00 92.20 317.00 64.00\n",
+ " 116 1.046 5.824 155.00 79.87 100.00 20.00\n",
+ " 117 1.048 9.138 - - - -\n",
+ " 118 1.050 9.952 355.00 68.45 333.00 68.00\n",
+ " 119 1.040 5.368 - - 181.00 37.00\n",
+ " 120 1.044 6.847 - - 128.00 26.00\n",
+ " 121 1.050 10.564 400.00 -21.93 - -\n",
+ " 122 1.050 16.516 300.00 -40.76 - -\n",
+ " 123 1.050 8.378 670.00 25.07 - -\n",
+ " 124 1.013 0.844 - - - -\n",
+ " 201 1.050 -12.611 142.00 21.73 108.00 22.00\n",
+ " 202 1.050 -12.651 168.00 14.28 97.00 20.00\n",
+ " 203 1.019 -9.121 - - 180.00 37.00\n",
+ " 204 1.015 -14.429 - - 74.00 15.00\n",
+ " 205 1.033 -14.929 - - 71.00 14.00\n",
+ " 206 1.028 -17.155 - - 136.00 28.00\n",
+ " 207 0.970 -22.392 110.00 38.00 125.00 25.00\n",
+ " 208 0.964 -21.696 - - 171.00 35.00\n",
+ " 209 1.020 -11.846 - - 175.00 36.00\n",
+ " 210 1.043 -14.163 - - 195.00 40.00\n",
+ " 211 1.028 -5.950 - - - -\n",
+ " 212 1.018 -4.164 - - - -\n",
+ " 213 1.050 -0.390 465.00 154.25 265.00 54.00\n",
+ " 214 1.050 -4.128 0.00 125.29 194.00 39.00\n",
+ " 215 1.044 4.742 260.00 86.30 317.00 64.00\n",
+ " 216 1.047 4.679 155.00 79.81 100.00 20.00\n",
+ " 217 1.049 8.086 - - - -\n",
+ " 218 1.050 8.906 355.00 60.31 333.00 68.00\n",
+ " 219 1.040 4.449 - - 181.00 37.00\n",
+ " 220 1.044 6.123 - - 128.00 26.00\n",
+ " 221 1.050 9.516 296.97 -7.62 - -\n",
+ " 222 1.050 15.467 300.00 -41.84 - -\n",
+ " 223 1.050 7.762 726.00 0.68 - -\n",
+ " 224 1.017 -0.386 - - - -\n",
+ " 301 1.050 -23.504 104.00 48.97 108.00 22.00\n",
+ " 302 1.050 -23.570 126.00 34.30 97.00 20.00\n",
+ " 303 0.998 -17.733 - - 180.00 37.00\n",
+ " 304 1.007 -23.757 - - 74.00 15.00\n",
+ " 305 1.028 -24.498 - - 71.00 14.00\n",
+ " 306 1.020 -26.020 - - 136.00 28.00\n",
+ " 307 0.957 -30.662 110.00 37.98 125.00 25.00\n",
+ " 308 0.951 -29.947 - - 171.00 35.00\n",
+ " 309 1.007 -19.748 - - 175.00 36.00\n",
+ " 310 1.032 -22.314 - - 195.00 40.00\n",
+ " 311 1.018 -12.834 - - - -\n",
+ " 312 1.003 -11.045 - - - -\n",
+ " 313 1.035 -7.624 355.00 149.98 265.00 54.00\n",
+ " 314 1.050 -9.655 0.00 166.72 194.00 39.00\n",
+ " 315 1.042 1.503 190.00 128.78 317.00 64.00\n",
+ " 316 1.045 1.163 155.00 79.13 100.00 20.00\n",
+ " 317 1.047 5.119 - - - -\n",
+ " 318 1.050 6.217 355.00 63.24 333.00 68.00\n",
+ " 319 1.039 0.850 - - 181.00 37.00\n",
+ " 320 1.044 2.456 - - 128.00 26.00\n",
+ " 321 1.050 6.905 355.00 -3.52 - -\n",
+ " 322 1.050 12.932 310.00 -39.97 - -\n",
+ " 323 1.050 4.057 710.00 74.93 - -\n",
+ " 324 0.999 -5.501 - - - -\n",
+ " 325 1.049 4.598 - - - -\n",
+ " -------- -------- -------- --------\n",
+ " Total: 8703.97 1718.74 8550.00 1740.00\n",
+ "\n",
+ "================================================================================\n",
+ "| Branch Data |\n",
+ "================================================================================\n",
+ "Brnch From To From Bus Injection To Bus Injection Loss (I^2 * Z)\n",
+ " # Bus Bus P (MW) Q (MVAr) P (MW) Q (MVAr) P (MW) Q (MVAr)\n",
+ "----- ----- ----- -------- -------- -------- -------- -------- --------\n",
+ " 1 101 102 7.84 -26.19 -7.84 -24.32 0.002 0.01\n",
+ " 2 101 103 -0.58 14.65 0.73 -20.08 0.159 0.61\n",
+ " 3 101 105 52.74 0.21 -52.18 -0.55 0.559 2.16\n",
+ " 4 102 104 34.94 13.72 -34.50 -15.64 0.441 1.70\n",
+ " 5 102 106 43.90 -4.74 -43.02 2.51 0.881 3.38\n",
+ " 6 103 109 3.68 -15.56 -3.61 12.48 0.063 0.24\n",
+ " 7 103 124 -184.41 -1.36 185.10 30.14 0.685 28.78\n",
+ " 8 104 109 -39.50 0.64 39.91 -2.00 0.408 1.57\n",
+ " 9 105 110 -18.82 -13.45 18.93 11.25 0.108 0.41\n",
+ " 10 106 110 -92.98 -137.09 94.12 -124.54 1.140 4.97\n",
+ " 11 107 108 168.71 19.74 -164.51 -5.57 4.193 15.98\n",
+ " 12 107 203 61.29 4.77 -59.84 -3.91 1.451 5.56\n",
+ " 13 108 109 -10.60 -5.60 10.65 1.10 0.051 0.20\n",
+ " 14 108 110 4.11 -23.83 -3.91 19.79 0.199 0.77\n",
+ " 15 109 111 -93.72 -30.19 93.91 38.39 0.195 8.20\n",
+ " 16 109 112 -128.23 -17.38 128.57 31.54 0.337 14.16\n",
+ " 17 110 111 -134.37 19.56 134.71 -5.09 0.345 14.47\n",
+ " 18 110 112 -169.77 33.94 170.33 -10.41 0.560 23.53\n",
+ " 19 111 113 -156.55 3.54 157.95 -2.98 1.398 11.19\n",
+ " 20 111 114 -72.08 -36.85 72.37 29.89 0.295 2.48\n",
+ " 21 112 113 -94.16 -23.47 94.69 17.16 0.531 4.25\n",
+ " 22 112 123 -204.74 2.33 209.60 15.18 4.857 39.26\n",
+ " 23 113 123 -179.70 8.11 183.05 -1.38 3.351 26.50\n",
+ " 24 113 215 -117.94 -0.22 119.25 -7.05 1.306 9.79\n",
+ " 25 114 116 -266.37 34.31 269.69 -4.05 3.323 39.22\n",
+ " 26 115 116 14.59 -23.89 -14.58 20.08 0.013 0.11\n",
+ " 27 115 121 -177.03 7.91 178.77 -4.98 1.739 14.20\n",
+ " 28 115 121 -177.03 7.91 178.77 -4.98 1.739 14.20\n",
+ " 29 115 124 187.47 36.27 -185.10 -30.14 2.377 17.66\n",
+ " 30 116 117 -240.85 22.84 242.46 -14.93 1.609 13.94\n",
+ " 31 116 119 40.73 21.01 -40.67 -25.87 0.061 0.47\n",
+ " 32 117 118 -111.10 2.55 111.33 -4.27 0.225 1.57\n",
+ " 33 117 122 -131.35 12.39 133.63 -19.65 2.275 17.06\n",
+ " 34 118 121 -44.66 2.36 44.72 -7.95 0.055 0.48\n",
+ " 35 118 121 -44.66 2.36 44.72 -7.95 0.055 0.48\n",
+ " 36 119 120 -70.16 -5.56 70.39 -1.62 0.228 1.82\n",
+ " 37 119 120 -70.16 -5.56 70.39 -1.62 0.228 1.82\n",
+ " 38 120 123 -134.39 -11.38 134.89 10.00 0.499 3.66\n",
+ " 39 120 123 -134.39 -11.38 134.89 10.00 0.499 3.66\n",
+ " 40 121 122 -164.10 22.63 166.37 -21.11 2.274 17.18\n",
+ " 41 123 217 7.57 -8.73 -7.57 -8.31 0.005 0.04\n",
+ " 42 201 202 5.24 -26.53 -5.23 -24.29 0.001 0.00\n",
+ " 43 201 203 -24.84 19.93 25.42 -23.83 0.573 2.20\n",
+ " 44 201 205 53.61 6.34 -53.02 -6.57 0.585 2.26\n",
+ " 45 202 204 31.49 19.07 -31.06 -21.04 0.428 1.65\n",
+ " 46 202 206 44.74 -0.50 -43.83 -1.62 0.911 3.50\n",
+ " 47 203 209 38.80 -12.07 -38.31 10.60 0.482 1.85\n",
+ " 48 203 224 -184.37 2.82 185.04 25.55 0.675 28.36\n",
+ " 49 204 209 -42.94 6.04 43.44 -7.03 0.498 1.92\n",
+ " 50 205 210 -17.98 -7.43 18.06 5.14 0.078 0.30\n",
+ " 51 206 210 -92.17 -131.96 93.29 -126.64 1.127 4.91\n",
+ " 52 207 208 -15.00 13.00 15.07 -14.32 0.071 0.27\n",
+ " 53 208 209 -101.32 0.22 106.08 13.59 4.755 18.25\n",
+ " 54 208 210 -84.75 -20.90 88.24 29.75 3.489 13.39\n",
+ " 55 209 211 -125.38 -35.41 125.73 49.95 0.346 14.54\n",
+ " 56 209 212 -160.82 -17.75 161.35 40.17 0.534 22.42\n",
+ " 57 210 211 -179.30 15.98 179.91 9.81 0.614 25.79\n",
+ " 58 210 212 -215.29 35.77 216.19 2.14 0.902 37.90\n",
+ " 59 211 213 -218.99 -13.71 221.72 24.71 2.725 21.80\n",
+ " 60 211 214 -86.64 -46.05 87.08 40.21 0.436 3.66\n",
+ " 61 212 213 -152.09 -49.66 153.55 50.60 1.454 11.64\n",
+ " 62 212 223 -225.45 7.35 231.38 18.84 5.925 47.89\n",
+ " 63 213 223 -175.27 24.93 178.46 -19.79 3.187 25.21\n",
+ " 64 214 216 -281.08 46.08 284.78 -11.45 3.699 43.65\n",
+ " 65 215 216 4.47 -24.58 -4.46 20.73 0.010 0.08\n",
+ " 66 215 221 -184.05 11.27 185.93 -7.19 1.882 15.37\n",
+ " 67 215 221 -184.05 11.27 185.93 -7.19 1.882 15.37\n",
+ " 68 215 224 187.39 31.41 -185.04 -25.55 2.346 17.43\n",
+ " 69 216 217 -248.08 24.53 249.78 -15.81 1.704 14.77\n",
+ " 70 216 219 22.76 25.99 -22.72 -31.05 0.037 0.28\n",
+ " 71 217 218 -110.83 10.66 111.05 -12.38 0.226 1.58\n",
+ " 72 217 222 -131.39 13.47 133.67 -20.73 2.278 17.09\n",
+ " 73 218 221 -44.53 2.35 44.58 -7.94 0.055 0.47\n",
+ " 74 218 221 -44.53 2.35 44.58 -7.94 0.055 0.47\n",
+ " 75 219 220 -79.14 -2.97 79.43 -3.73 0.289 2.32\n",
+ " 76 219 220 -79.14 -2.97 79.43 -3.73 0.289 2.32\n",
+ " 77 220 223 -143.43 -9.27 144.00 8.39 0.567 4.16\n",
+ " 78 220 223 -143.43 -9.27 144.00 8.39 0.567 4.16\n",
+ " 79 221 222 -164.06 22.62 166.33 -21.11 2.273 17.17\n",
+ " 80 301 302 8.64 -27.26 -8.64 -23.56 0.002 0.01\n",
+ " 81 301 303 -39.86 35.56 41.40 -35.63 1.540 5.91\n",
+ " 82 301 305 27.21 18.68 -26.99 -20.28 0.227 0.88\n",
+ " 83 302 304 11.14 30.50 -10.79 -32.75 0.351 1.35\n",
+ " 84 302 306 26.50 7.36 -26.14 -11.52 0.366 1.41\n",
+ " 85 303 309 26.14 -15.26 -25.87 13.08 0.271 1.04\n",
+ " 86 303 324 -247.53 13.89 248.80 39.49 1.271 53.39\n",
+ " 87 304 309 -63.21 17.75 64.37 -16.11 1.161 4.47\n",
+ " 88 305 310 -44.01 6.28 44.45 -7.17 0.434 1.66\n",
+ " 89 306 310 -109.86 -120.44 111.49 -131.32 1.633 7.11\n",
+ " 90 307 308 -15.00 12.98 15.07 -14.25 0.072 0.28\n",
+ " 91 308 309 -101.87 1.21 106.82 13.44 4.943 18.97\n",
+ " 92 308 310 -84.20 -21.96 87.76 31.20 3.563 13.67\n",
+ " 93 309 311 -143.49 -35.07 143.94 54.24 0.457 19.18\n",
+ " 94 309 312 -176.84 -11.35 177.49 38.94 0.657 27.60\n",
+ " 95 310 311 -202.57 20.54 203.38 13.12 0.801 33.66\n",
+ " 96 310 312 -236.13 46.75 237.25 0.29 1.120 47.04\n",
+ " 97 311 313 -199.55 -7.00 201.85 14.90 2.305 18.44\n",
+ " 98 311 314 -147.77 -60.36 148.97 61.06 1.204 10.11\n",
+ " 99 312 313 -134.86 -52.09 136.08 51.45 1.218 9.74\n",
+ " 100 312 323 -279.89 12.86 289.30 41.86 9.416 76.11\n",
+ " 101 313 323 -247.93 29.63 254.40 1.78 6.471 51.18\n",
+ " 102 314 316 -342.97 66.67 348.54 -10.00 5.565 65.66\n",
+ " 103 315 316 35.64 -22.59 -35.61 18.93 0.031 0.27\n",
+ " 104 315 321 -207.93 13.19 210.34 -4.80 2.408 19.66\n",
+ " 105 315 321 -207.93 13.19 210.34 -4.80 2.408 19.66\n",
+ " 106 315 324 253.23 60.97 -248.80 -39.49 4.421 32.84\n",
+ " 107 316 317 -286.68 29.76 288.97 -15.95 2.288 19.83\n",
+ " 108 316 319 28.75 20.44 -28.72 -25.47 0.037 0.29\n",
+ " 109 317 318 -150.00 2.34 150.42 -2.77 0.410 2.87\n",
+ " 110 317 322 -138.97 13.61 141.51 -18.80 2.549 19.11\n",
+ " 111 318 321 -50.17 3.06 50.24 -8.52 0.069 0.60\n",
+ " 112 318 321 -50.17 3.06 50.24 -8.52 0.069 0.60\n",
+ " 113 319 320 -76.14 -5.76 76.41 -1.09 0.269 2.15\n",
+ " 114 319 320 -76.14 -5.76 76.41 -1.09 0.269 2.15\n",
+ " 115 320 323 -140.41 -11.91 140.96 10.87 0.546 4.00\n",
+ " 116 320 323 -140.41 -11.91 140.96 10.87 0.546 4.00\n",
+ " 117 321 322 -166.15 23.13 168.49 -21.16 2.332 17.62\n",
+ " 118 325 121 -115.62 8.45 117.11 -18.69 1.499 12.12\n",
+ " 119 318 223 -28.08 -8.12 28.18 -15.15 0.095 0.76\n",
+ " 120 323 325 -115.62 9.54 115.62 -8.45 0.000 1.10\n",
+ " -------- --------\n",
+ " Total: 153.965 1442.60\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf_RTS_GMLC.to_mpc()\n",
+ "_ = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "28f76ab2",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 8.1, 12-Jul-2025\n",
+ "Power Flow -- AC-polar-power formulation\n",
+ "\n",
+ "Newton's method converged in 4 iterations.\n",
+ "PF successful\n",
+ "\n",
+ "Converged in 0.05 seconds\n",
+ "================================================================================\n",
+ "| System Summary |\n",
+ "================================================================================\n",
+ "\n",
+ "How many? How much? P (MW) Q (MVAr)\n",
+ "--------------------- ------------------- ------------- -----------------\n",
+ "Buses 73 Total Gen Capacity 14549.8 -1615.0 to 4406.0\n",
+ "Generators 158 On-line Capacity 9076.0 -1615.0 to 4406.0\n",
+ "Committed Gens 96 Generation (actual) 8704.0 1718.7\n",
+ "Loads 51 Load 8550.0 1740.0\n",
+ " Fixed 51 Fixed 8550.0 1740.0\n",
+ " Dispatchable 0 Dispatchable -0.0 of -0.0 -0.0\n",
+ "Shunts 3 Shunt (inj) -0.0 -316.1\n",
+ "Branches 120 Losses (I^2 * Z) 153.97 1442.60\n",
+ "Transformers 16 Branch Charging (inj) - 1780.0\n",
+ "Inter-ties 5 Total Inter-tie Flow 331.2 25.0\n",
+ "Areas 3\n",
+ "\n",
+ " Minimum Maximum\n",
+ " ------------------------- --------------------------------\n",
+ "Voltage Magnitude 0.951 p.u. @ bus 308 1.050 p.u. @ bus 121\n",
+ "Voltage Angle -30.66 deg @ bus 307 16.52 deg @ bus 122\n",
+ "P Losses (I^2*R) - 9.42 MW @ line 312-323\n",
+ "Q Losses (I^2*X) - 76.11 MVAr @ line 312-323\n",
+ "\n",
+ "================================================================================\n",
+ "| Bus Data |\n",
+ "================================================================================\n",
+ " Bus Voltage Generation Load\n",
+ " # Mag(pu) Ang(deg) P (MW) Q (MVAr) P (MW) Q (MVAr)\n",
+ "----- ------- -------- -------- -------- -------- --------\n",
+ " 101 1.047 -8.575 168.00 10.68 108.00 22.00\n",
+ " 102 1.047 -8.634 168.00 4.66 97.00 20.00\n",
+ " 103 1.011 -7.980 - - 180.00 37.00\n",
+ " 104 1.017 -10.745 - - 74.00 15.00\n",
+ " 105 1.035 -10.928 - - 71.00 14.00\n",
+ " 106 1.032 -13.157 - - 136.00 28.00\n",
+ " 107 1.050 -3.989 355.00 49.51 125.00 25.00\n",
+ " 108 1.017 -9.342 - - 171.00 35.00\n",
+ " 109 1.027 -8.460 - - 175.00 36.00\n",
+ " 110 1.050 -10.203 - - 195.00 40.00\n",
+ " 111 1.027 -4.083 - - - -\n",
+ " 112 1.020 -2.396 - - - -\n",
+ " 113 1.035 0.000* 220.00 76.07 265.00 54.00\n",
+ " 114 1.044 -2.552 0.00 103.20 194.00 39.00\n",
+ " 115 1.043 5.977 165.00 92.20 317.00 64.00\n",
+ " 116 1.046 5.824 155.00 79.87 100.00 20.00\n",
+ " 117 1.048 9.138 - - - -\n",
+ " 118 1.050 9.952 355.00 68.45 333.00 68.00\n",
+ " 119 1.040 5.368 - - 181.00 37.00\n",
+ " 120 1.044 6.847 - - 128.00 26.00\n",
+ " 121 1.050 10.564 400.00 -21.93 - -\n",
+ " 122 1.050 16.516 300.00 -40.76 - -\n",
+ " 123 1.050 8.378 670.00 25.07 - -\n",
+ " 124 1.013 0.844 - - - -\n",
+ " 201 1.050 -12.611 142.00 21.73 108.00 22.00\n",
+ " 202 1.050 -12.651 168.00 14.28 97.00 20.00\n",
+ " 203 1.019 -9.121 - - 180.00 37.00\n",
+ " 204 1.015 -14.429 - - 74.00 15.00\n",
+ " 205 1.033 -14.929 - - 71.00 14.00\n",
+ " 206 1.028 -17.155 - - 136.00 28.00\n",
+ " 207 0.970 -22.392 110.00 38.00 125.00 25.00\n",
+ " 208 0.964 -21.696 - - 171.00 35.00\n",
+ " 209 1.020 -11.846 - - 175.00 36.00\n",
+ " 210 1.043 -14.163 - - 195.00 40.00\n",
+ " 211 1.028 -5.950 - - - -\n",
+ " 212 1.018 -4.164 - - - -\n",
+ " 213 1.050 -0.390 465.00 154.25 265.00 54.00\n",
+ " 214 1.050 -4.128 0.00 125.29 194.00 39.00\n",
+ " 215 1.044 4.742 260.00 86.30 317.00 64.00\n",
+ " 216 1.047 4.679 155.00 79.81 100.00 20.00\n",
+ " 217 1.049 8.086 - - - -\n",
+ " 218 1.050 8.906 355.00 60.31 333.00 68.00\n",
+ " 219 1.040 4.449 - - 181.00 37.00\n",
+ " 220 1.044 6.123 - - 128.00 26.00\n",
+ " 221 1.050 9.516 296.97 -7.62 - -\n",
+ " 222 1.050 15.467 300.00 -41.84 - -\n",
+ " 223 1.050 7.762 726.00 0.68 - -\n",
+ " 224 1.017 -0.386 - - - -\n",
+ " 301 1.050 -23.504 104.00 48.97 108.00 22.00\n",
+ " 302 1.050 -23.570 126.00 34.30 97.00 20.00\n",
+ " 303 0.998 -17.733 - - 180.00 37.00\n",
+ " 304 1.007 -23.757 - - 74.00 15.00\n",
+ " 305 1.028 -24.498 - - 71.00 14.00\n",
+ " 306 1.020 -26.020 - - 136.00 28.00\n",
+ " 307 0.957 -30.662 110.00 37.98 125.00 25.00\n",
+ " 308 0.951 -29.947 - - 171.00 35.00\n",
+ " 309 1.007 -19.748 - - 175.00 36.00\n",
+ " 310 1.032 -22.314 - - 195.00 40.00\n",
+ " 311 1.018 -12.834 - - - -\n",
+ " 312 1.003 -11.045 - - - -\n",
+ " 313 1.035 -7.624 355.00 149.98 265.00 54.00\n",
+ " 314 1.050 -9.655 0.00 166.72 194.00 39.00\n",
+ " 315 1.042 1.503 190.00 128.78 317.00 64.00\n",
+ " 316 1.045 1.163 155.00 79.13 100.00 20.00\n",
+ " 317 1.047 5.119 - - - -\n",
+ " 318 1.050 6.217 355.00 63.24 333.00 68.00\n",
+ " 319 1.039 0.850 - - 181.00 37.00\n",
+ " 320 1.044 2.456 - - 128.00 26.00\n",
+ " 321 1.050 6.905 355.00 -3.52 - -\n",
+ " 322 1.050 12.932 310.00 -39.97 - -\n",
+ " 323 1.050 4.057 710.00 74.93 - -\n",
+ " 324 0.999 -5.501 - - - -\n",
+ " 325 1.049 4.598 - - - -\n",
+ " -------- -------- -------- --------\n",
+ " Total: 8703.97 1718.74 8550.00 1740.00\n",
+ "\n",
+ "================================================================================\n",
+ "| Branch Data |\n",
+ "================================================================================\n",
+ "Brnch From To From Bus Injection To Bus Injection Loss (I^2 * Z)\n",
+ " # Bus Bus P (MW) Q (MVAr) P (MW) Q (MVAr) P (MW) Q (MVAr)\n",
+ "----- ----- ----- -------- -------- -------- -------- -------- --------\n",
+ " 1 101 102 7.84 -26.19 -7.84 -24.32 0.002 0.01\n",
+ " 2 101 103 -0.58 14.65 0.73 -20.08 0.159 0.61\n",
+ " 3 101 105 52.74 0.21 -52.18 -0.55 0.559 2.16\n",
+ " 4 102 104 34.94 13.72 -34.50 -15.64 0.441 1.70\n",
+ " 5 102 106 43.90 -4.74 -43.02 2.51 0.881 3.38\n",
+ " 6 103 109 3.68 -15.56 -3.61 12.48 0.063 0.24\n",
+ " 7 103 124 -184.41 -1.36 185.10 30.14 0.685 28.78\n",
+ " 8 104 109 -39.50 0.64 39.91 -2.00 0.408 1.57\n",
+ " 9 105 110 -18.82 -13.45 18.93 11.25 0.108 0.41\n",
+ " 10 106 110 -92.98 -137.09 94.12 -124.54 1.140 4.97\n",
+ " 11 107 108 168.71 19.74 -164.51 -5.57 4.193 15.98\n",
+ " 12 107 203 61.29 4.77 -59.84 -3.91 1.451 5.56\n",
+ " 13 108 109 -10.60 -5.60 10.65 1.10 0.051 0.20\n",
+ " 14 108 110 4.11 -23.83 -3.91 19.79 0.199 0.77\n",
+ " 15 109 111 -93.72 -30.19 93.91 38.39 0.195 8.20\n",
+ " 16 109 112 -128.23 -17.38 128.57 31.54 0.337 14.16\n",
+ " 17 110 111 -134.37 19.56 134.71 -5.09 0.345 14.47\n",
+ " 18 110 112 -169.77 33.94 170.33 -10.41 0.560 23.53\n",
+ " 19 111 113 -156.55 3.54 157.95 -2.98 1.398 11.19\n",
+ " 20 111 114 -72.08 -36.85 72.37 29.89 0.295 2.48\n",
+ " 21 112 113 -94.16 -23.47 94.69 17.16 0.531 4.25\n",
+ " 22 112 123 -204.74 2.33 209.60 15.18 4.857 39.26\n",
+ " 23 113 123 -179.70 8.11 183.05 -1.38 3.351 26.50\n",
+ " 24 113 215 -117.94 -0.22 119.25 -7.05 1.306 9.79\n",
+ " 25 114 116 -266.37 34.31 269.69 -4.05 3.323 39.22\n",
+ " 26 115 116 14.59 -23.89 -14.58 20.08 0.013 0.11\n",
+ " 27 115 121 -177.03 7.91 178.77 -4.98 1.739 14.20\n",
+ " 28 115 121 -177.03 7.91 178.77 -4.98 1.739 14.20\n",
+ " 29 115 124 187.47 36.27 -185.10 -30.14 2.377 17.66\n",
+ " 30 116 117 -240.85 22.84 242.46 -14.93 1.609 13.94\n",
+ " 31 116 119 40.73 21.01 -40.67 -25.87 0.061 0.47\n",
+ " 32 117 118 -111.10 2.55 111.33 -4.27 0.225 1.57\n",
+ " 33 117 122 -131.35 12.39 133.63 -19.65 2.275 17.06\n",
+ " 34 118 121 -44.66 2.36 44.72 -7.95 0.055 0.48\n",
+ " 35 118 121 -44.66 2.36 44.72 -7.95 0.055 0.48\n",
+ " 36 119 120 -70.16 -5.56 70.39 -1.62 0.228 1.82\n",
+ " 37 119 120 -70.16 -5.56 70.39 -1.62 0.228 1.82\n",
+ " 38 120 123 -134.39 -11.38 134.89 10.00 0.499 3.66\n",
+ " 39 120 123 -134.39 -11.38 134.89 10.00 0.499 3.66\n",
+ " 40 121 122 -164.10 22.63 166.37 -21.11 2.274 17.18\n",
+ " 41 123 217 7.57 -8.73 -7.57 -8.31 0.005 0.04\n",
+ " 42 201 202 5.24 -26.53 -5.23 -24.29 0.001 0.00\n",
+ " 43 201 203 -24.84 19.93 25.42 -23.83 0.573 2.20\n",
+ " 44 201 205 53.61 6.34 -53.02 -6.57 0.585 2.26\n",
+ " 45 202 204 31.49 19.07 -31.06 -21.04 0.428 1.65\n",
+ " 46 202 206 44.74 -0.50 -43.83 -1.62 0.911 3.50\n",
+ " 47 203 209 38.80 -12.07 -38.31 10.60 0.482 1.85\n",
+ " 48 203 224 -184.37 2.82 185.04 25.55 0.675 28.36\n",
+ " 49 204 209 -42.94 6.04 43.44 -7.03 0.498 1.92\n",
+ " 50 205 210 -17.98 -7.43 18.06 5.14 0.078 0.30\n",
+ " 51 206 210 -92.17 -131.96 93.29 -126.64 1.127 4.91\n",
+ " 52 207 208 -15.00 13.00 15.07 -14.32 0.071 0.27\n",
+ " 53 208 209 -101.32 0.22 106.08 13.59 4.755 18.25\n",
+ " 54 208 210 -84.75 -20.90 88.24 29.75 3.489 13.39\n",
+ " 55 209 211 -125.38 -35.41 125.73 49.95 0.346 14.54\n",
+ " 56 209 212 -160.82 -17.75 161.35 40.17 0.534 22.42\n",
+ " 57 210 211 -179.30 15.98 179.91 9.81 0.614 25.79\n",
+ " 58 210 212 -215.29 35.77 216.19 2.14 0.902 37.90\n",
+ " 59 211 213 -218.99 -13.71 221.72 24.71 2.725 21.80\n",
+ " 60 211 214 -86.64 -46.05 87.08 40.21 0.436 3.66\n",
+ " 61 212 213 -152.09 -49.66 153.55 50.60 1.454 11.64\n",
+ " 62 212 223 -225.45 7.35 231.38 18.84 5.925 47.89\n",
+ " 63 213 223 -175.27 24.93 178.46 -19.79 3.187 25.21\n",
+ " 64 214 216 -281.08 46.08 284.78 -11.45 3.699 43.65\n",
+ " 65 215 216 4.47 -24.58 -4.46 20.73 0.010 0.08\n",
+ " 66 215 221 -184.05 11.27 185.93 -7.19 1.882 15.37\n",
+ " 67 215 221 -184.05 11.27 185.93 -7.19 1.882 15.37\n",
+ " 68 215 224 187.39 31.41 -185.04 -25.55 2.346 17.43\n",
+ " 69 216 217 -248.08 24.53 249.78 -15.81 1.704 14.77\n",
+ " 70 216 219 22.76 25.99 -22.72 -31.05 0.037 0.28\n",
+ " 71 217 218 -110.83 10.66 111.05 -12.38 0.226 1.58\n",
+ " 72 217 222 -131.39 13.47 133.67 -20.73 2.278 17.09\n",
+ " 73 218 221 -44.53 2.35 44.58 -7.94 0.055 0.47\n",
+ " 74 218 221 -44.53 2.35 44.58 -7.94 0.055 0.47\n",
+ " 75 219 220 -79.14 -2.97 79.43 -3.73 0.289 2.32\n",
+ " 76 219 220 -79.14 -2.97 79.43 -3.73 0.289 2.32\n",
+ " 77 220 223 -143.43 -9.27 144.00 8.39 0.567 4.16\n",
+ " 78 220 223 -143.43 -9.27 144.00 8.39 0.567 4.16\n",
+ " 79 221 222 -164.06 22.62 166.33 -21.11 2.273 17.17\n",
+ " 80 301 302 8.64 -27.26 -8.64 -23.56 0.002 0.01\n",
+ " 81 301 303 -39.86 35.56 41.40 -35.63 1.540 5.91\n",
+ " 82 301 305 27.21 18.68 -26.99 -20.28 0.227 0.88\n",
+ " 83 302 304 11.14 30.50 -10.79 -32.75 0.351 1.35\n",
+ " 84 302 306 26.50 7.36 -26.14 -11.52 0.366 1.41\n",
+ " 85 303 309 26.14 -15.26 -25.87 13.08 0.271 1.04\n",
+ " 86 303 324 -247.53 13.89 248.80 39.49 1.271 53.39\n",
+ " 87 304 309 -63.21 17.75 64.37 -16.11 1.161 4.47\n",
+ " 88 305 310 -44.01 6.28 44.45 -7.17 0.434 1.66\n",
+ " 89 306 310 -109.86 -120.44 111.49 -131.32 1.633 7.11\n",
+ " 90 307 308 -15.00 12.98 15.07 -14.25 0.072 0.28\n",
+ " 91 308 309 -101.87 1.21 106.82 13.44 4.943 18.97\n",
+ " 92 308 310 -84.20 -21.96 87.76 31.20 3.563 13.67\n",
+ " 93 309 311 -143.49 -35.07 143.94 54.24 0.457 19.18\n",
+ " 94 309 312 -176.84 -11.35 177.49 38.94 0.657 27.60\n",
+ " 95 310 311 -202.57 20.54 203.38 13.12 0.801 33.66\n",
+ " 96 310 312 -236.13 46.75 237.25 0.29 1.120 47.04\n",
+ " 97 311 313 -199.55 -7.00 201.85 14.90 2.305 18.44\n",
+ " 98 311 314 -147.77 -60.36 148.97 61.06 1.204 10.11\n",
+ " 99 312 313 -134.86 -52.09 136.08 51.45 1.218 9.74\n",
+ " 100 312 323 -279.89 12.86 289.30 41.86 9.416 76.11\n",
+ " 101 313 323 -247.93 29.63 254.40 1.78 6.471 51.18\n",
+ " 102 314 316 -342.97 66.67 348.54 -10.00 5.565 65.66\n",
+ " 103 315 316 35.64 -22.59 -35.61 18.93 0.031 0.27\n",
+ " 104 315 321 -207.93 13.19 210.34 -4.80 2.408 19.66\n",
+ " 105 315 321 -207.93 13.19 210.34 -4.80 2.408 19.66\n",
+ " 106 315 324 253.23 60.97 -248.80 -39.49 4.421 32.84\n",
+ " 107 316 317 -286.68 29.76 288.97 -15.95 2.288 19.83\n",
+ " 108 316 319 28.75 20.44 -28.72 -25.47 0.037 0.29\n",
+ " 109 317 318 -150.00 2.34 150.42 -2.77 0.410 2.87\n",
+ " 110 317 322 -138.97 13.61 141.51 -18.80 2.549 19.11\n",
+ " 111 318 321 -50.17 3.06 50.24 -8.52 0.069 0.60\n",
+ " 112 318 321 -50.17 3.06 50.24 -8.52 0.069 0.60\n",
+ " 113 319 320 -76.14 -5.76 76.41 -1.09 0.269 2.15\n",
+ " 114 319 320 -76.14 -5.76 76.41 -1.09 0.269 2.15\n",
+ " 115 320 323 -140.41 -11.91 140.96 10.87 0.546 4.00\n",
+ " 116 320 323 -140.41 -11.91 140.96 10.87 0.546 4.00\n",
+ " 117 321 322 -166.15 23.13 168.49 -21.16 2.332 17.62\n",
+ " 118 325 121 -115.62 8.45 117.11 -18.69 1.499 12.12\n",
+ " 119 318 223 -28.08 -8.12 28.18 -15.15 0.095 0.76\n",
+ " 120 323 325 -115.62 9.54 115.62 -8.45 0.000 1.10\n",
+ " -------- --------\n",
+ " Total: 153.965 1442.60\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf_RTS_GMLC.to_mpc()\n",
+ "_ = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "47837a00",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "m.exit()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "46de9421",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "env",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.14.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/tests/results/case118/gencost.csv b/tests/results/case118/gencost.csv
index 16f220c..6e4f978 100644
--- a/tests/results/case118/gencost.csv
+++ b/tests/results/case118/gencost.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,0.0,0.0,3.0,0.01,40.0,0.0
2,2.0,0.0,0.0,3.0,0.01,40.0,0.0
3,2.0,0.0,0.0,3.0,0.01,40.0,0.0
diff --git a/tests/results/case118/schema/gencost.csv b/tests/results/case118/schema/gencost.csv
index 16f220c..6e4f978 100644
--- a/tests/results/case118/schema/gencost.csv
+++ b/tests/results/case118/schema/gencost.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,0.0,0.0,3.0,0.01,40.0,0.0
2,2.0,0.0,0.0,3.0,0.01,40.0,0.0
3,2.0,0.0,0.0,3.0,0.01,40.0,0.0
diff --git a/tests/results/case118_prefix_suffix/mpc.gencost_test.csv b/tests/results/case118_prefix_suffix/mpc.gencost_test.csv
index 16f220c..6e4f978 100644
--- a/tests/results/case118_prefix_suffix/mpc.gencost_test.csv
+++ b/tests/results/case118_prefix_suffix/mpc.gencost_test.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,0.0,0.0,3.0,0.01,40.0,0.0
2,2.0,0.0,0.0,3.0,0.01,40.0,0.0
3,2.0,0.0,0.0,3.0,0.01,40.0,0.0
diff --git a/tests/results/case9/gencost.csv b/tests/results/case9/gencost.csv
index a988c52..b618f70 100644
--- a/tests/results/case9/gencost.csv
+++ b/tests/results/case9/gencost.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,1500.0,0.0,3.0,0.11,5.0,150.0
2,2.0,2000.0,0.0,3.0,0.085,1.2,600.0
3,2.0,3000.0,0.0,3.0,0.1225,1.0,335.0
diff --git a/tests/results/case9/schema/gencost.csv b/tests/results/case9/schema/gencost.csv
index a988c52..b618f70 100644
--- a/tests/results/case9/schema/gencost.csv
+++ b/tests/results/case9/schema/gencost.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,1500.0,0.0,3.0,0.11,5.0,150.0
2,2.0,2000.0,0.0,3.0,0.085,1.2,600.0
3,2.0,3000.0,0.0,3.0,0.1225,1.0,335.0
diff --git a/tests/results/case9_prefix_suffix/mpc.gencost_test.csv b/tests/results/case9_prefix_suffix/mpc.gencost_test.csv
index a988c52..b618f70 100644
--- a/tests/results/case9_prefix_suffix/mpc.gencost_test.csv
+++ b/tests/results/case9_prefix_suffix/mpc.gencost_test.csv
@@ -1,4 +1,4 @@
-,MODEL,STARTUP,SHUTDOWN,NCOST,COST_2,COST_1,COST_0
+,MODEL,STARTUP,SHUTDOWN,NCOST,C2,C1,C0
1,2.0,1500.0,0.0,3.0,0.11,5.0,150.0
2,2.0,2000.0,0.0,3.0,0.085,1.2,600.0
3,2.0,3000.0,0.0,3.0,0.1225,1.0,335.0
diff --git a/tests/test_read_matpower_cases.py b/tests/test_read_matpower_cases.py
index ddf158c..defb8b8 100644
--- a/tests/test_read_matpower_cases.py
+++ b/tests/test_read_matpower_cases.py
@@ -1,3 +1,5 @@
+import warnings
+
import pandas as pd
from matpower import path_matpower, start_instance
from pandas.testing import assert_frame_equal, assert_index_equal
@@ -27,7 +29,9 @@ def assert_cf_equal(cf1, cf2):
def test_case9():
CASE_NAME = "case9.m"
- CaseFrames(CASE_NAME)
+ cf = CaseFrames(CASE_NAME)
+ cols = pd.Index(["MODEL", "STARTUP", "SHUTDOWN", "NCOST", "C2", "C1", "C0"])
+ assert cf.gencost.columns.equals(cols)
def test_case4_dist():
@@ -57,6 +61,46 @@ def test_case118():
assert_cf_equal(cf, cf_mpc)
+def test_case_RTS_GMLC():
+ # NOTE: case with gencost piecewise linear
+ m = start_instance()
+
+ # TODO: test read without load_case_engine
+ CASE_NAME = "case_RTS_GMLC.m"
+ cf = CaseFrames(CASE_NAME)
+ cf_lc = CaseFrames(CASE_NAME, load_case_engine=m)
+
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ "ignore", category=RuntimeWarning, message=".*invalid value.*"
+ )
+ cf.infer_numpy()
+ cf_lc.infer_numpy()
+
+ cols = pd.Index(
+ [
+ "MODEL",
+ "STARTUP",
+ "SHUTDOWN",
+ "NCOST",
+ "X1",
+ "Y1",
+ "X2",
+ "Y2",
+ "X3",
+ "Y3",
+ "X4",
+ "Y4",
+ ]
+ )
+ assert cf.gencost.columns.equals(cols)
+ assert cf_lc.gencost.columns.equals(cols)
+
+ assert_cf_equal(cf, cf_lc)
+
+ m.exit()
+
+
def test_t_case9_dcline():
CASE_NAME = f"{path_matpower}/lib/t/t_case9_dcline.m"
CaseFrames(CASE_NAME)