SlideShare une entreprise Scribd logo
1  sur  59
Télécharger pour lire hors ligne
Python
Power systems analysis in PSS®E using
In the Name of God
Isfahan University of Technology
Department of Electrical & Computer Engineering
Power Systems Analysis Lab.
programming language
1
Python?
• Name of a kind of snakes
• Developed By Guido van Rossum at CWI in the early 1990s in the Netherlands
Download it from http://www.python.org
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
2
Why Python?
Simple
Easy to Learn
Free and Open Source
High-level language
Portable
Interpreted
Object Oriented
extensible
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
3
How to programming Python?
Some Python interpreters:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
4
Getting started with Python
1- Command line mode
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
5
Getting started with Python
2- Script mode
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
6
Getting started with Python
3-Python syntax colors
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
7
Getting started with Python
4- Blocks of Code
Note: Dots indicates blank spaces before the code !!
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
..two spaces means this is part of block 1
..two spaces means this is still a part of block 1
....four spaces means we just started block number 2
....four spaces means we are still in block number 2
........eight spaces means we started block number 3
....four spaces means we want this code to be grouped with block 2
........eight spaces for block 3
8
Getting started with Python
5- Operators
The most common operators are:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
9
Getting started with Python
6- Using Python as a Calculator
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
10
Getting started with Python
7- Strings
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
11
Getting started with Python
7- Strings
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
12
Getting started with Python
8- Variables
You can name a variable almost anything and use symbols like the _underscore !
But don’t use these words:
Note: No need to define variable Types! The first assignment to a variable creates it.
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
13
Getting started with Python
9- Logical operators and Boolean data types
The words “and, or,” and “not” are logical operators.
A simple condition:
A compound condition:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
14
Getting started with Python
10- Sequence types
Tuple
A simple immutable ordered sequence of items
Items can be of mixed types, including collection types
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
15
Getting started with Python
10- Sequence types
Dictionary
Mutable
key-value pair
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
16
Getting started with Python
10- Sequence types
List
Mutable ordered sequence of items of mixed types
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
17
Getting started with Python
11- Copy a variable
• For simple variables:
# b is a copy of the old value!!
• But mutable variables are always equal to each other!!
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
18
Getting started with Python
12- Conditional statements
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
19
Getting started with Python
13- Loop statements
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
20
Getting started with Python
14- Define a Function
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
21
Getting started with Python
15- Class
• A class is a User-Defined variable
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
22
Getting started with Python
16- Module
• Modules are imported from other scripts using the import command
• As an example:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
23
Getting started with Python
17- Work with files
Note: Read function didn’t skip the blank character!!
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
24
Getting started with Python
18- Input Data:
There are some simple ways to request data from user:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
25
Getting started with Python
19- Try and except:
You can try to do something in your script and make an exception for the time that
Python can’t run your code!!
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
26
Getting started with Python
20- Help
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
27
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
28
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
29
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
30
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
31
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
32
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
33
Getting started with Python
Simple examples
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
34
Part 2
35
Program Automation?
Provides the mechanism to control PSS/E other than by direct interaction!
• PSS/E Automation file languages:
• Response files
• IPLAN commands
• Fortran call statements
• Python commands
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
36
Program Automation?
• Response files
• Often referred to as “idv” files or “Batch” commands!
• A set of instructions and inputs emulating the program manual operation
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
37
Program Automation?
• IPLAN commands
• A simple programming language designed for PSS/E
• Has limited capabilities compared to modern programming languages!
• Described in the IPLAN manual:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
38
Program Automation?
• Fortran call statements
• A well-documented language
• But we don’t use it here!! 
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
39
Program Automation?
• Some important modules:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
40
Python & PSS/E
• ways of connecting:
1.The Embedded Interpreter Environment
• Allows PSS/E to execute Python files and commands.
• Run Program Automation File in PSS/E
2.The External Interpreter Environment
• Python programs access PSS/E functions without running GUI
• Faster and better Way
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
41
Python & PSS/E
1.The Embedded Interpreter Environment
Select the Python file type and specify the file name
Execute operations through the PSS/E GUI
click the Stop Recording button
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
42
Python & PSS/E
2.The External Interpreter Environment
Code that is suggested in the PSS/E manual to get an External Interpreter
Environment:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
43
Python & PSS/E
Functions
Most of useful functions are in psspy module. For example:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
44
Python & PSS/E
Functions
Most of useful functions are in psspy module. For example:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
45
Python & PSS/E
Functions
Most of useful functions are in psspy module. For example:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
46
Python & PSS/E
Functions
How can I find them?
1-The API file
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
47
Python & PSS/E
Functions
How can I find them?
2-The record mode
I. Click the Start Recording button
II. Select the Python file type and specify the file name
III. Execute operations through the PSS/E GUI
IV. click the Stop Recording button
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
48
Python & PSS/E
Functions
How can I use them?
1-Option mode
2-Array mode
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
49
psspy.fnsl(
options1=0, # disable tap stepping adjustment.
options5=0, # disable switched shunt adjustment.
)
psspy.fnsl([0,_i,_i,_i,0,_i,_i,_i])
Python & PSS/E
Important functions
Power Flow Operation (API-Chapter 1)
Describes the API routines corresponding to the operational functions of the PSS®E Power Flow and
Fault Analysis.
Example:
fnsl (Newton-Raphson power flow function)
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
50
Python & PSS/E
Important functions
Power Flow Data Changing (API-Chapter 2)
Describes the API routines used to add or modify power flow data.
Example:
branch_data (Modify the data of an existing non-transformer branch in the working case or to add
a new non-transformer branch to the working case)
If you want to change the reactance of the branch from bus 456 to bus 459 circuit 1 to 0.025 pu:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
51
ierr = psspy.branch_data(456,459,"1",[_i,_i,_i,_i,_i,_i], [_f,0.025,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f])
Equal to:
ierr = psspy.branch_data(456,459,"1", realar2 = 0.025)
Python & PSS/E
Important functions
Single Element Data Retrieval (API-Chapter 7)
Defines API routines that are used to retrieve data for a single element (e.g., bus,
branch, area, etc.) from the PSS®E engine and test on various program states.
Example:
busdat (Use this API to return real bus values)
If you want to retrieve the pu voltage at the bus 1:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
52
busNumber = 1
paramStr = 'PU'
ierr, Vpu = psspy.busdat(busNumber, paramStr)
Python & PSS/E
Important functions
Remove Elements From a Power Flow Case (API-Chapter 1)
Example:
purg(delete specified outaged equipment items from the working case (activity PURG).)
purgbrn(delete the specified non-transformer branch or two-winding transformer from the
working case (activity PURG).)
If you want to remove the line from bus 201 to bus 202 circuit "1“:
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
53
fromBus = 201
toBus = 202
ckt = '1'
ierr = psspy.purgbrn(fromBus, toBus, ckt)
Python & PSS/E
Silencing PSS/E Output
• PSS/E prints a voluminous amount of information to the command line when you are running a program
• silence is a function that turn off this outputs and save logs in a file
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
54
Python & PSS/E
Simple example
• Optimum placement of a fixed capacitor (100 MVAR) on feeders of “savnw” grid
• Scaling loads (5%) with fixed power factor for making disturbance in network and save case file as “savnw1”
• Log will save in a “psse_logfile.log” and report output is a file named “report.txt”
• Before allocating capacitor, total losses were as below:
69.04 MW & 1267.50 MVAR
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
55
Python & PSS/E
Simple example (Code)
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
56
Python & PSS/E
Simple example (Results)
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
57
0
10
20
30
40
50
60
70
80
90
MW Losses
MW
Python & PSS/E
Simple example (Results)
Department of Electrical and Computer Engineering
Power Systems Analysis Lab.
Amin Rabanian
58
0
200
400
600
800
1000
1200
1400
1600
MVAR Losses
MVAR
THE END
59

