Skip to content

Commit

Permalink
ADD: load shedding problem (MLD) (#151)
Browse files Browse the repository at this point in the history
* WIP: Add support for MLD problem

Adds variables, constraints, and objectives for mld problems (relaxed only), including standard and with storage.

* WIP: add_setpoint!

Adds setpoint values to solution

Updates objective

Fixes error in tp_test.jl

* FIX: variable_tp_active_storage_on_off loops over wrong ref

should loop over :storage, not :gen, updates lower and upper bounds

Adds docstrings to new functions

Updates objective functions, adding max loadability objective

* FIX: load models documentation

* ADD: LinDistFlow for MLD

* FIX: tests

* FIX: re-enable tests

* ADD: tranformers to mld_bf problem

Temporarily adds PowerModels branch fix/BFForm-constraint_voltage_angle_difference to manifest.

* UPD: manifest.toml

* ADD: unit tests

Adds unit tests and cleans up unused functions.

Update changelog

* UPD: Manifest.toml

* UPD: Documentation

* UPD: Project.toml & README

Updates README to include new problem specification, and changes PowerModels required version to v0.12.2+

* FIX: PowerModels function rename

* UPD: tp_strg_opf

Adds transformers to strg opf for NFAForm

* FIX: Missing ACP KCL for strorage + transformers

* UPD: MLD objective function

* UPD: parse of storage kva -> thermal_rating

Adds division by nconductors of thermal_rating, qmin, qmax (kva, kvar)

* UPD: mld tests for storage

* RM: PowerModels master no longer needed

* ADD: mld_uc

* ADD: ACP for MLD

* FIX: missing on/off constraints, ACP

Adds missing voltage, generator and storage on/off constraints for AC, DC, and W problems.

* UPD: explicity export some PowerModels

* UPD: make all z_ variables conductorless

* UPD: objective function

needed abs()

obj: min ab(X) + Y

introduce X'
X' >= X
X' >= -X

obj: min X' + Y

* FIX: incorrect delegation back to PowerModels

constraint_ohms_yt_from -> constraint_ohms_yt_to

* UPD: remove conductor level lookup for z variable

* UPD: Documentation

* DOC: Fix leftover occurance of TPPM reference
  • Loading branch information
pseudocubic authored Aug 1, 2019
1 parent d995943 commit a12dfc9
Show file tree
Hide file tree
Showing 32 changed files with 1,283 additions and 77 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PowerModelsDistribution.jl Change Log
===================================

### staged
- none
- Add continuous load shedding problem (mld)

### v0.5.0
- Enforce function naming conventions (starts with `_`: internal function; ends with `!`: transforms data; `correct_`: corrects network data; `check_`: warnings about network data) (breaking)
Expand Down
42 changes: 23 additions & 19 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
version = "0.8.10"

[[BinaryProvider]]
deps = ["Libdl", "SHA"]
deps = ["Libdl", "Logging", "SHA"]
git-tree-sha1 = "c7361ce8a2129f20b0e05a89f7070820cfed6648"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.4"
version = "0.5.6"

[[Calculus]]
deps = ["Compat"]
git-tree-sha1 = "f60954495a7afcee4136f78d1d60350abd37a409"
git-tree-sha1 = "bd8bbd105ba583a42385bd6dc4a20dad8ab3dc11"
uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
version = "0.4.1"
version = "0.5.0"

[[CommonSubexpressions]]
deps = ["Test"]
Expand All @@ -34,10 +34,10 @@ uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.1.0"

[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"]
git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038"
deps = ["InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "0809951a1774dc724da22d26e4289bbaab77809a"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.15.0"
version = "0.17.0"

[[Dates]]
deps = ["Printf"]
Expand All @@ -64,10 +64,10 @@ deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[EzXML]]
deps = ["BinaryProvider", "Libdl", "Pkg", "Printf", "Test"]
git-tree-sha1 = "ad00b79cca4bb3eabb4209217859c553af4401f5"
deps = ["BinaryProvider", "Libdl", "Printf"]
git-tree-sha1 = "724e13b7522563a18ae4a5cc4a9792ae3b0da3e6"
uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
version = "0.9.1"
version = "0.9.3"

[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "InteractiveUtils", "LinearAlgebra", "NaNMath", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Test"]
Expand All @@ -77,19 +77,19 @@ version = "0.10.3"

[[InfrastructureModels]]
deps = ["JuMP", "Memento"]
git-tree-sha1 = "131d2d24a2a0d404f59dceab2fb8f8cca2aadce5"
git-tree-sha1 = "d380c59122887b4794e72bf92e9cf2a664654f18"
uuid = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
version = "0.2.1"
version = "0.2.2"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON]]
deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"]
git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa"
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.20.0"
version = "0.21.0"

[[JuMP]]
deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics"]
Expand Down Expand Up @@ -147,17 +147,21 @@ git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.1.0"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "db2b35dedab3c0e46dc15996d170af07a5ab91c9"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.6"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PowerModels]]
deps = ["InfrastructureModels", "JSON", "JuMP", "LinearAlgebra", "MathOptInterface", "Memento", "SparseArrays"]
git-tree-sha1 = "9538663d7a58472d0a642a3efa97cc97481353f2"
repo-rev = "master"
repo-url = "https://github.com/lanl-ansi/PowerModels.jl.git"
git-tree-sha1 = "1e3deea188e92d904bcffd4992d8e309786b9257"
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
version = "0.12.0"
version = "0.12.2"

