PSSE - How to get Started with simulations and python scripting
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.
- 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.
- Double-click on this PSSE32 icon shorcut created in the Test folder and its graphical interface will open up.
- 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 test.py.
- 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.
- 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.
- 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.
- 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.
- Next click on the Load tab and type in the information telling that the load is 100 MW, 50 MVar.
- Go to File->Save and save the network file as (a) raw data file - SMIB.raw and (b) saved case file - SMIB.sav.
- 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.
- Now convert the load and generator to Norton equivalents, go Power Flow->Convert Loads and Generators and click Convert Generators and Convert Loads boxes.
- 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.
- Save this Network case as, SMIBconv.sav.
- 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.
- 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.
- 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.
- 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.
- Save snap file by going to the save menu and choosing snap file, save this as SMIB.snp.
- Next type 0 in Run to box and hit Run. Next type 1 in Run to box and hit Run. Finally close this box.
- Next go to Disturbance->Trip line, select From Bus 1 to Bus 2 and Circuit ID as 1.
- Again go to Dynamics->Perform Simulation->Perform Simulation(start/run) and in the Run to box type 2 and Run.
- Now to to Disturbance->Close line and close the line opened before.
- Again go to Dynamics->Perform Simulation->Perform Simulation(start/run) and in the Run to box type 20 and Run.
- 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.
- Open the GOP1.out file by CTRL+o and File type .out and select GOP1.out.
- 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.
- Go I/O Control->Stop Recording. Open test.py using a text editor and have a browse through.
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.
- solution1.py - 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.
- run.py - 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.
- plots.py - Before you run this script please install matplotlib-0.98.5.2.win32-py2.5.exe 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 plots.py 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.
- Resources for Automating PSSE with Python
- PSSE Tutorial
- PSSE User Support
- 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 <email@example.com>
Thursday May 19, 2011 11:18 AM
Research | Home