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

Jd/outagesv2 #1061

Merged
merged 6 commits into from
Feb 29, 2024
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
6 changes: 5 additions & 1 deletion src/PowerSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ export PriorityCurrentLimiter
export Source
export PeriodicVariableSource

export Contingency

# Outages
export Outage
export ForcedOutage
export GeometricDistributionForcedOutage
export PlannedOutage
export TimeSeriesForcedOutage

export Service
export AbstractReserve
Expand Down Expand Up @@ -620,6 +623,7 @@ include("models/supplemental_constructors.jl")
include("models/supplemental_accessors.jl")

# Supplemental attributes
include("contingencies.jl")
include("outages.jl")

# Definitions of PowerSystem
Expand Down
2 changes: 1 addition & 1 deletion src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ Gets components availability. Requires type T to have the method get_available i
"""

function get_available_components(::Type{T}, sys::System) where {T <: Component}
return get_components(x -> get_available(x), T, sys)
return get_components(get_available, T, sys)
end

"""
Expand Down
1 change: 1 addition & 0 deletions src/contingencies.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abstract type Contingency <: SupplementalAttribute end
104 changes: 78 additions & 26 deletions src/outages.jl
Original file line number Diff line number Diff line change
@@ -1,63 +1,115 @@
abstract type Outage <: SupplementalAttribute end
abstract type Outage <: Contingency end

struct ForcedOutage <: Outage
forced_outage_rate::Float64
mean_time_to_recovery::Int
outage_probability::Float64
recovery_probability::Float64
"""Get `components_uuid`."""
get_component_uuids(x::Outage) = x.component_uuids
"""Get `internal`."""
get_internal(x::Outage) = x.internal
"""Get `time_series_container`."""
get_time_series_container(x::Outage) = x.time_series_container

"""
Attribute that contains information regarding forced outages where the transition probabilities
are modeled with geometric distributions. The outage probabilities and recovery probabilities can be modeled as time
series.

# Arguments
- `time_to_recovery::Int`: Time elapsed to recovery after a failure in Milliseconds.
- `outage_transition_probability::Float64`: Characterizes the probability of failure (1 - p) in the geometric distribution.
- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage
- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify
"""
struct GeometricDistributionForcedOutage <: Outage
mean_time_to_recovery::Float64
outage_transition_probability::Float64
time_series_container::InfrastructureSystems.TimeSeriesContainer
component_uuids::InfrastructureSystems.ComponentUUIDs
internal::InfrastructureSystemsInternal
end

function ForcedOutage(;
forced_outage_rate = 0.0,
mean_time_to_recovery = 0,
outage_probability = 0.0,
recovery_probability = 0.0,
function GeometricDistributionForcedOutage(;
mean_time_to_recovery = 0.0,
outage_transition_probability = 0.0,
time_series_container = InfrastructureSystems.TimeSeriesContainer(),
component_uuids = InfrastructureSystems.ComponentUUIDs(),
internal = InfrastructureSystemsInternal(),
)
return ForcedOutage(
forced_outage_rate,
return GeometricDistributionForcedOutage(
mean_time_to_recovery,
outage_probability,
recovery_probability,
outage_transition_probability,
time_series_container,
component_uuids,
internal,
)
end

get_component_uuids(x::ForcedOutage) = x.component_uuids
get_internal(x::ForcedOutage) = x.internal
get_time_series_container(x::ForcedOutage) = x.time_series_container
"""Get [`GeometricDistributionForcedOutage`](@ref) `time_to_recovery`."""
get_mean_time_to_recovery(value::GeometricDistributionForcedOutage) =
value.mean_time_to_recovery
"""Get [`GeometricDistributionForcedOutage`](@ref) `outage_probability`."""
get_outage_transition_probability(value::GeometricDistributionForcedOutage) =
value.outage_transition_probability

"""
Attribute that contains information regarding planned outages.

# Arguments
- `outage_schedule::String`: String name of the time series used for the scheduled outages
- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage
- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify
"""
struct PlannedOutage <: Outage
time_to_recovery::Int
outage_schedule::Int
outage_schedule::String
time_series_container::InfrastructureSystems.TimeSeriesContainer
component_uuids::InfrastructureSystems.ComponentUUIDs
internal::InfrastructureSystemsInternal
end

function PlannedOutage(;
time_to_recovery = 0,
outage_schedule = 0.0,
outage_schedule,
time_series_container = InfrastructureSystems.TimeSeriesContainer(),
component_uuids = InfrastructureSystems.ComponentUUIDs(),
internal = InfrastructureSystemsInternal(),
)
return PlannedOutage(
time_to_recovery,
outage_schedule,
time_series_container,
component_uuids,
internal,
)
end

get_component_uuids(x::PlannedOutage) = x.component_uuids
get_internal(x::PlannedOutage) = x.internal
get_time_series_container(x::PlannedOutage) = x.time_series_container
"""Get [`PlannedOutage`](@ref) `outage_schedule`."""
get_outage_schedule(value::PlannedOutage) = value.outage_schedule

"""
Attribute that contains the representation of the status of the component forced outage.
The data can be obtained from the simulation of an stochastic process or historical information.

# Arguments
- `outage_status_scenario::String`: String name of the time series used for the forced outage status in the model. 1 is used represent outaged and 0 for available.
- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage
- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify
"""
struct TimeSeriesForcedOutage <: Outage
outage_status_scenario::String
time_series_container::InfrastructureSystems.TimeSeriesContainer
component_uuids::InfrastructureSystems.ComponentUUIDs
internal::InfrastructureSystemsInternal
end

function TimeSeriesForcedOutage(;
outage_status_scenario,
time_series_container = InfrastructureSystems.TimeSeriesContainer(),
component_uuids = InfrastructureSystems.ComponentUUIDs(),
internal = InfrastructureSystemsInternal(),
)
return TimeSeriesForcedOutage(
outage_status_scenario,
time_series_container,
component_uuids,
internal,
)
end

"""Get [`TimeSeriesForcedOutage`](@ref) `outage_status_scenario`."""
get_outage_status_scenario(value::TimeSeriesForcedOutage) = value.outage_status_scenario
8 changes: 4 additions & 4 deletions test/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ function create_system_with_outages()
initial_time = Dates.DateTime("2020-01-01T00:00:00")
end_time = Dates.DateTime("2020-01-01T23:00:00")
dates = collect(initial_time:Dates.Hour(1):end_time)
fo1 = ForcedOutage(; forced_outage_rate = 1.0)
fo2 = ForcedOutage(; forced_outage_rate = 2.0)
po1 = PlannedOutage(; outage_schedule = 3.0)
po2 = PlannedOutage(; outage_schedule = 4.0)
fo1 = GeometricDistributionForcedOutage(; outage_probability = 0.5)
fo2 = GeometricDistributionForcedOutage(; outage_probability = 0.5)
po1 = PlannedOutage(; outage_schedule = "1")
po2 = PlannedOutage(; outage_schedule = "1")
add_supplemental_attribute!(sys, gen1, fo1)
add_supplemental_attribute!(sys, gen1, po1)
add_supplemental_attribute!(sys, gen2, fo2)
Expand Down
Loading