PowerModelsDistribution.jl icon indicating copy to clipboard operation
PowerModelsDistribution.jl copied to clipboard

[BUG] Errors in "Extending PowerModelsDistribution.jl " tutorial

Open John-Boik opened this issue 1 year ago • 1 comments

The tutorial Extending PowerModelsDistribution.jl throws an error towards the end, in this block:

for k in K, l in 1:length(data_eng["load"])
		bus_id = data_eng["load"]["load$l"]["bus"]
		bus_ind = data_math_mn["bus_lookup"][bus_id]   # <--- error here
		sol_bus = sol_eng["nw"]["$k"]["bus"][bus_id]
		data_bus = data_eng["bus"][bus_id]
		vbase = data_math_mn["nw"]["$k"]["bus"]["$bus_ind"]["vbase"]
		phase = data_eng["load"]["load$l"]["connections"][1]
		ind = findfirst(data_bus["terminals"].==phase)
		vm_pu_lk[l,k] = abs(sol_bus["vr"][ind]+im*sol_bus["vi"][ind])/vbase
	end

The error is: KeyError: key "34" not found The error line is indicated above. As an aside, the next two lines do not throw an error:

sol_bus = sol_eng["nw"]["$k"]["bus"][bus_id]
data_bus = data_eng["bus"][bus_id]

The data_math_mn["bus_lookup"] has 10 elements that look like so:

  "8"  => Dict("101"=>1, "475"=>2, "619"=>3, "505"=>4, "332"=>5, "817"=>6, "453"=>7, "289"=>8, "596"=>9, "387"=>10…)
  "4"  => Dict("101"=>1, "475"=>2, "619"=>3, "505"=>4, "332"=>5, "817"=>6, "453"=>7, "289"=>8, "596"=>9, "387"=>10…)

Key "34" is not one of them. The data_eng["load"] has 55 elements that look like so:

  "load34" => Dict{String, Any}("model"=>POWER, "connections"=>[1, 4], "pd_nom"=>[0.701], "bus"=>"629", "configuration"…
  "load33" => Dict{String, Any}("model"=>POWER, "connections"=>[3, 4], "pd_nom"=>[9.584], "bus"=>"619", "configuration"…
  "load2"  => Dict{String, Any}("model"=>POWER, "connections"=>[2, 4], "pd_nom"=>[0.694], "bus"=>"47", "configuration"=…
  "load47" => Dict{String, Any}("model"=>POWER, "connections"=>[3, 4], "pd_nom"=>[0.045], "bus"=>"835", "configuration"…

The data_eng["load"]["load34"] looks like so:

Dict{String, Any} with 11 entries:
  "model"         => POWER
  "connections"   => [1, 4]
  "pd_nom"        => [0.701]
  "bus"           => "629"
  "configuration" => WYE
  "status"        => ENABLED
  "time_series"   => Dict("qd_nom"=>"normalized_load_profile", "pd_nom"=>"normalized_load_profile")
  "source_id"     => "load.load34"
  "vm_nom"        => 0.23
  "dispatchable"  => NO
  "qd_nom"        => [0.230408]

Can anyone suggest why the two problems would have a different set of buses for terminals that have loads? I'm using PowerModelsDistribution v0.15.1.

John-Boik avatar Feb 10 '24 19:02 John-Boik