Multi-period Scheduling Simulation#

Multi-period economic dispatch (ED) and unit commitment (UC) are also available.

In this case, we will show a 24-hour ED simulation.

[1]:
import ams
[2]:
ams.config_logger(stream_level=20)

Load Case#

[3]:
sp = ams.load(ams.get_case('5bus/pjm5bus_demo.xlsx'),
              setup=True,
              no_output=True,)
Parsing input file "/Users/jinningwang/work/ams/ams/cases/5bus/pjm5bus_demo.xlsx"...
Input file parsed in 0.2122 seconds.
Zero line rates detacted in rate_b, rate_c, adjusted to 999.
System set up in 0.0032 seconds.

Zonal Design#

The scheduling models in AMS have been developed with a zonal structure, which can be inspected in the model Area.

In AMS, model Area represents Balancing Authority territory, and Zone refers to loss zone. Typically, an Area can cover multiple Zone. For more details about the geographical definitions used in power systems, visit https://ps-wiki.github.io/wiki/area-zone-region/

Note: Since version 0.9.14, model Region is renamed to Zone for clarity.

[4]:
sp.Area.as_df()
[4]:
idx u name
uid
0 1 1.0 1
1 2 1.0 2
2 3 1.0 3

In device Bus, the Param area indicates the area of the bus. Correspondingly, the region of generator and load are determined by the bus they connected.

[5]:
sp.Bus.as_df()
[5]:
idx u name Vn vmax vmin v0 a0 xcoord ycoord area zone owner type
uid
0 0 1.0 A 230.0 1.1 0.9 1.0 0.0 0 0 1 Zone_A None 1
1 1 1.0 B 230.0 1.1 0.9 1.0 0.0 0 0 1 Zone_B None 1
2 2 1.0 C 230.0 1.1 0.9 1.0 0.0 0 0 2 Zone_C None 1
3 3 1.0 D 230.0 1.1 0.9 1.0 0.0 0 0 2 Zone_D None 1
4 4 1.0 E 230.0 1.1 0.9 1.0 0.0 0 0 3 Zone_E None 1

Multi-period Dispatch Base#

In AMS, multi-period dispatch involves devices in group Horizon. This group is developed to provide time-series data for multi-period dispatch.

[6]:
sp.Horizon.models
[6]:
OrderedDict([('EDTSlot', EDTSlot (24 devices) at 0x1158f14e0),
             ('UCTSlot', UCTSlot (24 devices) at 0x1158f1b40)])

We can get the idx of StaticGens.

[7]:
sp.StaticGen.get_all_idxes()
[7]:
['PV_1', 'PV_3', 'PV_5', 'PV_2', 'Slack_4']

In EDTSlot, Param sd refers the load factors of each region in each time slot, and Param ug represents the generator commitment status in each time slot.

To be more specific, EDT1 has sd=0.793,0.793,0.793, which means the load factor of each area is 0.793 in the first time slot, and 0.756 in the second time slot.

Next, EDT1 has ug=1,1,1,1,1, and it means the commitment status of generator PV_1, PV_3, PV_5, PV_2, and Slack_4 are all online.

