Skip to content

Commit

Permalink
FIX: deg2rad conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudocubic committed Mar 23, 2020
1 parent e8ddd25 commit 6338a0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/data_model/eng2math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ end
""
function _map_eng2math_voltage_source!(data_math::Dict{String,<:Any}, data_eng::Dict{<:Any,<:Any}; kron_reduced::Bool=true, kr_phases::Vector{Int}=[1,2,3], kr_neutral::Int=4)
# TODO create option for lossy vs lossless sourcebus connection
for (name, eng_obj) in data_eng["voltage_source"]
for (name, eng_obj) in get(data_eng, "voltage_source", Dict{Any,Any}())
nconductors = data_math["conductors"]

# TODO fix per unit problem
Expand All @@ -843,7 +843,7 @@ function _map_eng2math_voltage_source!(data_math::Dict{String,<:Any}, data_eng::
"name" => "_virtual_bus.voltage_source.$name",
"bus_type" => 3,
"vm" => eng_obj["vm"],
"va" => deg2rad.(eng_obj["va"]),
"va" => eng_obj["va"],
"vmin" => eng_obj["vm"],
"vmax" => eng_obj["vm"],
"basekv" => data_math["basekv"]
Expand Down
22 changes: 11 additions & 11 deletions src/data_model/units.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
const _dimensionalize_math = Dict(
"bus" => Dict("rad2deg"=>["va"], "vbase"=>["vm", "vr", "vi"]),
"gen" => Dict("sbase"=>["pg", "qg", "pg_bus", "qg_bus"]),
"load" => Dict("sbase"=>["pd", "qd", "pd_bus", "qd_bus"]),
"line" => Dict("sbase"=>["pf", "qf", "pt", "qt"]),
)


"finds voltage zones"
function _find_zones(data_model)
unused_line_ids = Set(keys(data_model["branch"]))
Expand Down Expand Up @@ -186,9 +194,9 @@ function _rebase_pu_bus!(bus, vbase, sbase, sbase_old, v_var_scalar)
_scale_props!(bus, ["rg", "xg"], z_scale)

# TODO fix
# if haskey(bus ,"va")
# bus["va"] = deg2rad.(bus["va"])
# end
if haskey(bus ,"va")
bus["va"] = deg2rad.(bus["va"])
end

# save new vbase
bus["vbase"] = vbase
Expand Down Expand Up @@ -324,14 +332,6 @@ function add_big_M!(data_model; kwargs...)
end


const _dimensionalize_math = Dict(
"bus" => Dict("rad2deg"=>["va"], "vbase"=>["vm", "vr", "vi"]),
"gen" => Dict("sbase"=>["pg", "qg", "pg_bus", "qg_bus"]),
"load" => Dict("sbase"=>["pd", "qd", "pd_bus", "qd_bus"]),
"line" => Dict("sbase"=>["pf", "qf", "pt", "qt"]),
)


""
function solution_make_si(solution, math_model; mult_sbase=true, mult_vbase=true, convert_rad2deg=true)
solution_si = deepcopy(solution)
Expand Down

0 comments on commit 6338a0b

Please sign in to comment.