[[Printf]]
deps = ["Unicode"]
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerModelsDistribution"
uuid = "d7431456-977f-11e9-2de3-97ff7677985e"
authors = ["David M Fobes <[email protected]>", "Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/PowerModelsDistribution.jl.git"
version = "0.5.0"
version = "0.5.1"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
Expand All @@ -16,22 +16,22 @@ PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
Cbc = ">= 0.4"
InfrastructureModels = "^0.2"
Ipopt = ">= 0.4"
JuMP = "^0.19.2"
JSON = ">= 0.18"
JuMP = "^0.19.2"
Juniper = ">= 0.4"
Memento = ">= 0.8, < 0.13"
PowerModels = "^0.12"
PowerModels = "^0.12.2"
SCS = ">= 0.4"
julia = "^1"

[extras]
AmplNLWriter = "7c4d4715-977e-5154-bfe0-e096adeac482"
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
AmplNLWriter = "7c4d4715-977e-5154-bfe0-e096adeac482"

[targets]
test = ["Cbc", "Ipopt", "JSON", "Juniper", "SCS", "Test"]
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# PowerModelsDistribution.jl

Release:
<!-- [![PowerModelsDistribution](http://pkg.julialang.org/badges/ThreePhasePowerModels_0.6.svg)](http://pkg.julialang.org/detail/PowerModelsDistribution) -->
[![docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://lanl-ansi.github.io/PowerModelsDistribution.jl/stable/)

Dev:
Expand All @@ -14,16 +13,20 @@ PowerModelsDistribution.jl is an extention package of PowerModels.jl for Steady-
This enables the definition of a wide variety of power network formulations and their comparison on common problem specifications.

**Core Problem Specifications**

* Power Flow (pf)
* Optimal Power Flow (opf), for the Bus Injection Model (BIM) as well as the Branch Flow Model (BFM)
* Continuous load shed, minimum load delta (mld), for the Branch Flow Model (LPLinUBFPowerModel) and Network Flow Approximation (NFAPowerModel)

**Core Network Formulations**

* AC (polar and rectangular coordinates)
* SDP BFM relaxation
* SOC BFM and BIM relaxation (W-space)
* Linear approximation (LinDist3Flow and simplified unbalanced DistFlow)

**Network Data Formats**

* Matlab ".m" files (extended for three-phase)
* OpenDSS ".dss" files

Expand All @@ -36,9 +39,10 @@ Community-driven development and enhancement of PowerModelsDistribution are welc

## Acknowledgments

This code has been developed as part of the Advanced Network Science Initiative at Los Alamos National Laboratory. The primary developers are David Fobes(@pseudocubic) and Carleton Coffrin(@ccoffrin) with support from the following contributors,
- Sander Claeys (@sanderclaeys) KU Leuven, transformer models and ACR formulation
- Frederik Geth (@frederikgeth) CSIRO, Distribution modeling advise
This code has been developed as part of the Advanced Network Science Initiative at Los Alamos National Laboratory. The primary developers are David Fobes(@pseudocubic) and Carleton Coffrin(@ccoffrin) with support from the following contributors:

* Sander Claeys (@sanderclaeys) KU Leuven, transformer models and ACR formulation
* Frederik Geth (@frederikgeth) CSIRO, Distribution modeling advise

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CurrentModule = PowerModelsDistribution

## Overview

ThreePowerModels.jl is a Julia/JuMP extension package to PowerModels.jl for modeling of Multi-Phase (with a focus on three-phase) power grids.
PowerModelsDistribution.jl is a Julia/JuMP extension package to PowerModels.jl for modeling of Multi-Phase (with a focus on three-phase) power grids.
## Installation

The latest stable release of PowerModels can be installed using the Julia package manager with
Expand Down
50 changes: 49 additions & 1 deletion docs/src/specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ variable_tp_branch_flow(pm, bounded=false)

for c in PMs.conductor_ids(pm)
PMs.variable_generation(pm, bounded=false, cnd=c)
variable_load_flow(pm, cnd=c)
variable_tp_load(pm, cnd=c)
PMs.variable_dcline_flow(pm, bounded=false, cnd=c)
end

Expand Down Expand Up @@ -205,3 +205,51 @@ for i in PMs.ids(pm, :trans)
constraint_tp_trans(pm, i)
end
```

## Minimal Load Delta (MLD) Problem Specification

Load shed (continuous) problem. See "Relaxations of AC Maximal Load Delivery for Severe Contingency Analysis" by C. Coffrin _et al._ (DOI: [10.1109/TPWRS.2018.2876507](https://ieeexplore.ieee.org/document/8494809)) for single-phase case.

### Variables

```math
\begin{align}
\mbox{variables: } & \nonumber \\
& z^v_i \in \{0,1\}\ \ \forall i \in N \mbox{ - bus voltage on/off variable} \\
& z^g_i \in \{0,1\}\ \ \forall i \in G \mbox{ - generator on/off variable} \\
& z^{b}_i \in \{0,1\}\ \ \forall i \in B\mbox{ - storage on/off variable} \\
& z^d_i \in (0,1)\ \ \forall i \in L \mbox{ - continuous load shedding variable} \\
& z^s_i \in (0,1)\ \ \forall i \in H \mbox{ - continuous shunt shedding variable}
\end{align}
```

### Objective

```math
\begin{align}
\mbox{minimize: }\left (
\sum_{\substack{i\in N,c\in C}}{10 \left (1-z^v_i \right )} + \sum_{\substack{i\in L,c\in C}}{10 \omega_{i,c}\left |\Re{\left (S^d_i\right )}\right |\left ( 1-z^d_i \right ) } + \sum_{\substack{i\in H,c\in C}}{\left | \Re{\left (S^s_i \right )}\right | \left (1-z^s_i \right ) } + \sum_{\substack{i\in G,c\in C}}{\Delta^g_i } + \sum_{\substack{i\in B,c\in C}}{\Delta^b_i} \right )
\end{align}
```
where

```math
\begin{align}
\Delta^g_i &>= \left [\Re{\left (S^g_{i}(0) \right )} - \Re{\left (S^g_i \right )} \right ] \\
\Delta^g_i &>= -\left [\Re{\left (S^g_{i}(0) \right )} - \Re{\left (S^g_i \right )} \right ] \\
\Delta^b_i &>= \left [\Re{\left (S^b_{i}(0) \right )} - \Re{\left (S^b_i \right )} \right ] \\
\Delta^b_i &>= -\left [\Re{\left (S^b_{i}(0) \right )} - \Re{\left (S^b_i \right )} \right ]
\end{align}
```

### Constraints

```math
\begin{align}
\mbox{subject to: } & \nonumber \\
& z^v_i v^l_{i,c} \leq \left | V_{i,c} \right | \leq z_i^v v^u_{i,c}\ \ \forall i \in N,\forall c \in C \\
& z^g_i S^{gl}_{i,c} \leq S^g_{i,c} \leq z^g_i S^{gu}_{i,c}\ \ \forall i \in G,\forall c \in C \\
& \sum_{\substack{k\in G_i,c\in C}} S^g_{k,c} - \sum_{\substack{k\in L_i,c\in C}} z^d_k S^d_{k,c}- \sum_{\substack{k\in H_i,c\in C}} z^s_k Y^s_{k,c}\left | V_{i,c} \right |^2 \nonumber \\
& = \sum_{\substack{(i,j)\in E_i\cup E_i^R,c\in C}} S_{ij,c}\ \forall i \in N
\end{align}
```
1 change: 1 addition & 0 deletions src/PowerModelsDistribution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module PowerModelsDistribution
include("io/dss_structs.jl")
include("io/opendss.jl")

include("prob/tp_mld.jl")
include("prob/tp_opf.jl")
include("prob/tp_opf_lm.jl")
include("prob/tp_opf_oltc.jl")
Expand Down
31 changes: 28 additions & 3 deletions src/core/constraint.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
""
"model current constraints"
function constraint_tp_model_current(pm::_PMs.GenericPowerModel; kwargs...)
for c in _PMs.conductor_ids(pm)
_PMs.constraint_model_current(pm; cnd=c, kwargs...)
end
end


""
"reference angle constraints"
function constraint_tp_theta_ref(pm::_PMs.GenericPowerModel, i::Int; nw::Int=pm.cnw)
for cnd in _PMs.conductor_ids(pm)
constraint_tp_theta_ref(pm, nw, cnd, i)
end
end


""
"storage loss constraints"
function constraint_tp_storage_loss(pm::_PMs.GenericPowerModel, n::Int, i, bus, r, x, standby_loss)
conductors = _PMs.conductor_ids(pm)
vm = [_PMs.var(pm, n, c, :vm, bus) for c in conductors]
Expand All @@ -25,3 +25,28 @@ function constraint_tp_storage_loss(pm::_PMs.GenericPowerModel, n::Int, i, bus,

JuMP.@NLconstraint(pm.model, sum(ps[c] for c in conductors) + (sd - sc) == standby_loss + sum( r[c]*(ps[c]^2 + qs[c]^2)/vm[c]^2 for c in conductors))
end


"on/off bus voltage magnitude constraint"
function constraint_tp_voltage_magnitude_on_off(pm::_PMs.GenericPowerModel, n::Int, c::Int, i::Int, vmin, vmax)
vm = _PMs.var(pm, n, c, :vm, i)
z_voltage = _PMs.var(pm, n, :z_voltage, i)

JuMP.@constraint(pm.model, vm <= vmax*z_voltage)
JuMP.@constraint(pm.model, vm >= vmin*z_voltage)
end


"on/off bus voltage magnitude squared constraint for relaxed formulations"
function constraint_tp_voltage_magnitude_sqr_on_off(pm::_PMs.GenericPowerModel, n::Int, c::Int, i::Int, vmin, vmax)
w = _PMs.var(pm, n, c, :w, i)
z_voltage = _PMs.var(pm, n, :z_voltage, i)

if isfinite(vmax)
JuMP.@constraint(pm.model, w <= vmax^2*z_voltage)
end

if isfinite(vmin)
JuMP.@constraint(pm.model, w >= vmin^2*z_voltage)
end
end
Loading

0 comments on commit a12dfc9

Please sign in to comment.