First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Hi, I will try to answer your questions as I have written python script for my needs for ACCC calculations.
-Is there a way to automatically generate .sub, .mon and.con files? In general if you want to generate those files from python, you should prepare functions that can do that, but I think you don't need to do that automatically as usually you know before calculations what you want to analyse - area numbers and voltage levels. In .sub file you can create as many different subsystems as you want, give them different names, and later in python just manipulate in changing subsystem name rather than trying to generate new .sub file. The same advice for .mon file - put everything you want to monitor there, later on anyway you will need to program your specific python function for digging into ACCC results file and filtering what you need. For .con - I advice you to prepare different .con files for different levels of analyses - one for e.g. 400 kV level, another for just generators and so on - each for different purposes as some contingencys will run very long, e.g. n-2 for branches for voltage levels less than 400 kV.
-I wonder if I can save the the violated contingencies (only the contingency names/indices should be sufficient) to a list. Of course you can, so why we are using python instead of psse GUI - in python you can do everything :) Following python code will give you contingency list (excerptions from my code, sorry if something will not work):
#method 1: contingency list with short descriptions
sumry = pssarrays.accc_summary(accfile=acc)
print 'Contingency list:'
k = 0
for n in sumry.colabel:
k += 1
print k, n
#method 2: contingency list with full descriptions
for i in range(len(sumry.colabel)):
ContLabel = sumry.colabel[i]
try:
rlst = pssarrays.accc_solution(accfile=acc, colabel=ContLabel, stype='contingency',
busmsm=busmsm, sysmsm=sysmsm)
finally:
pass
if rlst is not None: # contingency solution found, proceed
msm = rlst.mvatotal #if need to check mismatch
msm2=rlst.mvaworst #also mismatch (msm2<msm - I dont know why)
if (only_bad_mismatch and msm2>maxMismatch) or (only_bad_mismatch==0): #if need to filter cases with high mismnatches - e.g. where no solution found
contdescr = rlst.codesc
s=contdescr[0]
for z in range(1,len(contdescr)):
s += ' & ' + contdescr[z]
print s #printing contingency full description
-Does any one know the Python module that can be used to create a specific contingency for either generator or branch?
No specific module I think, but you can write easily function that will generate .con file (which is in text format of course) where you can put all contingencys you want as e.g. one bus contingency description in .con file looks simple:
CONTINGENCY 'Line 111-222-1'
DISCONNECT BRANCH FROM BUS 111 TO BUS 222 CIRCUIT '1'
END
Just iterate over all branches changing bus numbers and putting those three lines into .con. Later on just re-run ACCC with newly created .con.
In my program I organized all ACCC things in two main functions - one for running ACCC, another for filtering results (only for buses, lines and transformers):
#running accc and generating report file (ACC_Report):
RunACCC(ACC_Sub=ACC_Sub
,ACC_Mon=ACC_Mon
,ACC_Con=ACC_Con
,ACC_Dfax=ACC_Dfax
,ACC_Report=ACC_Report
,Misamtch_tolerance=ACCC_Misamtch
,run_dfax=run_dfax )
#filtering problematic contingencys from ACC_Report file (results will be printed on screen and will be returned as a resulting list in python format):
repACC = MyACCC(acc=ACC_Report
, maxMismatch=ACCC_Misamtch
, show_contlist=0 #show contingency list
, show_monitlines=0 #show monitored lines
, show_monitbuses=0 #show monitored buses
, show_msm_report=1 #show mismatch report
, rep_lines=1, opt_lines={ 'Base': ['a', 80], 'Cont': ['a', 92] } #max allowable line loading in normal and n-1 cases
, rep_busvolt=1
, opt_buses={ '330': [300, 361], '110': [100, 121], '400': [360, 440] }
, rep_tr2=1, opt_tr2={ 'Base': ['a', 90], 'Cont': ['a', 100] }
, reports_to_screen=1 #output reports to screen
, rep_LinesReport=1 #output report of pre-defined lines list
, LinesList=LinesList #pre-defined list of lines for reporting
)
#repACC will return:
# [sav, baseBuses, baseLines, baseTR2, contBuses, contLines, contTR2, LMismatch, LinesReport]
# where:
# sav- sav file used for accc
# baseBuses - have format ['Bus', 'Name', 'BasekV', 'minkV', 'maxkV', 'kV', 'deltakV'] - voltages for monitored buses in normal case
# contBuses - have format ['Bus', 'Name', 'BasekV', 'minkV', 'maxkV', 'kV', 'deltakV', 'Worst contingency'] - voltages for monitored buses in worst contingency and that contingency description
# LinesReport- have format [bus1,bus2,id,percBase,percWorstCont,WorstContingencyLabel]
# where percBase - line loading in normal case, percWorstCont - loading after worst contingency