Skip to content

Commit

Permalink
fix uses of default attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Dec 13, 2023
1 parent 3f6e556 commit ca2f252
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
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
20 changes: 15 additions & 5 deletions src/core/service_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ 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 +63,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 +99,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 +114,7 @@ function ServiceModel(
feedforwards,
duals,
time_series_names,
attributes,
attributes_,
)
end

Expand Down

0 comments on commit ca2f252

Please sign in to comment.