Contenu connexe

En vedette

AMSC D-VAR® Model for PSSE_releasable
AMSC D-VAR® Model for PSSE_releasableAMSC D-VAR® Model for PSSE_releasable
AMSC D-VAR® Model for PSSE_releasable
johnwrightsmith
 
23 support for small rice threshers in nigeria 8-07
23 support for small rice threshers in nigeria 8-0723 support for small rice threshers in nigeria 8-07
23 support for small rice threshers in nigeria 8-07
mamoharar
 
Installing, Programming & Commissioning of Power System Protection Relays and...
Installing, Programming & Commissioning of Power System Protection Relays and...Installing, Programming & Commissioning of Power System Protection Relays and...
Installing, Programming & Commissioning of Power System Protection Relays and...
Living Online
 
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-1614_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
Isham Rashik
 
Power System Stability & Control
Power System Stability & ControlPower System Stability & Control
Power System Stability & Control
Azimah Aziz
 
Superconductivity
SuperconductivitySuperconductivity
Superconductivity
ad1729
 

En vedette (20)

OPAL-RT RT14 Conference: Power System Monitoring and Operator Training
OPAL-RT RT14 Conference: Power System Monitoring and Operator TrainingOPAL-RT RT14 Conference: Power System Monitoring and Operator Training
OPAL-RT RT14 Conference: Power System Monitoring and Operator Training
 
