09-2026
Copyright 2026, Battelle Energy Alliance, LLC, ALL RIGHTS RESERVED
Authors: Soumyadeep Nag, Shafiul Alam
PyRAPS_SS.py applies a altered-head operating condition to selected hydroelectric generators in a loaded PSS®E case. It recalculates their active-power limits, alters generation for a selected group of generators, redispatches eligible generators, solves the power flow, and saves the modified case.
- Reads all in-service generators from the active PSS®E case.
- Reads governor information, generator redispatch eligibility, and the list of hydro units to derate from three CSV files.
- Calculates each generator's effective maximum power for the specified per-unit head
H0. - Derates each listed, in-service hydro unit.
- Limits hydropower generation to 95% of the new maximum when its original output exceeds the derated maximum, leaving headroom for losses and response.
- Redispatches eligible online generators in proportion to their upward or downward reserve.
- Runs a full-Newton power flow.
- If the swing generator exceeds its effective maximum, performs another proportional redispatch and solves the power flow again.
- Writes a generator reserve report and, following successful solutions, saves the modified PSS®E case.
- A compatible installation of Siemens PSS®E with Python support
- The PSS®E
psspymodule available in the Python environment - Python's built-in
csvmodule - An active PSS®E case with the required network data and dynamic models already loaded
The script does not initialize PSS®E, open a .sav case, or load a .dyr file. Run it only after those steps have been completed by the calling script, an IDE environment, or the PSS®E GUI.
Edit the values near the top of PyRAPS_SS.py:
# Desired head level in per unit
H0 = 0.9
# Input files
bsl_file = 'baseload.csv'
trate_file = 'gov_and_trate.csv'
derating_file = 'Affected_generators.csv'H0 = 0.9 represents a head equal to 90% of the reference head.
The output case name is set near the end of the script:
file = "HS_NW_CAL90.sav"All relative file paths are resolved from the process's current working directory.
Each CSV must contain a header row. The script uses fixed column positions, so retain the expected ordering even if the header names differ.
Maps each supported governor model to the relative PSS®E CON index containing its turbine rating. This is done according to the PSSE model library. This can be updated if required.
Example:
governor_model,trate_con_number
HYGOV,5
HYG3U1,10The actual model names and indices must match the dynamic models used in the active case. If a governor is not listed, the script does not apply a governor-based turbine-rating constraint.
Identifies machines that may participate in redispatch.
A baseload flag of 0 makes an online generator eligible for redispatch. Other values exclude it. Machine IDs must match PSS®E IDs after surrounding spaces are removed.
Example:
bus_number,bus_name,machine_id,baseload_flag
101,PLANT_A,1,0
205,PLANT_B,2,1Lists the hydro machines whose available power is to be derated.
Example:
record,bus_number,bus_name,machine_id
1,301,HYDRO_A,1
2,302,HYDRO_B,1For most hydro governor models, the derated maximum is:
For an HYG3U1 governor, the script reads g_max, qnl, and At from the model's dynamic constants and uses:
This is done to maintain compatibility with the dynamic data adjustment. For the dynamic file only HYG3U1 models have H0 as an input parameter and hence are the only units that recieve a new H0. Consequently, their maximum power must be estimated taking into account their dynamic data + steady-state data or this will cause initialization errors.
The new maximum is not allowed below the existing PMIN. If the original generation exceeds the new maximum, generation is set to 95% of the new maximum and then checked against PMIN.
Place the script and its input CSV files in the working directory, load the required steady-state and dynamic data into PSS®E, and then run:
python PyRAPS_SS.pyIt can also be executed from the PSS®E GUI after the appropriate case and dynamic data are loaded (prefered method).
Created each time adjustgen() runs. It contains:
- bus number (the column is currently labeled
bus name); - generator ID;
- upward and downward reserve before redispatch;
- old and new generator output; and
- effective maximum and minimum power.
If redispatch is called a second time for swing-bus correction, this file is overwritten and therefore contains only the most recent redispatch pass.
The modified PSS®E case. It is saved only when both power-flow solutions converge.
The console also reports derated machines, convergence status, upward reserve, total PMAX change, total generation change, the swing-bus number, and the saved-case name.
- Check that all bus numbers and machine IDs in the CSV files exactly match the active case.
- Confirm every governor-to-
CONmapping against the applicable dynamic-model documentation. - The script does not explicitly act on nonzero PSS®E error codes returned by most API calls; review the PSS®E log for missing machines, models, or invalid values.
- Proportional upward redispatch uses only eligible generators with more than 10 MW of upward reserve and positive initial output.
PyRAPS_SS.py
baseload.csv
gov_and_trate.csv
Affected_generators.csv