-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32dd37e
commit 10a7c1c
Showing
91 changed files
with
2,348 additions
and
2,714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.jl.mem | ||
Manifest.toml | ||
*.DS_Store | ||
*.pras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name = "PRAS" | ||
uuid = "05348d26-1c52-11e9-35e3-9d51842d34b9" | ||
authors = [ | ||
"Gord Stephen <Gord.Stephen@nrel.gov>", | ||
"Surya Chandan Dhulipala <SuryaChandan.Dhulipala@nrel.gov>", | ||
"Hari Sundar <Hari.Sundar@nrel.gov>" | ||
] | ||
version = "0.7.0" | ||
|
||
[deps] | ||
PRASCapacityCredits = "2e1a2ed5-e89d-4cd3-bc86-c0e88a73d3a3" | ||
PRASCore = "c5c32b99-e7c3-4530-a685-6f76e19f7fe2" | ||
PRASFiles = "a2806276-6d43-4ef5-91c0-491704cd7cf1" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
|
||
[compat] | ||
PRASCapacityCredits = "0.7" | ||
PRASCore = "0.7" | ||
PRASFiles = "0.7" | ||
julia = "1" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module PRAS | ||
|
||
using Reexport | ||
|
||
@reexport using PRASCore | ||
@reexport using PRASCapacityCredits | ||
|
||
import PRASFiles: toymodel, rts_gmlc | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using PRAS | ||
using Test | ||
|
||
sys = PRAS.rts_gmlc() | ||
|
||
sf, = assess(sys, SequentialMonteCarlo(samples=100), Shortfall()) | ||
|
||
eue = EUE(sf) | ||
lole = LOLE(sf) | ||
|
||
@test val(eue) isa Float64 | ||
@test stderror(eue) isa Float64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name = "PRASCapacityCredits" | ||
uuid = "2e1a2ed5-e89d-4cd3-bc86-c0e88a73d3a3" | ||
authors = ["Gord Stephen <gord.stephen@nrel.gov>"] | ||
version = "0.7.0" | ||
|
||
[deps] | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
PRASCore = "c5c32b99-e7c3-4530-a685-6f76e19f7fe2" | ||
|
||
[compat] | ||
Distributions = "0.25" | ||
PRASCore = "0.7" | ||
julia = "1" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
src/CapacityCredit/CapacityCredit.jl → ...apacityCredits/src/PRASCapacityCredits.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module PRASCore | ||
|
||
import Reexport: @reexport | ||
|
||
include("Systems/Systems.jl") | ||
include("Results/Results.jl") | ||
include("Simulations/Simulations.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
""" | ||
Flow | ||
Flow metric represents the flow between interfaces at timestamps | ||
in a FlowResult with a (interfaces, timestamps) matrix API. | ||
Separate samples are averaged together into mean and std values. | ||
See [`FlowSamples`](@ref) for all flow samples. | ||
""" | ||
struct Flow <: ResultSpec end | ||
|
||
struct FlowAccumulator <: ResultAccumulator{Flow} | ||
|
||
flow_interface::Vector{MeanVariance} | ||
flow_interfaceperiod::Matrix{MeanVariance} | ||
|
||
flow_interface_currentsim::Vector{Int} | ||
|
||
end | ||
|
||
function accumulator( | ||
sys::SystemModel{N}, nsamples::Int, ::Flow | ||
) where {N} | ||
|
||
n_interfaces = length(sys.interfaces) | ||
flow_interface = [meanvariance() for _ in 1:n_interfaces] | ||
flow_interfaceperiod = [meanvariance() for _ in 1:n_interfaces, _ in 1:N] | ||
|
||
flow_interface_currentsim = zeros(Int, n_interfaces) | ||
|
||
return FlowAccumulator( | ||
flow_interface, flow_interfaceperiod, flow_interface_currentsim) | ||
|
||
end | ||
|
||
function merge!( | ||
x::FlowAccumulator, y::FlowAccumulator | ||
) | ||
|
||
foreach(merge!, x.flow_interface, y.flow_interface) | ||
foreach(merge!, x.flow_interfaceperiod, y.flow_interfaceperiod) | ||
|
||
end | ||
|
||
accumulatortype(::Flow) = FlowAccumulator | ||
|
||
struct FlowResult{N,L,T<:Period,P<:PowerUnit} <: AbstractFlowResult{N,L,T} | ||
|
||
nsamples::Union{Int,Nothing} | ||
interfaces::Vector{Pair{String,String}} | ||
timestamps::StepRange{ZonedDateTime,T} | ||
|
||
flow_mean::Matrix{Float64} | ||
|
||
flow_interface_std::Vector{Float64} | ||
flow_interfaceperiod_std::Matrix{Float64} | ||
|
||
end | ||
|
||
function getindex(x::FlowResult, i::Pair{<:AbstractString,<:AbstractString}) | ||
i_i, reverse = findfirstunique_directional(x.interfaces, i) | ||
flow = mean(view(x.flow_mean, i_i, :)) | ||
return reverse ? -flow : flow, x.flow_interface_std[i_i] | ||
end | ||
|
||
function getindex(x::FlowResult, i::Pair{<:AbstractString,<:AbstractString}, t::ZonedDateTime) | ||
i_i, reverse = findfirstunique_directional(x.interfaces, i) | ||
i_t = findfirstunique(x.timestamps, t) | ||
flow = x.flow_mean[i_i, i_t] | ||
return reverse ? -flow : flow, x.flow_interfaceperiod_std[i_i, i_t] | ||
end | ||
|
||
function finalize( | ||
acc::FlowAccumulator, | ||
system::SystemModel{N,L,T,P,E}, | ||
) where {N,L,T,P,E} | ||
|
||
nsamples = length(system.interfaces) > 0 ? | ||
first(acc.flow_interface[1].stats).n : nothing | ||
|
||
flow_mean, flow_interfaceperiod_std = mean_std(acc.flow_interfaceperiod) | ||
flow_interface_std = last(mean_std(acc.flow_interface)) / N | ||
|
||
fromregions = getindex.(Ref(system.regions.names), system.interfaces.regions_from) | ||
toregions = getindex.(Ref(system.regions.names), system.interfaces.regions_to) | ||
|
||
return FlowResult{N,L,T,P}( | ||
nsamples, Pair.(fromregions, toregions), system.timestamps, | ||
flow_mean, flow_interface_std, flow_interfaceperiod_std) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
FlowSamples | ||
Flow samples represent the flow between interfaces at timestamps, which has | ||
not been averaged across different samples. This presents a | ||
3D matrix API (interfaces, timestamps, samples). | ||
See [`Flow`](@ref) for sample-averaged flow data. | ||
""" | ||
struct FlowSamples <: ResultSpec end | ||
|
||
struct FlowSamplesAccumulator <: ResultAccumulator{FlowSamples} | ||
|
||
flow::Array{Int,3} | ||
|
||
end | ||
|
||
function accumulator( | ||
sys::SystemModel{N}, nsamples::Int, ::FlowSamples | ||
) where {N} | ||
|
||
ninterfaces = length(sys.interfaces) | ||
flow = zeros(Int, ninterfaces, N, nsamples) | ||
|
||
return FlowSamplesAccumulator(flow) | ||
|
||
end | ||
|
||
function merge!( | ||
x::FlowSamplesAccumulator, y::FlowSamplesAccumulator | ||
) | ||
|
||
x.flow .+= y.flow | ||
return | ||
|
||
end | ||
|
||
accumulatortype(::FlowSamples) = FlowSamplesAccumulator | ||
|
||
struct FlowSamplesResult{N,L,T<:Period,P<:PowerUnit} <: AbstractFlowResult{N,L,T} | ||
|
||
interfaces::Vector{Pair{String,String}} | ||
timestamps::StepRange{ZonedDateTime,T} | ||
|
||
flow::Array{Int,3} | ||
|
||
end | ||
|
||
function getindex(x::FlowSamplesResult, i::Pair{<:AbstractString,<:AbstractString}) | ||
i_i, reverse = findfirstunique_directional(x.interfaces, i) | ||
flow = vec(mean(view(x.flow, i_i, :, :), dims=1)) | ||
return reverse ? -flow : flow | ||
end | ||
|
||
|
||
function getindex(x::FlowSamplesResult, i::Pair{<:AbstractString,<:AbstractString}, t::ZonedDateTime) | ||
i_i, reverse = findfirstunique_directional(x.interfaces, i) | ||
i_t = findfirstunique(x.timestamps, t) | ||
flow = vec(x.flow[i_i, i_t, :]) | ||
return reverse ? -flow : flow | ||
end | ||
|
||
function finalize( | ||
acc::FlowSamplesAccumulator, | ||
system::SystemModel{N,L,T,P,E}, | ||
) where {N,L,T,P,E} | ||
|
||
fromregions = getindex.(Ref(system.regions.names), system.interfaces.regions_from) | ||
toregions = getindex.(Ref(system.regions.names), system.interfaces.regions_to) | ||
|
||
return FlowSamplesResult{N,L,T,P}( | ||
Pair.(fromregions, toregions), system.timestamps, acc.flow) | ||
|
||
end |
Oops, something went wrong.