This notebook shows an example of changing the generator setpoints in a time-domain simulation. Data in this example is trivial, but the example can be retrofitted for scenarios such as economic dispatch incorporation or reinforcement learning.
Steps are the folllwing:
TDS.config.tf
,import andes
from andes.utils import get_case
kundur = get_case('kundur/kundur_full.xlsx')
ss = andes.run(kundur)
Working directory: "/home/hcui7/repos/andes/examples" Loaded config from file "/home/hcui7/.andes/andes.rc" Using generated Python code. Parsing input file "/home/hcui7/repos/andes/andes/cases/kundur/kundur_full.xlsx"... Input file parsed in 0.4837 seconds. System internal structure set up in 0.0319 seconds. -> System connectivity check results: No islanded bus detected. No islanded areas detected. Each island has a slack bus correctly defined and enabled. -> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) Power flow initialized. 0: |F(x)| = 14.9282832 1: |F(x)| = 3.608627841 2: |F(x)| = 0.1701107882 3: |F(x)| = 0.002038626956 4: |F(x)| = 3.745103977e-07 Converged in 5 iterations in 0.0153 seconds. Report saved to "kundur_full_out.txt" in 0.0029 seconds.
-> Single process finished in 0.7215 seconds.
# disable the Toggler in this case
ss.Toggler.alter('u', 1, 0)
# simulate to t=1 sec
# specify the first stop in `ss.TDS.config.tf`
ss.TDS.config.tf = 1
ss.TDS.run()
-> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-1 s. Fixed step size: h=33.33 ms. Shrink if not converged. Initialization for dynamics was successful in 0.0255 seconds.
100%|███████████████████████████████| 100/100 [00:00<00:00, 841.67%/s]
Simulation completed in 0.1210 seconds. Outputs to "kundur_full_out.lst" and "kundur_full_out.npz". Outputs written in 0.0086 seconds.
True
TGOV1.paux0.v
¶First, let's check the equations of TGOV1. ss.TGOV1.paux0
is associated with equation 0 = paux - paux0
, in which paux
is added to the power input equation.
print(ss.TGOV1.doc())
Model <TGOV1> in Group <TurbineGov> TGOV1 turbine governor model. Implements the PSS/E TGOV1 model without deadband. Parameters Name | Description | Default | Unit | Properties -------+-----------------------------------+---------+------+----------------- idx | unique device idx | | | u | connection status | 1 | bool | name | device name | | | syn | Synchronous generator idx | | | mandatory,unique Tn | Turbine power rating. Equal to | | MVA | | `Sn` if not provided. | | | wref0 | Base speed reference | 1 | p.u. | R | Speed regulation gain (mach. base | 0.050 | p.u. | ipower | default) | | | VMAX | Maximum valve position | 1.200 | p.u. | power VMIN | Minimum valve position | 0 | p.u. | power T1 | Valve time constant | 0.100 | | T2 | Lead-lag lead time constant | 0.200 | | T3 | Lead-lag lag time constant | 10 | | Dt | Turbine damping coefficient | 0 | | power Sg | Rated power from generator | 0 | MVA | Vn | Rated voltage from generator | 0 | kV | Variables (States + Algebraics) Name | Type | Description | Unit | Properties -------+----------+--------------------------------------+------+----------- LAG_y | State | State in lag TF | | v_str LL_x | State | State in lead-lag | | v_str omega | ExtState | Generator speed | p.u. | paux | Algeb | Auxiliary power input | | v_str pout | Algeb | Turbine final output power | | v_str wref | Algeb | Speed reference variable | | v_str pref | Algeb | Reference power input | | v_str wd | Algeb | Generator under speed | p.u. | v_str pd | Algeb | Pref plus under speed times gain | p.u. | v_str LL_y | Algeb | Output of lead-lag | | v_str tm | ExtAlgeb | Mechanical power interface to SynGen | | Variable Initialization Equations Name | Type | Initial Value -------+----------+-------------- LAG_y | State | pd * 1 LL_x | State | LAG_y omega | ExtState | paux | Algeb | paux0 pout | Algeb | u*tm0 wref | Algeb | wref0 pref | Algeb | tm0 * R wd | Algeb | 0 pd | Algeb | u * tm0 LL_y | Algeb | LAG_y tm | ExtAlgeb | Differential Equations Name | Type | RHS of Equation "T x' = f(x, y)" | T (LHS) -------+----------+----------------------------------+-------- LAG_y | State | 1 * pd - LAG_y | T1 LL_x | State | (LAG_y - LL_x) | T3 omega | ExtState | | Algebraic Equations Name | Type | RHS of Equation "0 = g(x, y)" ------+----------+------------------------------------------------------------ paux | Algeb | paux0 - paux pout | Algeb | (LL_y + Dt * wd) - pout wref | Algeb | wref0 - wref pref | Algeb | pref0 * R - pref wd | Algeb | (wref - omega) - wd pd | Algeb | u*(wd + pref + paux) * gain - pd LL_y | Algeb | 1 * T2 * (LAG_y - LL_x) + 1 * LL_x * T3 - LL_y * T3+ | | LL_LT1_z1 * LL_LT2_z1 * (LL_y - 1 * LL_x) tm | ExtAlgeb | u * (pout - tm0) Services Name | Equation | Type -------+----------+------------- pref0 | tm0 | ConstService paux0 | 0 | ConstService gain | u/R | ConstService Discrete Name | Type | Info ---------+------------+--------------- LAG_lim | AntiWindup | Limiter in Lag LL_LT1 | LessThan | LL_LT2 | LessThan | Blocks Name | Type | Info -----+---------------+----- LAG | LagAntiWindup | LL | LeadLag |
ss.TGOV1.paux0.v
array([0., 0., 0., 0.])
# look up the original values of TGOV1 make sure they are as expected
ss.TGOV1.paux0.v
array([0., 0., 0., 0.])
# MUST use in-place assignments.
# Here, we increase the setpoint of the 0-th generator
# method 1: use in-place assignment again
ss.TGOV1.paux0.v[0] = 0.05
# method 2: use ``ss.TGOV1.alter()``
# ss.TGOV1.alter('paux0', 1, 0.05)
ss.TGOV1.paux0.v
array([0.05, 0. , 0. , 0. ])
Continue to simulate to 2 seconds.
ss.TDS.config.tf = 2
ss.TDS.run()
100%|█████████████████████████████| 100.0/100 [00:00<00:00, 411.67%/s]
Simulation completed in 0.2435 seconds. Outputs to "kundur_full_out.lst" and "kundur_full_out.npz". Outputs written in 0.0057 seconds.
True
ss.TDS.plotter.plot(ss.TGOV1.paux)
(<Figure size 900x600 with 1 Axes>, <AxesSubplot:xlabel='Time [s]'>)
ss.TDS.plotter.plot(ss.TGOV1.pout)
(<Figure size 900x600 with 1 Axes>, <AxesSubplot:xlabel='Time [s]'>)
ss.TDS.plotter.plot(ss.GENROU.omega)
(<Figure size 900x600 with 1 Axes>, <AxesSubplot:xlabel='Time [s]'>)
In this example, we clear the auxiliary power previously set to TGOV1.paux0.v
# method 1: use in-place assignment again
ss.TGOV1.paux0.v[0] = 0.
# method 2: use ``ss.TGOV1.alter()``
# ss.TGOV1.alter('paux0', 1, 0)
# set the new ending time to 10 sec.
ss.TDS.config.tf = 10
ss.TDS.run()
100%|██████████████████████████████| 100.0/100 [00:01<00:00, 80.66%/s]
Simulation completed in 1.2425 seconds. Outputs to "kundur_full_out.lst" and "kundur_full_out.npz". Outputs written in 0.0278 seconds.
True
ss.TDS.plotter.plot(ss.TGOV1.paux)
(<Figure size 900x600 with 1 Axes>, <AxesSubplot:xlabel='Time [s]'>)
ss.TDS.plotter.plot(ss.GENROU.omega)
(<Figure size 900x600 with 1 Axes>, <AxesSubplot:xlabel='Time [s]'>)