From 498f8f365f96a445c613cde9488017b5cc6bcd80 Mon Sep 17 00:00:00 2001 From: jtabarez <53569964+jtabarez@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:11:29 -0700 Subject: [PATCH] generators added and lag 2 transformer --- src/core/admittance_matrix.jl | 40 +++ src/data_model/components.jl | 184 ++++++------ src/data_model/eng2math.jl | 4 +- src/io/dss/dss2eng.jl | 46 ++- src/prob/fs copy.jl | 106 ------- src/prob/pf_mc copy.jl | 344 ----------------------- test/data/dist/3Bus_example_EXP_Y.CSV | 13 + test/data/dist/3Bus_example_VLN_Node.Txt | 18 +- test/data/dist/case3_gen_wye.dss | 48 ++++ test/data/dist/ut_trans_EXP_YPRIM.CSV | 48 ---- test/data/dist/ut_trans_VLN_Node.Txt | 18 +- test/test.jl | 6 +- 12 files changed, 265 insertions(+), 610 deletions(-) delete mode 100644 src/prob/fs copy.jl delete mode 100644 src/prob/pf_mc copy.jl create mode 100644 test/data/dist/3Bus_example_EXP_Y.CSV create mode 100644 test/data/dist/case3_gen_wye.dss delete mode 100644 test/data/dist/ut_trans_EXP_YPRIM.CSV diff --git a/src/core/admittance_matrix.jl b/src/core/admittance_matrix.jl index 0e1feff..f715522 100644 --- a/src/core/admittance_matrix.jl +++ b/src/core/admittance_matrix.jl @@ -424,11 +424,39 @@ function build_mc_delta_current_vector(data, v, z_matrix) (n, m) = size(v) delta_i = zeros(Complex{Float64}, n, 1) build_mc_delta_current_load!(delta_i, v, data) + build_mc_delta_current_generator!(delta_i, v, data) build_mc_delta_current_inverter!(delta_i, v, data, z_matrix) return _SP.sparse(delta_i) end +function build_mc_delta_current_generator!(delta_i, v, data) + for (_, gen) in data["gen"] + if occursin("generator", gen["source_id"]) + if gen["gen_model"] == 1 + calc_delta_current_generator!(gen, delta_i, v, data) + end + end + end +end + + +function calc_delta_current_generator!(gen, delta_i, v, data) + bus = gen["gen_bus"] + if occursin("generator", gen["source_id"]) + if gen["gen_model"] == 1 + for (_j, j) in enumerate(gen["connections"]) + if haskey(data["admittance_map"], (bus, j)) + s = -(gen["pg"][_j] + 1im * gen["qg"][_j]) + y = conj(s) / gen["vnom_kv"]^2 / 1000 + delta_i[data["admittance_map"][(bus, j)], 1] += conj(s * data["settings"]["power_scale_factor"] / v[data["admittance_map"][(bus, j)], 1]) - y * v[data["admittance_map"][(bus, j)], 1] + end + end + end + end +end + + function build_mc_delta_current_load!(delta_i, v, data) for (_, load) in data["load"] if load["model"] == _PMD.POWER @@ -565,11 +593,23 @@ end function update_mc_delta_current_vector(model, v) (n, m) = size(v) delta_i = zeros(Complex{Float64}, n, 1) + update_mc_delta_current_generator!(delta_i, v, model.data) update_mc_delta_current_load!(delta_i, v, model.data) return _SP.sparse(delta_i) end +function update_mc_delta_current_generator!(delta_i, v, data) + for (_, gen) in data["gen"] + if occursin("generator", gen["source_id"]) + if gen["gen_model"] == 1 + calc_delta_current_generator!(gen, delta_i, v, data) + end + end + end +end + + function update_mc_delta_current_load!(delta_i, v, data) for (_, load) in data["load"] if data["settings"]["loading"] diff --git a/src/data_model/components.jl b/src/data_model/components.jl index c9e8b2b..a44dfd2 100644 --- a/src/data_model/components.jl +++ b/src/data_model/components.jl @@ -356,11 +356,34 @@ function _map_eng2math_mc_admittance_voltage_source!(data_math::Dict{String,<:An end +function _map_eng2math_mc_admittance_generator!(data_math::Dict{String,<:Any}, data_eng::Dict{String,<:Any}; pass_props::Vector{String}=String[]) + if haskey(data_math, "gen") + for (name, gen) in data_math["gen"] + if occursin("generator", gen["source_id"]) + if gen["gen_model"] == 1 + y = zeros(Complex{Float64}, 4, 4) + for (i, pg) in enumerate(gen["pg"]) + kv = gen["vnom_kv"] + s = -(pg + 1im * gen["qg"][i]) + y_ = conj(s) / kv^2 / 1000 + y[i,i] += y_ + y[i,4] -= y[i,i] + y[4,i] -= y[i,4] + y[4,4] += y[i,i] + end + end + gen["p_matrix"] = y + end + end + end +end + + function _map_eng2math_mc_admittance_solar!(data_math::Dict{String,<:Any}, data_eng::Dict{String,<:Any}; pass_props::Vector{String}=String[]) if haskey(data_math, "gen") for (name, gen) in data_math["gen"] if occursin("solar", gen["source_id"]) - n = length(gen["connections"]) + n = length(gen["connections"]) y = zeros(n, n) if gen["configuration"] == _PMD.WYE for (i, connection) in enumerate(gen["connections"]) @@ -436,90 +459,93 @@ function _map_eng2math_mc_admittance_2w_transformer!(transformer::Dict{String,<: (2,1) => [3,2], (2,2) => [7,4], (2,3) => [11,6] - ) - - if transformer["dss"]["phases"] == 3 - z = sum(transformer["rw"]) + 1im .* transformer["xsc"][1] - z_1volt= z * 3/transformer["sm_nom"][1]/1000 - z_b = [z_1volt 0 0;0 z_1volt 0;0 0 z_1volt] - b = [1 0 0;-1 0 0;0 1 0;0 -1 0;0 0 1;0 0 -1] - y1 = b*inv(z_b)*transpose(b) - n = zeros(Float64, 12, 6) - a = zeros(Int64,8,12) - for w = 1:2 - if transformer["configuration"][w] == _PMD.WYE - w == 1 ? connections = transformer["f_connections"] : connections = transformer["t_connections"] - for (_,k) in enumerate(connections) - if haskey(lookup, (w,k)) - i = lookup[(w,k)][1] - j = lookup[(w,k)][2] - n[i,j] = 1/(transformer["tm_nom"][w]/sqrt(3)*1000*transformer["tm_set"][w][k]) - n[i+1,j] = - n[i,j] - end - end - if w == 1 - a[1,1] = a[2,5] = a[3,9] = a[4,2] = a[4,6] = a[4,10] = 1 - else - a[5,3] = a[6,7] = a[7,11] = a[8,4] = a[8,8] = a[8,12] = 1 - end - elseif transformer["configuration"][w] == _PMD.DELTA - w == 1 ? connections = transformer["f_connections"] : connections = transformer["t_connections"] - for (_,k) in enumerate(connections) - if haskey(lookup, (w,k)) - i = lookup[(w,k)][1] - j = lookup[(w,k)][2] - n[i,j] = 1/(transformer["tm_nom"][w]*1000*transformer["tm_set"][w][k]) - n[i+1,j] = - n[i,j] - end - end - if w == 1 - a[1,1] = a[1,6] = a[2,5] = a[2,10] = a[3,9] = a[3,2] = 1 - else - a[5,3] = a[6,7] = a[7,11] = a[8,4] = a[8,8] = a[8,12] = 1 # wrong - end + ) + if transformer["dss"]["phases"] == 3 + z = sum(transformer["rw"]) + 1im .* transformer["xsc"][1] + z_1volt= z * 3/transformer["sm_nom"][1]/1000 + z_b = [z_1volt 0 0;0 z_1volt 0;0 0 z_1volt] + b = [1 0 0;-1 0 0;0 1 0;0 -1 0;0 0 1;0 0 -1] + y1 = b*inv(z_b)*transpose(b) + n = zeros(Float64, 12, 6) + a = zeros(Int64,8,12) + for w = 1:2 + if transformer["configuration"][w] == _PMD.WYE + w == 1 ? connections = transformer["f_connections"] : connections = transformer["t_connections"] + for (_,k) in enumerate(connections) + if haskey(lookup, (w,k)) + i = lookup[(w,k)][1] + j = lookup[(w,k)][2] + n[i,j] = 1/(transformer["tm_nom"][w]/sqrt(3)*1000*transformer["tm_set"][w][k]) + n[i+1,j] = - n[i,j] end end - y_w = n*y1*transpose(n) - p_matrix = a*y_w*transpose(a) - - ybase = (transformer["sm_nom"][1]/3) / (transformer["tm_nom"][2]*transformer["tm_set"][2][1]/sqrt(3))^2 /1000 - if haskey(transformer["dss"], "%noloadloss") - shunt = (transformer["g_sh"] + 1im * transformer["b_sh"])*ybase - p_matrix[5,5] += shunt - p_matrix[5,8] -= shunt - p_matrix[6,6] += shunt - p_matrix[6,8] -= shunt - p_matrix[7,7] += shunt - p_matrix[7,8] -= shunt - p_matrix[8,5] -= shunt - p_matrix[8,6] -= shunt - p_matrix[8,7] -= shunt - p_matrix[8,8] += 3*shunt + if w == 1 + a[1,1] = a[2,5] = a[3,9] = a[4,2] = a[4,6] = a[4,10] = 1 + else + a[5,3] = a[6,7] = a[7,11] = a[8,4] = a[8,8] = a[8,12] = 1 end - transformer["p_matrix"] = p_matrix - elseif transformer["dss"]["phases"] == 1 - z = sum(transformer["rw"]) + 1im .* transformer["xsc"][1] - z_1volt= z * 1/transformer["sm_nom"][1]/1000 - b = [1 ;-1] - y1 = b*1/z_1volt*transpose(b) - n = zeros(Float64, 4, 2) - a = zeros(Int64,4,4) - for w = 1:2 - if transformer["configuration"][w] == _PMD.WYE - i = lookup[(w,1)][1] - j = lookup[(w,1)][2] - n[i,j] = 1/(transformer["tm_nom"][w]*1000*transformer["tm_set"][w][1]) + elseif transformer["configuration"][w] == _PMD.DELTA + w == 1 ? connections = transformer["f_connections"] : connections = transformer["t_connections"] + for (_,k) in enumerate(connections) + if haskey(lookup, (w,k)) + i = lookup[(w,k)][1] + j = lookup[(w,k)][2] + n[i,j] = 1/(transformer["tm_nom"][w]*1000*transformer["tm_set"][w][k]) n[i+1,j] = - n[i,j] - if w == 1 - a[1,1] = a[2,2] = 1 - else - a[3,3] = a[4,4] = 1 - end end end - y_w = n*y1*transpose(n) - p_matrix = a*y_w*transpose(a) - transformer["p_matrix"] = p_matrix + if w == 1 + if transformer["leadlag"] == "lag" + a[1,1] = a[1,6] = a[2,5] = a[2,10] = a[3,9] = a[3,2] = 1 + else + a[1,1] = a[1,10] = a[2,2] = a[2,5] = a[3,6] = a[3,9] = 1 + end + else + a[5,3] = a[6,7] = a[7,11] = a[8,4] = a[8,8] = a[8,12] = 1 # wrong + end + end + end + y_w = n*y1*transpose(n) + p_matrix = a*y_w*transpose(a) + + ybase = (transformer["sm_nom"][1]/3) / (transformer["tm_nom"][2]*transformer["tm_set"][2][1]/sqrt(3))^2 /1000 + if haskey(transformer["dss"], "%noloadloss") + shunt = (transformer["g_sh"] + 1im * transformer["b_sh"])*ybase + p_matrix[5,5] += shunt + p_matrix[5,8] -= shunt + p_matrix[6,6] += shunt + p_matrix[6,8] -= shunt + p_matrix[7,7] += shunt + p_matrix[7,8] -= shunt + p_matrix[8,5] -= shunt + p_matrix[8,6] -= shunt + p_matrix[8,7] -= shunt + p_matrix[8,8] += 3*shunt + end + transformer["p_matrix"] = p_matrix + elseif transformer["dss"]["phases"] == 1 + z = sum(transformer["rw"]) + 1im .* transformer["xsc"][1] + z_1volt= z * 1/transformer["sm_nom"][1]/1000 + b = [1 ;-1] + y1 = b*1/z_1volt*transpose(b) + n = zeros(Float64, 4, 2) + a = zeros(Int64,4,4) + for w = 1:2 + if transformer["configuration"][w] == _PMD.WYE + i = lookup[(w,1)][1] + j = lookup[(w,1)][2] + n[i,j] = 1/(transformer["tm_nom"][w]*1000*transformer["tm_set"][w][1]) + n[i+1,j] = - n[i,j] + if w == 1 + a[1,1] = a[2,2] = 1 + else + a[3,3] = a[4,4] = 1 + end + end + end + y_w = n*y1*transpose(n) + p_matrix = a*y_w*transpose(a) + transformer["p_matrix"] = p_matrix end end diff --git a/src/data_model/eng2math.jl b/src/data_model/eng2math.jl index 6c9559e..1278798 100644 --- a/src/data_model/eng2math.jl +++ b/src/data_model/eng2math.jl @@ -157,7 +157,7 @@ end "field/values to passthrough from the ENGINEERING to MATHEMATICAL data models" const _pmp_eng2math_passthrough = Dict{String,Vector{String}}( - "generator" => String["zr", "zx", "grid_forming"], + "generator" => String["zr", "zx", "grid_forming", "gen_model", "xdp", "rp", "xdpp", "vnom_kv"], "solar" => String["i_max", "solar_max", "kva", "pf", "grid_forming", "balanced", "vminpu", "transformer", "type", "pv_model", "transformer_id"], "voltage_source" => String["zr", "zx"], "load" => String["vminpu", "vmaxpu"], @@ -180,7 +180,7 @@ transform_data_model( "admittance model" const _mc_admittance_asset_types = [ - "line", "voltage_source", "load", "transformer", "shunt", "solar" + "line", "voltage_source", "load", "transformer", "shunt", "solar", "generator" ] "custom version of 'transform_data_model' to build admittance model and deal with transformers" diff --git a/src/io/dss/dss2eng.jl b/src/io/dss/dss2eng.jl index 43fac44..708edfb 100644 --- a/src/io/dss/dss2eng.jl +++ b/src/io/dss/dss2eng.jl @@ -110,19 +110,43 @@ end function _dss2eng_gen_dynamics!(data_eng::Dict{String,<:Any}, data_dss::Dict{String,<:Any}) if haskey(data_eng, "generator") for (id, generator) in data_eng["generator"] + dss_obj = data_dss["generator"][id] + _PMD._apply_like!(dss_obj, data_dss, "generator") + defaults = _PMD._apply_ordered_properties(_PMD._create_generator(id; _PMD._to_kwargs(dss_obj)...), dss_obj) + zbase = defaults["kv"]^2/defaults["kva"]*1000 + xdp = defaults["xdp"] * zbase + rp = xdp/defaults["xrdp"] + xdpp = defaults["xdpp"] * zbase + generator["xdp"] = fill(xdp, length(generator["connections"])) + generator["rp"] = fill(rp, length(generator["connections"])) + generator["xdpp"] = fill(xdpp, length(generator["connections"])) if haskey(generator["dss"], "model") - if generator["dss"]["model"] == 3 - dss_obj = data_dss["generator"][id] - _PMD._apply_like!(dss_obj, data_dss, "generator") - defaults = _PMD._apply_ordered_properties(_PMD._create_generator(id; _PMD._to_kwargs(dss_obj)...), dss_obj) - zbase = defaults["kv"]^2/defaults["kva"]*1000 - xdp = defaults["xdp"] * zbase - rp = xdp/defaults["xrdp"] - xdpp = defaults["xdpp"] * zbase - generator["xdp"] = fill(xdp, length(generator["connections"])) - generator["rp"] = fill(rp, length(generator["connections"])) - generator["xdpp"] = fill(xdpp, length(generator["connections"])) + model = generator["dss"]["model"] + else + model = 1 + end + generator["gen_model"] = model + if model == 1 + if haskey(generator["dss"], "kvar") + generator["qg"] = fill(generator["dss"]["kvar"]/length(generator["pg"]), length(generator["pg"])) + else + generator["qg"] = fill(0.0, length(generator["pg"])) + end + if haskey(generator["dss"], "kv") + generator["vnom_kv"] = generator["dss"]["kv"] / sqrt(3) end + # if generator["dss"]["model"] == 3 + # dss_obj = data_dss["generator"][id] + # _PMD._apply_like!(dss_obj, data_dss, "generator") + # defaults = _PMD._apply_ordered_properties(_PMD._create_generator(id; _PMD._to_kwargs(dss_obj)...), dss_obj) + # zbase = defaults["kv"]^2/defaults["kva"]*1000 + # xdp = defaults["xdp"] * zbase + # rp = xdp/defaults["xrdp"] + # xdpp = defaults["xdpp"] * zbase + # generator["xdp"] = fill(xdp, length(generator["connections"])) + # generator["rp"] = fill(rp, length(generator["connections"])) + # generator["xdpp"] = fill(xdpp, length(generator["connections"])) + # end end end end diff --git a/src/prob/fs copy.jl b/src/prob/fs copy.jl deleted file mode 100644 index aad9830..0000000 --- a/src/prob/fs copy.jl +++ /dev/null @@ -1,106 +0,0 @@ -""" - solve_fault_study(case::Dict{String,Any}, solver; kwargs...) - -Solves a fault study using all active faults under `case["fault"]` for transmission (matpower) data sets given an optimization `solver` - -`kwargs` can be any valid keyword argument for PowerModels' run_model function. -""" -function solve_fault_study(case::Dict{String,Any}, solver; kwargs...) - data = deepcopy(case) - check_pf!(data, solver) - - result = _PM.run_model(data, _PM.IVRPowerModel, solver, build_fault_study; ref_extensions=[ref_add_fault!], solution_processors=[solution_fs!], kwargs...) - - return result -end - - -""" - solve_fault_study(case::Dict{String,<:Any}, fault_studies::Dict{String,<:Any}, solver; kwargs...)::Dict{String,Any} - -Solves a series fault studies in `fault_studies`, e.g., generated by [`build_fault_study`](@ref build_fault_study) for transmission (matpower) data sets given an optimization `solver` - -`kwargs` can be any valid keyword argument for PowerModels' run_model function. -""" -function solve_fault_study(case::Dict{String,<:Any}, fault_studies::Dict{String,<:Any}, solver; kwargs...)::Dict{String,Any} - solutions = deepcopy(fault_studies) - - data = deepcopy(case) - check_pf!(data, solver) - - for (i,fault) in fault_studies - data["fault"] = Dict{String,Any}("1" => fault) - - solutions[i] = _PM.run_model(data, _PM.IVRPowerModel, solver, build_fault_study; ref_extensions=[ref_add_fault!], solution_processors=[solution_fs!], kwargs...) - end - - - return solutions -end - - -""" - solve_fault_study(file::String, solver; kwargs...) - -Given a `file`, parses file and solves a series of fault studies -""" -function solve_fault_study(file::String, solver; kwargs...) - data = parse_file(file) - - return solve_fault_study(data, build_fault_study(data), solver; kwargs...) -end - - -""" - build_fault_study(pm::_PM.AbstractPowerModel) - -Builds a transmission fault study optimization problem -""" -function build_fault_study(pm::_PM.AbstractPowerModel) - _PM.variable_bus_voltage(pm, bounded = true) - variable_bus_fault_current(pm) - variable_branch_current(pm, bounded = false) - variable_gen(pm, bounded = false) # inverter currents are always bounded - variable_pq_inverter(pm) - - has_pq_gens = false - has_v_gens = false - - for (n, nw_ref) in _PM.nws(pm) - for (i, gen) in nw_ref[:gen] - if gen["inverter_mode"] == "pq" - has_pq_gens = true - end - - if gen["inverter_mode"] == "v" - has_v_gens = true - end - end - end - - if has_pq_gens && !has_v_gens - objective_max_inverter_power(pm) - elseif !has_pq_gens && has_v_gens - objective_min_inverter_voltage_regulation(pm) - elseif has_pq_gens && has_v_gens - objective_min_inverter_error(pm) - end - - constraint_gen_voltage_drop(pm) - constraint_pq_inverter(pm) - constraint_v_inverter(pm) - - for i in _PM.ids(pm, :fault) - constraint_bus_fault_current(pm, i) - end - - for (i, bus) in _PM.ref(pm, :bus) - constraint_current_balance(pm, i) - end - - for i in _PM.ids(pm, :branch) - _PM.constraint_current_from(pm, i) - _PM.constraint_current_to(pm, i) - _PM.constraint_voltage_drop(pm, i) - end -end diff --git a/src/prob/pf_mc copy.jl b/src/prob/pf_mc copy.jl deleted file mode 100644 index be0a95b..0000000 --- a/src/prob/pf_mc copy.jl +++ /dev/null @@ -1,344 +0,0 @@ -""" - solve_mc_pf(data::Dict{String,<:Any}, solver; kwargs...) - -Run Power Flow Problem with Solar -""" -function solve_mc_pf(data::Dict{String,<:Any}, solver; kwargs...) - solution = _PMD.solve_mc_model( - data, - _PMD.IVRUPowerModel, - solver, - build_mc_pf; - eng2math_passthrough=_pmp_eng2math_passthrough, - make_pu_extensions=[_rebase_pu_gen_dynamics!], - dimensionalize_math_extensions=_pmp_dimensionalize_math_extensions, - ref_extensions=[ref_add_mc_solar!, ref_add_grid_forming_bus!], - kwargs... - ) - - return solution -end - - -""" - solve_mc_pf(file::String, solver; kwargs...) - -Run Power Flow Problem with Solar -""" -function solve_mc_pf(file::String, solver; kwargs...) - return solve_mc_pf(parse_file(file), solver; kwargs...) -end - - -""" - build_mc_pf(pm::_PMD.AbstractUnbalancedPowerModel) - -Constructor for Power Flow Problem with Solar -""" -function build_mc_pf(pm::_PMD.AbstractUnbalancedPowerModel) - _PMD.variable_mc_bus_voltage(pm, bounded=false) - _PMD.variable_mc_branch_current(pm, bounded=false) - _PMD.variable_mc_transformer_current(pm, bounded=false) - _PMD.variable_mc_generator_current(pm, bounded=false) - _PMD.variable_mc_load_current(pm, bounded = false) - - variable_mc_pq_inverter(pm) - variable_mc_grid_formimg_inverter(pm) - - for (i, bus) in _PMD.ref(pm, :ref_buses) - @assert bus["bus_type"] == 3 - _PMD.constraint_mc_theta_ref(pm, i) - _PMD.constraint_mc_voltage_magnitude_only(pm, i) - end - - for id in _PMD.ids(pm, :gen) - _PMD.constraint_mc_generator_power(pm, id) - end - - for id in _PMD.ids(pm, :load) - _PMD.constraint_mc_load_power(pm, id) - end - - for (i, bus) in _PMD.ref(pm, :bus) - _PMD.constraint_mc_current_balance(pm, i) - - # PV Bus Constraints - if length(_PMD.ref(pm, :bus_gens, i)) > 0 && !(i in _PMD.ids(pm, :ref_buses)) - # this assumes inactive generators are filtered out of bus_gens - @assert bus["bus_type"] == 2 - if !(i in _PMD.ids(pm, :solar_gfli)) - _PMD.constraint_mc_voltage_magnitude_only(pm, i) - if !(i in _PMD.ids(pm, :solar_gfmi)) - for j in _PMD.ref(pm, :bus_gens, i) - _PMD.constraint_mc_gen_power_setpoint_real(pm, j) - end - end - end - end - - end - - for i in _PMD.ids(pm, :branch) - _PMD.constraint_mc_current_from(pm, i) - _PMD.constraint_mc_current_to(pm, i) - _PMD.constraint_mc_bus_voltage_drop(pm, i) - end - - for i in _PMD.ids(pm, :transformer) - _PMD.constraint_mc_transformer_power(pm, i) - end - - for i in _PMD.ids(pm, :solar_gfli) - constraint_mc_pq_inverter(pm, i) - end - - for i in _PMD.ids(pm, :solar_gfmi) - constraint_mc_grid_forming_inverter_impedance(pm, i) - # constraint_mc_grid_forming_inverter(pm, i) - end -end - - -""" - solve_mc_dg_pf(data::Dict{String,<:Any}, solver; kwargs...) - -Run Power Flow Problem with DG -""" -function solve_mc_dg_pf(data::Dict{String,<:Any}, solver; kwargs...) - return _PMD.solve_mc_model(data, _PMD.ACPUPowerModel, solver, build_mc_dg_pf; kwargs...) -end - -""" - solve_mc_dg_pf(file::String, solver; kwargs...) - -Run Power Flow Problem with DG -""" -function solve_mc_dg_pf(file::String, solver; kwargs...) - return solve_mc_dg_pf(parse_file(file; import_all=true), solver; kwargs...) -end - -""" - build_mc_dg_pf(pm::_PMD.AbstractUnbalancedPowerModel) - -Constructor for Power Flow Problem with DG -""" -function build_mc_dg_pf(pm::_PMD.AbstractUnbalancedPowerModel) - _PMD.variable_mc_bus_voltage(pm; bounded=false) - _PMD.variable_mc_branch_power(pm; bounded=false) - # _PMD.variable_mc_branch_current(pm; bounded=false) - _PMD.variable_mc_transformer_power(pm; bounded=false) - # _PMD.variable_mc_transformer_current(pm; bounded=false) - _PMD.variable_mc_generator_current(pm; bounded=false) - _PMD.variable_mc_load_current(pm; bounded=false) - # _PMD.variable_mc_storage_power(pm; bounded=false) - - _PMD.constraint_mc_model_voltage(pm) - - for (i,bus) in _PMD.ref(pm, :ref_buses) - @assert bus["bus_type"] == 3 - - _PMD.constraint_mc_theta_ref(pm, i) - _PMD.constraint_mc_voltage_magnitude_only(pm, i) - end - - # gens should be constrained before KCL, or Pd/Qd undefined - for id in _PMD.ids(pm, :gen) - _PMD.constraint_mc_generator_power(pm, id) - end - - # loads should be constrained before KCL, or Pd/Qd undefined - for id in _PMD.ids(pm, :load) - _PMD.constraint_mc_load_power(pm, id) - end - - for (i,bus) in _PMD.ref(pm, :bus) - _PMD.constraint_mc_current_balance(pm, i) - # _PMD.constraint_mc_load_current_balance(pm, i) - - - # PV Bus Constraints - if length(_PMD.ref(pm, :bus_gens, i)) > 0 && !(i in _PMD.ids(pm,:ref_buses)) - # this assumes inactive generators are filtered out of bus_gens - - for j in _PMD.ref(pm, :bus_gens, i) - _PMD.constraint_mc_gen_power_setpoint_real(pm, j) - constraint_mc_gen_power_setpoint_imag(pm, j) - end - end - end - - # for i in ids(pm, :storage) - # _PM.constraint_storage_state(pm, i) - # _PM.constraint_storage_complementarity_nl(pm, i) - # _PMD.constraint_mc_storage_losses(pm, i) - # _PMD.constraint_mc_storage_thermal_limit(pm, i) - # end - - for i in _PMD.ids(pm, :branch) - _PMD.constraint_mc_ohms_yt_from(pm, i) - _PMD.constraint_mc_ohms_yt_to(pm, i) - # _PMD.constraint_mc_current_from(pm, i) - # _PMD.constraint_mc_current_to(pm, i) - # _PMD.constraint_mc_bus_voltage_drop(pm, i) - end - - for i in _PMD.ids(pm, :transformer) - _PMD.constraint_mc_transformer_power(pm, i) - end -end - - -function compute_mc_pf(model::AdmittanceModel) - z = _SP.sparse(model.z) - i = _SP.sparse(model.i) - v = _SP.sparse(model.v) - delta_i_control = _SP.sparse(model.delta_i_control) - delta_i = _SP.sparse(model.delta_i) - max_it = 10 - it_pf = 0 - _i = i + delta_i_control + delta_i - _v = deepcopy(v) - last_v = deepcopy(v) - while it_pf != max_it - _v = z*_i - if maximum((abs.(_v-last_v))) < .0001 - break - else - _delta_i_control = update_mc_delta_current_control_vector(model, _v) - it_control = 0 - _i = i + _delta_i_control + delta_i - while it_control != max_it - __v = z*_i - if maximum((abs.(__v-_v))) < .0001 - _v = __v - break - else - _delta_i_control = update_mc_delta_current_control_vector(model, __v) - _i = i + _delta_i_control + delta_i - _v = __v - it_control += 1 - end - end - println(it_control) - delta_i = update_mc_delta_current_vector(model, _v) - _i = i + _delta_i_control + delta_i - last_v = _v - it_pf += 1 - end - end - return solution_mc_pf(_v, it_pf, maximum((abs.(_v-last_v))), i + delta_i_control + delta_i, model) -end - - -function compute_mc_pf(y, model::AdmittanceModel) - z = _SP.sparse(inv(y)) - i = _SP.sparse(model.i) - v = _SP.sparse(model.v) - delta_i_control = _SP.sparse(model.delta_i_control) - delta_i = _SP.sparse(model.delta_i) - max_it = 10 - it_pf = 0 - _i = i + delta_i_control + delta_i - _v = deepcopy(v) - last_v = deepcopy(v) - while it_pf != max_it - _v = z*_i - # println("calc v: ", abs.(_v)) - # println("calc va:", angle.(_v).*180/pi) - if maximum((abs.(_v-last_v))) < .0001 - break - else - _delta_i_control = update_mc_delta_current_control_vector(model, _v) - # println("calc delta_i: ", abs.(_delta_i_control)) - # println("calc ia:", angle.(_delta_i_control).*180/pi) - it_control = 0 - _i = i + _delta_i_control + delta_i - while it_control != max_it - __v = z*_i - # println("calc v: ", abs.(__v)) - # println("calc va:", angle.(__v).*180/pi) - # println("_____________________________________________________") - if maximum((abs.(__v-_v))) < .0001 - _v = __v - break - else - _delta_i_control = update_mc_delta_current_control_vector(model, __v) - # println("calc delta_i: ", abs.(_delta_i_control)) - # println("calc ia:", angle.(_delta_i_control).*180/pi) - _i = i + _delta_i_control + delta_i - _v = __v - it_control += 1 - if it_control == 10 - println("over: control") - end - end - end - println(it_control) - delta_i = update_mc_delta_current_vector(model, _v) - _i = i + _delta_i_control + delta_i - last_v = _v - it_pf += 1 - if it_pf == 10 - println("over: pf") - end - end - end - println(it_pf) - return _v -end - -# function _compute_mc_pf(model::AdmittanceModel) -# z = _SP.sparse(model.z) -# i = _SP.sparse(model.i) -# v = _SP.sparse(model.v) -# delta_i = _SP.sparse(model.delta_i) -# max_it = 10 -# it = 1 -# _i = i + delta_i -# _v = deepcopy(v) -# last_v = deepcopy(v) -# while it != max_it -# _v = z*_i -# println() -# if maximum((abs.(_v-last_v))) < .0001 -# break -# else -# _delta_i = update_mc_delta_current_vector(model, _v) -# _i = i + _delta_i -# last_v = _v -# it += 1 -# end -# end -# return _v, it, maximum((abs.(_v-last_v))) -# end - -# function _compute_mc_pf(model::AdmittanceModel) -# z = _SP.sparse(model.z) -# i = _SP.sparse(model.i) -# v = _SP.sparse(model.v) -# c = _SP.sparse(model.c) -# max_it = 10 -# it = 1 -# _i = i -# _v = deepcopy(v) -# last_v = deepcopy(v) -# delta_i = i -# println(abs.(z*_i)) -# println(abs.(v)) -# println(i) -# while it != max_it -# _v = z*_i -# if maximum((abs.(_v-last_v))) < .0001 -# break -# else -# _delta_i = -conj.(c*(abs.(v).^2-abs.(_v).^2)./_v) -# _i = i + _delta_i -# last_v = _v -# it += 1 -# end -# end -# println(it) -# println(maximum((abs.(_v-last_v)))) -# return _v -# end - diff --git a/test/data/dist/3Bus_example_EXP_Y.CSV b/test/data/dist/3Bus_example_EXP_Y.CSV new file mode 100644 index 0000000..b1b08d1 --- /dev/null +++ b/test/data/dist/3Bus_example_EXP_Y.CSV @@ -0,0 +1,13 @@ +12, +"SOURCEBUS.1", 1668089.361 , +j -6014809.812 ,152229.2696 , +j 48588.06765 ,152229.2696 , +j 48588.06765 ,-9.672516195 , +j 5.641533135 ,2.762716966 , +j -1.612352875 ,2.762716966 , +j -1.612352875 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"SOURCEBUS.2", 152229.2696 , +j 48588.06765 ,1668089.361 , +j -6014809.812 ,152229.2696 , +j 48588.06765 ,2.762716966 , +j -1.612352875 ,-9.672516195 , +j 5.641533135 ,2.762716966 , +j -1.612352875 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"SOURCEBUS.3", 152229.2696 , +j 48588.06765 ,152229.2696 , +j 48588.06765 ,1668089.361 , +j -6014809.812 ,2.762716966 , +j -1.612352875 ,2.762716966 , +j -1.612352875 ,-9.672516195 , +j 5.641533135 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"PRIMARY.1", -9.672516195 , +j 5.641533135 ,2.762716966 , +j -1.612352875 ,2.762716966 , +j -1.612352875 ,26.42309351 , +j -15.21375065 ,-7.550601188 , +j 4.347798866 ,-7.550601188 , +j 4.347798866 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 , +"PRIMARY.2", 2.762716966 , +j -1.612352875 ,-9.672516195 , +j 5.641533135 ,2.762716966 , +j -1.612352875 ,-7.550601188 , +j 4.347798866 ,26.42309351 , +j -15.21375065 ,-7.550601188 , +j 4.347798866 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 , +"PRIMARY.3", 2.762716966 , +j -1.612352875 ,2.762716966 , +j -1.612352875 ,-9.672516195 , +j 5.641533135 ,-7.550601188 , +j 4.347798866 ,-7.550601188 , +j 4.347798866 ,26.42309351 , +j -15.21375065 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 , +"LOADBUS.1", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,8.750288658 , +j -4.973613558 ,-2.393942111 , +j 1.367722995 ,-2.393942111 , +j 1.367722995 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"LOADBUS.2", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,-2.393942111 , +j 1.367722995 ,8.750288658 , +j -4.973613558 ,-2.393942111 , +j 1.367722995 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"LOADBUS.3", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,-2.393942111 , +j 1.367722995 ,-2.393942111 , +j 1.367722995 ,8.750288658 , +j -4.973613558 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 , +"PV_BUS.1", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,8.250288658 , +j -4.723613558 ,-2.393942111 , +j 1.367722995 ,-2.393942111 , +j 1.367722995 , +"PV_BUS.2", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,2.393942111 , +j -1.367722995 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,-2.393942111 , +j 1.367722995 ,8.250288658 , +j -4.723613558 ,-2.393942111 , +j 1.367722995 , +"PV_BUS.3", 0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,2.393942111 , +j -1.367722995 ,2.393942111 , +j -1.367722995 ,-8.375288658 , +j 4.786123158 ,0 , +j 0 ,0 , +j 0 ,0 , +j 0 ,-2.393942111 , +j 1.367722995 ,-2.393942111 , +j 1.367722995 ,8.250288658 , +j -4.723613558 , diff --git a/test/data/dist/3Bus_example_VLN_Node.Txt b/test/data/dist/3Bus_example_VLN_Node.Txt index fe27774..cfb61da 100644 --- a/test/data/dist/3Bus_example_VLN_Node.Txt +++ b/test/data/dist/3Bus_example_VLN_Node.Txt @@ -6,12 +6,12 @@ Bus Node VLN (kV) Angle pu Base kV Node-Node VLL (kV) SOURCEBUS 1 0.22999 /_ 0.0 0.9959 0.400 1-2 0.39836 /_ 30.0 0.9959 - 2 0.22999 /_ -120.0 0.9959 0.400 2-3 0.39836 /_ -90.0 0.9959 - 3 0.22999 /_ 120.0 0.9959 0.400 3-1 0.39836 /_ 150.0 0.9959 -PRIMARY . 1 0.22654 /_ -0.2 0.98094 0.400 1-2 0.39384 /_ 30.0 0.9846 - - 2 0.22848 /_ -120.1 0.98936 0.400 2-3 0.39481 /_ -90.0 0.98702 - - 3 0.22795 /_ 120.1 0.98704 0.400 3-1 0.39428 /_ 149.8 0.98571 -SWITCHBUS 1 0.22654 /_ -0.2 0.98094 0.400 1-2 0.39384 /_ 30.0 0.9846 - - 2 0.22848 /_ -120.1 0.98936 0.400 2-3 0.39481 /_ -90.0 0.98702 - - 3 0.22795 /_ 120.1 0.98704 0.400 3-1 0.39428 /_ 149.8 0.98571 -LOADBUS . 1 0.22252 /_ -0.5 0.96355 0.400 1-2 0.38859 /_ 29.9 0.97148 - - 2 0.22673 /_ -120.2 0.98176 0.400 2-3 0.39068 /_ -90.1 0.97671 - - 3 0.22558 /_ 120.3 0.97678 0.400 3-1 0.38954 /_ 149.7 0.97385 +PRIMARY . 1 0.22527 /_ -0.1 0.97547 0.400 1-2 0.39019 /_ 29.9 0.97547 + - 2 0.22527 /_ -120.1 0.97547 0.400 2-3 0.39019 /_ -90.1 0.97547 + - 3 0.22527 /_ 119.9 0.97547 0.400 3-1 0.39019 /_ 149.9 0.97547 +LOADBUS . 1 0.21716 /_ -0.2 0.94034 0.400 1-2 0.37614 /_ 29.8 0.94034 + - 2 0.21716 /_ -120.2 0.94034 0.400 2-3 0.37614 /_ -90.2 0.94034 + - 3 0.21716 /_ 119.8 0.94034 0.400 3-1 0.37614 /_ 149.8 0.94034 +PV_BUS .. 1 0.22791 /_ 0.0 0.98687 0.400 1-2 0.39475 /_ 30.0 0.98687 + - 2 0.22791 /_ -120.0 0.98687 0.400 2-3 0.39475 /_ -90.0 0.98687 + - 3 0.22791 /_ 120.0 0.98687 0.400 3-1 0.39475 /_ 150.0 0.98687 diff --git a/test/data/dist/case3_gen_wye.dss b/test/data/dist/case3_gen_wye.dss new file mode 100644 index 0000000..d581d62 --- /dev/null +++ b/test/data/dist/case3_gen_wye.dss @@ -0,0 +1,48 @@ + +Clear +New Circuit.3Bus_example +! define a really stiff source +~ basekv=0.4 BaseMVA=1 pu=0.9959 MVAsc1=1e6 MVAsc3=1e6 + +!Define Linecodes + + +New linecode.556MCM nphases=3 basefreq=50 ! ohms per 5 mile +~ rmatrix = ( 0.1000 | 0.0400 0.1000 | 0.0400 0.0400 0.1000) +~ xmatrix = ( 0.0583 | 0.0233 0.0583 | 0.0233 0.0233 0.0583) +~ cmatrix = (50.92958178940651 | -0 50.92958178940651 | -0 -0 50.92958178940651 ) ! small capacitance + + +New linecode.4/0QUAD nphases=3 basefreq=50 ! ohms per 100ft +~ rmatrix = ( 0.1167 | 0.0467 0.1167 | 0.0467 0.0467 0.1167) +~ xmatrix = (0.0667 | 0.0267 0.0667 | 0.0267 0.0267 0.0667 ) +~ cmatrix = (50.92958178940651 | -0 50.92958178940651 | -0 -0 50.92958178940651 ) ! small capacitance + +!Define lines + +New Line.OHLine bus1=sourcebus.1.2.3 Primary.1.2.3 linecode = 556MCM length=1 ! 5 mile line +New Line.Quad Bus1=Primary.1.2.3 loadbus.1.2.3 linecode = 4/0QUAD length=1 ! 100 ft +New Line.PV_line Bus1=PV_bus.1.2.3 Primary.1.2.3 linecode = 4/0QUAD length=1 ! 100 ft + +!Loads - single phase + +New Load.L1 phases=3 bus1=loadbus.1.2.3 Conn=Wye kW=60 kvar=30 model=1 kV=.4 + +New Generator.G1 phases=3 bus1=PV_bus.1.2.3 conn=wye kv=.4 kw=20 kvar=10 + + +Set voltagebases=[0.4] +Set tolerance=0.000001 +set defaultbasefreq=60 +Calcvoltagebases + +batchedit load..* enable=false +batchedit capacitor..* enabled=false +new fault.test phases=3 bus1=loadbus.1.2.3 r=.005 enabled=true + +Solve mode=snap + +set mode=dynamic controlmode=time +set stepsize=.0002s +number=800 +solve diff --git a/test/data/dist/ut_trans_EXP_YPRIM.CSV b/test/data/dist/ut_trans_EXP_YPRIM.CSV deleted file mode 100644 index 5faada4..0000000 --- a/test/data/dist/ut_trans_EXP_YPRIM.CSV +++ /dev/null @@ -1,48 +0,0 @@ -Vsource.SOURCE -420247.0941 , -1515337.661 , 38352.52574 , 12240.61224 , 38352.52574 , 12240.61224 , -420247.0941 , 1515337.661 , -38352.52574 , -12240.61224 , -38352.52574 , -12240.61224 , -38352.52574 , 12240.61224 , 420247.0941 , -1515337.661 , 38352.52574 , 12240.61224 , -38352.52574 , -12240.61224 , -420247.0941 , 1515337.661 , -38352.52574 , -12240.61224 , -38352.52574 , 12240.61224 , 38352.52574 , 12240.61224 , 420247.0941 , -1515337.661 , -38352.52574 , -12240.61224 , -38352.52574 , -12240.61224 , -420247.0941 , 1515337.661 , --420247.0941 , 1515337.661 , -38352.52574 , -12240.61224 , -38352.52574 , -12240.61224 , 420247.0941 , -1515337.661 , 38352.52574 , 12240.61224 , 38352.52574 , 12240.61224 , --38352.52574 , -12240.61224 , -420247.0941 , 1515337.661 , -38352.52574 , -12240.61224 , 38352.52574 , 12240.61224 , 420247.0941 , -1515337.661 , 38352.52574 , 12240.61224 , --38352.52574 , -12240.61224 , -38352.52574 , -12240.61224 , -420247.0941 , 1515337.661 , 38352.52574 , 12240.61224 , 38352.52574 , 12240.61224 , 420247.0941 , -1515337.661 , -Transformer.TX1 -0.02430724356, -0.04051207398, -0.01215362178, 0.0202560363 , -0.01215362178, 0.0202560363 , 0 , 0 , -0.05788939865, 0.09648233108, 0.05788939865, -0.09648233108, 0 , 0 , 0 , 0 , --0.01215362178, 0.0202560363 , 0.02430724356, -0.04051207398, -0.01215362178, 0.0202560363 , 0 , 0 , 0 , 0 , -0.05788939865, 0.09648233108, 0.05788939865, -0.09648233108, 0 , 0 , --0.01215362178, 0.0202560363 , -0.01215362178, 0.0202560363 , 0.02430724356, -0.04051207398, 0 , 0 , 0.05788939865, -0.09648233108, 0 , 0 , -0.05788939865, 0.09648233108, 0 , 0 , -0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , --0.05788939865, 0.09648233108, 0 , 0 , 0.05788939865, -0.09648233108, 0 , 0 , 0.2772977941 , -0.4629963392, 0 , 0 , 0 , 0 , -0.2772977941, 0.4629963235 , -0.05788939865, -0.09648233108, -0.05788939865, 0.09648233108, 0 , 0 , 0 , 0 , 0 , 0 , 0.2772977941 , -0.4629963392, 0 , 0 , -0.2772977941, 0.4629963235 , -0 , 0 , 0.05788939865, -0.09648233108, -0.05788939865, 0.09648233108, 0 , 0 , 0 , 0 , 0 , 0 , 0.2772977941 , -0.4629963392, -0.2772977941, 0.4629963235 , -0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , -0.2772977941, 0.4629963235 , -0.2772977941, 0.4629963235 , -0.2772977941, 0.4629963235 , 0.8318933824 , -1.388989033 , -Line.LINE1 -0.392897258 , -0.7340862203, 0.2595639246 , -0.6674201945, 0.2595639246 , -0.6674201945, -0.392897258 , 0.7340867481 , -0.2595639246, 0.6674200814 , -0.2595639246, 0.6674200814 , -0.2595639246 , -0.6674201945, 0.392897258 , -0.7340862203, 0.2595639246 , -0.6674201945, -0.2595639246, 0.6674200814 , -0.392897258 , 0.7340867481 , -0.2595639246, 0.6674200814 , -0.2595639246 , -0.6674201945, 0.2595639246 , -0.6674201945, 0.392897258 , -0.7340862203, -0.2595639246, 0.6674200814 , -0.2595639246, 0.6674200814 , -0.392897258 , 0.7340867481 , --0.392897258 , 0.7340867481 , -0.2595639246, 0.6674200814 , -0.2595639246, 0.6674200814 , 0.392897258 , -0.7340862203, 0.2595639246 , -0.6674201945, 0.2595639246 , -0.6674201945, --0.2595639246, 0.6674200814 , -0.392897258 , 0.7340867481 , -0.2595639246, 0.6674200814 , 0.2595639246 , -0.6674201945, 0.392897258 , -0.7340862203, 0.2595639246 , -0.6674201945, --0.2595639246, 0.6674200814 , -0.2595639246, 0.6674200814 , -0.392897258 , 0.7340867481 , 0.2595639246 , -0.6674201945, 0.2595639246 , -0.6674201945, 0.392897258 , -0.7340862203, -Line.LINE2 -1.192897258 , -1.13408622 , -0.1404360754, -0.4674201945, -0.1404360754, -0.4674201945, -1.192897258 , 1.134086748 , 0.1404360754 , 0.4674200814 , 0.1404360754 , 0.4674200814 , --0.1404360754, -0.4674201945, 1.192897258 , -1.13408622 , -0.1404360754, -0.4674201945, 0.1404360754 , 0.4674200814 , -1.192897258 , 1.134086748 , 0.1404360754 , 0.4674200814 , --0.1404360754, -0.4674201945, -0.1404360754, -0.4674201945, 1.192897258 , -1.13408622 , 0.1404360754 , 0.4674200814 , 0.1404360754 , 0.4674200814 , -1.192897258 , 1.134086748 , --1.192897258 , 1.134086748 , 0.1404360754 , 0.4674200814 , 0.1404360754 , 0.4674200814 , 1.192897258 , -1.13408622 , -0.1404360754, -0.4674201945, -0.1404360754, -0.4674201945, -0.1404360754 , 0.4674200814 , -1.192897258 , 1.134086748 , 0.1404360754 , 0.4674200814 , -0.1404360754, -0.4674201945, 1.192897258 , -1.13408622 , -0.1404360754, -0.4674201945, -0.1404360754 , 0.4674200814 , 0.1404360754 , 0.4674200814 , -1.192897258 , 1.134086748 , -0.1404360754, -0.4674201945, -0.1404360754, -0.4674201945, 1.192897258 , -1.13408622 , -Load.LOAD1 -0.001008112705, -0.001781780595, -0.001008112705, 0.001781780595, --0.001008112705, 0.001781780595, 0.001008113713, -0.001781782377, -Load.LOAD2 -0.001219113039, -0.001992780928, -0.001219113039, 0.001992780928, --0.001219113039, 0.001992780928, 0.001219114258, -0.001992782921, -Load.LOAD3 -0.001430113372, -0.002203781262, -0.001430113372, 0.002203781262, --0.001430113372, 0.002203781262, 0.001430114802, -0.002203783466, -Load.LOAD4 -0.01398865784, -0.00775047259, -0.01398865784, 0.00775047259, --0.01398865784, 0.00775047259, 0.01398867183, -0.00775048034, -Load.LOAD5 -0.01606805293, -0.009829867675, -0.01606805293, 0.009829867675, --0.01606805293, 0.009829867675, 0.016068069 , -0.009829877505, -Load.LOAD6 -0.01814744802, -0.01190926276, -0.01814744802, 0.01190926276, --0.01814744802, 0.01190926276, 0.01814746616, -0.01190927467, diff --git a/test/data/dist/ut_trans_VLN_Node.Txt b/test/data/dist/ut_trans_VLN_Node.Txt index 46b8dd5..c9d07b4 100644 --- a/test/data/dist/ut_trans_VLN_Node.Txt +++ b/test/data/dist/ut_trans_VLN_Node.Txt @@ -6,12 +6,12 @@ Bus Node VLN (kV) Angle pu Base kV Node-Node VLL (kV) SOURCEBUS 1 6.3509 /_ 0.0 1 11.000 1-2 11 /_ 30.0 1 - 2 6.3509 /_ -120.0 1 11.000 2-3 11 /_ -90.0 1 - 3 6.3509 /_ 120.0 1 11.000 3-1 11 /_ 150.0 1 -1 ....... 1 6.1432 /_ 0.7 0.9673 11.000 1-2 10.617 /_ 30.6 0.96514 - - 2 6.1142 /_ -119.3 0.96274 11.000 2-3 10.587 /_ -89.2 0.96248 - - 3 6.1255 /_ 120.9 0.96451 11.000 3-1 10.636 /_ 150.8 0.96693 -2 ....... 1 2.1535 /_ -30.1 0.93249 4.000 1-2 3.7205 /_ -0.4 0.93013 - - 2 2.1352 /_ -150.4 0.92458 4.000 2-3 3.6786 /_ -120.5 0.91966 - - 3 2.1148 /_ 89.7 0.91575 4.000 3-1 3.6922 /_ 120.1 0.92305 -3 ....... 1 2.1268 /_ -30.0 0.92092 4.000 1-2 3.6691 /_ -0.4 0.91728 - - 2 2.1018 /_ -150.4 0.91012 4.000 2-3 3.6186 /_ -120.5 0.90464 - - 3 2.0798 /_ 89.8 0.90059 4.000 3-1 3.639 /_ 120.3 0.90975 +1 ....... 1 6.1396 /_ 0.9 0.96673 11.000 1-2 10.641 /_ 30.7 0.96737 + - 2 6.1321 /_ -119.4 0.96555 11.000 2-3 10.594 /_ -89.4 0.96306 + - 3 6.1112 /_ 120.8 0.96227 11.000 3-1 10.605 /_ 150.9 0.96412 +2 ....... 1 2.1545 /_ 29.8 0.93294 4.000 1-2 3.7141 /_ 59.5 0.92853 + - 2 2.1303 /_ -90.4 0.92243 4.000 2-3 3.6767 /_ -60.4 0.91918 + - 3 2.1188 /_ 149.8 0.91746 4.000 3-1 3.7006 /_ -179.9 0.92514 +3 ....... 1 2.1278 /_ 29.9 0.92136 4.000 1-2 3.6627 /_ 59.5 0.91567 + - 2 2.0968 /_ -90.3 0.90795 4.000 2-3 3.6167 /_ -60.3 0.90417 + - 3 2.0838 /_ 149.9 0.90233 4.000 3-1 3.6473 /_ -179.8 0.91184 diff --git a/test/test.jl b/test/test.jl index 180660c..2771c8c 100644 --- a/test/test.jl +++ b/test/test.jl @@ -32,5 +32,7 @@ ipopt_solver = optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6, "print_le # result = PowerModelsProtection.solve_mc_fault_study(model) -data = parse_file("../test/data/dist/case3_unbalanced.dss") -model = PowerModelsProtection.instantiate_mc_admittance_model(data;loading=true) \ No newline at end of file +# data = parse_file("../test/data/dist/ut_trans_2w_dy_lead.dss") +data = parse_file("../test/data/dist/case3_gen_wye.dss") +model = PowerModelsProtection.instantiate_mc_admittance_model(data) +sol = PowerModelsProtection.compute_mc_pf(model)