D-SVC Data Sheet R2
D-SVC Data Sheet R2D-SVC Data Sheet R2
D-SVC Data Sheet R2
 
AMSC D-VAR® Model for PSSE_releasable
AMSC D-VAR® Model for PSSE_releasableAMSC D-VAR® Model for PSSE_releasable
AMSC D-VAR® Model for PSSE_releasable
 
23 support for small rice threshers in nigeria 8-07
23 support for small rice threshers in nigeria 8-0723 support for small rice threshers in nigeria 8-07
23 support for small rice threshers in nigeria 8-07
 
FAULT DETECTION ON OVERHEAD TRANSMISSION LINE USING ARTIFICIAL NEURAL NET...
 FAULT DETECTION ON OVERHEAD TRANSMISSION LINE  USING ARTIFICIAL NEURAL NET... FAULT DETECTION ON OVERHEAD TRANSMISSION LINE  USING ARTIFICIAL NEURAL NET...
FAULT DETECTION ON OVERHEAD TRANSMISSION LINE USING ARTIFICIAL NEURAL NET...
 
D-SMES
D-SMESD-SMES
D-SMES
 
Methods of Voltage Control
Methods of Voltage ControlMethods of Voltage Control
Methods of Voltage Control
 
Installing, Programming & Commissioning of Power System Protection Relays and...
Installing, Programming & Commissioning of Power System Protection Relays and...Installing, Programming & Commissioning of Power System Protection Relays and...
Installing, Programming & Commissioning of Power System Protection Relays and...
 
Grid calculations ELVIS event Antti Harjula
Grid calculations ELVIS event Antti HarjulaGrid calculations ELVIS event Antti Harjula
Grid calculations ELVIS event Antti Harjula
 
Superconductivity
SuperconductivitySuperconductivity
Superconductivity
 
Superconducting magnetic energy storage
Superconducting magnetic energy storageSuperconducting magnetic energy storage
Superconducting magnetic energy storage
 
Transient enhancement technique
Transient enhancement techniqueTransient enhancement technique
Transient enhancement technique
 
VSC based HVDC system
VSC based HVDC systemVSC based HVDC system
VSC based HVDC system
 
