-
Notifications
You must be signed in to change notification settings - Fork 29
LOLD Implementation #108
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
base: main
Are you sure you want to change the base?
LOLD Implementation #108
Changes from all commits
f5c18f8
a315b67
e6c2910
5c06e9c
237c582
da59c25
f47c862
eed875c
81c7c70
9df6d85
4e646f5
30ae683
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| # # Interpreting Resource Adequacy Metrics | ||
| # | ||
| # In practice, no single metric fully captures system adequacy. Instead, | ||
| # multiple complementary metrics should be considered together to understand | ||
| # the frequency, distribution and severity of shortfall events. | ||
| # ([NERC (2018)](https://www.nerc.com/globalassets/who-we-are/standing-committees/rstc/pawg/probabilistic_adequacy_and_measures_report.pdf), | ||
| # [EPRI](https://www.epri.com/research/products/3002027833), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it appropriate to cite ESIG report as well - https://www.esig.energy/reports-briefs/new-resource-adequacy-criteria/? |
||
| # [Stephen et al. 2022](https://doi.org/10.1109/PMAPS53380.2022.9810615)). | ||
| # | ||
| # For this reason, PRAS provides multiple result specifications and derived | ||
| # metrics that allow different aspects of system risk to be evaluated | ||
| # consistently. | ||
|
|
||
| # ## Event-Based Interpretation | ||
| # | ||
| # Resource adequacy metrics can be understood by first defining three related concepts ([Stephen et al. 2022](https://doi.org/10.1109/PMAPS53380.2022.9810615)): | ||
| # | ||
| # - An **event-period** is a simulation time step in which a shortfall occurs. | ||
| # - An **event-day** is a day containing at least one event-period. | ||
| # - An **adequacy event** is a set of event-periods that are contiguous at the highest available temporal resolution. | ||
| # | ||
| # These distinctions are important because each resource adequacy metric counts a different quantity, | ||
| # corresponding directly to one of these concepts: | ||
| # | ||
| # - **LOLE** is the expected number of event-periods | ||
| # - **LOLD** is the expected number of event-days | ||
| # | ||
|
akrivi marked this conversation as resolved.
|
||
| # These metrics are related, but they are not interchangeable. | ||
| # | ||
| #md # !!! note | ||
| #md # In PRAS the time resolution of LOLE is determined by the | ||
| #md # simulation timestamps of the system and is not assumed to always be hourly. | ||
|
|
||
| # Another important reason to use multiple metrics, as described in | ||
| # ([Stephen et al. 2022](https://doi.org/10.1109/PMAPS53380.2022.9810615)), | ||
| # is that systems with similar shortfall magnitudes or counts of event-periods | ||
| # can exhibit very different temporal patterns. | ||
| # | ||
| # We can consider a simple example of two cases next: | ||
| # | ||
| # **Case A**: One day with 10 hours of shortfall | ||
| # | ||
| # **Case B**: Ten days with 1 hour of shortfall each | ||
| # | ||
| # | Metric | Case A | Case B | | ||
| # |------|--------|--------| | ||
| # | LOLE | same | same | | ||
| # | EUE | same | same | | ||
| # | LOLD | 1 | 10 | | ||
| # | ||
| # As we can see in the table above, even though LOLE and EUE are identical in this case, | ||
| # LOLD reveals that shortfall events are more dispersed in Case B. | ||
|
akrivi marked this conversation as resolved.
|
||
| # | ||
|
|
||
| # Because event-periods may be distributed across many days, a system with the | ||
| # same number of shortfall periods can have very different numbers of event-days. | ||
| # As a result, exact conversions between hourly and daily adequacy | ||
| # criteria are not generally possible | ||
| # ([Stephen et al. 2022](https://doi.org/10.1109/PMAPS53380.2022.9810615)). | ||
|
|
||
| # This behavior is reflected in PRAS results, where LOLE and LOLD provide | ||
| # complementary views of how shortfall events are distributed in time. | ||
| # | ||
| #md # !!! note | ||
| #md # LOLD is currently available only for `ShortfallSamples`. Calling LOLD on a `Shortfall` result | ||
| #md # will raise an error. | ||
|
|
||
| # ## Mathematical Interpretation | ||
| # | ||
| # In PRAS, adequacy metrics can be interpreted from Monte Carlo shortfall | ||
| # samples. | ||
| # | ||
| # Using the following notation: | ||
| # | ||
| # - ``r`` indexes regions | ||
| # - ``t`` indexes timestamps | ||
| # - ``d`` indexes calendar days | ||
| # - ``s`` indexes Monte Carlo samples | ||
| # - ``e`` indexes adequacy events | ||
| # - ``S_{r,t,s}`` denotes the shortfall in region ``r``, at timestamp ``t``, | ||
| # in Monte Carlo sample ``s`` | ||
| # - ``T(d)`` is the set of timestamps in day ``d`` | ||
| # | ||
| # the adequacy metrics can be expressed as expectations over Monte Carlo samples: | ||
| # | ||
| # ### LOLE | ||
| # | ||
| # LOLE counts the expected number of event-periods with shortfall: | ||
|
|
||
| # ```math | ||
| # \mathrm{LOLE} = | ||
| # \mathbb{E}\left[\sum_t | ||
| # \mathbf{1}\left(\sum_r S_{r,t,s} > 0\right)\right] | ||
| # ``` | ||
| # | ||
| # | ||
| # ### LOLD | ||
| # | ||
| # LOLD counts the expected number of days containing at least one shortfall: | ||
|
|
||
| # ```math | ||
| # \mathrm{LOLD} = \mathbb{E}\left[\sum_d I_{d,s}\right] | ||
| # ``` | ||
| # | ||
| # where: | ||
|
|
||
| # ```math | ||
| # I_{d,s} = | ||
| # \begin{cases} | ||
| # 1 & \text{if } \exists t \in T(d) \text{ such that } \sum_r S_{r,t,s} > 0 \\ | ||
| # 0 & \text{otherwise} | ||
| # \end{cases} | ||
| # ``` | ||
|
|
||
| # ## Analysis with PRAS | ||
| # | ||
| # We revisit the [RTS-GMLC](https://github.com/GridMod/RTS-GMLC) with increased system load to induce shortfall | ||
| # which was described in [PRAS walkthrough](@ref pras_walkthrough) | ||
|
|
||
| using PRAS | ||
| sys = PRAS.rts_gmlc() | ||
| sys.regions.load .+= 700.0 | ||
|
|
||
| shortfall_samples, = assess( | ||
| sys, | ||
| SequentialMonteCarlo(samples=100, seed=1), | ||
| ShortfallSamples(), | ||
| ) | ||
|
|
||
| # And print the metrics we discussed above: | ||
| println(LOLE(shortfall_samples)) | ||
| println(LOLD(shortfall_samples)) | ||
|
|
||
| # In the RTS example above, the system has approximately 85 shortfall hours | ||
| # but only 25.8 shortfall days. This indicates that shortfall events are | ||
| # temporally clustered, meaning that multiple shortfall hours tend to occur within the | ||
| # same day rather than being evenly distributed across the year. | ||
|
|
||
|
|
||
| # ## References | ||
| # | ||
| # - [NERC (2018), *Probabilistic Adequacy and Measures Technical Reference Report*](https://www.nerc.com/globalassets/who-we-are/standing-committees/rstc/pawg/probabilistic_adequacy_and_measures_report.pdf) | ||
| # - [EPRI, *Resource Adequacy Gap Assessment: Resource Adequacy Assessment Framework*](https://www.epri.com/research/products/3002027833) | ||
| # - [Stephen et al. (2022), *Clarifying the Interpretation and Use of the LOLE Resource Adequacy Metric*](https://doi.org/10.1109/PMAPS53380.2022.9810615) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,4 +202,28 @@ ue_ncvar = NCVAR(shortfall, ue_cvar) | |
| println("System NCVAR: $(ue_ncvar)") | ||
|
|
||
| # We can also find the unserved energy CVAR by region | ||
| regional_ue_cvar = CVAR.(:energy, shortfall, alpha, sys.regions.names) | ||
| regional_ue_cvar = CVAR.(:energy, shortfall, alpha, sys.regions.names) | ||
|
|
||
| # ## Export Aggregate Results | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure if we need this here, and would favor the results db/event viewer which will come soon, mainly because we don't expose how this can be read back in or develop tools for down stream analysis with this output. |
||
|
|
||
| # After exploring the simulation outputs, we may want to save the | ||
| # aggregate results for reporting or further post-processing. | ||
|
|
||
| # Rather than querying individual metrics (e.g., LOLE, EUE) | ||
| # one by one, PRAS provides a utility to export all aggregate | ||
| # system-level and region-level results in a single step. | ||
|
|
||
| using PRASFiles | ||
|
|
||
| output_path = saveshortfall(shortfall, sys, "pras_output"); | ||
| println("Results exported to: ", output_path) | ||
|
|
||
| # This creates a timestamped directory containing a `pras_results.json` | ||
| # file with: | ||
| # - system-level metrics (LOLE, EUE, NEUE, LOLD) | ||
| # - region-level metrics | ||
| # - load and capacity summaries | ||
| # - horizon timestamps | ||
|
|
||
| # Note that only aggregate results are exported. Sample-level data | ||
| # from the Monte Carlo simulation are not included. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -261,4 +261,32 @@ stderror(x::NCVAR) = stderror(x.ncvar) | |
| function Base.show(io::IO, x::NCVAR) | ||
| print(io, "NCVAR@$(x.alpha) = ", x.ncvar, " ppm") | ||
|
|
||
| end | ||
| end | ||
|
|
||
| """ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this to below NEUE please |
||
| LOLD | ||
|
|
||
| `LOLD` reports loss of load days over a particular time period | ||
| and regional extent. | ||
|
|
||
| Contains both the estimated value itself as well as the standard error | ||
| of that estimate, which can be extracted with `val` and `stderror`, | ||
| respectively. | ||
| """ | ||
| struct LOLD{D} <: ReliabilityMetric | ||
| lold::MeanEstimate | ||
|
|
||
| function LOLD{D}(lold::MeanEstimate) where {D} | ||
| val(lold) >= 0 || throw(DomainError(val(lold), | ||
| "$(val(lold)) is not a valid expected count of event-days")) | ||
| new{D}(lold) | ||
| end | ||
| end | ||
|
|
||
| val(x::LOLD) = val(x.lold) | ||
| stderror(x::LOLD) = stderror(x.lold) | ||
|
|
||
| function Base.show(io::IO, x::LOLD{D}) where {D} | ||
| print(io, "LOLD = ", x.lold, " event-day/", | ||
| D == 1 ? "day" : string(D) * "days") | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this is an extension to PRAS walkthrough, please give me your thoughts! Can you also include the CVAR here if we go ahead with this? Also will be nice to link this to the docs/resourceadequacy.md page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually let's keep this here, bring CVAR in. Call this "Multi metric resource adequacy analyses with PRAS"