PSSE - How to get Started with simulations and python scripting

[ Single-machine Infinite-bus simulation steps | Python Scripting | Example Files | Links | Acknowledgement ]




Let us see how we can simulate the dynamics of this single-machine infinite-bus system. We have a classical generator model (fixed-voltage behind transient impedance) at Bus 1 and an infinite-bus and load connected at Bus 2.

We will first create the SMIB system with two branches connecting Bus 1 and 2. We will trip one of the two lines for 1 second, then reconnect it and simulate the resulting response.

The parameters selected for this test system are: 100 MVA base power, 100 kV base voltage, line impedance 0.2pu, load 100 MW, 50 MVar, generator 50 MW, 10 MVar, synchronous impedance 1pu and transient impedance 0.2pu., load is 100MW and 50 MVar.

Please follow these steps to get started.

  1. Create a new folder, let us say we name it Test. Make a shortcut item of PSSE32 command, place it in the Test folder, right-click on this icon and open Properties. In the Start In box, put the complete path of the Test folder.
  2. Double-click on this PSSE32 icon shorcut created in the Test folder and its graphical interface will open up.
  3. Go I/O Control->Start Recording and when the file dialogue box opens, select the type of file as python and give it a name test and make sure it is in the Test folder. This file will record every thing you do now as a python commands in the file
  4. Use CTRL+n or click on the New File icon or go File->New to open a new file. Select the Network Case radio button. Note down the base MVA and frequency in those boxes. Type in the headings to your liking.
  5. A Network spreadsheet will open up with the bus tab at the bottom selected. Put in the description of the two buses. Remember to put the Code 2 (generator bus) for the generator bus (labelled 1 above) and Code 3 (slack bus) for the Bus 2. Put base KV as 100 and other cells are not important and most likely they will take on default values which are safe.
  6. Next create two branches connecting Buses 1 and 2. Click on the Branches tab. Make two rows of data connecting Buses 1 and 2 and give then ID as 1 and 2. Let the branch X value be 0.2pu and leave the rest as default values.
  7. Next click on the Machine tab at the bottom of the spreadsheet. First type in number 1 and put Pgen 50 MW Qgen 10 MVar and Xtran as 0.2pu. Next type in Number 2 in the next row and Xtrans as zero. Select sensible values for maximum and minimum values or be happy with the default values.
  8. Next click on the Load tab and type in the information telling that the load is 100 MW, 50 MVar.
  9. Go to File->Save and save the network file as (a) raw data file - SMIB.raw and (b) saved case file - SMIB.sav.
  10. Go to Power Flow -> Solution->Solve or CTRL+Shift+S or use the icon, and use the default values to solve the case. Check in the Output Bar that the solution has converged.
  11. Now convert the load and generator to Norton equivalents, go Power Flow->Convert Loads and Generators and click Convert Generators and Convert Loads boxes.
  12. Run the load flow meant for converted cases, to do this go Power Flow->Solution->TYSL, and then click on the FACT box and choose either radio button.
  13. Save this Network case as, SMIBconv.sav.
  14. Create a file SMIB.dyr in the Test directory with the following contents:
    1 'GENCLS' 1 20.0 0.10000/
    2 'GENCLS' 1 0.0 0.0/
    1 'TGOV1' 1 0.50000E-01 0.50000E-01 1.0500 0.30000
    1.0000 1.0000 0.0000/
    or copy SMIB.dyr file and keep it in the Test folder. This first statement says that this is a classical generator model connected to Bus 1, and is identified as the generator 1 (there can be many generators connected to a bus), it has H = 20, and D=0.1. The second statement says that this is an infinite-bus (H=0, D=0). The third statement says that a governor is attached to the generator at Bus 1.
  15. CTRL+o (or the usual icon or menu item), in the open dialogue, select type as dyr and then select SMIB.dyr. Then in the next dialogue box, type CC1, CT1, and compile in the three empty boxes.
  16. Go to Dynamics->Define Simulation output(CHAN)->Machine Quantity. Initially we define four outputs, Generator 1, angle and speed, Infinite-bus angle and speed. Type in appropriate numbers and give channels the names you like.After enering the particulars, press Go and then give details of the next variable you wish to store. Close the dialogue box after you have assigned all the channels. You can assign other variables to channels if you like.
  17. Now go to the Dynamics->Perform Simulation->Perform Simulation(start/run). In the Channel output file box type GOP1.out. In the Print Every, Write Every, Plot Every boxes you can type 1. Press the Initialize button.
  18. Save snap file by going to the save menu and choosing snap file, save this as SMIB.snp.
  19. Next type 0 in Run to box and hit Run. Next type 1 in Run to box and hit Run. Finally close this box.
  20. Next go to Disturbance->Trip line, select From Bus 1 to Bus 2 and Circuit ID as 1.
  21. Again go to Dynamics->Perform Simulation->Perform Simulation(start/run) and in the Run to box type 2 and Run.
  22. Now to to Disturbance->Close line and close the line opened before.
  23. Again go to Dynamics->Perform Simulation->Perform Simulation(start/run) and in the Run to box type 20 and Run.
  24. Now we can plot this data. Open a new file (CTRL+n or icon or the menu item) and select the Plot Book radio button.
  25. Open the GOP1.out file by CTRL+o and File type .out and select GOP1.out.
  26. Click on Plot Data tab. In the tree view on the LHS of the window, open Channel Files->GOP1 folder and drop one of the channels on the open plot window. You can create new plots or delete plots from the Edit menu items and drop different channels and view these plots. These plots can be exported using File->Export and then appropriate selections and here is a sample of speed and angle plots.
  27. Go I/O Control->Stop Recording. Open using a text editor and have a browse through.


