diff --git a/README.md b/README.md
index 81183a0..3e9aa18 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,19 @@ cf = CaseFrames(case_path)
print(cf.gencost)
```
+Since `matpower` itself suggests that we should use `loadcase` instead of parsing, we can use an engine using (require `matlab` or `octave`),
+
+```python
+from matpower import start_instance
+from matpowercaseframes import CaseFrames
+
+m = start_instance()
+
+case_name = f"case16am.m"
+cf_16am_lc = CaseFrames(case_name, load_case_engine=m)
+cf_16am_lc.branch # see that the branch is already in p.u., converted by `loadcase`
+```
+
Furthermore, `matpowercaseframes` also support generating data that is acceptable by `matpower` via `matpower-pip` package (require `matlab` or `octave`),
```python
@@ -44,7 +57,7 @@ from matpowercaseframes import CaseFrames
case_path = 'case9.m'
cf = CaseFrames(case_path)
-mpc = cf.to_dict()
+mpc = cf.to_mpc() # identical with cf.to_dict()
m = start_instance()
m.runpf(mpc)
diff --git a/matpowercaseframes/core.py b/matpowercaseframes/core.py
index d3cb37e..a5a3dc3 100644
--- a/matpowercaseframes/core.py
+++ b/matpowercaseframes/core.py
@@ -18,7 +18,7 @@
class CaseFrames:
- def __init__(self, data, update_index=True):
+ def __init__(self, data, update_index=True, load_case_engine=None):
"""Convert data into CaseFrames format
Args:
@@ -34,9 +34,17 @@ def __init__(self, data, update_index=True):
# TODO: support read excel
# TODO: support Path object
if isinstance(data, str):
- path = self._get_path(data)
# TYPE: str of path
- self._read_matpower(filepath=path)
+ path = self._get_path(data)
+
+ if load_case_engine is None:
+ # read with matpower parser
+ self._read_matpower(filepath=path)
+ else:
+ # read using loadcase
+ mpc = load_case_engine.loadcase(path)
+ self._read_oct2py_struct(struct=mpc)
+
elif isinstance(data, dict):
# TYPE: dict | oct2py.io.Struct
self._read_oct2py_struct(struct=data)
diff --git a/notebooks/load_case16am.ipynb b/notebooks/load_case16am.ipynb
index fafec97..bedb56b 100644
--- a/notebooks/load_case16am.ipynb
+++ b/notebooks/load_case16am.ipynb
@@ -348,6 +348,19 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {},
+ "outputs": [],
+ "source": [
+ "# # NOTE: using loadcase cause data in float\n",
+ "# CASE_NAME = f\"case16am.m\"\n",
+ "# mpc = m.loadcase(CASE_NAME)\n",
+ "# cf_16am_lc = CaseFrames(mpc)\n",
+ "# cf_16am_lc.branch"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
"outputs": [
{
"data": {
@@ -648,21 +661,69 @@
"14 0.0 1.0 -360.0 360.0 "
]
},
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
+ "# NOTE: using loadcase cause data in float\n",
"CASE_NAME = f\"case16am.m\"\n",
- "mpc = m.loadcase(CASE_NAME)\n",
- "cf_16am = CaseFrames(mpc)\n",
- "cf_16am.branch"
+ "cf_16am_lc = CaseFrames(CASE_NAME, load_case_engine=m)\n",
+ "cf_16am_lc.branch"
]
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 7.1, 08-Oct-2020 -- AC Power Flow (Newton)\n",
+ "\n",
+ "Newton's method power flow (power balance, polar) did not converge in 10 iterations.\n",
+ "\n",
+ ">>>>> Did NOT converge (0.02 seconds) <<<<<\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf_16am.to_mpc()\n",
+ "_ = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 7.1, 08-Oct-2020 -- AC Power Flow (Newton)\n",
+ "\n",
+ "Newton's method power flow (power balance, polar) did not converge in 10 iterations.\n",
+ "\n",
+ ">>>>> Did NOT converge (0.01 seconds) <<<<<\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf_16am_lc.to_mpc()\n",
+ "_ = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
diff --git a/notebooks/load_from_data.ipynb b/notebooks/load_from_data.ipynb
new file mode 100644
index 0000000..1411780
--- /dev/null
+++ b/notebooks/load_from_data.ipynb
@@ -0,0 +1,747 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from matpower import start_instance\n",
+ "from matpowercaseframes import CaseFrames"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "m = start_instance()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "path = \"../data/case9.m\"\n",
+ "cf = CaseFrames(path)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " BUS_I | \n",
+ " BUS_TYPE | \n",
+ " PD | \n",
+ " QD | \n",
+ " GS | \n",
+ " BS | \n",
+ " BUS_AREA | \n",
+ " VM | \n",
+ " VA | \n",
+ " BASE_KV | \n",
+ " ZONE | \n",
+ " VMAX | \n",
+ " VMIN | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 3 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 2 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 4 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " 5 | \n",
+ " 1 | \n",
+ " 90 | \n",
+ " 30 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " 6 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " 7 | \n",
+ " 1 | \n",
+ " 100 | \n",
+ " 35 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " 8 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " 9 | \n",
+ " 1 | \n",
+ " 125 | \n",
+ " 50 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 345 | \n",
+ " 1 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " BUS_I BUS_TYPE PD QD GS BS BUS_AREA VM VA BASE_KV ZONE VMAX \\\n",
+ "1 1 3 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "2 2 2 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "3 3 2 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "4 4 1 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "5 5 1 90 30 0 0 1 1 0 345 1 1.1 \n",
+ "6 6 1 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "7 7 1 100 35 0 0 1 1 0 345 1 1.1 \n",
+ "8 8 1 0 0 0 0 1 1 0 345 1 1.1 \n",
+ "9 9 1 125 50 0 0 1 1 0 345 1 1.1 \n",
+ "\n",
+ " VMIN \n",
+ "1 0.9 \n",
+ "2 0.9 \n",
+ "3 0.9 \n",
+ "4 0.9 \n",
+ "5 0.9 \n",
+ "6 0.9 \n",
+ "7 0.9 \n",
+ "8 0.9 \n",
+ "9 0.9 "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cf.bus"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "BUS_I int64\n",
+ "BUS_TYPE int64\n",
+ "PD int64\n",
+ "QD int64\n",
+ "GS int64\n",
+ "BS int64\n",
+ "BUS_AREA int64\n",
+ "VM int64\n",
+ "VA int64\n",
+ "BASE_KV int64\n",
+ "ZONE int64\n",
+ "VMAX float64\n",
+ "VMIN float64\n",
+ "dtype: object"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cf.bus.dtypes"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 7.1, 08-Oct-2020 -- AC Power Flow (Newton)\n",
+ "\n",
+ "Newton's method power flow (power balance, polar) converged in 4 iterations.\n",
+ "\n",
+ "Converged in 0.01 seconds\n",
+ "================================================================================\n",
+ "| System Summary |\n",
+ "================================================================================\n",
+ "\n",
+ "How many? How much? P (MW) Q (MVAr)\n",
+ "--------------------- ------------------- ------------- -----------------\n",
+ "Buses 9 Total Gen Capacity 820.0 -900.0 to 900.0\n",
+ "Generators 3 On-line Capacity 820.0 -900.0 to 900.0\n",
+ "Committed Gens 3 Generation (actual) 319.6 22.8\n",
+ "Loads 3 Load 315.0 115.0\n",
+ " Fixed 3 Fixed 315.0 115.0\n",
+ " Dispatchable 0 Dispatchable -0.0 of -0.0 -0.0\n",
+ "Shunts 0 Shunt (inj) -0.0 0.0\n",
+ "Branches 9 Losses (I^2 * Z) 4.64 48.38\n",
+ "Transformers 0 Branch Charging (inj) - 140.5\n",
+ "Inter-ties 0 Total Inter-tie Flow 0.0 0.0\n",
+ "Areas 1\n",
+ "\n",
+ " Minimum Maximum\n",
+ " ------------------------- --------------------------------\n",
+ "Voltage Magnitude 0.996 p.u. @ bus 9 1.040 p.u. @ bus 1\n",
+ "Voltage Angle -3.99 deg @ bus 9 9.28 deg @ bus 2\n",
+ "P Losses (I^2*R) - 2.30 MW @ line 8-9\n",
+ "Q Losses (I^2*X) - 15.83 MVAr @ line 8-2\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",
+ " 1 1.040 0.000* 71.64 27.05 - -\n",
+ " 2 1.025 9.280 163.00 6.65 - -\n",
+ " 3 1.025 4.665 85.00 -10.86 - -\n",
+ " 4 1.026 -2.217 - - - -\n",
+ " 5 1.013 -3.687 - - 90.00 30.00\n",
+ " 6 1.032 1.967 - - - -\n",
+ " 7 1.016 0.728 - - 100.00 35.00\n",
+ " 8 1.026 3.720 - - - -\n",
+ " 9 0.996 -3.989 - - 125.00 50.00\n",
+ " -------- -------- -------- --------\n",
+ " Total: 319.64 22.84 315.00 115.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 1 4 71.64 27.05 -71.64 -23.92 0.000 3.12\n",
+ " 2 4 5 30.70 1.03 -30.54 -16.54 0.166 0.90\n",
+ " 3 5 6 -59.46 -13.46 60.82 -18.07 1.354 5.90\n",
+ " 4 3 6 85.00 -10.86 -85.00 14.96 -0.000 4.10\n",
+ " 5 6 7 24.18 3.12 -24.10 -24.30 0.088 0.75\n",
+ " 6 7 8 -75.90 -10.70 76.38 -0.80 0.475 4.03\n",
+ " 7 8 2 -163.00 9.18 163.00 6.65 0.000 15.83\n",
+ " 8 8 9 86.62 -8.38 -84.32 -11.31 2.300 11.57\n",
+ " 9 9 4 -40.68 -38.69 40.94 22.89 0.258 2.19\n",
+ " -------- --------\n",
+ " Total: 4.641 48.38\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf.to_mpc()\n",
+ "sol = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " BUS_I | \n",
+ " BUS_TYPE | \n",
+ " PD | \n",
+ " QD | \n",
+ " GS | \n",
+ " BS | \n",
+ " BUS_AREA | \n",
+ " VM | \n",
+ " VA | \n",
+ " BASE_KV | \n",
+ " ZONE | \n",
+ " VMAX | \n",
+ " VMIN | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 1 | \n",
+ " 1.0 | \n",
+ " 3.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.040000 | \n",
+ " 0.000000 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 2.0 | \n",
+ " 2.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.025000 | \n",
+ " 9.280005 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 3.0 | \n",
+ " 2.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.025000 | \n",
+ " 4.664751 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 4.0 | \n",
+ " 1.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.025788 | \n",
+ " -2.216788 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " 5.0 | \n",
+ " 1.0 | \n",
+ " 90.0 | \n",
+ " 30.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.012654 | \n",
+ " -3.687396 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " 6.0 | \n",
+ " 1.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.032353 | \n",
+ " 1.966716 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " 7.0 | \n",
+ " 1.0 | \n",
+ " 100.0 | \n",
+ " 35.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.015883 | \n",
+ " 0.727536 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " 8.0 | \n",
+ " 1.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 1.025769 | \n",
+ " 3.719701 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " 9.0 | \n",
+ " 1.0 | \n",
+ " 125.0 | \n",
+ " 50.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
+ " 0.995631 | \n",
+ " -3.988805 | \n",
+ " 345.0 | \n",
+ " 1.0 | \n",
+ " 1.1 | \n",
+ " 0.9 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " BUS_I BUS_TYPE PD QD GS BS BUS_AREA VM VA \\\n",
+ "1 1.0 3.0 0.0 0.0 0.0 0.0 1.0 1.040000 0.000000 \n",
+ "2 2.0 2.0 0.0 0.0 0.0 0.0 1.0 1.025000 9.280005 \n",
+ "3 3.0 2.0 0.0 0.0 0.0 0.0 1.0 1.025000 4.664751 \n",
+ "4 4.0 1.0 0.0 0.0 0.0 0.0 1.0 1.025788 -2.216788 \n",
+ "5 5.0 1.0 90.0 30.0 0.0 0.0 1.0 1.012654 -3.687396 \n",
+ "6 6.0 1.0 0.0 0.0 0.0 0.0 1.0 1.032353 1.966716 \n",
+ "7 7.0 1.0 100.0 35.0 0.0 0.0 1.0 1.015883 0.727536 \n",
+ "8 8.0 1.0 0.0 0.0 0.0 0.0 1.0 1.025769 3.719701 \n",
+ "9 9.0 1.0 125.0 50.0 0.0 0.0 1.0 0.995631 -3.988805 \n",
+ "\n",
+ " BASE_KV ZONE VMAX VMIN \n",
+ "1 345.0 1.0 1.1 0.9 \n",
+ "2 345.0 1.0 1.1 0.9 \n",
+ "3 345.0 1.0 1.1 0.9 \n",
+ "4 345.0 1.0 1.1 0.9 \n",
+ "5 345.0 1.0 1.1 0.9 \n",
+ "6 345.0 1.0 1.1 0.9 \n",
+ "7 345.0 1.0 1.1 0.9 \n",
+ "8 345.0 1.0 1.1 0.9 \n",
+ "9 345.0 1.0 1.1 0.9 "
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cf = CaseFrames(sol)\n",
+ "cf.bus"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "BUS_I float64\n",
+ "BUS_TYPE float64\n",
+ "PD float64\n",
+ "QD float64\n",
+ "GS float64\n",
+ "BS float64\n",
+ "BUS_AREA float64\n",
+ "VM float64\n",
+ "VA float64\n",
+ "BASE_KV float64\n",
+ "ZONE float64\n",
+ "VMAX float64\n",
+ "VMIN float64\n",
+ "dtype: object"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cf.bus.dtypes"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "MATPOWER Version 7.1, 08-Oct-2020 -- AC Power Flow (Newton)\n",
+ "\n",
+ "Converged in 0.00 seconds\n",
+ "================================================================================\n",
+ "| System Summary |\n",
+ "================================================================================\n",
+ "\n",
+ "How many? How much? P (MW) Q (MVAr)\n",
+ "--------------------- ------------------- ------------- -----------------\n",
+ "Buses 9 Total Gen Capacity 820.0 -900.0 to 900.0\n",
+ "Generators 3 On-line Capacity 820.0 -900.0 to 900.0\n",
+ "Committed Gens 3 Generation (actual) 319.6 22.8\n",
+ "Loads 3 Load 315.0 115.0\n",
+ " Fixed 3 Fixed 315.0 115.0\n",
+ " Dispatchable 0 Dispatchable -0.0 of -0.0 -0.0\n",
+ "Shunts 0 Shunt (inj) -0.0 0.0\n",
+ "Branches 9 Losses (I^2 * Z) 4.64 48.38\n",
+ "Transformers 0 Branch Charging (inj) - 140.5\n",
+ "Inter-ties 0 Total Inter-tie Flow 0.0 0.0\n",
+ "Areas 1\n",
+ "\n",
+ " Minimum Maximum\n",
+ " ------------------------- --------------------------------\n",
+ "Voltage Magnitude 0.996 p.u. @ bus 9 1.040 p.u. @ bus 1\n",
+ "Voltage Angle -3.99 deg @ bus 9 9.28 deg @ bus 2\n",
+ "P Losses (I^2*R) - 2.30 MW @ line 8-9\n",
+ "Q Losses (I^2*X) - 15.83 MVAr @ line 8-2\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",
+ " 1 1.040 0.000* 71.64 27.05 - -\n",
+ " 2 1.025 9.280 163.00 6.65 - -\n",
+ " 3 1.025 4.665 85.00 -10.86 - -\n",
+ " 4 1.026 -2.217 - - - -\n",
+ " 5 1.013 -3.687 - - 90.00 30.00\n",
+ " 6 1.032 1.967 - - - -\n",
+ " 7 1.016 0.728 - - 100.00 35.00\n",
+ " 8 1.026 3.720 - - - -\n",
+ " 9 0.996 -3.989 - - 125.00 50.00\n",
+ " -------- -------- -------- --------\n",
+ " Total: 319.64 22.84 315.00 115.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 1 4 71.64 27.05 -71.64 -23.92 0.000 3.12\n",
+ " 2 4 5 30.70 1.03 -30.54 -16.54 0.166 0.90\n",
+ " 3 5 6 -59.46 -13.46 60.82 -18.07 1.354 5.90\n",
+ " 4 3 6 85.00 -10.86 -85.00 14.96 -0.000 4.10\n",
+ " 5 6 7 24.18 3.12 -24.10 -24.30 0.088 0.75\n",
+ " 6 7 8 -75.90 -10.70 76.38 -0.80 0.475 4.03\n",
+ " 7 8 2 -163.00 9.18 163.00 6.65 0.000 15.83\n",
+ " 8 8 9 86.62 -8.38 -84.32 -11.31 2.300 11.57\n",
+ " 9 9 4 -40.68 -38.69 40.94 22.89 0.258 2.19\n",
+ " -------- --------\n",
+ " Total: 4.641 48.38\n"
+ ]
+ }
+ ],
+ "source": [
+ "mpc = cf.to_mpc()\n",
+ "sol = m.runpf(mpc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# m.exit()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "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.12.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/tests/test_read_matpower_cases.py b/tests/test_read_matpower_cases.py
index 64bb115..6de24ca 100644
--- a/tests/test_read_matpower_cases.py
+++ b/tests/test_read_matpower_cases.py
@@ -29,16 +29,10 @@ def test_t_case9_dcline():
def test_loadcase_case16am():
m = start_instance()
- CASE_NAME = f"case16am.m"
- mpc = m.loadcase(CASE_NAME)
- CaseFrames(mpc)
+ CASE_NAME = "case16am.m"
+ CaseFrames(CASE_NAME, load_case_engine=m)
m.exit()
def test_read_without_ext():
CASE_NAME = 'case9'
- cf = CaseFrames(CASE_NAME)
-
- CASE_NAME = 'case9.m'
- cf_ext = CaseFrames(CASE_NAME)
-
- assert True
+ CaseFrames(CASE_NAME)