diff --git a/src/core/device_model.jl b/src/core/device_model.jl index 1e73d2a560..02d854e4d4 100644 --- a/src/core/device_model.jl +++ b/src/core/device_model.jl @@ -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}( @@ -69,7 +74,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation} duals, Vector{ServiceModel}(), time_series_names, - attributes, + attributes_, ) end end diff --git a/src/core/service_model.jl b/src/core/service_model.jl index 6ea786fa81..862e30c54b 100644 --- a/src/core/service_model.jl +++ b/src/core/service_model.jl @@ -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_for_model = get_default_attributes(D, B) + for (k, v) in attributes + attributes_for_model[k] = v + end + _check_service_formulation(D) _check_service_formulation(B) new{D, B}( @@ -57,7 +62,7 @@ mutable struct ServiceModel{D <: PSY.Service, B <: AbstractServiceFormulation} use_slacks, duals, time_series_names, - attributes, + attributes_for_model, contributing_devices_map, ) end @@ -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_for_model = get_default_attributes(D, B) + for (k, v) in attributes + attributes_for_model[k] = v + end + if !haskey(attributes_for_model, "aggregated_service_model") + push!(attributes_for_model, "aggregated_service_model" => true) end return ServiceModel( service_type, @@ -104,7 +113,7 @@ function ServiceModel( feedforwards, duals, time_series_names, - attributes, + attributes = attributes_for_model, ) end