Skip to content

Commit 31ac9f5

Browse files
Merge pull request #182 from darrylmelander/lifecycle-doc
Lifecycle doc
2 parents 7c184a7 + 311cab7 commit 31ac9f5

28 files changed

+1321
-697
lines changed
Loading

Diff for: doc/OnlineDocs/source/concepts/data_streams.rst

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Time Series Data Streams
22
========================
33

44
Prescient uses time series data from two data streams, the real-time stream
5-
(i.e., actuals) and the forecast stream. As their names imply, the real-time
5+
(i.e., actuals) and the forecast stream. As their names imply, the real-time
66
stream includes data that the simulation should treat as actual values that
77
occur at specific times in the simulation, and the forecast stream includes
88
forecasts for time periods that have not yet occured in the simulation.
@@ -13,25 +13,25 @@ generation data.
1313
Real-Time Data (Actuals)
1414
------------------------
1515

16-
The real-time data stream provides data that the simulation should treat as
16+
The real-time data stream provides data that the simulation should treat as
1717
actual values. Real-time values are typically used only when the simulation reaches
1818
the corresponding simulation time.
1919

2020
Real-time data can be provided at any time interval. The real-time data interval
21-
generally matches the SCED interval
22-
(see :ref:`sced-frequency-minutes<config_sced-frequency-minutes>`), but this is
23-
not a requirement. If the SCED interval does not match the real-time interval
21+
generally matches the SCED interval
22+
(see :ref:`sced-frequency-minutes<config_sced-frequency-minutes>`), but this is
23+
not a requirement. If the SCED interval does not match the real-time interval
2424
then real-time data will be interpolated or discarded as needed to match the SCED
2525
interval.
2626

2727
Forecasts
2828
---------
2929

30-
Forecast data are provided by the forecast data stream. The frequency of data
30+
Forecast data are provided by the forecast data stream. The frequency of data
3131
provided through the forecast stream must be hourly.
3232

33-
New forecasts are retrieved each time a new RUC plan is generated. The
34-
forecasts retrieved in a given batch are those required to satisfy the RUC horizon
33+
New forecasts are retrieved each time a new RUC plan is generated. The
34+
forecasts retrieved in a given batch are those required to satisfy the RUC horizon
3535
(see :ref:`ruc-horizon<config_ruc-horizon>`), starting with the RUC activation time.
3636

3737

@@ -40,17 +40,17 @@ forecasts retrieved in a given batch are those required to satisfy the RUC horiz
4040
Forecast Smoothing
4141
~~~~~~~~~~~~~~~~~~
4242

43-
As forecasts are retrieved from the forecast data stream, they may be adjusted so that
43+
As forecasts are retrieved from the forecast data stream, they may be adjusted so that
4444
near-term forecasts are more accurate than forecasts further into the future. This serves
4545
two purposes: first, to avoid large jumps in timeseries values due to inaccurate forecasts;
4646
and second, to model how forecasts become more accurate as their time approaches.
4747

48-
The number of forecasts to be smoothed is determined by the
48+
The number of forecasts to be smoothed is determined by the
4949
:ref:`ruc-prescience-hour<config_ruc-prescience-hour>` configuration option. Values for
50-
the current simulation time are set equal to their actual value, ignoring data read from
50+
the current simulation time are set equal to their actual value, ignoring data read from
5151
the forecast stream. Values for ``ruc-prescience-hour`` hours after the current simulation
5252
time are set equal to data read from the forecast stream. Between these two times,
53-
values are a weighted average of the values provided by the actuals and forecast data
53+
values are a weighted average of the values provided by the actuals and forecast data
5454
streams. The weights vary linearly with where the time falls between the current time
5555
and the ruc prescience hour. For example, if ``ruc-prescience-hour`` is 8, then the adjusted
5656
forecast for 2 hours after the current simulation time will be ``0.25*forecast + 0.75*actual``.
@@ -62,8 +62,8 @@ Real-Time Forecast Adjustments
6262
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6363

6464
Forecasts are adjusted further each time a SCED is run. This is done by comparing the forecast
65-
for the current time with the actual value for the current time. The ratio of these two
66-
values is calculated, then used as a scaling factor for forecast values. For example, if the
65+
for the current time with the actual value for the current time. The ratio of these two
66+
values is calculated, then used as a scaling factor for forecast values. For example, if the
6767
forecast for a value was 10% too high, all future forecasts for the same value are reduced by 10%.
6868

6969
.. note::

