diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index 73cc11e950..27d2b01299 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -429,6 +429,7 @@ include("core/parameters.jl") include("core/service_model.jl") include("core/device_model.jl") include("core/variables.jl") +include("core/event_keys.jl") include("core/auxiliary_variables.jl") include("core/constraints.jl") include("core/expressions.jl") diff --git a/src/core/constraints.jl b/src/core/constraints.jl index ac0f75957e..f63b73fc79 100644 --- a/src/core/constraints.jl +++ b/src/core/constraints.jl @@ -86,6 +86,9 @@ struct ActivePowerVariableLimitsConstraint <: PowerVariableLimitsConstraint end struct ReactivePowerVariableLimitsConstraint <: PowerVariableLimitsConstraint end struct ActivePowerVariableTimeSeriesLimitsConstraint <: PowerVariableLimitsConstraint end +abstract type EventConstraint <: ConstraintType end +struct OutageConstraint <: EventConstraint end + # These apply to the processing of constraint duals should_write_resulting_value(::Type{<:ConstraintType}) = true convert_result_to_natural_units(::Type{<:ConstraintType}) = false diff --git a/src/core/event_keys.jl b/src/core/event_keys.jl new file mode 100644 index 0000000000..9c2a370a6f --- /dev/null +++ b/src/core/event_keys.jl @@ -0,0 +1,22 @@ +abstract type EventType end + +struct EventKey{T <: EventType, U <: Union{PSY.Component, PSY.System}} + meta::String +end + +function EventKey( + ::Type{T}, + ::Type{U}, +) where {T <: EventType, U <: Union{PSY.Component, PSY.System}} + if isabstracttype(U) + error("Type $U can't be abstract") + end + return EventKey{T, U}("") +end + +get_entry_type( + ::EventKey{T, U}, +) where {T <: EventType, U <: Union{PSY.Component, PSY.System}} = T +get_component_type( + ::EventKey{T, U}, +) where {T <: EventType, U <: Union{PSY.Component, PSY.System}} = U diff --git a/src/core/parameters.jl b/src/core/parameters.jl index d14c113c26..c20086c733 100644 --- a/src/core/parameters.jl +++ b/src/core/parameters.jl @@ -310,6 +310,8 @@ struct CostFunctionParameter <: ObjectiveFunctionParameter end abstract type AuxVariableValueParameter <: RightHandSideParameter end +struct EventParameter <: ParameterType end + should_write_resulting_value(::Type{<:ParameterType}) = false should_write_resulting_value(::Type{<:RightHandSideParameter}) = true diff --git a/src/simulation/simulation_sequence.jl b/src/simulation/simulation_sequence.jl index 2ea134f7a9..dde88ceffb 100644 --- a/src/simulation/simulation_sequence.jl +++ b/src/simulation/simulation_sequence.jl @@ -240,6 +240,7 @@ mutable struct SimulationSequence horizons::OrderedDict{Symbol, Int} intervals::OrderedDict{Symbol, Dates.Millisecond} feedforwards::Dict{Symbol, Vector{<:AbstractAffectFeedforward}} + events::Dict{EventKey, Any} ini_cond_chronology::InitialConditionChronology execution_order::Vector{Int} executions_by_model::OrderedDict{Symbol, Int} @@ -249,6 +250,7 @@ mutable struct SimulationSequence function SimulationSequence(; models::SimulationModels, feedforwards = Dict{String, Vector{<:AbstractAffectFeedforward}}(), + events = Dict{EventKey, Any}(), ini_cond_chronology = InterProblemChronology(), ) # Allow strings or symbols as keys; convert to symbols. @@ -273,6 +275,7 @@ mutable struct SimulationSequence horizons, intervals, _attach_feedforwards(models, feedforwards), + event, ini_cond_chronology, execution_order, executions_by_model,