Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy Matpower Test Cases #288

Merged
merged 2 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/src/network-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The network data dictionary structure is roughly as follows:
The following commands can be used to explore the network data dictionary generated by a given PTI or Matpower (this example) data file,

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

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,
```
network_data = PowerModels.parse_file("nesta_case3_lmbd.m")
network_data = PowerModels.parse_file("case3.m")
PowerModels.print_summary(network_data) # default per-unit form
PowerModels.make_mixed_units(network_data)
PowerModels.print_summary(network_data) # mixed units form
```

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,
```
data = PowerModels.parse_file("nesta_case3_lmbd.m")
data = PowerModels.parse_file("case3.m")
opf_result = run_ac_opf(data, IpoptSolver())
PowerModels.print_summary(opf_result["solution"])

Expand All @@ -143,7 +143,7 @@ PowerModels.print_summary(pf_result["solution"])

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,
```
data = PowerModels.parse_file("nesta_case3_lmbd.m")
data = PowerModels.parse_file("case3.m")
PowerModels.propagate_topology_status(data)
opf_result = run_ac_opf(data, IpoptSolver())
```
Expand Down Expand Up @@ -294,5 +294,5 @@ PowerModels also has support for parsing PTI network files in the `.raw` format
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.

```julia
PowerModels.parse_file("nesta_case3_lmbd.raw"; import_all=true)
PowerModels.parse_file("case3.raw"; import_all=true)
```
20 changes: 10 additions & 10 deletions docs/src/quickguide.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Quick Start Guide

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,
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,

```julia
using PowerModels
using Ipopt

run_ac_opf("nesta_case3_lmbd.m", IpoptSolver())
run_ac_opf("case3.m", IpoptSolver())
```

Similarly, a DC Optimal Power Flow can be executed with

```julia
run_dc_opf("nesta_case3_lmbd.m", IpoptSolver())
run_dc_opf("case3.m", IpoptSolver())
```

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

```julia
run_ac_opf("nesta_case3_lmbd.raw", IpoptSolver())
run_ac_opf("case3.raw", IpoptSolver())
```

## Getting Results

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,

```julia
result = run_ac_opf("nesta_case3_lmbd.m", IpoptSolver())
result = run_ac_opf("case3.m", IpoptSolver())
```

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

```julia
run_opf("nesta_case3_lmbd.m", ACPPowerModel, IpoptSolver())
run_opf("case3.m", ACPPowerModel, IpoptSolver())
```

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,

```julia
run_opf("nesta_case3_lmbd.m", SOCWRPowerModel, IpoptSolver())
run_opf("case3.m", SOCWRPowerModel, IpoptSolver())
```

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

```julia
network_data = PowerModels.parse_file("nesta_case3_lmbd.m")
network_data = PowerModels.parse_file("case3.m")

run_opf(network_data, ACPPowerModel, IpoptSolver())

Expand All @@ -78,7 +78,7 @@ run_opf(network_data, ACPPowerModel, IpoptSolver())
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