Diff for: doc/OnlineDocs/source/concepts/index.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Modeling Concepts
2-
-----------------
3-
4-
.. toctree::
5-
:maxdepth: 2
6-
7-
ruc_sced_cycle.rst
8-
data_streams.rst
9-
reserves.rst
10-
markets.rst
1+
Modeling Concepts
2+
-----------------
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
ruc_sced_cycle.rst
8+
data_streams.rst
9+
reserves.rst
10+
markets.rst

Diff for: doc/OnlineDocs/source/concepts/markets.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Energy Markets and Pricing
2-
==========================
3-
1+
Energy Markets and Pricing
2+
==========================
3+

Diff for: doc/OnlineDocs/source/concepts/reserves.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Reserves and Ancillary Services
1+
Reserves and Ancillary Services
22
===============================

Diff for: doc/OnlineDocs/source/concepts/ruc_sced_cycle.rst

+30-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Prescient Simulation Cycle
44
.. image:: ../_static/image/RucScedCycle.png
55
:class: align-right
66

7-
Prescient simulates the operation of a power generation network throughout a
7+
Prescient simulates the operation of a power generation network throughout a
88
study horizon, finding the set of operational choices that satisfy demand at
99
the lowest possible cost.
1010

@@ -19,7 +19,7 @@ The RUC Cycle
1919
-------------
2020

