From 050fa787f6792e0aa4d71da3abc6cc6ca59c5579 Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Thu, 10 Oct 2024 12:57:17 -0600 Subject: [PATCH] add group name to technologymodel --- src/base/technology_model.jl | 4 ++- .../technologies/common/add_variable.jl | 4 +++ .../supply_constructor.jl | 35 +++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/base/technology_model.jl b/src/base/technology_model.jl index fb0e438..f2e8e1d 100644 --- a/src/base/technology_model.jl +++ b/src/base/technology_model.jl @@ -8,6 +8,7 @@ mutable struct TechnologyModel{ duals::Vector{DataType} time_series_names::Dict{Type{<:TimeSeriesParameter}, String} attributes::Dict{String, Any} + group_name::String end function _set_model!( @@ -72,6 +73,7 @@ function TechnologyModel( duals=Vector{DataType}(), time_series_names=get_default_time_series_names(D, A, B, C), attributes=Dict{String, Any}(), + group_name = "" ) where { D <: PSIP.Technology, A <: InvestmentTechnologyFormulation, @@ -86,5 +88,5 @@ function TechnologyModel( #_check_technology_formulation(D, A, B, C) #TODO: new is only defined for inner constructors, replace for now but we might want to reorganize this file later #new{D, B, C}(use_slacks, duals, time_series_names, attributes_, nothing) - return TechnologyModel{D, A, B, C}(use_slacks, duals, time_series_names, attributes_) + return TechnologyModel{D, A, B, C}(use_slacks, duals, time_series_names, attributes_, group_name) end diff --git a/src/technology_models/technologies/common/add_variable.jl b/src/technology_models/technologies/common/add_variable.jl index 69ab036..a199525 100644 --- a/src/technology_models/technologies/common/add_variable.jl +++ b/src/technology_models/technologies/common/add_variable.jl @@ -3,6 +3,7 @@ function add_variable!( variable_type::T, devices::U, formulation::AbstractTechnologyFormulation, + group_name::String ) where { T <: InvestmentVariableType, U <: Union{D, Vector{D}, IS.FlattenIteratorWrapper{D}}, @@ -17,6 +18,7 @@ function add_variable!( D, [PSIP.get_name(d) for d in devices], time_steps, + meta=group_name ) for t in time_steps, d in devices @@ -41,6 +43,7 @@ function add_variable!( variable_type::T, devices::U, formulation::AbstractTechnologyFormulation, + group_name::String ) where { T <: OperationsVariableType, U <: Union{D, Vector{D}, IS.FlattenIteratorWrapper{D}}, @@ -55,6 +58,7 @@ function add_variable!( D, [PSIP.get_name(d) for d in devices], time_steps, + meta = group_name ) for t in time_steps, d in devices diff --git a/src/technology_models/technology_constructors/supply_constructor.jl b/src/technology_models/technology_constructors/supply_constructor.jl index f13ce17..b8e0e72 100644 --- a/src/technology_models/technology_constructors/supply_constructor.jl +++ b/src/technology_models/technology_constructors/supply_constructor.jl @@ -21,7 +21,7 @@ function construct_technologies!( # BuildCapacity variable # This should break if a name is passed here a second time - add_variable!(container, BuildCapacity(), devices, B()) + add_variable!(container, BuildCapacity(), devices, B(), technology_model.group_name) # CumulativeCapacity add_expression!(container, CumulativeCapacity(), devices, B()) @@ -48,7 +48,7 @@ function construct_technologies!( devices = [PSIP.get_technology(T, p, n) for n in names] #ActivePowerVariable - add_variable!(container, ActivePowerVariable(), devices, C()) + add_variable!(container, ActivePowerVariable(), devices, C(), technology_model.group_name) # SupplyTotal add_to_expression!(container, EnergyBalance(), devices, C()) @@ -161,3 +161,34 @@ function construct_technologies!( return end + +#Added constructor for unit investment problems. Does not do anything yet, purely for testing purposes +function construct_technologies!( + container::SingleOptimizationContainer, + p::PSIP.Portfolio, + names::Vector{String}, + ::ArgumentConstructStage, + ::CapitalCostModel, + technology_model::TechnologyModel{T, B, C, D}, + # network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where { + T <: PSIP.SupplyTechnology, + B <: IntegerInvestment, + C <: BasicDispatch, + D <: FeasibilityTechnologyFormulation, +} + + #TODO: Port get_available_component functions from PSY + # filter based on technology names passed + #TODO: Review when we start working with larger models + devices = [PSIP.get_technology(T, p, n) for n in names] + #PSIP.get_technologies(T, p) + + # BuildCapacity variable + # This should break if a name is passed here a second time + add_variable!(container, BuildCapacity(), devices, B(), technology_model.group_name) + + # CumulativeCapacity + #add_expression!(container, CumulativeCapacity(), devices, B(), technology_model.group_name) + return +end \ No newline at end of file