Repository navigation
Expand file tree
/
Copy pathPyRAPS_DYR.py
More file actions
68 lines (50 loc) · 2.19 KB
/
Copy pathPyRAPS_DYR.py
File metadata and controls
68 lines (50 loc) · 2.19 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
"""
09-2026
Copyright 2026, Battelle Energy Alliance, LLC, ALL RIGHTS RESERVED
@authors: Soumyadeep Nag, Shafiul Alam
"""
import psspy
import csv
#Derated plants
derating_file = 'Affected_generators.csv'
Sid=-1 # All machines
Flag=1 # Only in-service machines at in-service plants
ierr, Nmach=psspy.amachcount(Sid, Flag) # get no of machines in the subsystem
ierr, iMbus = psspy.amachint(Sid, Flag, 'NUMBER') # get machine bus numbers
ierr, cMids = psspy.amachchar(Sid, Flag, 'ID') # get machine IDs
iMbus=iMbus[0]
cMids=cMids[0]
with open(derating_file, 'r') as file:
csv_reader = csv.reader(file)
header = next(csv_reader) # Read the header row
#print("Header:", header)
rows = list(csv_reader)
dert_bus = [row[1] for row in rows]
dert_ind = [row[3] for row in rows]
count = 0
#Set H0 to this values
H0 = .9
with open ('Change_H0_report.csv', mode='w', newline='') as file:
writer = csv.writer(file)
# Write header
header = ['bus name']+['Gen ID on the bus']+['GOV model']+['new head']
writer.writerow(header)
for i in range(len(rows)):
if int(dert_bus[i]) in iMbus:
indices = [j for j, x in enumerate(iMbus) if x == int(dert_bus[i])]
cMids_new = []
for x in indices:
cMids_new.append(cMids[x].strip())
if dert_ind[i] in cMids_new:
ierr, govMdl = psspy.mdlnam(int(dert_bus[i]), dert_ind[i], 'GOV') # get governor model name
if not govMdl is None:
govMdl = govMdl.strip()
if govMdl == 'HYG3U1':
#change head
ierr = psspy.change_plmod_con(int(dert_bus[i]), dert_ind[i], govMdl, 28, H0)
print(dert_bus[i],'unitid', dert_ind[i],'found')
count+=1
row = [dert_bus[i]]+[dert_ind[i]]+[govMdl]+[H0]
writer.writerow(row)
print(count,'units found with HYG3U1 and processed')
psspy.dyda(0,1,[2,2,0],0,r"""C:\Users\NAGS\OneDrive - Idaho National Laboratory\Desktop\Current proj\SDR - Modelling gaps\32HS11p_90.dyr""")