[8]:
sp.EDTSlot.as_df()
[8]:
idx u name sd ug
uid
0 EDT1 1.0 EDT1 0.793,0.793,0.793 1,1,1,1,1
1 EDT2 1.0 EDT2 0.756,0.756,0.756 1,1,1,1,1
2 EDT3 1.0 EDT3 0.723,0.723,0.723 1,1,1,1,1
3 EDT4 1.0 EDT4 0.708,0.708,0.708 1,1,1,1,1
4 EDT5 1.0 EDT5 0.7,0.7,0.7 1,1,1,1,1
5 EDT6 1.0 EDT6 0.706,0.706,0.706 1,1,1,1,1
6 EDT7 1.0 EDT7 0.75,0.75,0.75 1,1,1,1,1
7 EDT8 1.0 EDT8 0.802,0.802,0.802 1,1,1,1,1
8 EDT9 1.0 EDT9 0.828,0.828,0.828 1,1,1,1,1
9 EDT10 1.0 EDT10 0.851,0.851,0.851 1,1,1,1,1
10 EDT11 1.0 EDT11 0.874,0.874,0.874 1,1,1,1,1
11 EDT12 1.0 EDT12 0.898,0.898,0.898 1,1,1,1,1
12 EDT13 1.0 EDT13 0.919,0.919,0.919 1,1,1,1,1
13 EDT14 1.0 EDT14 0.947,0.947,0.947 1,1,1,1,1
14 EDT15 1.0 EDT15 0.97,0.97,0.97 1,1,1,1,1
15 EDT16 1.0 EDT16 0.987,0.987,0.987 1,1,1,1,1
16 EDT17 1.0 EDT17 1.0,1.0,1.0 1,1,1,1,1
17 EDT18 1.0 EDT18 1.0,1.0,1.0 1,1,1,1,1
18 EDT19 1.0 EDT19 0.991,0.991,0.991 1,1,1,1,1
19 EDT20 1.0 EDT20 0.956,0.956,0.956 1,1,1,1,1
20 EDT21 1.0 EDT21 0.93,0.93,0.93 1,1,1,1,1
21 EDT22 1.0 EDT22 0.905,0.905,0.905 1,1,1,1,1
22 EDT23 1.0 EDT23 0.849,0.849,0.849 1,1,1,1,1
23 EDT24 1.0 EDT24 0.784,0.784,0.784 1,1,1,1,1

Solve and Result#

[9]:
sp.ED.init()
Building system matrices
Parsing OModel for <ED>
Evaluating OModel for <ED>
Finalizing OModel for <ED>
<ED> initialized in 0.0275 seconds.
[9]:
True
[10]:
sp.ED.run(solver='CLARABEL')
<ED> solved as optimal in 0.0374 seconds, converged in 12 iterations with CLARABEL.
[10]:
True

All decision variables are collected in the dict vars.

[11]:
sp.ED.vars
[11]:
OrderedDict([('pg', Var: StaticGen.pg),
             ('vBus', Var: Bus.vBus),
             ('aBus', Var: Bus.aBus),
             ('pru', Var: StaticGen.pru),
             ('prd', Var: StaticGen.prd),
             ('prs', Var: StaticGen.prs)])

As we can see, the generator output pg is a 2D array, and the first dimension is the generator index, and the second dimension is the time slot.

[12]:
sp.ED.pg.v.round(4)
[12]:
array([[0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   ,
        0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   ,
        0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   , 0.2   ],
       [0.5   , 0.5   , 0.5   , 0.5   , 0.5   , 0.5   , 0.5   , 0.5   ,
        0.5751, 0.6908, 0.8064, 0.9271, 1.0327, 1.1735, 1.2891, 1.3746,
        1.44  , 1.44  , 1.3947, 1.2187, 1.088 , 0.9623, 0.6807, 0.5   ],
       [0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   ,
        0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   ,
        0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   , 0.6   ],
       [4.8289, 4.8258, 4.8231, 4.8218, 4.8211, 4.8217, 4.8253, 4.8297,
        4.9049, 5.0192, 5.1336, 5.2529, 5.3573, 5.4965, 5.6109, 5.6954,
        5.76  , 5.76  , 5.7153, 5.5413, 5.412 , 5.2877, 5.0093, 4.8282],
       [1.8011, 1.4342, 1.1069, 0.9582, 0.8789, 0.9383, 1.3747, 1.8903,
        2.    , 2.    , 2.    , 2.    , 2.    , 2.    , 2.    , 2.    ,
        2.    , 2.    , 2.    , 2.    , 2.    , 2.    , 2.    , 1.7118]])

Partial results can be accessed with desired time slot. In the retrieved result, the first dimension is the generator index, and the second dimension is the time slot.

[13]:
sp.ED.get(src='pg', attr='v', idx='PV_1', horizon=['EDT1'])
[13]:
0.20000003326887592

Or, get multiple variables in mutliple time slots.

[14]:
sp.ED.get(src='pg', attr='v', idx=['PV_1', 'PV_3'],
          horizon=['EDT1', 'EDT2', 'EDT3']).round(4)
[14]:
array([[0.2, 0.2, 0.2],
       [0.5, 0.5, 0.5]])