Skip to content

Commit

Permalink
Merge pull request #75 from Electa-Git/IVR-OPF
Browse files Browse the repository at this point in the history
Includes IVR OPF
  • Loading branch information
hakanergun authored Feb 17, 2022
2 parents b07b61b + 51c331c commit 15004a5
Show file tree
Hide file tree
Showing 9 changed files with 713 additions and 2 deletions.
2 changes: 0 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ The latest stable release of PowerModelACDC can be installed using the Julia pac
```julia
Pkg.add("PowerModelsACDC")
```
The current version of PowerModelsACDC is 0.3.2 and is compatible with PowerModels v0.17.2, InfrastrucureModels v0.5.3

!!! Important
This is a research-grade optimization package.

Expand Down
3 changes: 3 additions & 0 deletions src/PowerModelsACDC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ __init__() = Memento.register(_LOGGER)
include("prob/acdcopf.jl")
include("prob/acdcpf.jl")
include("prob/acdcopf_bf.jl")
include("prob/acdcopf_iv.jl")
include("prob/tnepopf.jl")
include("prob/acdctnepopf.jl")
include("prob/tnepopf_bf.jl")
Expand Down Expand Up @@ -52,6 +53,7 @@ include("formdcgrid/wrm.jl")
include("formdcgrid/bf.jl")
include("formdcgrid/lpac.jl")
include("formdcgrid/shared.jl")
include("formdcgrid/iv.jl")

include("formconv/acp.jl")
include("formconv/dcp.jl")
Expand All @@ -60,6 +62,7 @@ include("formconv/wrm.jl")
include("formconv/bf.jl")
include("formconv/lpac.jl")
include("formconv/shared.jl")
include("formconv/iv.jl")

include("core/constraint_template.jl")
include("io/multinetwork.jl")
Expand Down
47 changes: 47 additions & 0 deletions src/core/constraint_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,38 @@ function constraint_power_balance_ac(pm::_PM.AbstractPowerModel, i::Int; nw::Int
constraint_power_balance_ac(pm, nw, i, bus_arcs, bus_arcs_dc, bus_gens, bus_convs_ac, bus_loads, bus_shunts, pd, qd, gs, bs)
end

function constraint_current_balance_ac(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
bus = _PM.ref(pm, nw, :bus, i)
bus_arcs = _PM.ref(pm, nw, :bus_arcs, i)
bus_arcs_dc = _PM.ref(pm, nw, :bus_arcs_dc, i)
bus_gens = _PM.ref(pm, nw, :bus_gens, i)
bus_convs_ac = _PM.ref(pm, nw, :bus_convs_ac, i)
bus_loads = _PM.ref(pm, nw, :bus_loads, i)
bus_shunts = _PM.ref(pm, nw, :bus_shunts, i)

pd = Dict(k => _PM.ref(pm, nw, :load, k, "pd") for k in bus_loads)
qd = Dict(k => _PM.ref(pm, nw, :load, k, "qd") for k in bus_loads)

gs = Dict(k => _PM.ref(pm, nw, :shunt, k, "gs") for k in bus_shunts)
bs = Dict(k => _PM.ref(pm, nw, :shunt, k, "bs") for k in bus_shunts)

constraint_current_balance_ac(pm, nw, i, bus_arcs, bus_arcs_dc, bus_gens, bus_convs_ac, bus_loads, bus_shunts, pd, qd, gs, bs)
end

function constraint_power_balance_dc(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
bus_arcs_dcgrid = _PM.ref(pm, nw, :bus_arcs_dcgrid, i)
bus_convs_dc = _PM.ref(pm, nw, :bus_convs_dc, i)
pd = _PM.ref(pm, nw, :busdc, i)["Pdc"]
constraint_power_balance_dc(pm, nw, i, bus_arcs_dcgrid, bus_convs_dc, pd)
end

function constraint_current_balance_dc(pm::_PM.AbstractIVRModel, i::Int; nw::Int=_PM.nw_id_default)
bus_arcs_dcgrid = _PM.ref(pm, nw, :bus_arcs_dcgrid, i)
bus_convs_dc = _PM.ref(pm, nw, :bus_convs_dc, i)
pd = _PM.ref(pm, nw, :busdc, i)["Pdc"]
constraint_current_balance_dc(pm, nw, bus_arcs_dcgrid, bus_convs_dc, pd)
end

#
function constraint_ohms_dc_branch(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
branch = _PM.ref(pm, nw, :branchdc, i)
Expand Down Expand Up @@ -271,3 +297,24 @@ function constraint_conv_firing_angle_ne(pm::_PM.AbstractPowerModel, i::Int; nw:
Q2 = sin(pi) * S
constraint_conv_firing_angle_ne(pm, n, i, S, P1, Q1, P2, Q2)
end


function constraint_converter_limits(pm::_PM.AbstractIVRModel, i::Int; nw::Int=_PM.nw_id_default)
bigM = 1.1;
vpu = 1;
conv = _PM.ref(pm, nw, :convdc, i)
# pmax = conv["Pacrated"]
# pmin = -conv["Pacrated"]
# qmax = conv["Qacrated"]
# qmin = -conv["Qacrated"]
# pmaxdc = conv["Pacrated"] * bigM
# pmindc = -conv["Pacrated"] * bigM
imax = conv["Pacrated"]/vpu
vmax = conv["Vmmax"]
vmin = conv["Vmmin"]
pdcmin = -conv["Pacrated"] * bigM # to account for losses
pdcmax = conv["Pacrated"] * bigM # to account for losses
b_idx = conv["busdc_i"]

constraint_converter_limits(pm, nw, i, imax, vmax, vmin, b_idx, pdcmin, pdcmax)
end
Loading

2 comments on commit 15004a5

@hakanergun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/54844

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" 15004a5bd9a0cd99f87d844518d3b08abf6b6290
git push origin v0.5.2

Please sign in to comment.