Skip to content

Commit

Permalink
Merge pull request #34 from lanl-ansi/pms-v12
Browse files Browse the repository at this point in the history
Updates for PowerModels v0.12
  • Loading branch information
ccoffrin authored Jun 13, 2019
2 parents d0506ae + 311f57c commit 66d6622
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PowerModels]]
deps = ["InfrastructureModels", "JSON", "JuMP", "LinearAlgebra", "MathOptInterface", "Memento", "SparseArrays"]
git-tree-sha1 = "74d51121ad6fdf2fd1dc06403e2855dac1b8e192"
git-tree-sha1 = "0fcfcd19dbad6710d0f18bd4ae49a98a398c7b6c"
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
version = "0.11.2"
version = "0.12.0"

[[Printf]]
deps = ["Unicode"]
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "GasPowerModels"
uuid = "1fcaf345-95e3-5b8b-91d6-2145eb844b9d"
authors = ["Russell Bent"]
repo = "https://github.com/lanl-ansi/GasPowerModels.jl"
version = "0.1.0"
version = "0.1.1"

[deps]
GasModels = "5e113713-6c35-5477-b766-e1109486666f"
Expand All @@ -13,10 +13,10 @@ Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"

[compat]
JSON = ">= 0.18"
GasModels = "~0.4"
InfrastructureModels = "~0.2"
PowerModels = "~0.11"
JSON = ">= 0.18"
PowerModels = "~0.12"
julia = "^1"

[extras]
Expand Down
14 changes: 7 additions & 7 deletions docs/src/specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ GasModels.variable_production_mass_flow(gm)

### Constraints
```julia
PowerModels.constraint_voltage(pm)
PowerModels.constraint_model_voltage(pm)

for i in PowerModels.ids(pm, :ref_buses)
PowerModels.constraint_theta_ref(pm, i)
PowerModels.constraint_voltage_magnitude_setpoint(pm, i)
end

for i in PowerModels.ids(pm, :bus)
PowerModels.constraint_kcl_shunt(pm, i)
PowerModels.constraint_power_balance_shunt(pm, i)
if length(ref(pm, :bus_gens, i)) > 0 && !(i in ids(pm,:ref_buses))
PowerModels.constraint_voltage_magnitude_setpoint(pm, i)
for j in ref(pm, :bus_gens, i)
Expand Down Expand Up @@ -103,8 +103,8 @@ PowerModels.variable_generation(pm)
PowerModels.variable_branch_flow(pm)
PowerModels.variable_dcline_flow(pm)
PowerModels.variable_branch_flow_ne(pm)
PowerModels.constraint_voltage(pm)
PowerModels.constraint_voltage_ne(pm)
PowerModels.constraint_model_voltage(pm)
PowerModels.constraint_model_voltage_ne(pm)

GasModels.variable_flow(gm)
GasModels.variable_pressure_sqr(gm)
Expand All @@ -118,15 +118,15 @@ GasModels.variable_flow_ne(gm)

### Constraints
```julia
PowerModels.constraint_voltage(pm)
PowerModels.constraint_voltage_ne(pm)
PowerModels.constraint_model_voltage(pm)
PowerModels.constraint_model_voltage_ne(pm)

for i in ids(pm, :ref_buses)
PowerModels.constraint_theta_ref(pm, i)
end

for i in ids(pm, :bus)
PowerModels.constraint_kcl_shunt_ne(pm, i)
PowerModels.constraint_power_balance_shunt_ne(pm, i)
end

for i in ids(pm, :branch)
Expand Down
2 changes: 1 addition & 1 deletion src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
""
function build_generic_model(pdata::Dict{String,Any}, gdata::Dict{String,Any}, power_model_constructor, gas_model_constructor, post_method; power_ref_extensions=[], multinetwork=false, multiconductor=false, kwargs...)
gm = GasModels.build_generic_model(gdata, gas_model_constructor, empty_post_method; multinetwork=multinetwork, kwargs...)
pm = PowerModels.build_generic_model(pdata, power_model_constructor, empty_post_method; ref_extensions=power_ref_extensions, multinetwork=multinetwork, multiconductor=multiconductor)
pm = PowerModels.build_model(pdata, power_model_constructor, empty_post_method; ref_extensions=power_ref_extensions, multinetwork=multinetwork, multiconductor=multiconductor)

