Skip to content

Commit

Permalink
Merge pull request #26 from invenia/npr/renaming
Browse files Browse the repository at this point in the history
Rename accessors and fieldnames to give clearer and more consistent API
  • Loading branch information
nickrobinson251 authored Jul 25, 2022
2 parents 27adb3b + efaab0b commit caf14c5
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 92 deletions.
14 changes: 8 additions & 6 deletions src/FullNetworkSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ export GeneratorTimeSeries, GeneratorStatus, GeneratorStatusDA, GeneratorStatusR
export gens_per_zone, branches_by_breakpoints, get_datetimes
export get_zones, get_buses, get_generators, get_branches, get_lines, get_transformers
export get_regulation_requirements, get_operating_reserve_requirements, get_good_utility_requirements
export get_gens_per_bus, get_loads_per_bus, get_incs_per_bus, get_decs_per_bus, get_psds_per_bus
export get_ptdf, get_lodf
export get_gens_per_bus, get_loads_per_bus, get_incs_per_bus, get_decs_per_bus, get_psls_per_bus
export get_ptdf, get_lodfs
export get_initial_commitment, get_initial_downtime, get_initial_uptime
export get_bids, get_availability, get_must_run
export get_initial_generation, get_load, get_offer_curve
export get_pmin, get_pmax, get_regmin, get_regmax
export get_regulation, get_spinning, get_supplemental_on, get_supplemental_off
export get_increments, get_decrements, get_price_sensitive_loads
export get_availability, get_must_run
export get_initial_generation, get_loads, get_offer_curve
export get_pmin, get_pmax, get_regulation_min, get_regulation_max
export get_regulation_offers, get_spinning_offers, get_on_supplemental_offers, get_off_supplemental_offers
export get_commitment, get_regulation_commitment

include("system.jl")
include("accessors.jl")
include("deprecated.jl")

end
53 changes: 26 additions & 27 deletions src/accessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,32 @@ get_loads_per_bus(system::System) = system.loads_per_bus

"Returns the power transfer distribution factor of the system."
get_ptdf(system::System) = system.ptdf
"Returns the line outage distribution factor matrix of the system for a set of contingencies."
get_lodf(system::System) = system.lodf
"Returns a `Dictionary` of the line outage distribution factor matrices for the `System` indexed by contingencies."
get_lodfs(system::System) = system.lodfs

"Returns the generation of the generator at the start of the time period (pu)"
get_initial_generation(system::System) = system.generator_time_series.initial_generation
"Returns time series data of the load in the system"
get_load(system::System) = system.loads
"Returns time series data of the fixed loads in the system"
get_loads(system::System) = system.loads
"Returns time series data of the generator offer curves"
get_offer_curve(system::System) = system.generator_time_series.offer_curve
"Returns time series data of minimum generator output (pu)"
get_pmin(system::System) = system.generator_time_series.pmin
"Returns time series data of maximum generator output (pu)"
get_pmax(system::System) = system.generator_time_series.pmax
"Returns time series data of minimum generator output in the ancillary services market (pu)"
get_regmin(system::System) = system.generator_time_series.regulation_min
get_regulation_min(system::System) = system.generator_time_series.regulation_min
"Returns time series data of maximum generator output in the ancillary services market (pu)"
get_regmax(system::System) = system.generator_time_series.regulation_max
get_regulation_max(system::System) = system.generator_time_series.regulation_max

"Returns time series data of offer prices for ancillary servives regulation (\$ /pu)"
get_regulation(system::System) = system.generator_time_series.asm_regulation
"Returns time series data of offer prices for ancillary servives spinning (\$ /pu)"
get_spinning(system::System) = system.generator_time_series.asm_spin
"Returns time series data of offer prices for ancillary servives supplemental on (\$ /pu)"
get_supplemental_on(system::System) = system.generator_time_series.asm_sup_on
"Returns time series data of offer prices for ancillary servives supplemental off (\$ /pu)"
get_supplemental_off(system::System) = system.generator_time_series.asm_sup_off
"Returns time series data of offer prices for ancillary servives regulation reserves (\$ /pu)"
get_regulation_offers(system::System) = system.generator_time_series.regulation_offers
"Returns time series data of offer prices for ancillary servives spinning reserves (\$ /pu)"
get_spinning_offers(system::System) = system.generator_time_series.spinning_offers
"Returns time series data of offer prices for ancillary servives online supplemental reserves (\$ /pu)"
get_on_supplemental_offers(system::System) = system.generator_time_series.on_supplemental_offers
"Returns time series data of offer prices for ancillary servives offline supplemental reserves (\$ /pu)"
get_off_supplemental_offers(system::System) = system.generator_time_series.off_supplemental_offers

