示例#1
0
        public Vector <Complex32> makePQBus(SystemArrays array)
        {
            Vector <Complex32> thisPQbus = Vector <Complex32> .Build.Dense(array.numBuses);

            for (int i = 0; i < array.numBuses; i++)
            {
                float real      = 0.0F;
                float imaginary = 0.0F;
                if (array.bus[i].BusType == 1) //PQBus
                {
                    //NOTE : THIS IS ONLY INJECTED LOAD...wala pang drawn load
                    real      = array.load[i].MW;
                    imaginary = array.load[i].MVAR;
                    Complex32 PQ = new Complex32(real, imaginary);
                    thisPQbus[i] = PQ;
                }
                else
                {
                    real      = array.load[i].MW;
                    imaginary = 0.0F;
                    Complex32 PQ = new Complex32(real, imaginary);
                    thisPQbus[i] = PQ;
                }
            }
            return(thisPQbus);
        }
示例#2
0
        public Vector <Complex32> makeVBus(SystemArrays array)
        {
            //BUS TYPES
            //TYPE 1 = PQ Bus (load bus)
            //Type 2 = PV Bus (generator bus)
            //Type 3 = Slack Bus
            //NOTE: IF PQ Bus, provide default voltage which is 1.0+j0; ELSE provide the given Voltage + j0;

            Vector <Complex32> thisVbus = Vector <Complex32> .Build.Dense(array.numBuses);

            for (int i = 0; i < array.numBuses; i++)
            {
                Complex32 defaultV = new Complex32(1.0F, 0.0F);
                //if PQBus
                if (array.bus[i].BusType == 1)
                {
                    thisVbus[i] = defaultV;
                }
                else
                //PV bus
                {
                    if (array.bus[i].BusType == 2)
                    {
                        //if PV bus
                        //find the generator number that corresponds to the bus number
                        int       b      = getBusNumberOfGenerator(array, array.bus[i].BusNo);
                        float     real   = array.gen[b].VS;
                        Complex32 givenV = new Complex32(real, 0.0F);
                        thisVbus[i] = givenV;
                    }
                }
            }
            return(thisVbus);
        }
示例#3
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            sysArrayMain         = initializeTestData();
            sysArrayMain.MVABase = 230;

            Solver             solver = new Solver();
            Vector <Complex32> Vbus   = solver.GaussSolver(sysArrayMain);

            txtResult.Text = Vbus.ToString();
        }
示例#4
0
        private int GetLineIndex(int fromBus, int toBus, SystemArrays array)
        {
            int retVal = 0;

            for (int i = 0; i < array.numBuses; i++)
            {
                if (array.line[i].fromBus == fromBus && array.line[i].toBus == toBus)
                {
                    retVal = i;
                    i      = array.numBuses;
                }
            }
            return(retVal);
        }
示例#5
0
        private Complex32 TotalAdmittance(int bus, SystemArrays array)
        {
            Complex32 retVal = new Complex32(0.0F, 0.0F);

            for (int i = 0; i < array.numBuses; i++)
            {
                if (array.line[i].fromBus == bus || array.line[i].toBus == bus)
                {
                    Complex32 temp = new Complex32(array.line[i].R, array.line[i].X);
                    retVal += (1 / temp);
                }
            }
            return(retVal);
        }
示例#6
0
        private int getBusNumberOfGenerator(SystemArrays array, int busNo)
        {
            int retVal = 0;

            for (int i = 0; i < array.numGens; i++)
            {
                if (array.gen[i].BusNo == busNo)
                {
                    retVal = i;
                    i      = array.numGens;
                }
            }
            return(retVal);
        }
示例#7
0
 private SystemArrays InitializeYBus(SystemArrays array)
 {
     for (int i = 0; i < array.numBuses; i++)
     {
         for (int j = 0; j < array.numBuses; j++)
         {
             if (i == j)
             {
                 //diagonal matrix, solve for total admittance
                 array.Ybus[i, j] = TotalAdmittance(i, array);
             }
             else
             {
                 //off diagonal
                 int       index = GetLineIndex(i, j, array);
                 Complex32 y     = new Complex32(array.line[index].R, array.line[index].X);
                 array.Ybus[i, j] = y;
             }
         }
     }
     return(array);
 }
