#!/usr/bin/env python # coding: utf-8 # # Changing Turbine Governor Setpoints # 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: # # 1. Initialize a system by running the power flow, # 2. Set the first simulation stop time in `TDS.config.tf`, # 3. Run the simulation, # 3. Update the setpoints, # 4. Set the new simulation stop time and repeat from 3 until the end. # ## Step 1: Case Setup # In[1]: import andes from andes.utils import get_case # In[2]: kundur = get_case('kundur/kundur_full.xlsx') ss = andes.run(kundur) # In[3]: # disable the Toggler in this case ss.Toggler.alter('u', 1, 0) # ## Step 2: Set the First Stop Time # In[4]: # simulate to t=1 sec # specify the first stop in `ss.TDS.config.tf` ss.TDS.config.tf = 1 # ## Step 3: Run Simulation # In[5]: ss.TDS.run() # ## Step 4. Apply the auxiliary power setpoints to `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. # In[6]: print(ss.TGOV1.doc()) # In[7]: ss.TGOV1.paux0.v # In[8]: # look up the original values of TGOV1 make sure they are as expected ss.TGOV1.paux0.v # In[9]: # 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) # In[10]: ss.TGOV1.paux0.v # Continue to simulate to 2 seconds. # In[11]: ss.TDS.config.tf = 2 # In[12]: ss.TDS.run() # In[13]: ss.TDS.plotter.plot(ss.TGOV1.paux) # In[14]: ss.TDS.plotter.plot(ss.TGOV1.pout) # In[15]: ss.TDS.plotter.plot(ss.GENROU.omega) # ## Step 5: Set Another New Setpoints and New Ending TIme. # # In this example, we clear the auxiliary power previously set to `TGOV1.paux0.v` # In[16]: # 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 # In[17]: ss.TDS.run() # In[18]: ss.TDS.plotter.plot(ss.TGOV1.paux) # In[19]: ss.TDS.plotter.plot(ss.GENROU.omega) # In[20]: get_ipython().system('andes misc -C')