dclee131 / PowerFlowCVXRS

Solving Optimal Power Flow with Convex Restriction
MIT License
21 stars 9 forks source link

Phase-shifted power flow eqn not supported #2

Open dclee131 opened 4 years ago

dclee131 commented 4 years ago

Future release will include phase-shifted power flow described in the original paper.

bmmddzgj commented 1 year ago

@dclee131 When I run the following code block, there is an error.

## Initialize OPF
network_data=opf_initialization(network_data, 0.05)

## Set participation factor
[network_data["gen"][i]["ptc_factor"] = Int(network_data["bus"][string(gen["gen_bus"])]["bus_type"]==3) for (i,gen) in network_data["gen"]]

network_data=runpf(network_data)
println("Initial OPF objective solution: ",round(network_data["cost"],digits=2))

max_iter_SCRS = 10
network_data, result_cvxr = scrs(network_data, max_iter_SCRS); # run sequential convex restriction
{
    "name": "MethodError",
    "message": "MethodError: no method matching zero(::Type{Vector{AffExpr}})

Closest candidates are:
  zero(!Matched::Union{Type{P}, P}) where P<:Dates.Period
   @ Dates C:\\Users\\MNRG\\AppData\\Local\\Programs\\Julia-1.9.3\\share\\julia\\stdlib\\v1.9\\Dates\\src\\periods.jl:51
  zero(!Matched::GenericQuadExpr)
   @ JuMP C:\\Users\\MNRG\\.julia\\packages\\JuMP\\mvUVO\\src\\quad_expr.jl:115
  zero(!Matched::ForwardDiff.Dual)
   @ ForwardDiff C:\\Users\\MNRG\\.julia\\packages\\ForwardDiff\\PcZ48\\src\\dual.jl:357
  ...
",
    "stack": "MethodError: no method matching zero(::Type{Vector{AffExpr}})

Closest candidates are:
  zero(!Matched::Union{Type{P}, P}) where P<:Dates.Period
   @ Dates C:\\Users\\MNRG\\AppData\\Local\\Programs\\Julia-1.9.3\\share\\julia\\stdlib\\v1.9\\Dates\\src\\periods.jl:51
  zero(!Matched::GenericQuadExpr)
   @ JuMP C:\\Users\\MNRG\\.julia\\packages\\JuMP\\mvUVO\\src\\quad_expr.jl:115
  zero(!Matched::ForwardDiff.Dual)
   @ ForwardDiff C:\\Users\\MNRG\\.julia\\packages\\ForwardDiff\\PcZ48\\src\\dual.jl:357
  ...

Stacktrace:
  [1] _instantiate_zero(#unused#::Type{Vector{AffExpr}})
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:28
  [2] promote_operation_fallback(op::typeof(+), #unused#::Type{Vector{AffExpr}}, #unused#::Type{VariableRef})
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:51
  [3] promote_operation(::typeof(+), ::Type, ::Type)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:113
  [4] promote_operation_fallback(op::typeof(MutableArithmetics.add_mul), T::Type, args::Type)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:99
  [5] promote_operation(::typeof(MutableArithmetics.add_mul), ::Type, ::Type)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:113
  [6] mutability(::Type, ::Function, ::Type, ::Type)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:266
  [7] mutability(::Vector{AffExpr}, ::Function, ::Vector{AffExpr}, ::VariableRef)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\interface.jl:274
  [8] operate!!(op::typeof(MutableArithmetics.add_mul), x::Vector{AffExpr}, args::VariableRef)
    @ MutableArithmetics C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\rewrite.jl:93
  [9] macro expansion
    @ C:\\Users\\MNRG\\.julia\\packages\\MutableArithmetics\\cnvbo\\src\\rewrite.jl:326 [inlined]
 [10] macro expansion
    @ C:\\Users\\MNRG\\.julia\\packages\\JuMP\\mvUVO\\src\\macros.jl:1080 [inlined]
 [11] cvxrs(network_data::Dict{String, Any}, option::String, target_network_data::Nothing, phase_shift::Bool)
    @ Main c:\\Users\\MNRG\\Desktop\\PowerFlowCVXRS-master\\src\\main.jl:608
 [12] scrs(network_data::Dict{String, Any}, max_iter_SCRS::Int64, phase_shift::Bool)
    @ Main c:\\Users\\MNRG\\Desktop\\PowerFlowCVXRS-master\\src\\main.jl:824
 [13] scrs(network_data::Dict{String, Any}, max_iter_SCRS::Int64)
    @ Main c:\\Users\\MNRG\\Desktop\\PowerFlowCVXRS-master\\src\\main.jl:814
 [14] top-level scope
    @ c:\\Users\\MNRG\\Desktop\\PowerFlowCVXRS-master\\examples\\example.ipynb:11"
}

Is it because phase_shift is not involved?