示例#8
0
        private SystemArrays parseCSVcontents(string fileContents)
        {
            //local system array var
            SystemArrays sysArray = new SystemArrays();

            //string to parse
            string[] elements = fileContents.Split('@');

            //counter to mark each category: 1=Bus Data, 2=Load Data, 3=Shunt Data, 4=Generator Data, 5=Line Data, 6=Transformer DAta
            int ctr = 0;

            foreach (string element in elements)
            {
                ctr++;
                #region Parse Bus Data
                if (ctr == 1)
                {
                    //first element is Bus Data

                    //split to get rows of buses
                    string[] busRows = element.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                    //initialize system array as to the number of buses
                    sysArray.numBuses = busRows.Length;
                    sysArray.bus      = new Bus[busRows.Length - 1];


                    //parse array of bus rows
                    int i = -1;
                    foreach (string busRow in busRows)
                    {
                        if (busRow != "")
                        {
                            //initialize index marker
                            i++;

                            //get busData values from busRow
                            string[] busData = busRow.Split(',');

                            //parse each busData Value and save to system Array
                            //by following the order: I, 'NAME', BASKV, IDE, AREA, ZONE, OWNER, VR, VA

                            //firs element is BusNo
                            sysArray.bus[i].BusNo = Convert.ToInt32(busData[0]);

                            //2nd element is BusName
                            sysArray.bus[i].Name = busData[1];

                            //3rd element is KVA
                            sysArray.bus[i].BusKV = Convert.ToInt32(busData[2]);

                            //4th element is IDE -- busType?
                            sysArray.bus[i].BusType = Convert.ToInt32(busData[3]);

                            //skip elements 5th and 6th - irrelevant at this time

                            //7th element is VR
                            //sysArray.bus[i]. = Convert.ToSingle(busData[6]);

                            //8th element is VA
                            //sysArray.bus[i]. = Convert.ToSingle(busData[7]);
                        }
                    }
                }
                #endregion

                #region Parse Load Data
                else if (ctr == 2)
                {
                    //second element is Load Data

                    //split to get rows of Loads
                    string[] loadRows = element.Split(new string[] { "\\n" }, StringSplitOptions.None);

                    //initialize system array as to the number of buses
                    sysArray.numLoads = loadRows.Length;
                    sysArray.load     = new Load[loadRows.Length - 1];
                    //parse array of load rows
                    int i = -1;
                    foreach (string loadRow in loadRows)
                    {
                        //initialize index marker
                        i++;

                        //get loadData values from loadRow
                        string[] loadData = loadRow.Split(',');

                        //parse each loadData Value and save to system Array
                        //by following the order: I, ID, STATUS, AREA, ZONE, PL, QL

                        //firs element is load BusNo
                        sysArray.load[i].BusNo = Convert.ToInt32(loadData[0]);

                        //2nd element is ID
                        sysArray.load[i].ID = Convert.ToInt32(loadData[1]);

                        //3rd element is STATUS
                        sysArray.load[i].Status = Convert.ToInt32(loadData[2]);

                        //4th element is Area
                        sysArray.load[i].Area = Convert.ToInt32(loadData[3]);

                        //5th element is Zone
                        sysArray.load[i].Zone = Convert.ToInt32(loadData[4]);

                        //6th element is PL
                        sysArray.load[i].YL = Convert.ToInt32(loadData[5]);

                        //7th element is QL
                        sysArray.load[i].ZL = Convert.ToInt32(loadData[6]);
                    }
                }
                #endregion

                #region Parse Shunt Data
                else if (ctr == 3)
                {
                    //3rd element is Shunt Data
                    //do nothing
                }
                #endregion

                #region Parse Generator Data
                else if (ctr == 4)
                {
                    //first element is Generator Data

                    //split to get rows of generators
                    string[] genRows = element.Split(new string[] { "\\n" }, StringSplitOptions.None);

                    //initialize system array as to the number of generators
                    sysArray.numGens = genRows.Length;
                    sysArray.gen     = new Generator[genRows.Length - 1];
                    //parse array of gen rows
                    int i = -1;
                    foreach (string genRow in genRows)
                    {
                        //initialize index marker
                        i++;

                        //get genData values from genRow
                        string[] genData = genRow.Split(',');

                        //parse each genData Value and save to system Array
                        //by following the order: I, ID, PG, QG, QT, QB, VS, IREG, MBASE, ZR, ZX, RT, XT, GTAP, STAT

                        //firs element is BusNo
                        sysArray.gen[i].BusNo = Convert.ToInt32(genData[0]);

                        //2nd element is ID
                        sysArray.gen[i].ID = Convert.ToInt32(genData[1]);

                        //3rd element is PG
                        sysArray.gen[i].PG = Convert.ToInt32(genData[2]);

                        //4th element is QG
                        sysArray.gen[i].QG = Convert.ToInt32(genData[3]);

                        //5th element is QT
                        sysArray.gen[i].QT = Convert.ToInt32(genData[4]);

                        //6th element is QB
                        sysArray.gen[i].QB = Convert.ToInt32(genData[5]);

                        //7th element is VS
                        sysArray.gen[i].VS = Convert.ToInt32(genData[6]);

                        //8th element is IREG
                        sysArray.gen[i].IREG = Convert.ToInt32(genData[7]);

                        //9th element is MBASE
                        sysArray.gen[i].MBASE = Convert.ToInt32(genData[8]);

                        //10th element is ZR
                        sysArray.gen[i].ZR = Convert.ToInt32(genData[9]);

                        //11th element is ZX
                        sysArray.gen[i].ZX = Convert.ToInt32(genData[10]);

                        //12th element is RT
                        sysArray.gen[i].RT = Convert.ToInt32(genData[11]);

                        //13th element is XT
                        sysArray.gen[i].XT = Convert.ToInt32(genData[12]);

                        //14th element is GTAP
                        sysArray.gen[i].GTAP = Convert.ToInt32(genData[13]);

                        //15th element is STAT
                        sysArray.gen[i].Status = Convert.ToInt32(genData[14]);
                    }
                }
                #endregion

                #region Parse Line Data
                else if (ctr == 5)
                {
                    //FIFTH element is Line Data

                    //split to get rows of lines
                    string[] lineRows = element.Split(new string[] { "\\n" }, StringSplitOptions.None);

                    //initialize system array as to the number of lines
                    sysArray.numLines = lineRows.Length;
                    sysArray.line     = new Line[lineRows.Length - 1];

                    //parse array of bus lines
                    int i = -1;
                    foreach (string lineRow in lineRows)
                    {
                        //initialize index marker
                        i++;

                        //get lineData values from lineRow
                        string[] lineData = lineRow.Split(',');

                        //parse each lineData Value and save to system Array
                        //by following the order: I, J, CKT, STATUS, R, X, B2

                        //firs element is I
                        sysArray.line[i].fromBus = Convert.ToInt32(lineData[0]);

                        //2nd element is J
                        sysArray.line[i].toBus = Convert.ToInt32(lineData[1]);

                        //3rd element is CKT
                        sysArray.line[i].ckt = Convert.ToInt32(lineData[2]);

                        //4th element is Status
                        sysArray.line[i].status = Convert.ToInt32(lineData[3]);

                        //5th element is R
                        sysArray.line[i].R = Convert.ToInt32(lineData[4]);

                        //6th element is X
                        sysArray.line[i].X = Convert.ToInt32(lineData[5]);

                        //7th element is B2
                        sysArray.line[i].B2 = Convert.ToInt32(lineData[6]);
                    }
                }
                #endregion

                #region Parse Transformer Data
                else if (ctr == 6)
                {
                    //SIXTH element is Transformer Data

                    //split to get rows of transformers
                    string[] transRows = element.Split(new string[] { "\\n" }, StringSplitOptions.None);

                    //initialize system array as to the number of transformers
                    sysArray.numTrans = transRows.Length;

                    //parse array of transformer rows
                    int i = -1;
                    foreach (string transRow in transRows)
                    {
                        //initialize index marker
                        i++;

                        //get transData values from transRow
                        string[] transData = transRow.Split(',');
                        sysArray.trans = new Transformer[transRows.Length - 1];

                        //parse each transData Value and save to system Array
                        //by following the order: fromBus, toBus, CKT, STATUS, MVA, Z

                        //first element is fromBus
                        sysArray.trans[i].fromBus = Convert.ToInt32(transData[0]);

                        //2nd element is to=Bus
                        sysArray.trans[i].toBus = transData[1];

                        //3rd element is CKT
                        sysArray.trans[i].ckt = transData[2];

                        //4th element is status
                        sysArray.trans[i].Status = transData[3];

                        //5th element is MVA
                        sysArray.trans[i].MVA = Convert.ToDouble(transData[4]);

                        //6th element is Z
                        sysArray.trans[i].Z = Convert.ToInt32(transData[5]);
                    }
                }
            }
            #endregion

            return(sysArray);
        }
