You are on page 1of 11

s

int i,k,m,iLdfError,ctr_k,Tap,z;
int iNoofSCases,iMultipleSCases,iNoofSVCs,iNoofWTGs,iNoofTF2Ws,iNoofTF3Ws;
int iNoofVoltageScenarios,iMultipleVScenarios,iTotalRuns,iSaveScenarios;
int iNoofTapableTransformers;
int iNoofTriggers,iNoofActiveTriggers,iNoofPowerPoints,iNoofPoints,
iIsItDRPCTrigger;
double dVoltageSetPoint,dPSetPoint,dQSetPoint;
string strDate,strFilePath,strFileName,strTriggerName;
string strResultsFolderName,strResultsFolderPath,strResultsFilePathandName;
set
sXgrids,sSVCs,sWTGs,sTFWTGs,sTFGTs,sTF3Ws,sLines,sExportCables,sIACableType1,sIACab
leType2,sIACableType3,sIACableType4;
set
sStudyCases,sTriggers,sDRPCTriggers,sWTGTriggers,sDeleteElmRes,sDeleteViPages;
set
sResults,sGridResults,sSVCResults,sWTGResults,sTFWTGResults,sTFGTResults,sTF3WResul
ts,sExportCablesResults,sIACableType1Results,sIACableType2Results,sIACableType3Resu
lts,sIACableType4Results;
object
ldf,oProject,oActiveStudyCase,oActiveScenario,oBackupScenario,oBackupScenario1;
object oTrigger,oWTGTrigger,oDRPCTrigger;
object oXgrid,oSVC,oWTG,oTF2W,oTF3W,oLine,oExportCable;
object oGraphBoard,oViPage,oPlot,oDeleteViPage;
object
oResults,oGridResults,oSVCResults,oWTGResults,oTFWTGResults,oTFGTResults,oTF3WResul
ts,oExportCablesResults,oIACableType1Results,oIACableType2Results,oIACableType3Resu
lts,oIACableType4Results;

!Temporary Variables
object oTemp;
string strDateTemp,strTemp;
int iTempFlag,iOnce;
k=1;
!Future works
!All Future works are placed where they are relevent place and some are listed
below
!Future:Create a own grid summary box similar to grid summary box

!Clears all text in the output window


ClearOutput();

!de-activates the user-interface - will speed up the execution


EchoOff();

!Delete the any existing results file


sDeleteElmRes = this.GetContents('*.ElmRes');

Delete(sDeleteElmRes);

!Delete the any existing plot pages


oGraphBoard = GetGraphBoard();
sDeleteViPages = oGraphBoard.GetContents('*.SetViPage');
for
(oDeleteViPage=sDeleteViPages.First();oDeleteViPage;oDeleteViPage=sDeleteViPages.Ne
xt()){
oDeleteViPage.Close();
}
Delete(sDeleteViPages);

!Inputs
!Constants
iMultipleSCases = 0; !1 = Yes or 0 = No, Used to run multiple study cases !
Future: Use General select to give option to user to select required study cases
iMultipleVScenarios = 1; !1 = Yes or 0 = No, used to run multiple Voltage scenarios
iSaveScenarios = 0; !1 = Yes or 0 = No, used to create the changes to the
equiment as new scenarios

!Create the path of Log file and Name of log file


strDate = strftime('%d%m%y_%H%M');
!strProjectName = 'SimpleLoadFlow'; !Future: take this from Excel or Inputs or
project name or power factory file name
strFilePath = 'C:\LoadFlow';
strResultsFolderName = sprintf('%s_%s',strProjectName,strDate);
strResultsFolderPath = sprintf('%s\\%s',strFilePath,strResultsFolderName);
printf('%s',strResultsFolderPath);
strResultsFilePathandName = sprintf('%s\\%s',strResultsFolderPath,'Log.txt');

!Write Output window text to a Log File


!Redirect is an ComOp object inside this script
Redirect:f = strResultsFilePathandName;
Redirect.Execute();

