Skip to content

Implementation of fast N-2 contingency analysis algorithm based on work of prof. Turitsyn MIT group.

Notifications You must be signed in to change notification settings

pekap/N_2_contingency_analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast N-2 contingency analysis algorithm

Basic implementation of fast N-2 contingecy analysis algorithm developed by Prof. Kostya Turitsyn MIT research group.
The algorithm aims to find all dangerous N-2 contingencies in the grid. We call dangerous N-k contingency a set of k elements which tripping leads to violation of at least one constraint in the given power grid.

In this implementation we consider only lines as contingency elements and their power limits as constraints.

How to run

Clone this repo and add path to it to matlab path collection. You can see example of usage in code/tests/test_grid_class.m file. In that file we

  1. Load a MATPOWER grid case from /code/cases/ folder
runcase = loadcase('case300');
  1. Initialize grid object using constructor of the Grid_class
grid = Grid_class(runcase,'case300_experiment');
  1. Run N-0, N-1 and N-2 analysis.
grid.N_1_analysis();
grid.N_2_analysis('fast');
grid.N_2_analysis('bruteforce');

After running this, inside MATLAB command window we should see

OPF was successfuly solved
***********************************************
************   Start N-1 analysis  ************
***********************************************
	Processed 322/322. Number of dangerous N-1 contingecies is 0 : 

	N-1 analysis was performed,0 dangerous contigencies were found, 0 lines are violated 

***********************************************
************Start fast N-2 analysis************
***********************************************
	 0 iteration: number of potential confingecies::51558, B::103362
	 1 iteration: number of potential confingecies::4, B::291
	 2 iteration: number of potential confingecies::1, B::6

	Bruteforce enumeration over 1 pairs 
	Processed 100 percent. Number of contingencies 1; fake 0
	Running time for fast algorithm is 7.487977e-02 sec 

***********************************************
************Start bruteforce N-2 analysis************
***********************************************

	Bruteforce enumeration over 51842 pairs 
	Processed 100 percent. Number of contingencies 1; fake 123
	Running time for brute force algorithm is 1.420059e+01 sec 

In this case running time of our algorithm was almost 200 ~O(Number of branches) times less direct bruteforce enumeration.

What happens behind scenes

  1. We create grid object. During the process of the creation we

  2. Remap odd numeration. (some matpower cases have buses numerated in odd order)

  3. Delete branches that have 'off' status.

  4. Set shift angle to 0 and tap coefficient to 1 (generalization of our algorithm without this is trivial, but for demonstration we are left with this normalization)

  5. Remove parallel lines

  6. Run DC OPF

  7. Aggregate leafes (they lead to trivial N-1 contingencies which we are not interested in)

  8. We run N-1 contingency analysis

  9. Switch every single line 'off' one by one

  10. Look at response on other lines

  11. Create matrix of LODF

  12. Create array of max margins, to understand if grid is N-1 safe

  13. Save results to file in '/results/' folder

  14. We run N-2 contingency analysis

  15. It checks if N-1 analysis have already been run.

  16. If not runs it / else loads N-1 analysis data

  17. Starts appropriate analysis method 1. 'bruteforce' just enumerates all possible pairs 2. 'fast' uses developed algorithm to shrink the search space and then enumerates over it

  18. Results are being recorded to file in '/results/' folder. The results file contains all dangerous contingencies

For further explanation see description of the code and comments inside class files

Links

We use dcopf solver and grid cases from MATPOWER MATLAB package, which is included in our repo.

The algorithm presented here was developed by Prof. Kostya Turitsyn research group at MIT. Links to related works:
Original paper
Elaborated approach for generators as contingencies

For any suggestions please contact us at

Petya Kaplunovich pekap@mit.edu
Kostya Turitsyn turitsyn@mit.edu

About

Implementation of fast N-2 contingency analysis algorithm based on work of prof. Turitsyn MIT group.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages