Skip to content

Commit

Permalink
rm obsolete VariableContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
NLaws committed Aug 25, 2024
1 parent 918538c commit ab44e6f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## dev
- add `multiphase_variable_container` methods for bus and edge variables
- make variable indexing order consistent across single and multiphase models (bus/edge, time, phase)
- make variable indexing order consistent across single and multiphase models (bus/edge, time,
phase)
- rm `VariableContainer`

## v0.4.1
- add codecov to ci
Expand Down
2 changes: 0 additions & 2 deletions src/CommonOPF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const VARIABLE_NAMES = String[
"current_magnitude",
"current_magnitude_squared",
]
VariableContainer = Dict{String, Dict{Int, Any}} # edge/bus String, time step Int, variable(s)

export
dsstxt_to_sparse_array,
Expand Down Expand Up @@ -97,7 +96,6 @@ export

# variables
VARIABLE_NAMES,
VariableContainer,
multiphase_bus_variable_container,
multiphase_edge_variable_container,
add_time_vector_variables!,
Expand Down
10 changes: 5 additions & 5 deletions src/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ time-vector or matrix values. When `var_name` ends with "_squared" we return the
"""
function get_variable_values(model_key, var_name::String, m::JuMP.AbstractModel, net::Network{SinglePhase}; digits=8)
d = Dict()
if var in [:Pj, :Qj, :vsqrd]
if var_name in [:Pj, :Qj, :vsqrd]
vals = value.(m[model_key]) # time, bus
for b in busses(net)
d[b] = round.(vals[b,:].data, digits=digits)
Expand All @@ -55,18 +55,18 @@ function get_variable_values(model_key, var_name::String, m::JuMP.AbstractModel,
d[b] *= net.Sbase # scale powers back to absolute units TODO in BFM
end
end
elseif var in [:Pij, :Qij, :lij] # TODO make these a const in CommonOPF TODO in BFM
vals = value.(m[var])
elseif var_name in [:Pij, :Qij, :lij] # TODO make these a const in CommonOPF TODO in BFM
vals = value.(m[var_name])
for ek in edges(net)
d[ek] = round.(vals[ek,:].data, digits=digits)
if var == :lij
if var_name == :lij
d[ek] = sqrt.(d[ek])
else
d[ek] *= net.Sbase # scale powers back to absolute units
end
end
else
@warn "$var is not a valid variable symbol"
@warn "$var_name is not a valid variable symbol"
end
return d
end
Expand Down
1 change: 0 additions & 1 deletion test/test_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# TODO test Network.var_name_map and VARIABLE_NAMES
# TODO test get_variable_values with vectors and matrices
# TODO test get_variable_values with _squared, after defining containers with CommonOPF.VariableContainer
m = Model()
m.obj_dict[:vsqrd] = Dict("bus1" => [1.123456789])

Expand Down

0 comments on commit ab44e6f

Please sign in to comment.