Tutorial: Introduction to Transient Analysis using DIgSILENT PowerFactory.
Tutorial: Introduction to Transient Analysis using DIgSILENT PowerFactory.Tutorial: Introduction to Transient Analysis using DIgSILENT PowerFactory.
Tutorial: Introduction to Transient Analysis using DIgSILENT PowerFactory.
 
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-1614_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
14_H00141747_Doula Isham_B30UC_Power System Transient Stability_Poster_2015-16
 
Power System Stability & Control
Power System Stability & ControlPower System Stability & Control
Power System Stability & Control
 
Reactive power management
Reactive power managementReactive power management
Reactive power management
 
Transient stability analysis on a multi machine system in psat
Transient stability analysis on a multi machine system in psatTransient stability analysis on a multi machine system in psat
Transient stability analysis on a multi machine system in psat
 
Superconductivity
SuperconductivitySuperconductivity
Superconductivity
 
Definition & Classification Of Power System Stability
Definition & Classification Of Power System StabilityDefinition & Classification Of Power System Stability
Definition & Classification Of Power System Stability
 

Similaire à Part2

EE312_ Control System Engineering_Moodle_Page
EE312_ Control System Engineering_Moodle_PageEE312_ Control System Engineering_Moodle_Page
EE312_ Control System Engineering_Moodle_Page
Praneel Chand
 
Adam_Mcconnell_SPR11_v3
Adam_Mcconnell_SPR11_v3Adam_Mcconnell_SPR11_v3
Adam_Mcconnell_SPR11_v3
Adam McConnell
 
Introduction to plc programming
Introduction to plc programmingIntroduction to plc programming
Introduction to plc programming
nddng
 
Culturally Responsive Literacy Resources Template Part 1.docx
Culturally Responsive Literacy Resources Template Part 1.docxCulturally Responsive Literacy Resources Template Part 1.docx
Culturally Responsive Literacy Resources Template Part 1.docx
dorishigh
 

Similaire à Part2 (20)

Py tut-handout
Py tut-handoutPy tut-handout
Py tut-handout
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
Introduction to python3.pdf
Introduction to python3.pdfIntroduction to python3.pdf
Introduction to python3.pdf
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Robot Framework with Python | Edureka
Robot Framework with Python | EdurekaRobot Framework with Python | Edureka
Robot Framework with Python | Edureka
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Pi Is For Python
Pi Is For PythonPi Is For Python
Pi Is For Python
 
Python Programmimg language in Gurugram
Python  Programmimg language in GurugramPython  Programmimg language in Gurugram
Python Programmimg language in Gurugram
 
EE312_ Control System Engineering_Moodle_Page
EE312_ Control System Engineering_Moodle_PageEE312_ Control System Engineering_Moodle_Page
EE312_ Control System Engineering_Moodle_Page
 
Lab (1) installation of python
Lab (1) installation of pythonLab (1) installation of python
Lab (1) installation of python
 
python unit2.pptx
python unit2.pptxpython unit2.pptx
python unit2.pptx
 
Adam_Mcconnell_SPR11_v3
Adam_Mcconnell_SPR11_v3Adam_Mcconnell_SPR11_v3
Adam_Mcconnell_SPR11_v3
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
 
Introduction to plc programming
Introduction to plc programmingIntroduction to plc programming
Introduction to plc programming
 
Culturally Responsive Literacy Resources Template Part 1.docx
Culturally Responsive Literacy Resources Template Part 1.docxCulturally Responsive Literacy Resources Template Part 1.docx
Culturally Responsive Literacy Resources Template Part 1.docx
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)
 

