Ask Your Question

Questions about running contingency analysis for a large-scale network?

asked 2014-07-13 23:13:38 -0500

ypwang gravatar image

updated 2014-07-16 21:39:29 -0500

Eli Pack gravatar image

Hi there,

I am new to Python for PSSE. I appreciate that Jervis for setting up such a great learning community for PSSE users who want to use Python.

Right now, I want to use Python to fully automate a comprehensive contingency analysis for a real world large system with over 18,000 buses and 13,000 lines and 2000 generators. I intend to do this in the following steps: First, call ACCC for all possible N-1 contingency for the whole network -Is there a way to automatically generate .sub, .mon and.con files? (now I can only do it through PSSE GUI and can only generate DFAX through Python) -Does anyone know how long it would take for this size of network in PSSE?

Second, based on the solution report, I record the solutions of all the contingencies that violated either the line ratings limit or voltage magnitude limits in the Excel (I know I need to use the PSSEXCEL module). - Since I need to continue work on these results in subsequent steps in Python, I wonder if I can save the the violated contingencies (only the contingency names/indices should be sufficient) to a list. If this won't work, can I save the results in ZIP format and access the specific contingency names/indices in next step?

Third, after finding those violated contingencies, for each specific violated contingency (either generator or branch failure), I first want to create it using some Python module and then iteratively opening a branch (same unknown Python module needed here) using a for loop to find out if there are some branch-opening options are helpful in alleviating the previous violations that were caused by the contingency being considered. - Does any one know the Python module that can be used to create a specific contingency for either generator or branch?

Thanks very much for your valuable time and kind help in advance!!

Please forgive any misconception since I am not a power engineer:-)

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2014-07-16 02:05:36 -0500

rimux gravatar image

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]
    rlst = pssarrays.accc_solution(accfile=acc, colabel=ContLabel, stype='contingency',
                                   busmsm=busmsm, sysmsm=sysmsm)

  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
      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' 

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 ... (more)

edit flag offensive delete link more


Thanks so much for taking time to answer my lengthy question in such a detailed manner. I can easily see that your solutions have been nicely-explained (even though it will take me for a while to digest all your answers:-) ). I hope you won't mind to help me out if I have new questions. Thanks again

ypwang gravatar imageypwang ( 2014-07-16 09:54:58 -0500 )edit

Hi Rimux, do you know a python module that can output all the flow and bus voltage violations for all monitored elements? I know that accc_violations_report can do the job, but it only output to external report. I want use those violations on the fly in the python. Maybe I have to calculate myself.

ypwang gravatar imageypwang ( 2014-08-13 22:29:18 -0500 )edit

But it is good to have accc\_violation\_report module since it provides me a reference to compare with during the debug -- even though the calculation should be easy.

ypwang gravatar imageypwang ( 2014-08-13 22:33:26 -0500 )edit

I am fetching monitored elements by using api command accc_solution, e.g.: sm=pssarrays.accc_summary(accfile=acc) for i in range(len(sm.colabel)): CL = sumry.colabel[i] r=pssarrays.accc_solution(accfile=acc, colabel=CL, stype='contingency', busmsm=bm, sysmsm=sm) mva = r.mvaflow

rimux gravatar imagerimux ( 2014-08-18 13:05:37 -0500 )edit

Of course, would be nice that accc_violations_report would do output not only into text report but similar output like accc_solution. Maybe we should write to PSSE support proposing to include such improvement, shouldnt be big deal for them to implement this into next psse version I think.

rimux gravatar imagerimux ( 2014-08-18 13:15:38 -0500 )edit

answered 2014-08-13 23:11:18 -0500

ypwang gravatar image

Hi Rimux or anyone willing to help me out:

To avoid posting too many comments under you previous answer, I would like another contingency analysis question in here. Right now, I am trying to run ACCC for a whole N-1 contingency list (i.e. enumerate every single branch and every single generator in a specified subsystem), first I have problem creating a full single generator contingency list (I already asked this question in another separate thread, but if you know the answer, you are welcome to share you answer here:-). Secondly, since generator failure might cause generation-load-unbalance, I need to make proportional adjustment to all other online generators. So after finishing the whole Contingency analysis (including both branch and generator contingencies), I can only fetch all contingency labels through solu.colabel and decide the if a specific contingency is a branch one or a generator one, by searching keywork "SINGLE" (branch) or "UNIT"(generator). But I wonder if there is a easier way to identify a generator contingency. Also, do you know a way to do "proportional adjustment" to online generator's current dispatch which should be decided by a base case power flow run (correct?)?

Sorry for asking so many trivial questions at the same time. Please let me know if any part of my question is not clear to you. I would love to clarify further.

Thanks very much again!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


Asked: 2014-07-13 23:13:38 -0500

Seen: 11,498 times

Last updated: Aug 13 '14