Python Scripting

The above 27 steps can be easily coded as python commands and executed much more quickly and by changing parameters. Learning how run through these steps using python scripts gives it a great deal of flexibility. The above steps have been broken down into the following three python scripts. To run a python script, go (CTRL+Shift+A) I/O Control->Run Program Automation file and then select python in the file type.

  1. - This script reads the saved case SMIB.sav, dynamic data file SMIB.dyr, and creates a converted saved case SMIBconv.sav and a snap file SMIB.snp. This script reads files and make sure the path to those files is correct.
  2. - This script reads the saved & converted case SMIBconv.sav and the snap file SMIB.snp which has all the dynamic data and output channels information. After reading this it goes on the trip a line, simulate, connect back a line, and then simulate. It also creates two pdf files with speed and angle plots. This script reads files and make sure the path to those files is correct.
  3. - Before you run this script please install matplotlib- and numpy-1.3.0-win32-superpack-python2.5.exe as explained in comments of the example file made available by the PSSE. The script creates an eps plot from the data in GOP1.out. This script reads files and make sure the path to those files is correct.

PSSE has many macro languages for simulation automation - idev, IPLAN, PSSE batch commands, and python. If you are starting to use PSSE, it will be best if you start to use python to automate your work with PSSE. Extensive documentation exists for python scripting language and you can find out the specific python commands needed to perform a task in PSSE by recording your graphical user interface steps as a python script and then modifying it for your program automation purposes. It is expected that PSSE will put in a lot of resources to have python as its prefered language for program automation.

PSSE has written a few python modules. Most python commands are documented in the API manual. There are a few modules which are not yet documented but one good way to obtain information is to use help from within PSSE command line. Select python as the command line language. Then if you need information on PSSE's dyntools python module first type import dyntools and then help(dyntools).

The psspy module is loaded when you start PSSE but other modules have to be imported before you can use them. To get help on any psspy command you can use the help feature from within PSSE command line. Select python as the command line language and say you wanted help on strt command just type help(psspy.strt).

Please read the chapter on Program Automation in the PSSE documentation. It is a small chapter but has some very good information.



The directory Program Files\PTI\PSSE32\EXAMPLE comes with very useful example files. The best way to learn from these example files is to create your own systems and then copy-and-paste into your files from these example files. Another good way to learn is to always record what you do as python script and then make a proper script out of it.


Useful Links

  1. Resources for Automating PSSE with Python
  2. PSSE Tutorial
  3. PSSE User Support
  4. PSSE User Forum




Everything on this page is a reproduction of what I have learnt from Prahlad and Md Jahangir Hossain. My sincere thanks to both of them.


Hemanshu Pota <>
Last modified: Thursday May 19, 2011 11:18 AM
Research | Home