"Returns a flag indicating whether each generator was on at the start of the day."
function get_initial_commitment(system::SystemDA)
Expand All @@ -97,26 +97,25 @@ end
get_incs_per_bus(system::SystemDA) = system.incs_per_bus
"Returns a `Dictionary` of decrement bids at each bus."
get_decs_per_bus(system::SystemDA) = system.decs_per_bus
"Returns a `Dictionary` of price sensitive demand bids at each bus."
get_psds_per_bus(system::SystemDA) = system.psds_per_bus
"Returns a `Dictionary` of price sensitive load bids at each bus."
get_psls_per_bus(system::SystemDA) = system.psls_per_bus

"""
Returns time series data of bids for the bid type indicated. Bid type must be one of
`:increment`, `:decrement` or `:price_sensitive_demand`.
"""
function get_bids(system::SystemDA, type_of_bid::Symbol)
return getproperty(system, type_of_bid)
end
"Returns time series data of increment bids."
get_increments(system::SystemDA) = system.increments
"Returns time series data of decrement bids."
get_decrements(system::SystemDA) = system.decrements
"Returns time series data of price sensitive load bids."
get_price_sensitive_loads(system::SystemDA) = system.price_sensitive_loads

"Returns time series data of flags indicating if the generator is available to be committed in each hour"
get_availability(system::SystemDA) = system.generator_status.availability
"Returns time series data of flags indicating if the generator must be committed in each hour"
get_must_run(system::SystemDA) = system.generator_status.must_run

"Returns time series data of generator status in each hour"
get_commitment(system::SystemRT) = system.generator_status.status
"Returns time series data of generator regulation status in each hour"
get_regulation_commitment(system::SystemRT) = system.generator_status.status_regulation
"Returns time series data of generator commitment status in each hour"
get_commitment(system::SystemRT) = system.generator_status.commitment
"Returns time series data of generator regulation commitment status in each hour"
get_regulation_commitment(system::SystemRT) = system.generator_status.regulation_commitment

"""
gens_per_zone(system::System)
Expand Down
32 changes: 32 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# v1 deprecations, to be removed in v2

@deprecate get_lodf(system::System) get_lodfs(system)

@deprecate get_regmin(system::System) get_regulation_min(system)
@deprecate get_regmax(system::System) get_regulation_max(system)

@deprecate get_load(system::System) get_loads(system)

@deprecate get_regulation(system::System) get_regulation_offers(system)
@deprecate get_spinning(system::System) get_spinning_offers(system)
@deprecate get_supplemental_on(system::System) get_on_supplemental_offers(system)
@deprecate get_supplemental_off(system::System) get_off_supplemental_offers(system)

@deprecate get_psds_per_bus(system::System) get_psls_per_bus(system)

export get_bids
function get_bids(system::SystemDA, type_of_bid::Symbol)
if type_of_bid === :increment
Base.depwarn("`get_bids(system, :increment)` is deprecated, use `get_increments(system)` instead.", :get_bids)
return get_increments(system)
elseif type_of_bid === :decrement
Base.depwarn("`get_bids(system, :decrement)` is deprecated, use `get_decrements(system)` instead.", :get_bids)
return get_decrements(system)
elseif type_of_bid === :price_sensitive_demand
Base.depwarn("`get_bids(system, :price_sensitive_demand)` is deprecated, use `get_price_sensitive_loads(system)` instead.", :get_bids)
return get_price_sensitive_loads(system)
else
Base.depwarn("`get_bids` is deprecated, use `get_increments` or `get_decrements` or `get_price_sensitive_loads`.", :get_bids)
return getproperty(system, type_of_bid)
end
end
46 changes: 23 additions & 23 deletions src/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,25 @@ Base.@kwdef struct GeneratorTimeSeries
"Generator maximum output (pu)"
pmax::KeyedArray{Float64, 2}
"""
Ancillary services regulation offer prices (\$ /pu). Generators not providing the service
will have `missing` offer data
Ancillary services regulation reserve offer prices (\$ /pu).
Generators not providing the service will have `missing` offer data.
"""
asm_regulation::KeyedArray{Union{Missing, Float64}, 2}
regulation_offers::KeyedArray{Union{Missing, Float64}, 2}
"""
Ancillary services spinning offer prices (\$ /pu). Generators not providing the service
will have `missing` offer data
Ancillary services spinning reserve offer prices (\$ /pu).
Generators not providing the service will have `missing` offer data.
"""
asm_spin::KeyedArray{Union{Missing, Float64}, 2}
spinning_offers::KeyedArray{Union{Missing, Float64}, 2}
"""
Ancillary services supplemental on offer prices (\$ /pu). Generators not providing the service
will have `missing` offer data
Ancillary services online supplemental reserve offer prices (\$ /pu).
Generators not providing the service will have `missing` offer data.
"""
asm_sup_on::KeyedArray{Union{Missing, Float64}, 2}
on_supplemental_offers::KeyedArray{Union{Missing, Float64}, 2}
"""
Ancillary services supplemental off offer prices (\$ /pu). Generators not providing the service
will have `missing` offer data
Ancillary services offline supplemental reserve offer prices (\$ /pu).
Generators not providing the service will have `missing` offer data.
"""
asm_sup_off::KeyedArray{Union{Missing, Float64}, 2}
off_supplemental_offers::KeyedArray{Union{Missing, Float64}, 2}
end

"""
Expand All @@ -296,7 +296,7 @@ Fields:
$TYPEDFIELDS
"""
Base.@kwdef struct GeneratorStatusDA <: GeneratorStatus
"Hours each generator has been at its current status at the start of the day"
"Hours each generator has been at its current commitment status at the start of the day"
hours_at_status::KeyedArray{Float64, 1}
"Flag indicating if the generator is available to be committed in each hour"
availability::KeyedArray{Bool, 2}
Expand All @@ -314,9 +314,9 @@ $TYPEDFIELDS
"""
Base.@kwdef struct GeneratorStatusRT <: GeneratorStatus
"Generator commitment status indicated by a `Bool`"
status::KeyedArray{Bool, 2}
commitment::KeyedArray{Bool, 2}
"Generator regulation commitment status indicated by a `Bool`"
status_regulation::KeyedArray{Bool, 2}
regulation_commitment::KeyedArray{Bool, 2}
end

