コード例 #1
0
        private void AddNewMeasurementToBuffer(PhasorMeasurement phasorMeasurement)
        {
            m_rawMeasurementBuffer.Add(phasorMeasurement.DeepCopy());
            m_assertedMeasurementBuffer.Add(phasorMeasurement.DeepCopy());
            m_z[0, 0] = phasorMeasurement.PerUnitComplexPhasor;

            AssertRawMeasurement();
        }
コード例 #2
0
 private void InitializePhasors()
 {
     if (m_phasorType.Equals("Voltage"))
     {
         m_inputPhasor  = new PhasorMeasurement(m_magnitudeInputKey, m_angleInputKey, Measurements.PhasorType.VoltagePhasor, new VoltageLevel(1, m_baseKv));
         m_outputPhasor = new PhasorEstimate(m_magnitudeOutputKey, m_angleOutputKey, Measurements.PhasorType.VoltagePhasor, new VoltageLevel(1, m_baseKv));
     }
     else if (m_phasorType.Equals("Current"))
     {
         m_inputPhasor  = new PhasorMeasurement(m_magnitudeInputKey, m_angleInputKey, Measurements.PhasorType.CurrentPhasor, new VoltageLevel(1, m_baseKv));
         m_outputPhasor = new PhasorEstimate(m_magnitudeOutputKey, m_angleOutputKey, Measurements.PhasorType.CurrentPhasor, new VoltageLevel(1, m_baseKv));
     }
 }
コード例 #3
0
        private void GetMeasurement(PhasorMeasurement phasorMeasurement)
        {
            if (m_assertedMeasurementBuffer.Count < MAX_BUFFER_SIZE)
            {
                // If the measurement buffer is filling up, contine to add measurements.
                AddNewMeasurementToBuffer(phasorMeasurement);
            }
            else if (m_assertedMeasurementBuffer.Count == MAX_BUFFER_SIZE)
            {
                // If the measurement buffer is full, remove older (FIFO).
                RemoveOldestMeasurementFromBuffer();
                AddNewMeasurementToBuffer(phasorMeasurement);

                CheckAlgorithmStability();
            }
            else
            {
                throw new Exception("Measurement buffer size exceeded.");
            }
        }
コード例 #4
0
 private void ReplaceLatestMeasurement(PhasorMeasurement phasorMeasurement)
 {
     if (m_assertedMeasurementBuffer.Count < MAX_BUFFER_SIZE)
     {
         // If the measurement buffer is filling up, overwrite the measurement in the highest position
         m_assertedMeasurementBuffer[m_assertedMeasurementBuffer.Count - 1] = phasorMeasurement.DeepCopy();
         m_z[0, 0] = phasorMeasurement.PerUnitComplexPhasor;
         ReplaceLatestAssertment();
     }
     else if (m_assertedMeasurementBuffer.Count == MAX_BUFFER_SIZE)
     {
         // If the measurement buffer is full, overwrite the measurement in the highest position
         m_assertedMeasurementBuffer[BUFFER_TOP_POSITION] = phasorMeasurement.DeepCopy();
         m_z[0, 0] = phasorMeasurement.PerUnitComplexPhasor;
         ReplaceLatestAssertment();
     }
     else
     {
         throw new Exception("Measurement buffer size exceeded.");
     }
 }
コード例 #5
0
        /// <summary>
        /// The main function of the object. Accepts the latest phasor measurement and smooths it. The side effect is that the corresponding
        /// output of the <see cref="Smoother"/> will appear two frames later (smoothed of course).
        /// </summary>
        /// <param name="phasorMeasurement">The incoming <see cref="SynchrophasorAnalytics.Measurements.PhasorMeasurement"/> which holds the latest raw data.</param>
        public void Smooth(PhasorMeasurement phasorMeasurement)
        {
            // Time Update - Make Prediction
            ProjectSystemState();
            ProjectErrorCovariance();

            // Measurement Update - Get actual measurement
            UpdateKalmanGain();
            GetMeasurement(phasorMeasurement);

            // Compare
            CalculateObservationResidual();

            if (ToleranceIsViolated)
            {
                // Increment the number of sub optimal data points to reflect the number of times the tolerance was violated.
                m_numberOfSuboptimalDataPoints++;

                // If the magnitude of the observation residual is above a predefined threshold
                if (m_isStable)
                {
                    // and if the algorithm has stabilized, utilize the optimal predicted estimate to replace the bad measurement.
                    ReplaceLatestMeasurement(m_optimalPredictedEstimate);
                }
            }
            else
            {
                ResetStabilityCountWithStableParameters();
            }

            UpdateSystemState();
            UpdateErrorCovariance();

            if (TooMuchConsecutiveBadDataToContinue)
            {
                Reset();
            }
        }
        /// <summary>
        /// Computes the real time impedance of the shunt based on available current and voltage phasors.
        /// </summary>
        public void ComputeRealTimePositiveSequenceImpedance()
        {
            PhasorMeasurement V = ConnectedNode.Voltage.PositiveSequence.Measurement;
            PhasorMeasurement I = Current.PositiveSequence.Measurement;

            if (V.IncludeInEstimator && I.IncludeInEstimator)
            {
                double conductance = 0;
                double susceptance = 0;

                if (Current.MeasurementDirectionConvention == CurrentInjectionDirectionConvention.IntoTheShunt)
                {
                    // Shunt Susceptance
                    conductance = 2 * (V.PerUnitComplexPhasor / I.PerUnitComplexPhasor.Conjugate()).Real;
                    susceptance = 2 * (V.PerUnitComplexPhasor / I.PerUnitComplexPhasor.Conjugate()).Imaginary;
                }
                else if (Current.MeasurementDirectionConvention == CurrentInjectionDirectionConvention.OutOfTheShunt)
                {
                    // Shunt Susceptance
                    conductance = 2 * (V.PerUnitComplexPhasor / (-I.PerUnitComplexPhasor.Conjugate())).Real;
                    susceptance = 2 * (V.PerUnitComplexPhasor / (-I.PerUnitComplexPhasor.Conjugate())).Imaginary;
                }

                // Only set the values for positive sequence equivalence
                Impedance impedance = new Impedance()
                {
                    G1 = conductance,
                    G3 = conductance,
                    G6 = conductance,
                    B1 = susceptance,
                    B3 = susceptance,
                    B6 = susceptance
                };

                m_realTimeCalculatedImpedance = impedance;
            }
        }
コード例 #7
0
 private void InitializeObservationResidual()
 {
     m_observationResidual = new PhasorMeasurement(m_output.MagnitudeKey, m_output.AngleKey, m_output.Type, m_output.BaseKV.DeepCopy());
 }
コード例 #8
0
 private void InitializeOptimalSmoothedEstimate()
 {
     m_optimalSmoothedEstimate = new PhasorMeasurement(m_output.MagnitudeKey, m_output.AngleKey, m_output.Type, m_output.BaseKV.DeepCopy());
 }