|
| 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` |
0 commit comments