add_junction_generators(pm, gm)

Expand Down
6 changes: 3 additions & 3 deletions src/core/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ end

function get_solution(pm::GenericPowerModel, gm::GenericGasModel)
sol = Dict{AbstractString,Any}()
PowerModels.add_bus_voltage_setpoint(sol, pm)
PowerModels.add_generator_power_setpoint(sol, pm)
PowerModels.add_branch_flow_setpoint(sol, pm)
PowerModels.add_setpoint_bus_voltage!(sol, pm)
PowerModels.add_setpoint_generator_power!(sol, pm)
PowerModels.add_setpoint_branch_flow!(sol, pm)
GasModels.add_junction_pressure_setpoint(sol, gm)
return sol
end
Expand Down
4 changes: 2 additions & 2 deletions src/prob/gpf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ function post_gpf(pm::GenericPowerModel)
PowerModels.variable_branch_flow(pm, bounded = false)
PowerModels.variable_dcline_flow(pm, bounded = false)

PowerModels.constraint_voltage(pm)
PowerModels.constraint_model_voltage(pm)

for i in PowerModels.ids(pm, :ref_buses)
PowerModels.constraint_theta_ref(pm, i)
PowerModels.constraint_voltage_magnitude_setpoint(pm, i)
end

for i in PowerModels.ids(pm, :bus)
PowerModels.constraint_kcl_shunt(pm, i)
PowerModels.constraint_power_balance_shunt(pm, i)

# PV Bus Constraints
if length(ref(pm, :bus_gens, i)) > 0 && !(i in ids(pm,:ref_buses))
Expand Down
17 changes: 9 additions & 8 deletions src/prob/ne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export run_ne_popf

" entry point for running gas and electric power expansion planning only "
function run_ne(power_file, gas_file, power_model_constructor, gas_model_constructor, solver; solution_builder=get_ne_solution, kwargs...)
return run_generic_model(power_file, gas_file, power_model_constructor, gas_model_constructor, solver, post_ne; power_ref_extensions=[PowerModels.on_off_va_bounds_ref!,PowerModels.ne_branch_ref!], solution_builder=solution_builder, kwargs...)
return run_generic_model(power_file, gas_file, power_model_constructor, gas_model_constructor, solver, post_ne; power_ref_extensions=[PowerModels.ref_add_on_off_va_bounds!,PowerModels.ref_add_ne_branch!], solution_builder=solution_builder, kwargs...)
end

"Post all the constraints associated with expansion planning in electric power"
Expand All @@ -17,15 +17,15 @@ function post_tnep(pm::GenericPowerModel)
PowerModels.variable_dcline_flow(pm) # DC line flows. Not used in TPS paper
PowerModels.variable_branch_flow_ne(pm) # variable p,q in the TPS paper

PowerModels.constraint_voltage(pm) # adds upper and lower bounds on voltage and voltage squared, constraint 11 in TPS paper
PowerModels.constraint_voltage_ne(pm) # adds upper and lower bounds on voltage and voltage squared, constraint 11 in TPS paper
PowerModels.constraint_model_voltage(pm) # adds upper and lower bounds on voltage and voltage squared, constraint 11 in TPS paper
PowerModels.constraint_model_voltage_ne(pm) # adds upper and lower bounds on voltage and voltage squared, constraint 11 in TPS paper

for i in ids(pm, :ref_buses)
PowerModels.constraint_theta_ref(pm, i) # sets the reference bus phase angle to 0 (not explictly stated in TPS paper)
end