"""
Expand Down Expand Up @@ -348,10 +348,10 @@ Base.@kwdef mutable struct SystemDA <: System
"`Dictionary` where the keys are bus names and the values are decrement bid ids at that bus"
decs_per_bus::Dictionary{BusName, Vector{BidName}}
"""
`Dictionary` where the keys are bus names and the values are price sensitive demand bid
`Dictionary` where the keys are bus names and the values are price sensitive load bid
ids at that bus
"""
psds_per_bus::Dictionary{BusName, Vector{BidName}}
psls_per_bus::Dictionary{BusName, Vector{BidName}}
"`Dictionary` where the keys are bus names and the values are load ids at that bus"
loads_per_bus::Dictionary{BusName, Vector{BidName}}

Expand All @@ -368,7 +368,7 @@ Base.@kwdef mutable struct SystemDA <: System
by the keys of the `Dictionary`. Each entry is a `KeyedArray` with axis keys
`branch names x branch on outage`
"""
lodf::Dictionary{String, KeyedArray{Float64, 2}}
lodfs::Dictionary{String, KeyedArray{Float64, 2}}
"""
Power transfer distribution factor of the system. `KeyedArray` where the axis keys are
`branch names x bus names`
Expand All @@ -387,11 +387,11 @@ Base.@kwdef mutable struct SystemDA <: System

# Virtuals/PSD time series
"Increment bids time series data. `KeyedArray` where the axis keys are `bid ids x datetimes`"
increment::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
increments::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
"Decrement bids time series data. `KeyedArray` where the axis keys are `bid ids x datetimes`"
decrement::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
"Price sensitive demand bids time series data. `KeyedArray` where the axis keys are `bid ids x datetimes`"
price_sensitive_demand::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
decrements::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
"Price sensitive load bids time series data. `KeyedArray` where the axis keys are `bid ids x datetimes`"
price_sensitive_loads::KeyedArray{Vector{Tuple{Float64, Float64}}, 2}
end

"""
Expand Down Expand Up @@ -421,7 +421,7 @@ Base.@kwdef mutable struct SystemRT <: System
by the keys of the `Dictionary`. Each entry is a `KeyedArray` with axis keys
`branch names x branch on outage`
"""
lodf::Dictionary{String, KeyedArray{Float64, 2}}
lodfs::Dictionary{String, KeyedArray{Float64, 2}}
"""
Power transfer distribution factor of the system. `KeyedArray` where the axis keys are
`branch names x bus names`
Expand Down
Loading

2 comments on commit caf14c5

@nickrobinson251
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/64688

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.0 -m "<description of version>" caf14c55de2176146f6764a690236a94d053f1f4
git push origin v1.4.0

Please sign in to comment.