2121
The RUC cycle periodically generates a RUC plan. A RUC plan consists of two types of
22-
data: a unit commitment schedule and optionally a pricing schedule (when
22+
data: a unit commitment schedule and, optionally, a pricing schedule (when
2323
:ref:`compute-market-settlements<config_compute-market-settlements>` is True).
2424
The unit commitment schedule
2525
indicates which dispatchable generators should be activated or deactivated during
@@ -36,38 +36,48 @@ will go into effect at midnight, one at 8:00 a.m., and one at 4:00 p.m. Each
3636
RUC plan covers the time period that starts when it goes into effect and ends
3737
just as the next RUC plan becomes active.
3838

39-
A RUC plan is based on the current state of the system at the time the plan is
40-
generated (particularly the current dispatch and up- or down-time for dispatchable generators), and on
41-
forecasts for a number of upcoming time periods. The forecasts considered when
42-
forming a RUC plan must extend at least to the end of the RUC's planning period,
43-
but typically extend further into the future in order to avoid poor choices at
44-
the end of the plan ("end effects"). The amount of time to consider when
45-
generating a RUC plan is known as the RUC horizon. A commonly used RUC horizon
46-
is 48 hours.
39+
A RUC plan is based on the current state of the system at the time the plan is
40+
generated (particularly the current dispatch and up- or down-time for dispatchable
41+
generators), and on forecasts for a number of upcoming time periods. The forecasts
42+
considered when forming a RUC typically extend beyond the end of the RUC's planning
43+
period, to avoid poor choices at the end of the plan ("end effects").
4744

4845
The simulation can be configured to generate RUC plans some number of hours before
49-
they take effect. This is done by specifying a time of day for one of the plans to
50-
be generated. The gap between the specified generation time and the next time a RUC
51-
plan is scheduled to take effect is called the RUC gap. Each RUC plan still covers
46+
they take effect. Each RUC plan still covers
5247
the expected time period, from the time the plan takes effect until the next RUC plan
53-
takes effect, but its decisions will be based on what is known at the time the RUC
48+
takes effect, but its decisions will be based on what is known at the time the RUC
5449
plan is generated.
5550

51+
More information about RUCs is found in :doc:`../reference/ruc_details`.
52+
53+
5654
The SCED Cycle
5755
--------------
5856

59-
The SCED process selects dispatch levels for all active dispatchable generators
57+
The SCED process selects dispatch levels for all active dispatchable generators
6058
in the current simulation time period. Dispatch levels are determined using a process
6159
that is very similar to that used to build a RUC plan. The current state of the
6260
system, together with forecasts for a number of future time periods, are examined to
6361
select dispatch levels that satisfy current loads and forecasted future loads at the
6462
lowest possible cost.
6563

66-
The SCED cycle is more frequent than the RUC cycle, with new dispatch levels selected
64+
The SCED cycle is more frequent than the RUC cycle, with new dispatch levels selected
6765
at least once an hour. The SCED honors unit commitment decisions made in the RUC plan;
68-
whether each generator is committed or not is dictatated by the RUC schedule
66+
whether each generator is committed or not is dictatated by the RUC schedule
6967
currently in effect.
7068

71-
Costs are also determined with each SCED, based on dispatchable generation selected by
72-
the SCED process, the commitment and start-up costs as selected by the associated RUC
73-
process, as well as current actual demands and non-dispatchable generation levels.
69+
Costs are determined with each SCED, based on dispatchable generation levels selected by
70+
the SCED process, commitment and start-up decisions selected by the active RUC
71+
plan, and actual demands and non-dispatchable generation levels for the current simulation
72+
time. If market settlement is enabled, market-based generator revenue is also calculated.
73+
74+
More information about SCEDs is found in :doc:`../reference/sced_details`.
75+
76+
77+
.. seealso::
78+
79+
A more detailed description of the Prescient simulation process can be found
80+
in the :doc:`../reference/detailed_lifecycle` documentation.
81+
82+
More information about RUCs and SCEDs is available from
83+
:doc:`../reference/ruc_details` and :doc:`../reference/sced_details`.

Diff for: doc/OnlineDocs/source/examples/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Examples and Tutorials
1+
Examples and Tutorials
22
----------------------

Diff for: doc/OnlineDocs/source/reference/code.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Python Classes and Functions
2-
----------------------------
1+
Python Classes and Functions
2+
----------------------------
+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
Detailed Prescient Simulation Lifecycle
2+
=======================================
3+
4+
As Prescient simulates the operation of a power generation network, the simulation
5+
follows a repeating cycle of Reliability Unit Commitment (RUC) plans and Security
6+
Constrained Economic Dispatch (SCED) plans. This cycle is described at a high level
7+
in the concepts section (see :doc:`../concepts/ruc_sced_cycle`). This page
8+
provides a more detailed description of the simulation process, including plugin
9+
points that provide opportunities for custom code to observe or modify the
10+
simulation.
11+
12+
.. image:: ../_static/image/PrescientSimulationCycle.png
13+
:class: align-right
14+
15+
A Prescient simulation consists of three phases: startup, the main simulation
16+
loop, and finalization. Each phase includes one or more tasks that are executed
17+
in a specific order. In the case of the main simulation loop, these tasks are
18+
carried out multiple times, once per SCED during the simulation period.
19+
20+
The Prescient simulation lifecycle is executed when you run the Prescient
21+
command-line application, or in code when the `simulate()` method is called on
22+
a `prescient.simulator.Prescient` object.
23+
24+
Startup
25+
------------------
26+
27+
The startup phase consists of one-time activities that occur before the main
28+
simulation loop begins.
29+
30+
Pre-Simulation Startup
31+
......................
32+
33+
During the pre-simulation startup task, Prescient carries out activities such
34+
as parsing options, initializing plugins, and setting up data structures.
35+
36+
First, any plugins specified in the simulation configuration are given an
37+
opportunity to register their callbacks. See :ref:`Identifying Plugins` and
38+
:ref:`Plugin Module Initialization`.
39+
40+
After plugins have been initialized, two plugin callbacks are called:
41+
42+
* :ref:`plugin-options_preview`
43+
* :ref:`plugin-initialization`
44+
45+
After callbacks have been called, the current simulation time is set to midnight of
46+
the :ref:`simulation start date<config_start-date>`.
47+
48+
49+
The Main Simulation Loop
50+
------------------------
51+
52+
The main simulation loop is executed once for every simulation time step, where
53+
the simulation time step duration is the
54+
:ref:`SCED frequency<config_sced-frequency-minutes>`. The first simulation time
55+
step occurs at midnight of the first day (midnight is the beginning of the day,
56+
not the end). The last simulation time step occurs at the end of the final day
57+
of the simulation, just before midnight of the next day.
58+
59+
A SCED is solved every time through the loop. Some times through the loop, a RUC may
60+
also be generated and/or activated.
61+
62+
.. _Generate RUC:
63+
64+
Generate RUC
65+
............
66+
67+
If the current simulation time is a RUC generation hour, a new RUC is generated.
68+
This is either the same timestep the RUC will be activated, or an earlier
69+
timestep if a RUC delay has been specified. See :doc:`ruc_details` for information on the
70+
timing and frequency of RUC generation and its relationship to RUC activation.
71+
72+
Note that the initial RUC is always generated on the first timestep of the
73+
simulation, even if Prescient has been configured to generate other RUCs earlier
74+
than they are activated.
75+
76+
If a RUC is generated before its activation time, the first step of the RUC
77+
generation process is to solve a SCED-like model to estimate what the state of the
78+
system will be at the RUC activation time. Solving this model causes a single
79+
callback to be called:
80+
81+
* :ref:`plugin-after_get_initial_model_for_sced`
82+
83+
This callback is only called if the RUC is generated in a different timestep than
84+
the RUC will be activated. The initial RUC never triggers this callback.
85+
86+
As part of the RUC generation process, forecasts and actual values for upcoming
87+
periods are retrieved from the data source and loaded into Egret model. The
88+
callbacks listed below are called as a new batch of values is about to be loaded,
89+
giving plugins an opportunity to load any custom data they may need:
90+
91+
* :ref:`plugin-after_get_initial_model_for_simulation_actuals`
92+
* :ref:`plugin-after_get_initial_model_for_ruc`
93+
94+
Finally, the RUC itself is generated and solved. The following callbacks will be
95+
called:
96+
97+
* :ref:`plugin-before_ruc_solve`
98+
* :ref:`plugin-after_ruc_generation`
99+
100+
.. _Activate RUC:
101+
102+
Activate RUC
103+
............
104+
105+
If the current simulation time is a RUC activation time, the most recently
106+
generated RUC will be activated. Activating a RUC simply marks the point in the
107+
simulation when the RUC's decisions first begin to be followed. RUC activation
108+
hours occur at regular intervals starting at midnight of the first day and repeating
109+
at the :ref:`RUC frequency<config_ruc-every-hours>` for the rest of the simulation.
110+
See :doc:`ruc_details` for information on the timing and frequency of RUC
111+
activation.
112+
113+
The following callback is called each time a RUC is activated:
114+
115+
* :ref:`plugin-after_ruc_activation`
116+
117+
.. _Deploy SCED:
118+
119+
Deploy SCED
120+
...........
121+
122+
A SCED is generated, solved, and applied every simulation timestep.
123+
When a SCED is applied, generator setpoints are set for the current simulation time.
124+
See :doc:`sced_details`.
125+
126+
The following callbacks are called each time a SCED is deployed:
127+
128+
* :ref:`plugin-after_get_initial_model_for_sced`
129+
* :ref:`plugin-before_operations_solve`
130+
* :ref:`plugin-after_operations`
131+
* :ref:`plugin-update_operations_stats`
132+
133+
.. _Finalize Timestep:
134+
135+
Finalize Timestep
136+
.................
137+
138+
After SCED deployment is complete, statistics for the timestep are published
139+
and the simulation clock advances to the time of the next SCED, as determined
140+
by the :ref:`SCED frequency<config_sced-frequency-minutes>`.
141+
142+
Several callbacks related to statistics may be called at this time. Calling a
143+
callback related to statistics is referred to as "publishing" statistics.
144+
145+
Operations statistics (statistics about SCED results) are published every timestep
146+
by calling the following callback:
147+
148+
* :ref:`plugin-operations_stats`
149+
150+
If the timestep is the final timestep in a given hour, hourly statistics are
151+
published:
152+
153+
* :ref:`plugin-hourly_stats`
154+
155+
If the timestep is the final timestep in a given day, daily statistics are
156+
published:
157+
158+
* :ref:`plugin-daily_stats`
159+
160+
The simulation clock is advanced after all relevant statistics have been published.
161+
If the new time is later than the simulation end date, the main simulation loop
162+
ends and Prescient moves to the Finalization stage. Otherwise Prescient repeats the
163+
main simulation loop for the new timestep.
164+
165+
Finalization
166+
------------
167+
168+
The finalization phase consists of tasks that occur once at the end of the
169+
simulation.
170+
171+
Finalize Simulation
172+
...................
173+
174+
Statistics for the simulation as a whole are published during finalization:
175+
176+
* :ref:`plugin-overall_stats`
177+
178+
Another callback is called to notify callbacks that the simulation is complete,
179+
giving plugins a chance to cleanly shut down:
180+
181+
* :ref:`plugin-finalization`

Diff for: doc/OnlineDocs/source/reference/file_formats/custom-input.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ to acquire initial data, and to request updates to data for specific time
1616
periods.
1717

1818
For an example or a custom data provider, see the
19-
`example <https://github.com/grid-parity-exchange/Prescient/blob/main/prescient/simulator/tests/custom_data_provider.py>`_
19+
`example <https://github.com/grid-parity-exchange/Prescient/blob/main/prescient/simulator/tests/custom_data_provider.py>`_
2020
in the source code, or examine one of the `standard data providers
2121
<https://github.com/grid-parity-exchange/Prescient/tree/main/prescient/data/providers>`_.
2222

0 commit comments

Comments
 (0)