for i in ids(pm, :bus)
PowerModels.constraint_kcl_shunt_ne(pm, i) # Kirchoff's laws (constraints 1 and 2 in TPS paper)
PowerModels.constraint_power_balance_shunt_ne(pm, i) # Kirchoff's laws (constraints 1 and 2 in TPS paper)
end

for i in ids(pm, :branch)
Expand Down Expand Up @@ -123,9 +123,9 @@ end

function get_ne_solution(pm::GenericPowerModel, gm::GenericGasModel)
sol = Dict{AbstractString,Any}()
PowerModels.add_bus_voltage_setpoint(sol, pm)
PowerModels.add_generator_power_setpoint(sol, pm)
PowerModels.add_branch_flow_setpoint(sol, pm)
PowerModels.add_setpoint_bus_voltage!(sol, pm)
PowerModels.add_setpoint_generator_power!(sol, pm)
PowerModels.add_setpoint_branch_flow!(sol, pm)
GasModels.add_junction_pressure_setpoint(sol, gm)
GasModels.add_connection_ne(sol, gm)
GasModels.add_load_mass_flow_setpoint(sol, gm)
Expand All @@ -135,6 +135,7 @@ function get_ne_solution(pm::GenericPowerModel, gm::GenericGasModel)
GasModels.add_direction_setpoint(sol, gm)
GasModels.add_direction_ne_setpoint(sol,gm)
GasModels.add_valve_setpoint(sol, gm)
PowerModels.add_branch_ne_setpoint(sol, pm)
PowerModels.add_setpoint_branch_ne_flow!(sol, pm)
PowerModels.add_setpoint_branch_ne_built!(sol, pm)
return sol
end
11 changes: 6 additions & 5 deletions src/prob/neopf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

" entry point for running gas and electric power expansion planning with demand-based pricing and a pressure penalty (in TPS paper) "
function run_ne_opf(power_file, gas_file, power_model_constructor, gas_model_constructor, solver; solution_builder=get_ne_opf_solution, kwargs...)
return run_generic_model(power_file, gas_file, power_model_constructor, gas_model_constructor, solver, post_ne_opf; power_ref_extensions=[PowerModels.on_off_va_bounds_ref!,PowerModels.ne_branch_ref!], solution_builder=solution_builder, kwargs...)
return run_generic_model(power_file, gas_file, power_model_constructor, gas_model_constructor, solver, post_ne_opf; power_ref_extensions=[PowerModels.ref_add_on_off_va_bounds!,PowerModels.ref_add_ne_branch!], solution_builder=solution_builder, kwargs...)
end

" Construct the gas flow feasbility problem with demand being the cost model"
Expand Down Expand Up @@ -30,9 +30,9 @@ end

function get_ne_opf_solution(pm::GenericPowerModel, gm::GenericGasModel)
sol = Dict{AbstractString,Any}()
PowerModels.add_bus_voltage_setpoint(sol, pm)
PowerModels.add_generator_power_setpoint(sol, pm)
PowerModels.add_branch_flow_setpoint(sol, pm)
PowerModels.add_setpoint_bus_voltage!(sol, pm)
PowerModels.add_setpoint_generator_power!(sol, pm)
PowerModels.add_setpoint_branch_flow!(sol, pm)
GasModels.add_junction_pressure_setpoint(sol, gm)
GasModels.add_connection_ne(sol, gm)
GasModels.add_load_mass_flow_setpoint(sol, gm)
Expand All @@ -42,7 +42,8 @@ function get_ne_opf_solution(pm::GenericPowerModel, gm::GenericGasModel)
GasModels.add_direction_setpoint(sol, gm)
GasModels.add_direction_ne_setpoint(sol,gm)
GasModels.add_valve_setpoint(sol, gm)
PowerModels.add_branch_ne_setpoint(sol, pm)
PowerModels.add_setpoint_branch_ne_flow!(sol, pm)
PowerModels.add_setpoint_branch_ne_built!(sol, pm)
add_zone_cost_setpoint(sol, gm)
return sol
end
Expand Down

0 comments on commit 66d6622

Please sign in to comment.