private void BuildMatrices(Network network)
        {
            // Create the current measurement bus incidence matrix
            ComplexMatrix A = (new CurrentFlowMeasurementBusIncidenceMatrix(network)).Matrix;

            // Create the series admittance matrix
            ComplexMatrix Y = (new SeriesAdmittanceMatrix(network)).Matrix;

            // Create the shunt susceptance matrix
            ComplexMatrix Ys = (new LineShuntSusceptanceMatrix(network)).Matrix;

            // Compute the lower partition of the system matrix
            ComplexMatrix K = Y * A + Ys;

            List <int> rowsToBeRemoved         = RowsToRemove(network);
            int        numberOfRowsToBeRemoved = rowsToBeRemoved.Count();

            for (int i = 0; i < numberOfRowsToBeRemoved; i++)
            {
                int rowToRemove = rowsToBeRemoved.Max();
                K = MatrixCalculationExtensions.RemoveRow(K, rowToRemove);
                rowsToBeRemoved.Remove(rowToRemove);
            }

            List <int> columnsToBeRemoved         = ColumnsToRemove(network);
            int        numberOfColumnsToBeRemoved = columnsToBeRemoved.Count();

            for (int i = 0; i < numberOfColumnsToBeRemoved; i++)
            {
                int columnToRemove = columnsToBeRemoved.Max();
                K = MatrixCalculationExtensions.RemoveColumn(K, columnToRemove);
                columnsToBeRemoved.Remove(columnToRemove);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Builds the <see cref="LinearStateEstimator.Matrices.VoltageMeasurementBusIncidenceMatrix"/>, the
        /// <see cref="LinearStateEstimator.Matrices.CovarianceMatrix"/> and concatenates the <see cref="LinearStateEstimator.Matrices.SystemMatrix.LowerPartitionOfMatrix"/>
        /// with the <see cref="LinearStateEstimator.Matrices.VoltageMeasurementBusIncidenceMatrix"/>.
        /// </summary>
        /// <param name="network">The virtualized <see cref="Network"/> model.</param>
        private void BuildSystemMatrix(Network network)
        {
            // Build the Voltage Measurement-Bus Incidence Matrix
            m_II = new VoltageMeasurementBusIncidenceMatrix(network);

            // Build the Measurement Covariance Matrix
            m_R = new CovarianceMatrix(network);

            if (m_II.IsValid && m_seriesPartitionIsValid)
            {
                // Build the SystemMatrix
                DenseMatrix upperSystemMatrix = MatrixCalculationExtensions.VerticallyConcatenate(m_II.Matrix, m_K);
                // Build the SystemMatrix
                if (m_Ysh.IsValid)
                {
                    m_B = MatrixCalculationExtensions.VerticallyConcatenate(upperSystemMatrix, m_Ysh.Matrix);
                }
                else
                {
                    m_B = upperSystemMatrix;
                }
                m_systemMatrixIsValid = true;
            }
            else if (m_II.IsValid)
            {
                if (m_Ysh.IsValid)
                {
                    DenseMatrix upperSystemMatrix = MatrixCalculationExtensions.VerticallyConcatenate(m_II.Matrix, m_Ysh.Matrix);
                    m_B = upperSystemMatrix;
                }
                else
                {
                    m_B = m_II.Matrix;
                }
                m_systemMatrixIsValid = true;
            }
            else if (m_Ysh.IsValid)
            {
                m_B = m_Ysh.Matrix;
                m_systemMatrixIsValid = true;
            }
            else
            {
                m_systemMatrixIsValid = false;
            }
        }