Skip to content

Commit

Permalink
fixing gmd_mls.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Mate committed Apr 5, 2021
1 parent 35bca9d commit 7fe3c44
Show file tree
Hide file tree
Showing 25 changed files with 347 additions and 253 deletions.
12 changes: 7 additions & 5 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Multi-Infrastructure Control and Optimization Toolkit (MICOT) project, LA-CC-13-108.
Copyright (c) 2016, Triad National Security, LLC.

Copyright (c) 2016, Triad National Security, LLC. ALL RIGHTS RESERVED.
ALL RIGHTS RESERVED.

This software was produced for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration.

Expand All @@ -10,10 +10,12 @@ The U.S. Government has rights to use, reproduce, and distribute this software.

Additionally, redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Triad National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
3. Neither the name of Triad National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY TRIAD NATIONAL SECURITY, LLC AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TRIAD NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

LICENSEE AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE U.S. GOVERNMENT AND THE UNITED STATES GOVERNMENT'S CONTRACTORS AND SUBCONTRACTORS, AND SHALL INDEMNIFY AND HOLD HARMLESS THE U.S. GOVERNMENT AND THE UNITED STATES GOVERNMENT'S CONTRACTORS AND SUBCONTRACTORS FOR ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES, OR LOSSES THAT MAY ARISE FROM RECIPIENT'S USE OF THE WATERMODELS SOFTWARE OR PROVIDED DOCUMENTATION, INCLUDING ANY LIABILITIES OR DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, THE USE THEREOF.
53 changes: 30 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ PMsGMD solves for quasi-dc line flow and ac power flow problems in a system subj
Currently the following common industry and academic formulations have been implemented:
* GIC DC: quasi-dc power flow
* GIC -> AC - OPF: sequential quasi-dc power flow and ac optimal power flow
* GIC -> AC - MLS: sequential quasi-dc power flow and ac minimum-load-shed
* GIC + AC - MLS: ac minimum-load-shed coupled with a quasi-dc power flow

<!--
* GIC + AC - OPF: ac optimal power flow coupled with a quasi-dc power flow
* GIC + AC - MLS: ac minimum-load-shed coupled with a quasi-dc power flow
* GIC + AC - OTS: ac optimal transmission switching with load shed coupled with a quasi-dc power flow
-->

Expand Down Expand Up @@ -84,10 +86,22 @@ run_gmd("test/data/b4gic.m", optimizer, setting=setting)

### GIC -> AC-OPF

Solves for the quasi-dc voltages and currents, and uses the calculated quasi-dc currents through transformer windings as inputs to an AC-OPF to calculate the increase in transformer reactive power consumption.
Solves for the quasi-dc voltages and currents, and uses the calculated quasi-dc currents through transformer windings as inputs to an AC-OPF optimal power flow formulation to calculate the increase in transformer reactive power consumption.
`run_ac_gmd_opf_decoupled("test/data/b4gic.m")`


### GIC -> AC-MLS

Solves for the quasi-dc voltages and currents, and uses the calculated quasi-dc currents through transformer windings as inputs to an AC-MLS minimum-load-shedding formulation to calculate the increase in transformer reactive power consumption. The network topology is fixed.
`run_ac_gmd_mls("test/data/case24_ieee_rts_0.m")`


### GIC + AC-MLS

Solves the quasi-dc voltages and currents and the AC-MLS minimum-load-shedding formulation concurrently. The network topology is fixed.
`run_ac_gmd_mls_decoupled("test/data/case24_ieee_rts_0.m")`


