Knowledge Base

New Generation Study

Auxiliary File: NewGenStudy.aux

PowerWorld Case: B7OPF.pwb

PowerWorld Oneline: B7OPF.pwd

Output Files: NewGenBefore.auxNewGenAfter.auxNewGenCTGBefore.txtNewGenCTGAfter.txt

(Right-click on the above files and select Save Target As to save them to your computer.)

In this example we will add a new generator to a seven-bus system. We will first solve the power flow, run contingency analysis, calculate PTDFs, and save data to files. Then we will add a new generator, and finally re-run the power flow and contingency analysis and again save data to external files for comparison.

This example contains five Script sections:

Initial deletes output files from previous runs of this script, solves the power flow, sets the base case for difference flows and sets a reference case for contingency analysis.DoCalculations starts with the contingency reference case. It solves the power flow, runs contingency analysis, produces an automatic contingency report and calculates PTDFs.

SaveData saves data about the lines buses to an external file.

Addgen adds a new generator at bus 4.

After moves the before files to new locations, calls the DoCalculations and SaveData scripts, and then moves the after files to new locations.

The file also contains one data section, AddCTG, which is the list of contingencies to use for contingency analysis.

//Script to run calculations before and after adding
//a new generator
//This script is for a 7 bus case

SCRIPT Initial
//Clean up files
//Delete files that will be in the directory if
//this script has been run from the same directory
//earlier. Otherwise data will be appended to the
//same files over and over again.
//Enter PowerFlow mode so we can solve the power flow.
//Solve the power flow.
//Set the present case as the base case for difference
//Switch to contingency mode
//Set reference before doing contingency analysis

DATA addCTG(Contingency, [CTGlabel, CTGskip])
//Set up contigencies
//PowerWorld will ask if you want to create these
//contingencies since they don’t already exist. Say Yes.

//Contingency Label      Skip?
Contingencies           NO
//A list of contingencies to use for contingency analysis.
//    Action            Model Criteria      Status
"GEN 1 1 OPEN"                   ""          ALWAYS
"BRANCH 1 2 1 OPEN"              ""          ALWAYS
"BRANCH 2 5 1 OPEN"              ""          ALWAYS
"INTERFACE Left-Right OPEN"      ""          ALWAYS

SCRIPT DoCalculations
//Solve the power flow, run contingency analysis,
//and create a report.
//Enter the contingency mode.
//Start from the reference state
//Now switch to PowerFlow mode.
//Run the power flow to make sure it converges
//Look at the difference flow to see changes in the
//power flow.
//Do the analysis and calculations
//First enter contingency mode
//Solve the contingencies we entered above.
//Produce the automatic contingency report,
//save it as NewGenCTG.
//Switch to run mode.
//Calculate PTDFs for a transaction between areas 1 and 2.
CalculatePTDF([AREA 1], [AREA 2], AC);

//Save data about the buses to the file "NewGenResults.AUX".
SaveData("NewGenResults", AUX, BUS, [BusNum, BusGenMW, BusKVVolt, BusLoadMW, CTGViol], []);
//Append data about the branches to the "NewGenResults.AUX" file
SaveData("NewGenResults", AUX, BRANCH, [BusNum, BusNum:1, LineLimitPercent, LinePTDF], []);

SCRIPT addgen
//Add the new generator at bus 4
//Switch to Edit mode.
//Enter the data for the new generator using CreateData.
//CreateData(Object, [List of fields], [List of values] CreateData(GEN,[busnum, GenID, GENAGCAble, GenParFac, GenIOB, GenFixedCost, GenFuelCost, GenMWMin, GenMWMax,
[4,2,YES, 1,6, 1, 1, 5, 50, YES]);
//CreateData works for one generator.
//If we were entering several generators
//it would be much easier to use a data section.
//Make sure that the MW Limits are enforced
//on the new generator.
SetData(GEN, [busnum, GenID, GenEnforceMWLimits], [4, 2, YES]);

//Perform "after" analysis, save data to new files.
//First rename the files created before the new generator.
RenameFile("NewGenResults", "NewGenBefore");
RenameFile("NewGenCTG", "NewGenCTGBefore");
//Call the DoCalculations script to do the calculations.
LoadScript("NewGenStudy.AUX", DoCalculations);
//Call the SaveData script to save the data.
LoadScript("NewGenStudy.AUX", SaveData);
//Rename the files created after the new generator.
RenameFile("NewGenResults", "NewGenAfter");
RenameFile("NewGenCTG", "NewGenCTGAfter");

Tags: ,,,

June 28, 2012