You are on page 1of 3

object lFlow,Fsweep,NaduBus,stdCase,pccFsweep,oLine,AR1,AR2,MR1;

set AllObjs,resSet,setLines,lines,reactors;
int nR,nCR,nCX,harNum,colmn,matRow,matColmn,i,j,k,l,m,n,col,row,error,p,q,MR1tap;
double R, X,rValue,minRValue,Angle;
string path;
impedanceMat.Init(300,100,0.0);

ClearOutput();

stdCase=GetActiveStudyCase(); ! get study case


AllObjs = GetCalcRelevantObjects(); ! get all objects
setLines=GetCalcRelevantObjects('*.ElmLne', 1, 1); ! get lines/// NO Need
NaduBus = AllObjs.FirstFilt('PCC.ElmTerm'); ! get "PCC" bus object
NaduBus.ShowFullName(); ! dispaly selected bus name
!lFlow=GetFromStudyCase('ComLdf');
lines=SEL.AllLines();
MR1=AllObjs.FirstFilt('MannarReactor1.ElmShnt');
MR1.ShowFullName();
!----------------------------------------------------------------------------------
error = xlStart(); !// start MS Excel
if (error) {
Error('Unable to start MS Excel application');
exit();
}
xlNewWorkbook();
q=0; ! tap numbefr
l=1; ! row number in xlsx
!----------------------------------------------------------------------------------
for(p=0;p<6;p+=1){
if(MR1:outserv=1){ ! check reactor is out of service
!break;
printf('Reactor out of service');
printf('Case no base %d ',l);
}
if(MR1:outserv=0){

MR1:ncapa=q*5;
MR1tap=MR1:ncapa;
printf('Reactor tap position %d ',MR1tap);
printf('Case no tap %d ',l);
q=q+1;
}
Fsweep=GetCaseObject('ComFsweep'); ! run frequency scan
Fsweep.Execute();

resSet=stdCase.GetContents('Freq.Sweep.ElmRes'); ! frequency scan result obj


pccFsweep=resSet.First(); ! fsweep result objects
pccFsweep.Load(); ! load frequency sweep result object

nR=pccFsweep.GetNumberOfRows(); ! number of rows of res object


nCR = pccFsweep.FindColumn(NaduBus,'m:R'); ! column number of R in res obje
nCX = pccFsweep.FindColumn(NaduBus,'m:X'); ! column number of X in res objec

1
i=1; ! row number in result object
while(i<nR){
pccFsweep.GetValue(R,i,nCR);
pccFsweep.GetValue(X,i,nCX);
Angle=atan(X/R)*180/pi();
j=i*3;
impedanceMat.Set(l,j-2,R);
impedanceMat.Set(l,j-1,X);
impedanceMat.Set(l,j,Angle);
!printf('harmonic order %d Resistance R %f Reactance X %f',i+1,R,X);
xlSetValue(j-2,l,R);
xlSetValue(j-1,l,X);
xlSetValue(j,l,Angle);
i+=1;
}
pccFsweep.Release();
!----------------------------------------------------------------------------------
l=l+1; ! row number in xlsx
!printf('Case no start %d ',l);
for(oLine=lines.First();oLine;oLine=lines.Next()){
!oLine=setLines.First();
!for(m=0;m<3;m+=1){
!oLine=setLines.First();
!chkOutserv=oLine:outserv;
if(oLine:outserv=1){
k+=1;
}
else{
oLine.ShowFullName();
!lFlow.Execute();
oLine:outserv=1; ! line out of service
Fsweep=GetCaseObject('ComFsweep'); ! run frequency scan
Fsweep.Execute();
printf('Case no %d ',l);
resSet=stdCase.GetContents('Freq.Sweep.ElmRes'); ! frequency scan result obj
pccFsweep=resSet.First(); ! fsweep result objects
pccFsweep.Load(); ! load frequency sweep result object
oLine:outserv=0; ! out of service line put back to service
nR=pccFsweep.GetNumberOfRows(); ! number of rows of res object
nCR = pccFsweep.FindColumn(NaduBus,'m:R'); ! column number of R in res obje
nCX = pccFsweep.FindColumn(NaduBus,'m:X'); ! column number of X in res objec
i=1;
while(i<nR){
pccFsweep.GetValue(R,i,nCR);
pccFsweep.GetValue(X,i,nCX);
Angle=atan(X/R)*180/pi();
j=i*3;
impedanceMat.Set(l,j-2,R);
impedanceMat.Set(l,j-1,X);
impedanceMat.Set(l,j,Angle);
!printf('harmonic order %d Resistance R %f Reactance X %f',i+1,R,X);
xlSetValue(j-2,l,R);
xlSetValue(j-1,l,X);
xlSetValue(j,l,Angle);

2
i+=1;
}
pccFsweep.Release();

}
l+=1;

MR1:outserv=0; ! out of service reactor put back to service


}
}
MR1:outserv=1; ! out of service reactor out of service
printf('óut of ser lines %d ',k);
printf('Total cases %d ',l);

col=impedanceMat.GetNumberOfColumns();
row=impedanceMat.GetNumberOfRows();

printf('Matrix columns %d and rows %d ',col,row);

error = xlSaveWorkbookAs('E:\N EE\3.DIgSILENT Works\17. Nadukuda Wind New harmo


if (error) {
Error('Workbook could not be saved');
}
xlTerminate();

You might also like