```julia
network_data = PowerModels.parse_file("nesta_case3_lmbd.raw"; import_all=true)
network_data = PowerModels.parse_file("case3.raw"; import_all=true)
```

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.
Expand All @@ -102,7 +102,7 @@ loss_dc = Dict(name => data["pt"]+data["pf"] for (name, data) in result["soluti
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,

```julia
pm = build_generic_model("nesta_case3_lmbd.m", ACPPowerModel, PowerModels.post_opf)
pm = build_generic_model("case3.m", ACPPowerModel, PowerModels.post_opf)

print(pm.model)

Expand Down
6 changes: 2 additions & 4 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@

line_count = count(c -> c == '\n', output)
@test line_count >= 80 && line_count <= 100
@test contains(output, "name: nesta_case5_pjm")
@test contains(output, "name: case5")
@test contains(output, "Table: bus")
@test contains(output, "Table: load")
@test contains(output, "Table: gen")
@test contains(output, "Table: branch")
@test contains(output, "Table: areas")
end

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

line_count = count(c -> c == '\n', output)
@test line_count >= 80 && line_count <= 100
@test contains(output, "name: nesta_case5_pjm")
@test contains(output, "name: case5")
@test contains(output, "Table: bus")
@test contains(output, "Table: load")
@test contains(output, "Table: gen")
@test contains(output, "Table: branch")
@test contains(output, "Table: areas")
end

@testset "5-bus solution summary from dict" begin
Expand Down
2 changes: 2 additions & 0 deletions test/data/matpower/case14.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% from matpower - http://www.pserc.cornell.edu/matpower/

function mpc = case14

%CASE14 Power flow data for IEEE 14 bus test case.
Expand Down
5 changes: 3 additions & 2 deletions test/data/matpower/case24.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
% based on NESTA v0.6.0 case
% from pglib-opf - https://github.com/power-grid-lib/pglib-opf
% tests missing angmin,angmax data correction
% tests branch orientation data correction
% tests mpc.areas

function mpc = nesta_case24_ieee_rts__sad
function mpc = case24
mpc.version = '2';
mpc.baseMVA = 100.0;

Expand Down
2 changes: 1 addition & 1 deletion test/data/matpower/case3.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% tests refrence bus detection
% tests basic ac and hvdc modeling
% tests when gencost is present but not dclinecost
% based on nesta_case3_lmbd from NESTA v0.6.0

function mpc = case3
mpc.version = '2';
mpc.baseMVA = 100.0;
Expand Down
5 changes: 3 additions & 2 deletions test/data/matpower/case30.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
% NESTA v0.6.0
function mpc = nesta_case30_ieee
% from pglib-opf - https://github.com/power-grid-lib/pglib-opf

function mpc = case30
mpc.version = '2';
mpc.baseMVA = 100.0;

Expand Down
5 changes: 3 additions & 2 deletions test/data/matpower/case3_tnep.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
% based on NESTA v0.6.0
function mpc = case3_lmbd_tnep
% tests extra data needed for tnep problems

function mpc = case3_tnep
mpc.version = '2';
mpc.baseMVA = 100.0;

Expand Down
10 changes: 1 addition & 9 deletions test/data/matpower/case5.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
% NESTA v0.6.0
% used in tests of,
% - non-contiguous bus ids
% - tranformer orentation swapping
% - dual values
%

function mpc = nesta_case5_pjm
function mpc = case5
mpc.version = '2';
mpc.baseMVA = 100.0;

%% area data
% area refbus
mpc.areas = [
1 4;
];

%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
mpc.bus = [
Expand Down
3 changes: 2 additions & 1 deletion test/data/matpower/case5_asym.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
% NESTA v0.6.0
% tests asymetrical branch phase angle differences

function mpc = case5_asym
mpc.version = '2';
mpc.baseMVA = 100.0;
Expand Down
3 changes: 1 addition & 2 deletions test/data/matpower/case5_dc.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
% based on NESTA v0.6.0
% tests dc line with costs
% tests generator and dc line voltage setpoint warnings

function mpc = nesta_case5_pjm
function mpc = case5_dc
mpc.version = '2';
mpc.baseMVA = 100.0;

Expand Down
11 changes: 2 additions & 9 deletions test/data/matpower/case5_pwlc.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
% NESTA v0.6.0
% tests non-contiguous bus ids
% tests pwl cost functions

function mpc = nesta_case5_pjm
function mpc = case5_pwlc
mpc.version = '2';
mpc.baseMVA = 100.0;

%% area data
% area refbus
mpc.areas = [
1 4;
];

%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
mpc.bus = [
Expand Down
11 changes: 3 additions & 8 deletions test/data/matpower/case5_tnep.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
% based on NESTA v0.6.0
function mpc = case5_pjm_tnep
% tests extra data needed for tnep problems

function mpc = case5_tnep
mpc.version = '2';
mpc.baseMVA = 100.0;

%% area data
% area refbus
mpc.areas = [
1 4;
];

%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
mpc.bus = [
Expand Down
4 changes: 2 additions & 2 deletions test/data/matpower/case6.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Case to test two connected components in the network data
% the case is two replicates of the nesta_case3_lmbd network
% the case is two replicates of the case3 network

function mpc = nesta_case3_lmbd_2x
function mpc = case6
mpc.version = '2';
mpc.baseMVA = 100.0;

Expand Down