Part2

  • 1. Python Power systems analysis in PSS®E using In the Name of God Isfahan University of Technology Department of Electrical & Computer Engineering Power Systems Analysis Lab. programming language 1
  • 2. Python? • Name of a kind of snakes • Developed By Guido van Rossum at CWI in the early 1990s in the Netherlands Download it from http://www.python.org Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 2
  • 3. Why Python? Simple Easy to Learn Free and Open Source High-level language Portable Interpreted Object Oriented extensible Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 3
  • 4. How to programming Python? Some Python interpreters: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 4
  • 5. Getting started with Python 1- Command line mode Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 5
  • 6. Getting started with Python 2- Script mode Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 6
  • 7. Getting started with Python 3-Python syntax colors Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 7
  • 8. Getting started with Python 4- Blocks of Code Note: Dots indicates blank spaces before the code !! Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian ..two spaces means this is part of block 1 ..two spaces means this is still a part of block 1 ....four spaces means we just started block number 2 ....four spaces means we are still in block number 2 ........eight spaces means we started block number 3 ....four spaces means we want this code to be grouped with block 2 ........eight spaces for block 3 8
  • 9. Getting started with Python 5- Operators The most common operators are: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 9
  • 10. Getting started with Python 6- Using Python as a Calculator Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 10
  • 11. Getting started with Python 7- Strings Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 11
  • 12. Getting started with Python 7- Strings Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 12
  • 13. Getting started with Python 8- Variables You can name a variable almost anything and use symbols like the _underscore ! But don’t use these words: Note: No need to define variable Types! The first assignment to a variable creates it. Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 13
  • 14. Getting started with Python 9- Logical operators and Boolean data types The words “and, or,” and “not” are logical operators. A simple condition: A compound condition: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 14
  • 15. Getting started with Python 10- Sequence types Tuple A simple immutable ordered sequence of items Items can be of mixed types, including collection types Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 15
  • 16. Getting started with Python 10- Sequence types Dictionary Mutable key-value pair Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 16
  • 17. Getting started with Python 10- Sequence types List Mutable ordered sequence of items of mixed types Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 17
  • 18. Getting started with Python 11- Copy a variable • For simple variables: # b is a copy of the old value!! • But mutable variables are always equal to each other!! Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 18
  • 19. Getting started with Python 12- Conditional statements Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 19
  • 20. Getting started with Python 13- Loop statements Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 20
  • 21. Getting started with Python 14- Define a Function Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 21
  • 22. Getting started with Python 15- Class • A class is a User-Defined variable Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 22
  • 23. Getting started with Python 16- Module • Modules are imported from other scripts using the import command • As an example: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 23
  • 24. Getting started with Python 17- Work with files Note: Read function didn’t skip the blank character!! Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 24
  • 25. Getting started with Python 18- Input Data: There are some simple ways to request data from user: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 25
  • 26. Getting started with Python 19- Try and except: You can try to do something in your script and make an exception for the time that Python can’t run your code!! Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 26
  • 27. Getting started with Python 20- Help Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 27
  • 28. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 28
  • 29. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 29
  • 30. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 30
  • 31. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 31
  • 32. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 32
  • 33. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 33
  • 34. Getting started with Python Simple examples Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 34
  • 36. Program Automation? Provides the mechanism to control PSS/E other than by direct interaction! • PSS/E Automation file languages: • Response files • IPLAN commands • Fortran call statements • Python commands Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 36
  • 37. Program Automation? • Response files • Often referred to as “idv” files or “Batch” commands! • A set of instructions and inputs emulating the program manual operation Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 37
  • 38. Program Automation? • IPLAN commands • A simple programming language designed for PSS/E • Has limited capabilities compared to modern programming languages! • Described in the IPLAN manual: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 38
  • 39. Program Automation? • Fortran call statements • A well-documented language • But we don’t use it here!!  Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 39
  • 40. Program Automation? • Some important modules: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 40
  • 41. Python & PSS/E • ways of connecting: 1.The Embedded Interpreter Environment • Allows PSS/E to execute Python files and commands. • Run Program Automation File in PSS/E 2.The External Interpreter Environment • Python programs access PSS/E functions without running GUI • Faster and better Way Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 41
  • 42. Python & PSS/E 1.The Embedded Interpreter Environment Select the Python file type and specify the file name Execute operations through the PSS/E GUI click the Stop Recording button Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 42
  • 43. Python & PSS/E 2.The External Interpreter Environment Code that is suggested in the PSS/E manual to get an External Interpreter Environment: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 43
  • 44. Python & PSS/E Functions Most of useful functions are in psspy module. For example: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 44
  • 45. Python & PSS/E Functions Most of useful functions are in psspy module. For example: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 45
  • 46. Python & PSS/E Functions Most of useful functions are in psspy module. For example: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 46
  • 47. Python & PSS/E Functions How can I find them? 1-The API file Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 47
  • 48. Python & PSS/E Functions How can I find them? 2-The record mode I. Click the Start Recording button II. Select the Python file type and specify the file name III. Execute operations through the PSS/E GUI IV. click the Stop Recording button Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 48
  • 49. Python & PSS/E Functions How can I use them? 1-Option mode 2-Array mode Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 49 psspy.fnsl( options1=0, # disable tap stepping adjustment. options5=0, # disable switched shunt adjustment. ) psspy.fnsl([0,_i,_i,_i,0,_i,_i,_i])
  • 50. Python & PSS/E Important functions Power Flow Operation (API-Chapter 1) Describes the API routines corresponding to the operational functions of the PSS®E Power Flow and Fault Analysis. Example: fnsl (Newton-Raphson power flow function) Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 50
  • 51. Python & PSS/E Important functions Power Flow Data Changing (API-Chapter 2) Describes the API routines used to add or modify power flow data. Example: branch_data (Modify the data of an existing non-transformer branch in the working case or to add a new non-transformer branch to the working case) If you want to change the reactance of the branch from bus 456 to bus 459 circuit 1 to 0.025 pu: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 51 ierr = psspy.branch_data(456,459,"1",[_i,_i,_i,_i,_i,_i], [_f,0.025,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f]) Equal to: ierr = psspy.branch_data(456,459,"1", realar2 = 0.025)
  • 52. Python & PSS/E Important functions Single Element Data Retrieval (API-Chapter 7) Defines API routines that are used to retrieve data for a single element (e.g., bus, branch, area, etc.) from the PSS®E engine and test on various program states. Example: busdat (Use this API to return real bus values) If you want to retrieve the pu voltage at the bus 1: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 52 busNumber = 1 paramStr = 'PU' ierr, Vpu = psspy.busdat(busNumber, paramStr)
  • 53. Python & PSS/E Important functions Remove Elements From a Power Flow Case (API-Chapter 1) Example: purg(delete specified outaged equipment items from the working case (activity PURG).) purgbrn(delete the specified non-transformer branch or two-winding transformer from the working case (activity PURG).) If you want to remove the line from bus 201 to bus 202 circuit "1“: Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 53 fromBus = 201 toBus = 202 ckt = '1' ierr = psspy.purgbrn(fromBus, toBus, ckt)
  • 54. Python & PSS/E Silencing PSS/E Output • PSS/E prints a voluminous amount of information to the command line when you are running a program • silence is a function that turn off this outputs and save logs in a file Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 54
  • 55. Python & PSS/E Simple example • Optimum placement of a fixed capacitor (100 MVAR) on feeders of “savnw” grid • Scaling loads (5%) with fixed power factor for making disturbance in network and save case file as “savnw1” • Log will save in a “psse_logfile.log” and report output is a file named “report.txt” • Before allocating capacitor, total losses were as below: 69.04 MW & 1267.50 MVAR Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 55
  • 56. Python & PSS/E Simple example (Code) Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 56
  • 57. Python & PSS/E Simple example (Results) Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 57 0 10 20 30 40 50 60 70 80 90 MW Losses MW
  • 58. Python & PSS/E Simple example (Results) Department of Electrical and Computer Engineering Power Systems Analysis Lab. Amin Rabanian 58 0 200 400 600 800 1000 1200 1400 1600 MVAR Losses MVAR