Skip to content

Commit

Permalink
change get_available containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Feb 28, 2024
1 parent f5325a9 commit 3c21b08
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 58 deletions.
1 change: 1 addition & 0 deletions src/core/device_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ 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

Expand Down
1 change: 1 addition & 0 deletions src/core/network_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ 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

Expand Down
8 changes: 4 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,10 @@ 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
1 change: 1 addition & 0 deletions src/core/service_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function validate_available_devices(
system::PSY.System,
) where {T <: PSY.Device}
devices =
get_available_components(T, system, get_attribute(device_model, "filter_function"))
get_available_components(device_model, system, get_attribute(device_model, "filter_function"))
if isempty(devices)
return false
end
Expand Down
24 changes: 12 additions & 12 deletions src/devices_models/device_constructors/load_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function construct_device!(
D <: AbstractControllablePowerLoadFormulation,
}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, D())
add_variables!(container, ReactivePowerVariable, devices, D())
Expand Down Expand Up @@ -47,7 +47,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_constraints!(
container,
Expand Down Expand Up @@ -84,7 +84,7 @@ function construct_device!(
D <: AbstractControllablePowerLoadFormulation,
}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, D())

Expand Down Expand Up @@ -112,7 +112,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_constraints!(
container,
Expand All @@ -138,7 +138,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, PowerLoadInterruption())
add_variables!(container, ReactivePowerVariable, devices, PowerLoadInterruption())
Expand Down Expand Up @@ -177,7 +177,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_constraints!(
container,
Expand Down Expand Up @@ -211,7 +211,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, PowerLoadInterruption())
add_variables!(container, OnVariable, devices, PowerLoadInterruption())
Expand Down Expand Up @@ -240,7 +240,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {L <: PSY.ControllableLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_constraints!(
container,
Expand All @@ -266,7 +266,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {L <: PSY.ElectricLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model)
Expand Down Expand Up @@ -298,7 +298,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {L <: PSY.ElectricLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)

Expand Down Expand Up @@ -333,7 +333,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {L <: PSY.StaticLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model)
Expand Down Expand Up @@ -365,7 +365,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {L <: PSY.StaticLoad}
devices =
get_available_components(L, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
add_to_expression!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function construct_device!(
D <: AbstractRenewableDispatchFormulation,
}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, D())
add_variables!(container, ReactivePowerVariable, devices, D())
Expand Down Expand Up @@ -63,7 +63,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {R <: PSY.RenewableGen}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

if has_service_model(model)
add_constraints!(
Expand Down Expand Up @@ -120,7 +120,7 @@ function construct_device!(
D <: AbstractRenewableDispatchFormulation,
}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_variables!(container, ActivePowerVariable, devices, D())

Expand Down Expand Up @@ -165,7 +165,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {R <: PSY.RenewableGen}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

if has_service_model(model)
add_constraints!(
Expand Down Expand Up @@ -211,7 +211,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {R <: PSY.RenewableGen}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
add_parameters!(container, ReactivePowerTimeSeriesParameter, devices, model)
Expand Down Expand Up @@ -243,7 +243,7 @@ function construct_device!(
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {R <: PSY.RenewableGen}
devices =
get_available_components(R, sys, get_attribute(model, "filter_function"))
get_available_components(model, sys, get_attribute(model, "filter_function"))

add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
add_to_expression!(
Expand Down
Loading

0 comments on commit 3c21b08

Please sign in to comment.