示例#9
0
        private SystemArrays initializeTestData()
        {
            SystemArrays sArray = new SystemArrays();

            #region INITIALIZE BUS
            //set number of buses
            sArray.numBuses = 4;

            //sArray.Ybus
            Matrix <Complex32> Ybus = Matrix <Complex32> .Build.Dense(sArray.numBuses, sArray.numBuses);

            sArray.Ybus = Ybus;

            sArray.bus = new Bus[sArray.numBuses];
            for (int i = 0; i <= (sArray.numBuses - 1); i++)
            {
                sArray.bus[i] = new Bus();
            }


            //set bus data array for each bus element

            //bus 1 :   I, 'NAME', BASKV, IDE, AREA, ZONE, OWNER, VR, VA
            sArray.bus[0].BusNo   = 1;
            sArray.bus[0].Name    = "Bus" + sArray.bus[0].BusNo;
            sArray.bus[0].BusKV   = 230;
            sArray.bus[0].BusType = 3;

            //bus 2 :   I, 'NAME', BASKV, IDE, AREA, ZONE, OWNER, VR, VA
            sArray.bus[1].BusNo   = 2;
            sArray.bus[1].Name    = "Bus" + sArray.bus[1].BusNo;
            sArray.bus[1].BusKV   = 230;
            sArray.bus[1].BusType = 1;

            //bus 3 :   I, 'NAME', BASKV, IDE, AREA, ZONE, OWNER, VR, VA
            sArray.bus[2].BusNo   = 3;
            sArray.bus[2].Name    = "Bus" + sArray.bus[2].BusNo;
            sArray.bus[2].BusKV   = 230;
            sArray.bus[2].BusType = 1;

            //bus 4 :   I, 'NAME', BASKV, IDE, AREA, ZONE, OWNER, VR, VA
            sArray.bus[3].BusNo   = 4;
            sArray.bus[3].Name    = "Bus" + sArray.bus[3].BusNo;
            sArray.bus[3].BusKV   = 230;
            sArray.bus[3].BusType = 2;
            #endregion

            #region INITIALIZE LOAD
            //set number of loads
            sArray.numLoads = 4;
            sArray.load     = new Load[sArray.numLoads];
            for (int i = 0; i <= sArray.numLoads - 1; i++)
            {
                sArray.load[i] = new Load();
            }

            //set load data array for each load element
            //Load 1 : I, ID, STATUS, AREA, ZONE, PL, QL
            sArray.load[0].BusNo  = 1;
            sArray.load[0].ID     = 1;
            sArray.load[0].Status = 1;
            sArray.load[0].Area   = 0;
            sArray.load[0].Zone   = 0;
            sArray.load[0].MW     = 50.0F;
            sArray.load[0].MVAR   = 30.99F;

            //Load 2 : I, ID, STATUS, AREA, ZONE, PL, QL
            sArray.load[1].BusNo  = 2;
            sArray.load[1].ID     = 1;
            sArray.load[1].Status = 1;
            sArray.load[1].Area   = 0;
            sArray.load[1].Zone   = 0;
            sArray.load[1].MW     = 170.0F;
            sArray.load[1].MVAR   = 105.35F;

            //Load 3 : I, ID, STATUS, AREA, ZONE, PL, QL
            sArray.load[2].BusNo  = 3;
            sArray.load[2].ID     = 1;
            sArray.load[2].Status = 1;
            sArray.load[2].Area   = 0;
            sArray.load[2].Zone   = 0;
            sArray.load[2].MW     = 200.0F;
            sArray.load[2].MVAR   = 123.94F;

            //Load 3 : I, ID, STATUS, AREA, ZONE, PL, QL
            sArray.load[3].BusNo  = 4;
            sArray.load[3].ID     = 1;
            sArray.load[3].Status = 1;
            sArray.load[3].Area   = 0;
            sArray.load[3].Zone   = 0;
            sArray.load[3].MW     = 80.0F;
            sArray.load[3].MVAR   = 49.58F;
            #endregion

            #region INITIALIZE SHUNT
            //set number of SHUNT
            //do nothing
            #endregion

            #region INITIALIZE GENERATOR
            sArray.numGens = 2;
            sArray.gen     = new Generator[sArray.numGens];
            for (int i = 0; i <= sArray.numGens - 1; i++)
            {
                sArray.gen[i] = new Generator();
            }

            //set GENERATOR data array for each generator element
            //Generator 1 : I, ID, PG, QG, QT, QB, VS, IREG, MBASE, ZR, ZX, RT, XT, GTAP, STAT
            sArray.gen[0].BusNo  = 1;
            sArray.gen[0].ID     = 1;
            sArray.gen[0].PG     = 0.0F;
            sArray.gen[0].QG     = 0.0F;
            sArray.gen[0].QT     = 0.0F;
            sArray.gen[0].QB     = 0.0F;
            sArray.gen[0].VS     = 1.0F;
            sArray.gen[0].IREG   = 0;
            sArray.gen[0].MBASE  = 100;
            sArray.gen[0].ZR     = 0.0F;
            sArray.gen[0].ZX     = 0.0F;
            sArray.gen[0].RT     = 0.0F;
            sArray.gen[0].XT     = 0.0F;
            sArray.gen[0].GTAP   = 0.0F;
            sArray.gen[0].Status = 0;

            //Generator 2 : I, ID, PG, QG, QT, QB, VS, IREG, MBASE, ZR, ZX, RT, XT, GTAP, STAT
            sArray.gen[1].BusNo  = 1;
            sArray.gen[1].ID     = 4;
            sArray.gen[1].PG     = 318.0F;
            sArray.gen[1].QG     = 0.0F;
            sArray.gen[1].QT     = 0.0F;
            sArray.gen[1].QB     = 0.0F;
            sArray.gen[1].VS     = 1.02F;
            sArray.gen[1].IREG   = 0;
            sArray.gen[1].MBASE  = 100;
            sArray.gen[1].ZR     = 0.0F;
            sArray.gen[1].ZX     = 0.0F;
            sArray.gen[1].RT     = 0.0F;
            sArray.gen[1].XT     = 0.0F;
            sArray.gen[1].GTAP   = 0.0F;
            sArray.gen[1].Status = 0;
            #endregion

            #region INITIALIZE LINE
            sArray.numLines = 4;
            sArray.line     = new Line[sArray.numLines];
            for (int i = 0; i <= sArray.numLines - 1; i++)
            {
                sArray.line[i] = new Line();
            }

            //set LINE data array for each line element
            //Line 1 : I, J, CKT, STATUS, R, X, B2
            sArray.line[0].fromBus = 1;
            sArray.line[0].toBus   = 2;
            sArray.line[0].ckt     = 1;
            sArray.line[0].status  = 1;
            sArray.line[0].R       = 0.01008F;
            sArray.line[0].X       = 0.05040F;
            sArray.line[0].B2      = 0.05125F;

            //Line 2 : I, J, CKT, STATUS, R, X, B2
            sArray.line[1].fromBus = 1;
            sArray.line[1].toBus   = 3;
            sArray.line[1].ckt     = 1;
            sArray.line[1].status  = 1;
            sArray.line[1].R       = 0.00744F;
            sArray.line[1].X       = 0.03720F;
            sArray.line[1].B2      = 0.03875F;


            //Line 3 : I, J, CKT, STATUS, R, X, B2
            sArray.line[2].fromBus = 2;
            sArray.line[2].toBus   = 4;
            sArray.line[2].ckt     = 1;
            sArray.line[2].status  = 1;
            sArray.line[2].R       = 0.00744F;
            sArray.line[2].X       = 0.03720F;
            sArray.line[2].B2      = 0.03875F;

            //Line 4 : I, J, CKT, STATUS, R, X, B2
            sArray.line[3].fromBus = 3;
            sArray.line[3].toBus   = 4;
            sArray.line[3].ckt     = 1;
            sArray.line[3].status  = 1;
            sArray.line[3].R       = 0.01272F;
            sArray.line[3].X       = 0.06360F;
            sArray.line[3].B2      = 0.06375F;
            #endregion

            return(sArray);
        }
