Skip to content

Commit 01e4edb

Browse files
authored
Tidy Matpower Test Cases (#288)
* update case names to be consistent with file names * remove areas block from some test cases
1 parent f9abdb1 commit 01e4edb

14 files changed

+40
-57
lines changed

docs/src/network-data.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The network data dictionary structure is roughly as follows:
9292
The following commands can be used to explore the network data dictionary generated by a given PTI or Matpower (this example) data file,
9393

9494
```julia
95-
network_data = PowerModels.parse_file("nesta_case3_lmbd.m")
95+
network_data = PowerModels.parse_file("case3.m")
9696
display(network_data) # raw dictionary
9797
PowerModels.print_summary(network_data) # quick table-like summary
9898
PowerModels.component_table(network_data, "bus", ["vmin", "vmax"]) # component data in matrix form
@@ -124,15 +124,15 @@ Data exchange via JSON files is ideal for building algorithms, however it is har
124124

125125
The first of these helper functions are `make_per_unit` and `make_mixed_units`, which convert the units of the data inside a network data dictionary. The *mixed units* format follows the unit conventions from Matpower and other common power network formats where some of the values are in per unit and others are the true values. These functions can be used as follows,
126126
```
127-
network_data = PowerModels.parse_file("nesta_case3_lmbd.m")
127+
network_data = PowerModels.parse_file("case3.m")
128128
PowerModels.print_summary(network_data) # default per-unit form
129129
PowerModels.make_mixed_units(network_data)
130130
PowerModels.print_summary(network_data) # mixed units form
131131
```
132132

133133
Another useful helper function is `update_data`, which takes two network data dictionaries and updates the values in the first dictionary with the values from the second dictionary. This is particularly helpful when applying sparse updates to network data. A good example is using the solution of one computation to update the data in preparation for a second computation, like so,
134134
```
135-
data = PowerModels.parse_file("nesta_case3_lmbd.m")
135+
data = PowerModels.parse_file("case3.m")
136136
opf_result = run_ac_opf(data, IpoptSolver())
137137
PowerModels.print_summary(opf_result["solution"])
138138
@@ -143,7 +143,7 @@ PowerModels.print_summary(pf_result["solution"])
143143

144144
A variety of helper functions are available for processing the topology of the network. For example, `connected_components` will compute the collections of buses that are connected by branches (i.e. the network's islands). By default PowerModels will attempt to solve all of the network components simultaneously. The `select_largest_component` function can be used to only consider the largest component in the network. Finally the `propagate_topology_status` can be used to explicitly deactivate components that are implicitly inactive due to the status of other components (e.g. deactivating branches based on the status of their connecting buses), like so,
145145
```
146-
data = PowerModels.parse_file("nesta_case3_lmbd.m")
146+
data = PowerModels.parse_file("case3.m")
147147
PowerModels.propagate_topology_status(data)
148148
opf_result = run_ac_opf(data, IpoptSolver())
149149
```
@@ -294,5 +294,5 @@ PowerModels also has support for parsing PTI network files in the `.raw` format
294294
In addition to parsing the standard parameters required by PowerModels for calculations, PowerModels also supports parsing additional data fields that are defined by the PSS(R)E specification, but not used by PowerModels directly. This can be achieved via the `import_all` optional keyword argument in `parse_file` when loading a `.raw` file, e.g.
295295

296296
```julia
297-
PowerModels.parse_file("nesta_case3_lmbd.raw"; import_all=true)
297+
PowerModels.parse_file("case3.raw"; import_all=true)
298298
```

docs/src/quickguide.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Quick Start Guide
22

3-
Once PowerModels is installed, Ipopt is installed, and a network data file (e.g. `"nesta_case3_lmbd.m"` or `"nesta_case3_lmbd.raw"`) has been acquired, an AC Optimal Power Flow can be executed with,
3+
Once PowerModels is installed, Ipopt is installed, and a network data file (e.g. `"case3.m"` or `"case3.raw"`) has been acquired, an AC Optimal Power Flow can be executed with,
44

55
```julia
66
using PowerModels
77
using Ipopt
88

9-
run_ac_opf("nesta_case3_lmbd.m", IpoptSolver())
9+
run_ac_opf("case3.m", IpoptSolver())
1010
```
1111

1212
Similarly, a DC Optimal Power Flow can be executed with
1313

1414
```julia
15-
run_dc_opf("nesta_case3_lmbd.m", IpoptSolver())
15+
run_dc_opf("case3.m", IpoptSolver())
1616
```
1717

1818
PTI `.raw` files in the PSS(R)E v33 specification can be run similarly, e.g. in the case of an AC Optimal Power Flow
1919

2020
```julia
21-
run_ac_opf("nesta_case3_lmbd.raw", IpoptSolver())
21+
run_ac_opf("case3.raw", IpoptSolver())
2222
```
2323

2424
## Getting Results
2525

2626
The run commands in PowerModels return detailed results data in the form of a dictionary. Results dictionaries from either Matpower `.m` or PTI `.raw` files will be identical in format. This dictionary can be saved for further processing as follows,
2727

2828
```julia
29-
result = run_ac_opf("nesta_case3_lmbd.m", IpoptSolver())
29+
result = run_ac_opf("case3.m", IpoptSolver())
3030
```
3131

3232
For example, the algorithm's runtime and final objective value can be accessed with,
@@ -52,20 +52,20 @@ The function "run_ac_opf" and "run_dc_opf" are shorthands for a more general for
5252
For example, `run_ac_opf` is equivalent to,
5353

5454
```julia
55-
run_opf("nesta_case3_lmbd.m", ACPPowerModel, IpoptSolver())
55+
run_opf("case3.m", ACPPowerModel, IpoptSolver())
5656
```
5757

5858
where "ACPPowerModel" indicates an AC formulation in polar coordinates. This more generic `run_opf()` allows one to solve an OPF problem with any power network formulation implemented in PowerModels. For example, an SOC Optimal Power Flow can be run with,
5959

6060
```julia
61-
run_opf("nesta_case3_lmbd.m", SOCWRPowerModel, IpoptSolver())
61+
run_opf("case3.m", SOCWRPowerModel, IpoptSolver())
6262
```
6363

6464
## Modifying Network Data
6565
The following example demonstrates one way to perform multiple PowerModels solves while modifing the network data in Julia,
6666

6767
```julia
68-
network_data = PowerModels.parse_file("nesta_case3_lmbd.m")
68+
network_data = PowerModels.parse_file("case3.m")
6969

7070
run_opf(network_data, ACPPowerModel, IpoptSolver())
7171

@@ -78,7 +78,7 @@ run_opf(network_data, ACPPowerModel, IpoptSolver())
7878
Network data parsed from PTI `.raw` files supports data extensions, i.e. data fields that are within the PSS(R)E specification, but not used by PowerModels for calculation. This can be achieve by
7979

8080
```julia
81-
network_data = PowerModels.parse_file("nesta_case3_lmbd.raw"; import_all=true)
81+
network_data = PowerModels.parse_file("case3.raw"; import_all=true)
8282
```
8383

8484
This network data can be modified in the same way as the previous Matpower `.m` file example. For additional details about the network data, see the [PowerModels Network Data Format](@ref) section.
@@ -102,7 +102,7 @@ loss_dc = Dict(name => data["pt"]+data["pf"] for (name, data) in result["soluti
102102
The following example demonstrates how to break a `run_opf` call into seperate model building and solving steps. This allows inspection of the JuMP model created by PowerModels for the AC-OPF problem,
103103

104104
```julia
105-
pm = build_generic_model("nesta_case3_lmbd.m", ACPPowerModel, PowerModels.post_opf)
105+
pm = build_generic_model("case3.m", ACPPowerModel, PowerModels.post_opf)
106106

107107
print(pm.model)
108108

test/data.jl

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@
88

99
line_count = count(c -> c == '\n', output)
1010
@test line_count >= 80 && line_count <= 100
11-
@test contains(output, "name: nesta_case5_pjm")
11+
@test contains(output, "name: case5")
1212
@test contains(output, "Table: bus")
1313
@test contains(output, "Table: load")
1414
@test contains(output, "Table: gen")
1515
@test contains(output, "Table: branch")
16-
@test contains(output, "Table: areas")
1716
end
1817

1918
@testset "5-bus summary from file location" begin
2019
output = sprint(PowerModels.summary, "../test/data/matpower/case5.m")
2120

2221
line_count = count(c -> c == '\n', output)
2322
@test line_count >= 80 && line_count <= 100
24-
@test contains(output, "name: nesta_case5_pjm")
23+
@test contains(output, "name: case5")
2524
@test contains(output, "Table: bus")
2625
@test contains(output, "Table: load")
2726
@test contains(output, "Table: gen")
2827
@test contains(output, "Table: branch")
29-
@test contains(output, "Table: areas")
3028
end
3129

3230
@testset "5-bus solution summary from dict" begin

test/data/matpower/case14.m

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
% from matpower - http://www.pserc.cornell.edu/matpower/
2+
13
function mpc = case14
24

35
%CASE14 Power flow data for IEEE 14 bus test case.

test/data/matpower/case24.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
% based on NESTA v0.6.0 case
1+
% from pglib-opf - https://github.com/power-grid-lib/pglib-opf
22
% tests missing angmin,angmax data correction
33
% tests branch orientation data correction
4+
% tests mpc.areas
45

5-
function mpc = nesta_case24_ieee_rts__sad
6+
function mpc = case24
67
mpc.version = '2';
78
mpc.baseMVA = 100.0;
89

test/data/matpower/case3.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% tests refrence bus detection
33
% tests basic ac and hvdc modeling
44
% tests when gencost is present but not dclinecost
5-
% based on nesta_case3_lmbd from NESTA v0.6.0
5+
66
function mpc = case3
77
mpc.version = '2';
88
mpc.baseMVA = 100.0;

test/data/matpower/case30.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
% NESTA v0.6.0
2-
function mpc = nesta_case30_ieee
1+
% from pglib-opf - https://github.com/power-grid-lib/pglib-opf
2+
3+
function mpc = case30
34
mpc.version = '2';
45
mpc.baseMVA = 100.0;
56

test/data/matpower/case3_tnep.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
% based on NESTA v0.6.0
2-
function mpc = case3_lmbd_tnep
1+
% tests extra data needed for tnep problems
2+
3+
function mpc = case3_tnep
34
mpc.version = '2';
45
mpc.baseMVA = 100.0;
56

test/data/matpower/case5.m

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
% NESTA v0.6.0
21
% used in tests of,
32
% - non-contiguous bus ids
43
% - tranformer orentation swapping
54
% - dual values
6-
%
75

8-
function mpc = nesta_case5_pjm
6+
function mpc = case5
97
mpc.version = '2';
108
mpc.baseMVA = 100.0;
119

12-
%% area data
13-
% area refbus
14-
mpc.areas = [
15-
1 4;
16-
];
17-
1810
%% bus data
1911
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
2012
mpc.bus = [

test/data/matpower/case5_asym.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
% NESTA v0.6.0
1+
% tests asymetrical branch phase angle differences
2+
23
function mpc = case5_asym
34
mpc.version = '2';
45
mpc.baseMVA = 100.0;

test/data/matpower/case5_dc.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
% based on NESTA v0.6.0
21
% tests dc line with costs
32
% tests generator and dc line voltage setpoint warnings
43

5-
function mpc = nesta_case5_pjm
4+
function mpc = case5_dc
65
mpc.version = '2';
76
mpc.baseMVA = 100.0;
87

test/data/matpower/case5_pwlc.m

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
% NESTA v0.6.0
2-
% tests non-contiguous bus ids
1+
% tests pwl cost functions
32

4-
function mpc = nesta_case5_pjm
3+
function mpc = case5_pwlc
54
mpc.version = '2';
65
mpc.baseMVA = 100.0;
76

8-
%% area data
9-
% area refbus
10-
mpc.areas = [
11-
1 4;
12-
];
13-
147
%% bus data
158
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
169
mpc.bus = [

test/data/matpower/case5_tnep.m

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
% based on NESTA v0.6.0
2-
function mpc = case5_pjm_tnep
1+
% tests extra data needed for tnep problems
2+
3+
function mpc = case5_tnep
34
mpc.version = '2';
45
mpc.baseMVA = 100.0;
56

6-
%% area data
7-
% area refbus
8-
mpc.areas = [
9-
1 4;
10-
];
11-
127
%% bus data
138
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
149
mpc.bus = [

test/data/matpower/case6.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Case to test two connected components in the network data
2-
% the case is two replicates of the nesta_case3_lmbd network
2+
% the case is two replicates of the case3 network
33

4-
function mpc = nesta_case3_lmbd_2x
4+
function mpc = case6
55
mpc.version = '2';
66
mpc.baseMVA = 100.0;
77

0 commit comments

Comments
 (0)