<!--
### GIC + AC-OPF
Expand All @@ -99,12 +113,6 @@ This formulation has limitations in that it does not model increase in transform
Additionally, it may report higher reactive power consumption than reality on account of relaxing the "effective" transformer quasi-dc winding current magnitude.
### GIC + AC-MLS
Solve the minimum-load shedding problem for a network subjected to GIC with fixed topology.
`run_ac_gmd_ml("test/data/case24_ieee_rts_0.m")`
### GIC + AC-OTS
Solve the minimum-load shedding problem for a network subjected to GIC where lines and transformers can be opened or closed.
Expand Down Expand Up @@ -238,25 +246,26 @@ mpc.bus_gmd = {



## Contributors
## Acknowledgments

This code has been developed as part of the [Advanced Network Science Initiative](https://github.com/lanl-ansi) at Los Alamos National Laboratory.
The primary developers are [Arthur Barnes](https://github.com/bluejuniper) and [Adam Mate](https://github.com/adammate) with significant contributions from:
* [Russell Bent](https://github.com/rb004f)
* [Carleton Coffrin](https://github.com/ccoffrin)
* [David Fobes](https://github.com/pseudocubic)

In alphabetical order:
* Art Barnes (@bluejuniper): Decoupled model
* Russell Bent (@rb004f): ML and OTS implementation
* Carleton Coffrin (@ccoffrin): Architecture
* David Fobes (@pseudocubic): Architecture
* Adam Mate (@adammate): Decoupled time-extended model, [RTS-GMLC](https://github.com/GridMod/RTS-GMLC) integration
Special thanks to Mowen Lu for developing the ML and OTS problem specifications, and to Michael Rivera for a reference implementation of the Latingen-Pijirola matrix solver.

Acknowledgments:
The authors are grateful for Mowen Lu for developing the ML and OTS problem specifications, and for Michael Rivera for a reference implementation of the Latingen-Pijirola matrix solver.

This code has been developed as part of the Advanced Network Science Initiative at Los Alamos National Laboratory.
### Development

Community-driven development and enhancement of PMsGMD are welcome and encouraged.
Please feel free to fork this repository and share your contributions to the master branch with a pull request.


## Citing PMsGMD
### Citing PMsGMD

If you find PMsGMD useful in your work, we request that you cite the following [publication](https://arxiv.org/abs/2101.05042):
If you find PMsGMD useful in your work, we kindly request that you cite the following [publication](https://arxiv.org/abs/2101.05042):
```
@Misc{pmsgmd,
author = {A. {Mate} and A. K. {Barnes} and R. W. {Bent} and E. {Cotilla-Sanchez}},
Expand All @@ -275,6 +284,4 @@ If you find PMsGMD useful in your work, we request that you cite the following [

## License

This code is provided under a BSD license as part of the Multi-Infrastructure Control and Optimization Toolkit (MICOT) project, LA-CC-13-108.


This code is provided under a [BSD license](https://github.com/lanl-ansi/PowerModelsGMD.jl/blob/master/LICENSE.md) as part of the Multi-Infrastructure Control and Optimization Toolkit (MICOT) project, LA-CC-13-108.
6 changes: 4 additions & 2 deletions src/PowerModelsGMD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const _PMGMD = PowerModelsGMD

# Suppresses information and warning messages:
function silence()
Memento.info(_LOGGER, "Suppressing information and warning messages for the rest of this session. Use the Memento package for more fine-grained control of logging.")
Memento.info(_LOGGER, "Suppressing information and warning messages for the rest of this session.
Use the Memento package for more fine-grained control of logging.")
Memento.setlevel!(Memento.getlogger(_IM), "error")
Memento.setlevel!(Memento.getlogger(_PM), "error")
Memento.setlevel!(Memento.getlogger(_PMGMD), "error")
Expand All @@ -44,8 +45,9 @@ const _PMGMD = PowerModelsGMD
include("form/dcp.jl")
include("form/wr.jl")

# include("prob/gmd_ls.jl")
# include("prob/gmd_matrix.jl")
include("prob/gmd_mls_decoupled.jl")
include("prob/gmd_mls.jl")
# #include("prob/gmd_msse_decoupled.jl")
include("prob/gmd_opf_decoupled.jl")
# include("prob/gmd_opf_ts_decoupled.jl")
Expand Down
25 changes: 13 additions & 12 deletions src/core/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function constraint_dc_power_balance_shunt(pm::_PM.AbstractPowerModel, n::Int, i
if (JuMP.lower_bound(v_dc) > 0 || JuMP.upper_bound(v_dc) < 0)
println("WARNING")
println("DC voltage cannot go to 0. This could make the DC power balance constraint overly constrained in switching applications.")
println()
end

JuMP.@constraint(pm.model, sum(dc_expr[a] for a in gmd_bus_arcs) == (gs * v_dc))
Expand Down Expand Up @@ -242,7 +243,7 @@ end


"CONSTRAINT: computing qloss"
function constraint_zero_qloss(pm::_PM.AbstractPowerModel, n::Int, k, i::Int, j)
function constraint_zero_qloss(pm::_PM.AbstractPowerModel, n::Int, k, i, j)

qloss = _PM.var(pm, n, :qloss)

Expand All @@ -253,10 +254,10 @@ end


"CONSTRAINT: computing qloss assuming ac primary voltage is 1.0 per unit"
function constraint_qloss_vnom(pm::_PM.AbstractPowerModel, n::Int, k, i::Int, j, K, branchMVA)
function constraint_qloss_vnom(pm::_PM.AbstractPowerModel, n::Int, k, i, j, K, branchMVA)

i_dc_mag = _PM.var(pm, n, :i_dc_mag)[k]
qloss = _PM.var(pm, n, :qloss)
i_dc_mag = _PM.var(pm, n, :i_dc_mag)[k]

JuMP.@constraint(pm.model, qloss[(k,i,j)] == ((K * i_dc_mag) / (3.0 * branchMVA))) # 'K' is per phase
JuMP.@constraint(pm.model, qloss[(k,j,i)] == 0.0)
Expand Down Expand Up @@ -325,7 +326,7 @@ end


"CONSTRAINT: steady-state temperature"
function constraint_temperature_steady_state(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi, rate_a, delta_oil_rated)
function constraint_temperature_steady_state(pm::_PM.AbstractPowerModel, n::Int, i, fi, rate_a, delta_oil_rated)
# i is index of the (transformer) branch
# fi is index of the "from" branch terminal

Expand All @@ -341,7 +342,7 @@ end


"CONSTRAINT: steady-state temperature"
function constraint_temperature_steady_state(pm::_PM.AbstractDCPModel, n::Int, i::Int, fi, rate_a, delta_oil_rated)
function constraint_temperature_steady_state(pm::_PM.AbstractDCPModel, n::Int, i, fi, rate_a, delta_oil_rated)
# i is index of the (transformer) branch
# fi is index of the "from" branch terminal

Expand All @@ -356,7 +357,7 @@ end


"CONSTRAINT: initial temperature state"
function constraint_temperature_state_initial(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi)
function constraint_temperature_state_initial(pm::_PM.AbstractPowerModel, n::Int, i, fi)
# i is index of the (transformer) branch
# fi is index of the "from" branch terminal

Expand All @@ -369,7 +370,7 @@ end


"CONSTRAINT: initial temperature state"
function constraint_temperature_state_initial(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi, delta_oil_init)
function constraint_temperature_state_initial(pm::_PM.AbstractPowerModel, n::Int, i, fi, delta_oil_init)
# i is index of the (transformer) branch
# fi is index of the "from" branch terminal

Expand All @@ -380,7 +381,7 @@ end


"CONSTRAINT: temperature state"
function constraint_temperature_state(pm::_PM.AbstractPowerModel, n_1::Int, n_2::Int, i::Int, tau)
function constraint_temperature_state(pm::_PM.AbstractPowerModel, n_1::Int, n_2::Int, i, tau)

delta_oil_ss = var(pm, n_2, :ross, i)
delta_oil_ss_prev = var(pm, n_1, :ross, i)
Expand All @@ -394,7 +395,7 @@ end


"CONSTRAINT: steady-state hot-spot temperature"
function constraint_hotspot_temperature_steady_state(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi, rate_a, Re)
function constraint_hotspot_temperature_steady_state(pm::_PM.AbstractPowerModel, n::Int, i, fi, rate_a, Re)
# return delta_oil_rated*K^2
# println("Branch $i rating: $rate_a, TO rise: $delta_oil_rated")

Expand All @@ -407,7 +408,7 @@ end


"CONSTRAINT: hot-spot temperature"
function constraint_hotspot_temperature(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi)
function constraint_hotspot_temperature(pm::_PM.AbstractPowerModel, n::Int, i, fi)

delta_hotspot_ss = _PM.var(pm, n, :hsss, i)
delta_hotspot = _PM.var(pm, n, :hs, i)
Expand All @@ -418,7 +419,7 @@ end


"CONSTRAINT: absolute hot-spot temperature"
function constraint_absolute_hotspot_temperature(pm::_PM.AbstractPowerModel, n::Int, i::Int, fi, temp_ambient)
function constraint_absolute_hotspot_temperature(pm::_PM.AbstractPowerModel, n::Int, i, fi, temp_ambient)

delta_hotspot = _PM.var(pm, n, :hs, i)
#delta_hotspot = _PM.var(pm, n, :hsss, i)
Expand All @@ -430,7 +431,7 @@ end


"CONSTRAINT: average absolute hot-spot temperature"
function constraint_avg_absolute_hotspot_temperature(pm::_PM.AbstractPowerModel, i::Int, fi, max_temp)
function constraint_avg_absolute_hotspot_temperature(pm::_PM.AbstractPowerModel, i, fi, max_temp)

N = length(_PM.nws(pm))

Expand Down
4 changes: 2 additions & 2 deletions src/core/constraint_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function constraint_power_balance_shunt_gmd(pm::_PM.AbstractPowerModel, i::Int;


"CONSTRAINT: power balance with shunts for load shedding"
function constraint_power_balance_shunt_gmd_ls(pm::_PM.AbstractPowerModel, i::Int; nw::Int=nw_id_default)
function constraint_power_balance_shunt_gmd_mls(pm::_PM.AbstractPowerModel, i::Int; nw::Int=nw_id_default)

bus = _PM.ref(pm, nw, :bus, i)
bus_arcs = _PM.ref(pm, nw, :bus_arcs, i)
Expand All @@ -55,7 +55,7 @@ function constraint_power_balance_shunt_gmd_ls(pm::_PM.AbstractPowerModel, i::In
bus_gs = Dict(k => _PM.ref(pm, nw, :shunt, k, "gs") for k in bus_shunts)
bus_bs = Dict(k => _PM.ref(pm, nw, :shunt, k, "bs") for k in bus_shunts)

constraint_power_balance_shunt_gmd_ls(pm, nw, i, bus_arcs, bus_arcs_dc, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)
constraint_power_balance_shunt_gmd_mls(pm, nw, i, bus_arcs, bus_arcs_dc, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs)

end

Expand Down
4 changes: 2 additions & 2 deletions src/core/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end


"OBJECTIVE: minimizes load shedding and fuel cost"
function objective_gmd_min_ls(pm::_PM.AbstractPowerModel)
function objective_gmd_min_mls(pm::_PM.AbstractPowerModel)

@assert all(!_PM.ismulticonductor(pm) for n in _PM.nws(pm))

Expand All @@ -85,7 +85,7 @@ end


"OBJECTIVE: minimizes load shedding and fuel cost"
function objective_gmd_min_ls_on_off(pm::_PM.AbstractPowerModel)
function objective_gmd_mls_on_off(pm::_PM.AbstractPowerModel)

@assert all(!_PM.ismulticonductor(pm) for n in _PM.nws(pm))

Expand Down
Loading

0 comments on commit 7fe3c44

Please sign in to comment.