Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add RAVENS schema #472

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dadefbe
WIP: ravens to math converter for PMD.
juanjospina Aug 5, 2024
542f3dd
WIP: add bases to certain elements - debugging changes
juanjospina Aug 5, 2024
b5dea97
WIP: revise case3 ravens to math model code.
juanjospina Aug 7, 2024
d616a1e
WIP: case3 balanced working. Still missing transformers, shunts, gene…
juanjospina Aug 7, 2024
15d72f8
Revise ravens schema (#2)
juanjospina Aug 8, 2024
bbfa2d7
ADD: generator or rotating machine parser for ravens2math
juanjospina Sep 5, 2024
03a55d4
ADD: pv or photovoltaic unit parser for ravens2math.
juanjospina Sep 5, 2024
05f483e
ADD: storage or battery unit parser for ravens2math
juanjospina Sep 5, 2024
1021d87
REF: combined PVs and Battery Units in Ravens parser to avoid multipl…
juanjospina Sep 5, 2024
d7559d7
REF: ravens2math parser to fix impedance calculations and support fil…
juanjospina Sep 26, 2024
e7b082c
REF: add haskey check when looking for gens and power electronics
juanjospina Sep 26, 2024
8bb608d
WIP: Switches - still missing connection to virtual bus and branches.
juanjospina Sep 26, 2024
248210b
REF: OperationalLimitType parsing with new style.
juanjospina Oct 3, 2024
dda9e4a
FIX: storage ravens2math parser.
juanjospina Oct 7, 2024
a5d54a4
REF: a function that extracts the name of a ravens string.
juanjospina Oct 7, 2024
2fb384d
REF: replace SvStatus with Equipment.inService
juanjospina Oct 7, 2024
b54fbc5
FIX: charge and discharge on BatteryUnit.
juanjospina Oct 10, 2024
8ee4faa
WIP: Add Parser for PowerTransformer based on PowerTransformerEnd. Er…
juanjospina Oct 10, 2024
f6698b9
WIP: debig powertransformer issues related to terminals and bus_type …
juanjospina Oct 10, 2024
86f3f47
FIX: powertransformer issue related to fnode when creating virtual br…
juanjospina Oct 11, 2024
8726941
REF: phasecode in transformers.
juanjospina Oct 11, 2024
4688964
ADD: ShuntCompensator ravens parser.
juanjospina Oct 14, 2024
5f89b05
FIX: issues to be able to run test case with switches.
juanjospina Nov 7, 2024
6aa181d
REF: ravens2math by removing if statements and using phasecode map in…
juanjospina Nov 8, 2024
e04a1f0
REF: ravens2math to reduce if levels.
juanjospina Nov 8, 2024
86fa5be
ADD: unit tests for ravens parser.
juanjospina Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/PowerModelsDistribution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module PowerModelsDistribution
include("data_model/transformations/math2eng.jl")
include("data_model/transformations/utils.jl")
include("data_model/transformations/reduce.jl")
include("data_model/transformations/ravens2math.jl")

include("core/data.jl")
include("core/ref.jl")
Expand Down Expand Up @@ -113,6 +114,7 @@ module PowerModelsDistribution
include("io/common.jl")

include("data_model/utils.jl")
include("data_model/utils_ravens.jl")
include("data_model/checks.jl")
include("data_model/components.jl")
include("data_model/multinetwork.jl")
Expand Down
1,137 changes: 1,137 additions & 0 deletions src/data_model/transformations/ravens2math.jl

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions src/data_model/utils_ravens.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const _phasecode_map = Dict(
"PhaseCode.ABC" => [1, 2, 3],
"PhaseCode.AB" => [1, 2],
"PhaseCode.AC" => [1, 3],
"PhaseCode.BC" => [2, 3],
"PhaseCode.A" => [1],
"PhaseCode.B" => [2],
"PhaseCode.C" => [3]
)


"initializes the base math object of any type"
function _init_math_obj_ravens(obj_type::String, eng_id::Any, eng_obj::Dict{String,<:Any}, index::Int; pass_props::Vector{String}=String[])::Dict{String,Any}
math_obj = Dict{String,Any}(
"name" => "$eng_id",
"source_id" => "$obj_type.$eng_id"
)

math_obj["index"] = index

return math_obj
end


"converts impendance in Ohm/m by multiplying by length"
function _impedance_conversion_ravens(data_eng::Dict{String,Any}, eng_obj::Dict{String,Any}, key::String)

_conductor_count = data_eng["PerLengthPhaseImpedance.conductorCount"]
_impedance_matrix = zeros(Float64, _conductor_count, _conductor_count)

for obj in data_eng["PerLengthPhaseImpedance.PhaseImpedanceData"]
row = obj["PhaseImpedanceData.row"]
col = obj["PhaseImpedanceData.column"]
value = get(obj, key, 0.0)
_impedance_matrix[row, col] = value
_impedance_matrix[col, row] = value
end

return _impedance_matrix .* get(eng_obj, "Conductor.length", 1.0)
end


"converts impendance in Ohm/m by multiplying by length"
function _impedance_conversion_ravens_energy_source(data_eng::Dict{String,Any}, eng_obj::Dict{String,Any}, key1::String, key2::String)
# Default energy sources considered 3 phases
nphases = 3
_impedance_matrix = zeros(Float64, nphases, nphases)

z = get(eng_obj, key1, 0.0)
z0 = get(eng_obj, key2, 0.0)

for i in 1:nphases
for j in 1:i
if(i==j)
_impedance_matrix[i, j] = z + ((z0 - z)/3)
else
_impedance_matrix[i, j] = (z0 - z)/3
_impedance_matrix[j, i] = (z0 - z)/3
end
end
end

return _impedance_matrix .* get(eng_obj, "Conductor.length", 1.0)
end


"converts admittance by multiplying by 2πωl"
function _admittance_conversion_ravens(data_eng::Dict{String,<:Any}, eng_obj::Dict{String,<:Any}, key::String; freq::Float64=60.0)

_conductor_count = data_eng["PerLengthPhaseImpedance.conductorCount"]
_admittance_matrix = zeros(Float64, _conductor_count, _conductor_count)

for obj in data_eng["PerLengthPhaseImpedance.PhaseImpedanceData"]
row = obj["PhaseImpedanceData.row"]
col = obj["PhaseImpedanceData.column"]
value = get(obj, key, 0.0)
_admittance_matrix[row, col] = value
_admittance_matrix[col, row] = value
end

return _admittance_matrix .* get(eng_obj, "Conductor.length", 1.0) .* freq ./ 1e2 # divide by 2 to get both sides _to and _fr
end

"extracts the name from a ravens reference string"
function _extract_name(element)

name = replace(split(element, "::")[2], "'" => "")
return name
end


"calculates the shunt admittance matrix based on terminals and b or g"
function _calc_shunt_admittance_matrix(terminals, b)

N = length(terminals)
_shunt_matrix = b* Matrix(LinearAlgebra.I, N, N)
return _shunt_matrix

end
43 changes: 43 additions & 0 deletions src/prob/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ function instantiate_mc_model(
)
end

# @info "$(data["transformer"])"
# DEFINIDOEN_instantiate_mc_model

return _IM.instantiate_model(
data,
model_type,
Expand All @@ -129,6 +132,46 @@ function instantiate_mc_model(
end



function instantiate_mc_model_ravens(
data::Dict{String,<:Any},
model_type::Type,
build_method::Function;
ref_extensions::Vector{<:Function}=Function[],
multinetwork::Bool=ismultinetwork(data),
global_keys::Set{String}=Set{String}(),
ravens2math_extensions::Vector{<:Function}=Function[],
ravens2math_passthrough::Dict{String,<:Vector{<:String}}=Dict{String,Vector{String}}(),
make_pu_extensions::Vector{<:Function}=Function[],
kwargs...
)

@info "Converting CIM-RAVENS data model to MATHEMATICAL first to build JuMP model"

data = transform_data_model_ravens(
data;
multinetwork=multinetwork,
global_keys=global_keys,
ravens2math_extensions=ravens2math_extensions,
ravens2math_passthrough=ravens2math_passthrough,
make_pu_extensions=make_pu_extensions,
)

# @info "$(data["transformer"])"
# DEFINIDOEN_instantiate_mc_model_ravens

return _IM.instantiate_model(
data,
model_type,
build_method,
ref_add_core!,
union(_pmd_math_global_keys, global_keys),
pmd_it_sym;
ref_extensions=ref_extensions,
kwargs...
)
end

"""
solve_mc_model(
data::Dict{String,<:Any},
Expand Down
Loading
Loading