printf('===========================================================================
=======');
!Print Date of Execution
strDateTemp = strftime('Date of execution : %A, %d. %B %Y,
%H:%M:%S');
printf(strDateTemp);

!Get the Active project


oProject=GetActiveProject();

!Print Active Project name


printf('Project File Name : %o',oProject);

!Get all the study cases, including subfolders


sStudyCases=oProject.GetContents('*.IntCase',1);!1 - to include cases in subfolders

iNoofSCases = sStudyCases.Count();

!set number of cases to 1 if all study cases need not to run


if (.not.(iMultipleSCases)){
iNoofSCases = 1;
}
printf('Total Number of Study Cases : %d',iNoofSCases);

iTempFlag = 0;
!start of For loop for Study Cases
for (i=1;i<=iNoofSCases;i=i+1){
iSCaseNo = i;

printf('===========================================================================
=======');
if (iNoofSCases = 1) {
!Get Active Study Case
oActiveStudyCase = GetActiveStudyCase();
if (NULL = oActiveStudyCase) {
Warn('Warning:No Study Case has been Activated, hence the First Study
Case will be assigned Automatically');
!Assign the first Study Case from all the stuy cases
oActiveStudyCase = sStudyCases.First();
}
}
else {
if (iTempFlag = 0){
oActiveStudyCase=sStudyCases.First();
iTempFlag = 1; !This to ensure that the above command is executed only
once
}
else {
oActiveStudyCase=sStudyCases.Next();
}
}
oActiveStudyCase.Activate();
printf('Running Study Case : %d of %d',i,iNoofSCases);
printf('Active Study case : %o', oActiveStudyCase);

!Delete any existing results file


sDeleteElmRes = oActiveStudyCase.GetContents('ALL*.ElmRes');

Delete(sDeleteElmRes);

oActiveScenario = GetActiveScenario();
printf('Active Scenario : %o', oActiveScenario);
if (NULL = oActiveScenario) {
Warn('Warning: No Active Scenario Present in the study case');
}
else {
oBackupScenario = SaveAsScenario('BackUpScenario', 0); ! Create a backup
scenario - 0 - do not activate it
}

!Checking for Triggers and getting power points


mapTriggers.Clear();
sTriggers=oActiveStudyCase.GetContents('*.SetTrigger');
iNoofTriggers = sTriggers.Count();
if (iNoofTriggers >=0){
sDRPCTriggers.Clear();
sWTGTriggers.Clear();
for(oTrigger=sTriggers.First();oTrigger;oTrigger=sTriggers.Next()){
if (.not.(oTrigger:outserv)){!print and save only active Trigger names
mapTriggers.Insert(oTrigger,oTrigger:ftrigger); !save the Initial
Trigger value to map
strTriggerName = tolower(oTrigger:triggerName);
iIsItDRPCTrigger = strcmp('drpc',strTriggerName,4);
if(iIsItDRPCTrigger = 0){
sDRPCTriggers.Add(oTrigger); !Add active Triggers of DRPCs
}
else {
sWTGTriggers.Add(oTrigger); !Add active Triggers of WTGs
}
printf('Trigger Name - %s - Current Value :
%6.4f',oTrigger:triggerName,oTrigger:ftrigger);
}
}
}
iNoofActiveTriggers = sDRPCTriggers.Count()+ sWTGTriggers.Count();

if ({iNoofTriggers <=0}.or.{iNoofActiveTriggers <=0}){!if No triggers or active


triggers in the study case then set the no of power set points to 1
Warn('Warning: No Triggers or Active Triggers found in the study Case,
hence load flow will run with default power settings given in WTGs');
iNoofPoints = 1;
}
else {
printf('Active Triggers found in the study case :
%d',iNoofActiveTriggers);
iNoofPoints = PQVSetPoints.NRow(); !Future: Right now taking from a matrix
later decide a better input format
}

!Get the required Equipment objects in to sets


GetRequiredEquipment.Execute();
sSVCs = GetRequiredEquipment:sAllSVCs;
sWTGs = GetRequiredEquipment:sAllWTGs;
sTFWTGs = GetRequiredEquipment:sAllTF2WsWTGs;
sTFGTs = GetRequiredEquipment:sAllTF2WsGTs;
sTF3Ws = GetRequiredEquipment:sAllTF3Ws;
sExportCables = GetRequiredEquipment:sExportCables;
sIACableType1 = GetRequiredEquipment:sIACableType1;
sIACableType2 = GetRequiredEquipment:sIACableType2;
sIACableType3 = GetRequiredEquipment:sIACableType3;
sIACableType4 = GetRequiredEquipment:sIACableType4;
sXgrids = GetCalcRelevantObjects('*.ElmXnet',0); !0 to exclude the out of
service elements
oXgrid = sXgrids.FirstFilt('GRID.ElmXnet');

sGridResults.Clear();
oResults = oActiveStudyCase.CreateObject('ElmRes','ALLResults',k);
oGridResults = oActiveStudyCase.CreateObject('ElmRes','ALLGridResults',k);
oSVCResults = oActiveStudyCase.CreateObject('ElmRes','ALLSVCResults',k);
oWTGResults = oActiveStudyCase.CreateObject('ElmRes','ALLWTGResults',k);
oTFWTGResults = oActiveStudyCase.CreateObject('ElmRes','ALLTFWTGResults',k);
oTFGTResults = oActiveStudyCase.CreateObject('ElmRes','ALLTFGTResults',k);
oTF3WResults = oActiveStudyCase.CreateObject('ElmRes','ALLTF3WResults',k);
oExportCablesResults =
oActiveStudyCase.CreateObject('ElmRes','ALLExportCableResults',k);
oIACableType1Results =
oActiveStudyCase.CreateObject('ElmRes','ALLIACableType1Results',k);
oIACableType2Results =
oActiveStudyCase.CreateObject('ElmRes','ALLIACableType2Results',k);
oIACableType3Results =
oActiveStudyCase.CreateObject('ElmRes','ALLIACableType3Results',k);
oIACableType4Results =
oActiveStudyCase.CreateObject('ElmRes','ALLIACableType4Results',k);

sResults.Add(oResults);
sGridResults.Add(oGridResults);
sSVCResults.Add(oSVCResults);
sWTGResults.Add(oWTGResults);
sTFGTResults.Add(oTFGTResults);
sTFWTGResults.Add(oTFWTGResults);
sTF3WResults.Add(oTF3WResults);
sExportCablesResults.Add(oExportCablesResults);
sIACableType1Results.Add(oIACableType1Results);
sIACableType2Results.Add(oIACableType2Results);
sIACableType3Results.Add(oIACableType3Results);
sIACableType4Results.Add(oIACableType4Results);

oResults.AddVars(this,'b:iSCaseNo');
oResults.AddVars(this,'b:dVsetpoint');
oResults.AddVars(this,'b:dPsetpoint');
oResults.AddVars(this,'b:dQsetpoint');

!Assigning Variables of Equipments to Results file


for (oSVC=sSVCs.First(); oSVC; oSVC = sSVCs.Next()) {
oResults.AddVars(oSVC,'n:u1:bus1','m:I:bus1','m:P:bus1','m:Q:bus1');
}

for (oWTG=sWTGs.First(); oWTG; oWTG = sWTGs.Next()) {


oResults.AddVars(oWTG,'n:u1:bus1','m:I:bus1','m:P:bus1','m:Q:bus1');
}

for (oTF2W=sTFWTGs.First(); oTF2W; oTF2W = sTFWTGs.Next()) {

oResults.AddVars(oTF2W,'m:u1:bushv','m:I:bushv','m:P:bushv','m:Q:bushv','m:S:bushv'
);

oResults.AddVars(oTF2W,'m:u1:buslv','m:I:buslv','m:P:buslv','m:Q:buslv','m:S:buslv'
,'c:nntap','c:loading');
}

for (oTF2W=sTFGTs.First(); oTF2W; oTF2W = sTFGTs.Next()) {

oResults.AddVars(oTF2W,'m:u1:bushv','m:I:bushv','m:P:bushv','m:Q:bushv','m:S:bushv'
);

oResults.AddVars(oTF2W,'m:u1:buslv','m:I:buslv','m:P:buslv','m:Q:buslv','m:S:buslv'
,'c:nntap','c:loading');
}

for (oTF3W=sTF3Ws.First(); oTF3W; oTF3W = sTF3Ws.Next()) {

oResults.AddVars(oTF3W,'m:u1:bushv','m:I:bushv','m:phii:bushv','m:P:bushv','m:Q:bus
hv','m:S:bushv');

oResults.AddVars(oTF3W,'m:u1:busmv','m:I:busmv','m:phii:busmv','m:P:busmv','m:Q:bus
mv','m:S:busmv');

oResults.AddVars(oTF3W,'m:u1:buslv','m:I:buslv','m:phii:buslv','m:P:buslv','m:Q:bus
lv','m:S:buslv');
oResults.AddVars(oTF3W,'c:n3tap_m','c:loading');
}

for (oLine=sExportCables.First(); oLine; oLine = sExportCables.Next()) {

oResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S:bus1');

oResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S:bus2','c:cu
rnom','c:Imax','c:loading');
}
if (sIACableType1 .not. NULL){
for (oLine=sIACableType1.First(); oLine; oLine = sIACableType1.Next()) {

oResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S:bus1');

oResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S:bus2','c:cu
rnom','c:Imax','c:loading');
}
}

if (sIACableType2 .not. NULL){


for (oLine=sIACableType2.First(); oLine; oLine = sIACableType2.Next()) {

oResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S:bus1');

oResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S:bus2','c:cu
rnom','c:Imax','c:loading');
}
}

if (sIACableType3 .not. NULL){


for (oLine=sIACableType3.First(); oLine; oLine = sIACableType3.Next()) {

oResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S:bus1');

oResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S:bus2','c:cu
rnom','c:Imax','c:loading');
}
}

if (sIACableType4 .not. NULL){


for (oLine=sIACableType4.First(); oLine; oLine = sIACableType4.Next()) {

oResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S:bus1');

oResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S:bus2','c:cu
rnom','c:Imax','c:loading');
}
}
oResults.AddVars(oXgrid,'m:P:bus1','m:Q:bus1','m:I:bus1','n:u1:bus1');

oGridResults.AddVars(this,'b:iSCaseNo');
oGridResults.AddVars(this,'b:dVsetpoint');
oGridResults.AddVars(this,'b:dPsetpoint');
oGridResults.AddVars(this,'b:dQsetpoint');

!Assigning Variables of Equipments to Results file


for (oSVC=sSVCs.First(); oSVC; oSVC = sSVCs.Next()) {
oSVCResults.AddVars(oSVC,'n:u1:bus1','m:I:bus1','m:P:bus1','m:Q:bus1');
}

for (oWTG=sWTGs.First(); oWTG; oWTG = sWTGs.Next()) {


oWTGResults.AddVars(oWTG,'n:u1:bus1','m:I:bus1','m:P:bus1','m:Q:bus1');
}

for (oTF2W=sTFWTGs.First(); oTF2W; oTF2W = sTFWTGs.Next()) {


oTFWTGResults.AddVars(oTF2W,'m:u1:bushv','m:I:bushv','m:P:bushv','m:Q:bushv','m:S:b
ushv');

oTFWTGResults.AddVars(oTF2W,'m:u1:buslv','m:I:buslv','m:P:buslv','m:Q:buslv','m:S:b
uslv','c:nntap','c:loading');
}

for (oTF2W=sTFGTs.First(); oTF2W; oTF2W = sTFGTs.Next()) {

oTFGTResults.AddVars(oTF2W,'m:u1:bushv','m:I:bushv','m:P:bushv','m:Q:bushv','m:S:bu
shv');

oTFGTResults.AddVars(oTF2W,'m:u1:buslv','m:I:buslv','m:P:buslv','m:Q:buslv','m:S:bu
slv','c:nntap','c:loading');
}

for (oTF3W=sTF3Ws.First(); oTF3W; oTF3W = sTF3Ws.Next()) {

oTF3WResults.AddVars(oTF3W,'m:u1:bushv','m:I:bushv','m:phii:bushv','m:P:bushv','m:Q
:bushv','m:S:bushv');

oTF3WResults.AddVars(oTF3W,'m:u1:busmv','m:I:busmv','m:phii:busmv','m:P:busmv','m:Q
:busmv','m:S:busmv');

oTF3WResults.AddVars(oTF3W,'m:u1:buslv','m:I:buslv','m:phii:buslv','m:P:buslv','m:Q
:buslv','m:S:buslv');
oTF3WResults.AddVars(oTF3W,'c:n3tap_m','c:loading');
}

for (oLine=sExportCables.First(); oLine; oLine = sExportCables.Next()) {

oExportCablesResults.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S
:bus1');

oExportCablesResults.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S
:bus2','c:curnom','c:Imax','c:loading');
}

if (sIACableType1 .not. NULL){


for (oLine=sIACableType1.First(); oLine; oLine = sIACableType1.Next()) {

oIACableType1Results.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S
:bus1');

oIACableType1Results.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S
:bus2','c:curnom','c:Imax','c:loading');
}
}

if (sIACableType2 .not. NULL){


for (oLine=sIACableType2.First(); oLine; oLine = sIACableType2.Next()) {

oIACableType2Results.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S
:bus1');

oIACableType2Results.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S
:bus2','c:curnom','c:Imax','c:loading');
}
}
if (sIACableType3 .not. NULL){
for (oLine=sIACableType3.First(); oLine; oLine = sIACableType3.Next()) {

oIACableType3Results.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S
:bus1');

oIACableType3Results.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S
:bus2','c:curnom','c:Imax','c:loading');
}
}

if (sIACableType4 .not. NULL){


for (oLine=sIACableType4.First(); oLine; oLine = sIACableType4.Next()) {

oIACableType4Results.AddVars(oLine,'n:u:bus1','m:I:bus1','m:P:bus1','m:Q:bus1','m:S
:bus1');

oIACableType4Results.AddVars(oLine,'n:u:bus2','m:I:bus2','m:P:bus2','m:Q:bus2','m:S
:bus2','c:curnom','c:Imax','c:loading');
}
}

oGridResults.AddVars(oXgrid,'m:P:bus1','m:Q:bus1','m:I:bus1','n:u1:bus1');

!Future: use a map oblect to save Xgrid and all sets for backup in case if
required to change it to its original values
!Create Plot pages and initialise their settings

iOnce = 0;
!For loop for Voltage Scenarios

printf('---------------------------------------------------------------------------
-------');
!Plot
oResults = sResults.Obj(k-1);
oGridResults = sGridResults.Obj(k-1);
oSVCResults = sSVCResults.Obj(k-1);
oWTGResults = sWTGResults.Obj(k-1);
oTFWTGResults = sTFWTGResults.Obj(k-1);
oTFGTResults = sTFGTResults.Obj(k-1);
oTF3WResults = sTF3WResults.Obj(k-1);
oExportCablesResults = sExportCablesResults.Obj(k-1);
oIACableType1Results = sIACableType1Results.Obj(k-1);
oIACableType2Results = sIACableType2Results.Obj(k-1);
oIACableType3Results = sIACableType3Results.Obj(k-1);
oIACableType4Results = sIACableType4Results.Obj(k-1);
!printf('%o',oResults);

if (PlotResultsChoice = 1){
InitialisePlots.Execute(iNoofPoints,GetRequiredEquipment);
PlotResults.Execute(1,1,oXgrid,GetRequiredEquipment,oGridResults);
}

oResults.InitialiseWriting();
oGridResults.InitialiseWriting();
oSVCResults.InitialiseWriting();
oWTGResults.InitialiseWriting();
oTFWTGResults.InitialiseWriting();
oTFGTResults.InitialiseWriting();
oTF3WResults.InitialiseWriting();
oExportCablesResults.InitialiseWriting();
oIACableType1Results.InitialiseWriting();
oIACableType2Results.InitialiseWriting();
oIACableType3Results.InitialiseWriting();
oIACableType4Results.InitialiseWriting();
ctr_k = 0;
iNoofTapableTransformers = 0;
!For loop for Power Set Points
for (m=1;m<=iNoofPoints;m=m+1){
dVoltageSetPoint = PQVSetPoints.Get(m,3);
dPSetPoint = PQVSetPoints.Get(m,1);
dQSetPoint = PQVSetPoints.Get(m,2);
printf('Running Step : %d of %d (Vset = (%4.3f pu), Pset =
(%4.3f pu), Qset = (%4.3f pu))',m,iNoofPoints, dVoltageSetPoint, dPSetPoint,
dQSetPoint);

if (iNoofPoints > 1){ !Change the Power set points only if any active
triggers are present otherwise run with the existing values
!Change the current value of WTG Triggers to change the power set point
oWTGTrigger = sWTGTriggers.First();
while(oWTGTrigger){
oWTGTrigger:ftrigger = PQVSetPoints.Get(m,1);
oWTGTrigger = sWTGTriggers.Next();
}

!Change the current value of DRPC Triggers to change the Reactive power
set point
oDRPCTrigger = sDRPCTriggers.First();
while(oDRPCTrigger){
oDRPCTrigger:ftrigger = PQVSetPoints.Get(m,2);
oDRPCTrigger = sDRPCTriggers.Next();
}
oXgrid:usetp = PQVSetPoints.Get(m,3);
!Assigning to the results variable
dPsetpoint = PQVSetPoints.Get(m,1);
dQsetpoint = PQVSetPoints.Get(m,2);
}

!Initialize Load flow object


ldf = GetCaseObject('ComLdf');
if(.not. ldf){
Error('No load flow calculation command (*.ComLdf) found!');
exit(); !Exit if Load Flow Calculation not found
}

!Enable/Disable tap changers


ctr_k=ctr_k+1;
if (ctr_k > 2){
ctr_k = 1;
}
if (ctr_k = 1){
ldf:iopt_at = 1;
}
if (ctr_k = 2){
ldf:iopt_at = 0;
z=1;
for (oTF2W=sTFGTs.First(); oTF2W; oTF2W = sTFGTs.Next()) {
oTF2W:e:nntap = TempTapSetting.Get(z, 1);
z=z+1;
}
for (oTF3W=sTF3Ws.First(); oTF3W; oTF3W = sTF3Ws.Next()) {
oTF3W:e:n3tap_m = TempTapSetting.Get(z, 1);
z=z+1;
}
}
!Run load flow
iLdfError = ldf.Execute();

if(iLdfError){
Error('Initial load flow calculation does not converge! Please set up
basic scenario correctly.');
exit();
}
printf('Running Power Set Point : %d of
%d',m,iNoofPoints);

if (ctr_k = 1){
z=1;
for (oTF2W=sTFGTs.First(); oTF2W; oTF2W = sTFGTs.Next()) {
Tap=oTF2W:c:nntap;
TempTapSetting.Set(z,1,Tap);
z=z+1;
}
for (oTF3W=sTF3Ws.First(); oTF3W; oTF3W = sTF3Ws.Next()) {
Tap=oTF3W:c:n3tap_m;
TempTapSetting.Set(z,1,Tap);
z=z+1;
}

oResults.WriteDraw();
oGridResults.WriteDraw();
oSVCResults.WriteDraw();
oWTGResults.WriteDraw();
oTFWTGResults.WriteDraw();
oTFGTResults.WriteDraw();
oTF3WResults.WriteDraw();
oExportCablesResults.WriteDraw();
oIACableType1Results.WriteDraw();
oIACableType2Results.WriteDraw();
oIACableType3Results.WriteDraw();
oIACableType4Results.WriteDraw();
!oResults.FinishWriting();

}!End of For loop of Power set points


oResults.FinishWriting();
oGridResults.FinishWriting();
oSVCResults.FinishWriting();
oWTGResults.FinishWriting();
oTFWTGResults.FinishWriting();
oTFGTResults.FinishWriting();
oTF3WResults.FinishWriting();
oExportCablesResults.FinishWriting();
oIACableType1Results.FinishWriting();
oIACableType2Results.FinishWriting();
oIACableType3Results.FinishWriting();
oIACableType4Results.FinishWriting();
!oResults.Release();

if(iSaveScenarios){
!Future: add code to save scenarios with "code created appropriate names" and
discard changes to the existing scenario
}
else {
if (NULL <> oActiveScenario) {!if the scenario is not existing then no need
to back up and save
oBackupScenario.Apply(0); !0 - just apply the data without further
confirmation requests
Delete(oBackupScenario);
oActiveScenario.Save();
}
}
}!End of For loop of Study Cases

printf('===========================================================================
=======');

!Re-activates the user-interface


EchoOn();

if (PlotResultsChoice = 1){
!Export all plots to folder
ExportPlots.Execute(strResultsFolderPath);
printf('All Pictures are closed and exported to the folder
%s',strResultsFolderPath);
}

!Export all results to folder


ExportResultstoCSVfiles.Execute(strResultsFolderPath);

!Stop redirecting the Output Window text to log file


!StopRedirect is an ComCl object inside this script
StopRedirect.Execute();

You might also like