Skip to content

Commit

Permalink
ADD: linear storage model to be used with all formulations based on a…
Browse files Browse the repository at this point in the history
… predefined problem specification.
  • Loading branch information
juanjospina committed Sep 19, 2024
1 parent 0a915ab commit f838cb6
Show file tree
Hide file tree
Showing 8 changed files with 1,361 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## staged

- 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.
- 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.
- Fixed issue with functions in `objective_storage.jl` not transforming correctly the cost.

## v0.9.2

Expand Down
2 changes: 2 additions & 0 deletions src/PowerModelsITD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module PowerModelsITD
include("core/objective_dmld_simple.jl")
include("core/objective_storage.jl")
include("core/solution.jl")
include("core/constraint_storage_linear.jl")

include("data_model/transformations.jl")

Expand All @@ -67,6 +68,7 @@ module PowerModelsITD
include("prob/opfitd_oltc.jl")
include("prob/opfitd_dmld.jl")
include("prob/opfitd_storage.jl")
include("prob/opfitd_storage_linear.jl")

# This must come last to support automated export.
include("core/export.jl")
Expand Down
38 changes: 38 additions & 0 deletions src/core/constraint_storage_linear.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
constraint_storage_losses_linear(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
Template function for storage loss constraints for linear model - transmission.
"""
function constraint_storage_losses_linear(pm::_PM.AbstractPowerModel, i::Int; nw::Int=_PM.nw_id_default)
storage = _PM.ref(pm, nw, :storage, i)

# force storage model to be linear
storage["r"] = 0.0
storage["x"] = 0.0

_PM.constraint_storage_losses(pm, nw, i, storage["storage_bus"], storage["r"], storage["x"], storage["p_loss"], storage["q_loss"])
end


"""
constraint_mc_storage_losses_linear(pm::_PMD.AbstractUnbalancedPowerModel, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
Template function for storage loss constraints for linear model - distribution.
"""
function constraint_mc_storage_losses_linear(pmd::_PMD.AbstractUnbalancedPowerModel, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
storage = _PMD.ref(pmd, nw, :storage, i)

# force storage model to be linear in nonlinear formulations
storage["r"] = 0.0
storage["x"] = 0.0

_PMD.constraint_mc_storage_losses(pmd, nw, i, storage["storage_bus"], storage["connections"], storage["r"], storage["x"], storage["p_loss"], storage["q_loss"])
nothing
end


""
function constraint_mc_storage_losses_linear(pmd::_PMD.AbstractUBFModels, i::Int; nw::Int=_PMD.nw_id_default)::Nothing
_PMD.constraint_mc_storage_losses(pmd, i; nw=nw)
nothing
end
4 changes: 2 additions & 2 deletions src/core/objective_storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function _objective_itd_min_fuel_cost_polynomial_linquad_storage(pmitd::Abstract
for (n, nw_ref) in _PMD.nws(pmd)
for (i, strg) in nw_ref[:storage]
dsch = _PMD.var(pmd, n, :sd, i) # get discharge power value
strg_cost_dollar_per_pu = strg["cost"][1]#*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
strg_cost_dollar_per_pu = strg["cost"][1]*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
strg_cost_dollar_per_pu = round(strg_cost_dollar_per_pu, digits=4)
pmd_strg_cost[(n,i)] = strg_cost_dollar_per_pu*dsch # compute discharge cost
end
Expand Down Expand Up @@ -260,7 +260,7 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractPower
for (n, nw_ref) in _PMD.nws(pmd)
for (i, strg) in nw_ref[:storage]
dsch = _PMD.var(pmd, n, :sd, i) # get discharge power value
strg_cost_dollar_per_pu = strg["cost"][1]#*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
strg_cost_dollar_per_pu = strg["cost"][1]*nw_ref[:settings]["sbase_default"] # convert from $/kWh -> $/pu
strg_cost_dollar_per_pu = round(strg_cost_dollar_per_pu, digits=4)
pmd_strg_cost[(n,i)] = strg_cost_dollar_per_pu*dsch # compute discharge cost
end
Expand Down
Loading

0 comments on commit f838cb6

Please sign in to comment.