-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpsse_template.py
More file actions
106 lines (98 loc) · 4.34 KB
/
psse_template.py
File metadata and controls
106 lines (98 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Importing PSSE module from PSSE installation folder
# DO NOT MODIFY this -- you must have Python 3.9 32 bits installed !!!
import sys
sys.path.insert(1, 'C:\\Program Files (x86)\\PTI\\PSSE34\\PSSPY39')
# Importing PSSE python modules
import psse34
import psspy
# Some pre-defined functions to support the script
def fnsl_error_check(ierr):
options = {
0: 'FNSL activity performed successfully.',
1: 'Invalid OPTIONS value.',
2: 'Generators are converted.',
3: 'Buses in island(s) without a swing bus; use activity TREE.',
4: 'Bus type code and series element status inconsistencies.',
5: 'Prerequisite requirements for API are not met.'
}
status = {
'status': False,
'message': 'Error message not recognized, you are probably performing other activity then FNSL.'
}
if ierr > 5 or ierr < 0:
return status
else:
status['message'] = options[ierr]
if ierr == 0:
status['status'] = True
return status
def pout_error_check(ierr):
options = {
0: 'POUT activity performed successfully.',
1: 'Invalid SID value or subsystem SID is not defined.',
2: 'Invalid ALL value.',
3: 'Prerequisite requirements for API are not met.'
}
status = {
'status': False,
'message': 'Error message not recognized, you are probably performing other activity then POUT.'
}
if ierr > 3 or ierr < 0:
return status
else:
status['message'] = options[ierr]
if ierr == 0:
status['status'] = True
return status
# Input here the desired files (backslash must be doubled -> \\)
root = 'C:\\Users\\brislim\\Downloads\\PSSE Training\\Power Flow 1\\'
raw = root + '*.raw'
sav = root + 'EXER4-1.sav'
sld = root + 'EXER2-3.sld'
# Initializing PSSE 34 and loading case
psspy.psseinit()
psspy.case(sav)
'''
Calling FNSL with options:
( OPTIONS )( Description )( Value 1 )( Value 2 )( Value 3 )( Value 4 )( Value 5 )
OPTIONS(1) Tap adjustment flag 0 (disable) 1 (stepping) 2 (direct) N/A N/A
OPTIONS(2) Area interchange adjustment flag 0 (disable) 1 (tie line) 2 (tie line and loads) N/A N/A
OPTIONS(3) Phase shift adjustment flag 0 (disable) 1 (enable) N/A N/A N/A
OPTIONS(4) DC tap adjustment flag 0 (disable) 1 (enable) N/A N/A N/A
OPTIONS(5) Switched shunt adjustment flag 0 (disable) 1 (enable) 2 (continuous) N/A N/A
OPTIONS(6) Flat start flag 0 (disable) 1 (flat start) 2 (flat - magnitudes) 3 (flat - angles) 4 (flat - both)
OPTIONS(7) VAr limit flag 0 (immediatly) > 0 (iteration n) -1 (ignore) N/A N/A
OPTIONS(8) Non-divergent solution flag 0 (disable) 1 (enable) N/A N/A N/A
'''
options = [
1, # OPTIONS(1)
0, # OPTIONS(2)
0, # OPTIONS(3)
1, # OPTIONS(4)
1, # OPTIONS(5)
0, # OPTIONS(6)
99, # OPTIONS(7)
0 # OPTIONS(8)
]
ierr = psspy.fnsl(options)
status = fnsl_error_check(ierr)
print(status)
if not status['status']:
exit()
'''
Calling POUT with INPUTS (* default):
( INPUTS )( Description )( Value 1 )( Value 2 )( Value 3 )( Value 4 )( Value 5 )
SID Valid subsystem identifier 0 * Any valid SID Any valid SID Any valid SID Any valid SID
ALL All buses or specified subsystem 0 (only buses in SID) 1 (all buses) N/A N/A N/A
'''
with open('pout.txt', 'w') as output:
sys.stdout = output
inputs = [
0, # SID
1 # ALL
]
ierr = psspy.pout(inputs[0], inputs[1])
status = pout_error_check(ierr)
print(status)
if not status['status']:
exit()