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 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
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 @@
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}(
Expand All @@ -57,7 +62,7 @@
use_slacks,
duals,
time_series_names,
attributes,
attributes_for_model,
contributing_devices_map,
)
end
Expand Down Expand Up @@ -93,8 +98,12 @@
) 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

Check warning on line 104 in src/core/service_model.jl

View check run for this annotation

Codecov / codecov/patch

src/core/service_model.jl#L103-L104

Added lines #L103 - L104 were not covered by tests
if !haskey(attributes_for_model, "aggregated_service_model")
push!(attributes_for_model, "aggregated_service_model" => true)
end
return ServiceModel(
service_type,
Expand All @@ -104,7 +113,7 @@
feedforwards,
duals,
time_series_names,
attributes,
attributes = attributes_for_model,
)
end

Expand Down
Loading