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

Jd/psi decompositionv3 #1066

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/core/device_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
services::Vector{ServiceModel}
time_series_names::Dict{Type{<:TimeSeriesParameter}, String}
attributes::Dict{String, Any}
subsystem::Union{Nothing, String}

function DeviceModel(
::Type{D},
Expand All @@ -75,6 +76,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
Vector{ServiceModel}(),
time_series_names,
attributes_,
nothing,
)
end
end
Expand All @@ -94,6 +96,9 @@ get_time_series_names(m::DeviceModel) = m.time_series_names
get_attributes(m::DeviceModel) = m.attributes
get_attribute(::Nothing, ::String) = nothing
get_attribute(m::DeviceModel, key::String) = get(m.attributes, key, nothing)
get_subsystem(m::DeviceModel) = m.subsystem

set_subsystem!(m::DeviceModel, id::String) = m.subsystem = id

function get_reference_bus(
m::DeviceModel{T, U},
Expand Down
7 changes: 6 additions & 1 deletion src/core/network_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mutable struct NetworkModel{T <: PM.AbstractPowerModel}
duals::Vector{DataType}
radial_network_reduction::PNM.RadialNetworkReduction
reduce_radial_branches::Bool
subsystem::Union{Nothing, String}

function NetworkModel(
::Type{T};
Expand All @@ -52,6 +53,7 @@ mutable struct NetworkModel{T <: PM.AbstractPowerModel}
duals,
PNM.RadialNetworkReduction(),
reduce_radial_branches,
nothing,
)
end
end
Expand All @@ -67,6 +69,9 @@ get_reference_buses(m::NetworkModel{T}) where {T <: PM.AbstractPowerModel} =
get_subnetworks(m::NetworkModel) = m.subnetworks
get_bus_area_map(m::NetworkModel) = m.bus_area_map
has_subnetworks(m::NetworkModel) = !isempty(m.bus_area_map)
get_subsystem(m::NetworkModel) = m.subsystem

set_subsystem!(m::NetworkModel, id::String) = m.subsystem = id

function add_dual!(model::NetworkModel, dual)
dual in model.duals && error("dual = $dual is already stored")
Expand Down Expand Up @@ -139,7 +144,7 @@ function _assign_subnetworks_to_buses(
subnetworks = model.subnetworks
temp_bus_map = Dict{Int, Int}()
radial_network_reduction = PSI.get_radial_network_reduction(model)
for bus in PSI.get_available_components(PSY.ACBus, sys)
for bus in PSI.get_available_components(model, PSY.ACBus, sys)
bus_no = PSY.get_number(bus)
mapped_bus_no = PNM.get_mapped_bus_number(radial_network_reduction, bus)
if haskey(temp_bus_map, bus_no)
Expand Down
11 changes: 7 additions & 4 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ end

function init_optimization_container!(
container::OptimizationContainer,
::Type{T},
network_model::NetworkModel{T},
sys::PSY.System,
) where {T <: PM.AbstractPowerModel}
PSY.set_units_base_system!(sys, "SYSTEM_BASE")
Expand All @@ -358,10 +358,13 @@ function init_optimization_container!(
container.time_steps = 1:get_horizon(settings)

if T <: CopperPlatePowerModel || T <: AreaBalancePowerModel
total_number_of_devices = length(get_available_components(PSY.Device, sys))
total_number_of_devices =
length(get_available_components(network_model, PSY.Device, sys))
else
total_number_of_devices = length(get_available_components(PSY.Device, sys))
total_number_of_devices += length(get_available_components(PSY.ACBranch, sys))
total_number_of_devices =
length(get_available_components(network_model, PSY.Device, sys))
total_number_of_devices +=
length(get_available_components(network_model, PSY.ACBranch, sys))
end

# The 10e6 limit is based on the sizes of the lp benchmark problems http://plato.asu.edu/ftp/lpcom.html
Expand Down
5 changes: 5 additions & 0 deletions src/core/service_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mutable struct ServiceModel{D <: PSY.Service, B <: AbstractServiceFormulation}
time_series_names::Dict{Type{<:TimeSeriesParameter}, String}
attributes::Dict{String, Any}
contributing_devices_map::Dict{Type{<:PSY.Component}, Vector{<:PSY.Component}}
subsystem::Union{Nothing, String}
function ServiceModel(
::Type{D},
::Type{B},
Expand All @@ -64,6 +65,7 @@ mutable struct ServiceModel{D <: PSY.Service, B <: AbstractServiceFormulation}
time_series_names,
attributes_for_model,
contributing_devices_map,
nothing,
)
end
end
Expand All @@ -86,6 +88,9 @@ get_contributing_devices_map(m::ServiceModel, key) =
get(m.contributing_devices_map, key, nothing)
get_contributing_devices(m::ServiceModel) =
[z for x in values(m.contributing_devices_map) for z in x]
get_subsystem(m::ServiceModel) = m.subsystem

set_subsystem!(m::ServiceModel, id::String) = m.subsystem = id

function ServiceModel(
service_type::Type{D},
Expand Down
Loading
Loading