Skip to content

Commit 71ee016

Browse files
authored
ADD: linear storage model to be used with all formulations based on a predefined problem specification. (#26)
1 parent 0a915ab commit 71ee016

File tree

8 files changed

+1361
-3
lines changed

8 files changed

+1361
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## staged
44

55
- Updated to use the new `NonlinearExpr` syntax introduced in JuMP v1.15. In most cases, there should be no user-visible changes. `Breaking change`: PowerModels v0.21.2+, PowerModelsDistribution v0.16+, and JuMP v1.23.2+ should be used to support new compatibility (enforced in `Project.toml`). This upgrade signifcantly decreases the time to build large-scale models.
6+
- Added a new problem formulation `opfitd_storage_linear.jl` that removes the complementary_nl constraint by making rs=0 and xs=0, allows the use of a linear storage model for T&D co-optimization using nonlinear formulations.
7+
- Fixed issue with functions in `objective_storage.jl` not transforming correctly the cost.
68

79
## v0.9.2
810

src/PowerModelsITD.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module PowerModelsITD
4848
include("core/objective_dmld_simple.jl")
4949
include("core/objective_storage.jl")
5050
include("core/solution.jl")
51+
include("core/constraint_storage_linear.jl")
5152

5253
include("data_model/transformations.jl")
5354

@@ -67,6 +68,7 @@ module PowerModelsITD
6768
include("prob/opfitd_oltc.jl")
6869
include("prob/opfitd_dmld.jl")
6970
include("prob/opfitd_storage.jl")
71+
include("prob/opfitd_storage_linear.jl")
7072

7173
# This must come last to support automated export.
7274
include("core/export.jl")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
constraint_storage_losses_linear(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
3+
4+
Template function for storage loss constraints for linear model - transmission.
5+
"""
6+
function constraint_storage_losses_linear(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
7+
storage = _PM.ref(pm, nw, :storage, i)
8+
9+
# force storage model to be linear
10+
storage["r"] = 0.0
11+
storage["x"] = 0.0
12+
13+
_PM.constraint_storage_losses(pm, nw, i, storage["storage_bus"], storage["r"], storage["x"], storage["p_loss"], storage["q_loss"])
14+
end
15+
16+
17+
"""
18+
constraint_mc_storage_losses_linear(pm::_PMD.AbstractUnbalancedPowerModel, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
19+
20+
Template function for storage loss constraints for linear model - distribution.
21+
"""
22+
function constraint_mc_storage_losses_linear(pmd::_PMD.AbstractUnbalancedPowerModel, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
23+
storage = _PMD.ref(pmd, nw, :storage, i)
24+
25+
# force storage model to be linear in nonlinear formulations
26+
storage["r"] = 0.0
27+
storage["x"] = 0.0
28+
29+
_PMD.constraint_mc_storage_losses(pmd, nw, i, storage["storage_bus"], storage["connections"], storage["r"], storage["x"], storage["p_loss"], storage["q_loss"])
30+
nothing
31+
end
32+
33+
34+
""
35+
function constraint_mc_storage_losses_linear(pmd::_PMD.AbstractUBFModels, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
36+
_PMD.constraint_mc_storage_losses(pmd, i; nw=nw)
37+
nothing
38+
end

src/core/objective_storage.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function _objective_itd_min_fuel_cost_polynomial_linquad_storage(pmitd::Abstract
125125
for (n, nw_ref) in _PMD.nws(pmd)
126126
for (i, strg) in nw_ref[:storage]
127127
dsch = _PMD.var(pmd, n, :sd, i) # get discharge power value
128-
strg_cost_dollar_per_pu = strg["cost"][1]#*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
128+
strg_cost_dollar_per_pu = strg["cost"][1]*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
129129
strg_cost_dollar_per_pu = round(strg_cost_dollar_per_pu, digits=4)
130130
pmd_strg_cost[(n,i)] = strg_cost_dollar_per_pu*dsch # compute discharge cost
131131
end
@@ -260,7 +260,7 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractPower
260260
for (n, nw_ref) in _PMD.nws(pmd)
261261
for (i, strg) in nw_ref[:storage]
262262
dsch = _PMD.var(pmd, n, :sd, i) # get discharge power value
263-
strg_cost_dollar_per_pu = strg["cost"][1]#*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
263+
strg_cost_dollar_per_pu = strg["cost"][1]*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
264264
strg_cost_dollar_per_pu = round(strg_cost_dollar_per_pu, digits=4)
265265
pmd_strg_cost[(n,i)] = strg_cost_dollar_per_pu*dsch # compute discharge cost
266266
end

0 commit comments

Comments
 (0)