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

fix uses of default attributes #1028

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions src/core/device_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
use_slacks = false,
duals = Vector{DataType}(),
time_series_names = get_default_time_series_names(D, B),
attributes = get_default_attributes(D, B),
attributes = Dict{String, Any}(),
) where {D <: PSY.Device, B <: AbstractDeviceFormulation}
attributes_ = get_default_attributes(D, B)
for (k, v) in attributes
attributes_[k] = v
end

_check_device_formulation(D)
_check_device_formulation(B)
new{D, B}(
Expand All @@ -69,7 +74,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
duals,
Vector{ServiceModel}(),
time_series_names,
attributes,
attributes_,
)
end
end
Expand Down
19 changes: 14 additions & 5 deletions src/core/service_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ mutable struct ServiceModel{D <: PSY.Service, B <: AbstractServiceFormulation}
feedforwards = Vector{AbstractAffectFeedforward}(),
duals = Vector{DataType}(),
time_series_names = get_default_time_series_names(D, B),
attributes = get_default_attributes(D, B),
attributes = Dict{String, Any}(),
contributing_devices_map = Dict{Type{<:PSY.Component}, Vector{<:PSY.Component}}(),
) where {D <: PSY.Service, B <: AbstractServiceFormulation}
attributes_ = get_default_attributes(D, B)
for (k, v) in attributes
attributes_[k] = v
end

_check_service_formulation(D)
_check_service_formulation(B)
new{D, B}(
Expand All @@ -57,7 +62,7 @@ mutable struct ServiceModel{D <: PSY.Service, B <: AbstractServiceFormulation}
use_slacks,
duals,
time_series_names,
attributes,
attributes_,
contributing_devices_map,
)
end
Expand Down Expand Up @@ -93,8 +98,12 @@ function ServiceModel(
) where {D <: PSY.Service, B <: AbstractServiceFormulation}
# If more attributes are used later, move free form string to const and organize
# attributes
if !haskey(attributes, "aggregated_service_model")
push!(attributes, "aggregated_service_model" => true)
attributes_ = get_default_attributes(D, B)
for (k, v) in attributes
attributes_[k] = v
end
if !haskey(attributes_, "aggregated_service_model")
push!(attributes_, "aggregated_service_model" => true)
end
return ServiceModel(
service_type,
Expand All @@ -104,7 +113,7 @@ function ServiceModel(
feedforwards,
duals,
time_series_names,
attributes,
attributes_,
)
end

Expand Down
Loading