Skip to content

Commit

Permalink
add subsystem to parameter attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Jul 30, 2024
1 parent 950fdb0 commit e5b304d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/core/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct TimeSeriesAttributes{T <: PSY.TimeSeriesData} <: ParameterAttributes
name::String
multiplier_id::Base.RefValue{Int}
component_name_to_ts_uuid::Dict{String, String}
subsystem::Base.RefValue{String}
end

function TimeSeriesAttributes(
Expand All @@ -18,6 +19,7 @@ function TimeSeriesAttributes(
name,
Base.RefValue{Int}(multiplier_id),
component_name_to_ts_uuid,
Base.RefValue{String}(""),
)
end

Expand All @@ -29,6 +31,13 @@ function set_time_series_multiplier_id!(attr::TimeSeriesAttributes, val::Int)
return
end

get_subsystem(attr::TimeSeriesAttributes) = attr.subsystem[]
function set_subsystem!(attr::TimeSeriesAttributes, val::String)
attr.subsystem[] = val
return
end
set_subsystem!(::TimeSeriesAttributes, ::Nothing) = nothing

function add_component_name!(attr::TimeSeriesAttributes, name::String, uuid::String)
if haskey(attr.component_name_to_ts_uuid, name)
throw(ArgumentError("$name is already stored"))
Expand Down
4 changes: 2 additions & 2 deletions src/operation/time_series_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ function get_time_series_values!(
time_series_type::Type{T},
model::DecisionModel,
component,
name,
name::String,
multiplier_id::Int,
initial_time,
initial_time::Dates.DateTime,
horizon::Int;
ignore_scaling_factors = true,
) where {T <: PSY.Forecast}
Expand Down
2 changes: 2 additions & 0 deletions src/parameters/add_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ function _add_time_series_parameters!(
time_steps,
)
set_time_series_multiplier_id!(get_attributes(param_container), time_series_mult_id)
set_subsystem!(get_attributes(param_container), get_subsystem(model))
jump_model = get_jump_model(container)

for (ts_uuid, ts_values) in initial_values
Expand Down Expand Up @@ -282,6 +283,7 @@ function _add_parameters!(
)

set_time_series_multiplier_id!(get_attributes(parameter_container), time_series_mult_id)
set_subsystem!(get_attributes(param_container), get_subsystem(model))
jump_model = get_jump_model(container)
ts_vector = get_time_series(container, service, T(), name)
multiplier = get_multiplier_value(T(), service, V())
Expand Down
7 changes: 6 additions & 1 deletion src/parameters/update_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ function _update_parameter_values!(
horizon = get_time_steps(get_optimization_container(model))[end]
ts_name = get_time_series_name(attributes)
multiplier_id = get_time_series_multiplier_id(attributes)
subsystem = get_subsystem(attributes)
template = get_template(model)
device_model = get_model(template, V)
if isempty(subsystem)
device_model = get_model(template, V)
else
device_model = get_model(template, V, subsystem)
end
components = get_available_components(device_model, get_system(model))
ts_uuids = Set{String}()
for component in components
Expand Down

0 comments on commit e5b304d

Please sign in to comment.