示例#10
0
        public Vector <Complex32> GaussSolver(SystemArrays array)
        {
            #region "Initialize Vectors & Complex Numbers"
            Vector <Complex32> Vbus = Vector <Complex32> .Build.Dense(array.numBuses);

            Vector <Complex32> PQbus = Vector <Complex32> .Build.Dense(array.numBuses);

            double tolerance = 1.0e-6;

            Complex32 accel    = new Complex32(1.6f, 0.0f); //remove
            Complex32 sumIRem  = new Complex32(0.0f, 0.0f);
            Complex32 sumPVRem = new Complex32(0.0f, 0.0f);

            #endregion
            //assume that this is MakeYBus
            #region Call the method to Generate Vbus complex vector flat start nd fixed voltages
            Vbus = makeVBus(array);
            #endregion

            #region Calculate PQbus which defines net apparent scheduled power into each bus
            PQbus = makePQBus(array);
            #endregion

            #region "Iterate & Calculate Vbus at all buses"

            #region Initialize arrays & variables
            //make new array of PV bus fixed setpoint magnitudes
            Complex32[] VbusSet = new Complex32[array.numBuses];

            //generate a vector for the previous oteratopm calculated values of Vbus
            //to subtract from latest calculated, and compare to tolerance
            Vector <Complex32> VbusOld = Vector <Complex32> .Build.Dense(array.numBuses);

            Vector <Complex32> VbusDiff = Vector <Complex32> .Build.Dense(array.numBuses);

            //initialize Ybus
            array = InitializeYBus(array);

            //initialize the 'previous' Vbus values to the initial flat start values
            Vbus.CopyTo(VbusOld);

            //Define the maximum, absolute magnitude of bus voltage difference of all buses
            //since previous iteration
            double diff = 1.0;
            #endregion

            while (diff > tolerance)
            {
                //SOLVE V for each bus once
                //parallel for(0,array.numBuses, 1=>
                for (int i = 0; i < array.numBuses; i++)
                {
                    #region Solve for PQ (load) buses (Type 1)
                    if (array.bus[i].BusType == 1)
                    {
                        //calculate all remote  bus current components
                        for (int j = 0; j < array.numBuses; j++)
                        {
                            if (j == 1)
                            {
                                continue;
                            }
                            //sum of components at remote bus numbers greater than i
                            sumIRem += array.Ybus[i, j] * Vbus[j];
                        }
                        //calculate local bus current components
                        //Vbus[i] = (i/array.Ybus[i,i]) * ((PQbus[i].Conjugate() / Vbus[i].Conjugate()) - sumIRem);
                        Vbus[i] = (i / array.Ybus[i, i]) * ((PQbus[i] / Vbus[i].Conjugate()) - sumIRem);

                        //calculate acceleration and update Vbus with accelerated values
                        VbusDiff[i] = Vbus[i] - VbusOld[i];
                        Vbus[i]     = VbusOld[i] + VbusDiff[i] * accel;
                    }
                    sumIRem  = 0;
                    sumPVRem = 0;
                    #endregion

                    #region Solve for PV (generator) buses (Type 2)
                    if (array.bus[i].BusType == 2)
                    {
                        VbusSet[i] = Vbus[i].Magnitude;

                        //calculate all remote bus current components
                        for (int j = 0; j < array.numBuses; j++)
                        {
                            sumPVRem += array.Ybus[i, j] * Vbus[j];
                        }

                        //calculate first VARs at the local bus
                        float Qnew = -(Vbus[i].Conjugate() * sumPVRem).Imaginary;

                        sumPVRem = 0;
                        //calculate local voltage usigng new value of Q
                        PQbus[i] = new Complex32(PQbus[i].Real, Qnew);

                        for (int j = 0; j < array.numBuses; j++)
                        {
                            if (j == i)
                            {
                                continue;
                            }
                            sumPVRem += array.Ybus[i, j] * Vbus[j];
                        }

                        Vbus[i] = (1 / array.Ybus[i, i]) * ((PQbus[i].Conjugate()) - sumPVRem);
                        //force Vbus[i] magnitude to voltage setpoint, and angle to newly calculated Vbus[i] voltage
                        Vbus[i] = VbusSet[i] * Vbus[i] / Vbus[i].Magnitude;
                    }
                    #endregion


                    //goto next bus
                    sumIRem  = 0;
                    sumPVRem = 0;
                }

                //ALL BUS voltages have been calculated for this iteration
                //start next iteration (k)
                iterations++;

                //give the magnitude of greatest value in VbusDiff vector
                diff = VbusDiff.AbsoluteMaximum().Real;

                //note: you cannot set one vector equal to the other or they will be considered the same
                //You must instead copy the values from one to the other
                //copy the latest Vbus Vector elements to VbusOld vector
                Vbus.CopyTo(VbusOld);
            }
            #endregion

            return(Vbus);
        }