Beispiel #1
0
        /// <summary>
        /// Performs step of integration
        /// </summary>
        /// <param name="t0">Step start</param>
        /// <param name="t1">Step finish</param>
        public override void Step(double t0, double t1)
        {
            isBusy = true;
            if (Dim == 0)
            {
                return;
            }
            double dt = t1 - t0;
            int    i  = 0;
            double t  = t0;

            foreach (IMeasurements m in equations)
            {
                for (int j = 0; j < m.Count; j++)
                {
                    w[i] = (double)m[j].Parameter();
                    ++i;
                }
            }
            StaticExtensionDataPerformerPortable.Time = t;
            StaticExtensionDataPerformerPortable.Desktop.ResetUpdatedMeasurements();
            UpdateMeasurements();
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                s.CalculateDerivations();
                for (int j = 0; j < m.Count; j++)
                {
                    IDerivation der = m[j] as IDerivation;
                    w[i] = w[i] + Measurement.GetDouble(der.Derivation) * dt;
                    ++i;
                }
                s.CopyVariablesToSolver(i - m.Count, w);
            }
            isBusy = false;
        }
Beispiel #2
0
        /// <summary>
        /// Performs step of integration
        /// </summary>
        /// <param name="t0">Step start</param>
        /// <param name="t1">Step finish</param>
        public override void Step(double t0, double t1)
        {
            isBusy = true;
            if (Dim == 0)
            {
                return;
            }
            double dt = t1 - t0;
            int    i  = 0;

            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                m.UpdateMeasurements(true);
                int n = s.GetVariablesCount();
                for (int j = 0; j < n; j++)
                {
                    w[i] = (double)m[j].Parameter();
                    f[i] = w[i];
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), w);
            }
            double t = t0;

            timeProvider.Time = t;
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                s.CalculateDerivations();
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    IDerivation der = m[j] as IDerivation;
                    z[i]    = Measurement.GetDouble(der.Derivation);
                    k[0, i] = z[i] * dt;
                    w[i]    = f[i] + 0.5 * k[0, i];
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), w);
            }
            t = t0 + 0.5 * dt;
            timeProvider.Time = t;
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                s.CalculateDerivations();
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    IDerivation der = m[j] as IDerivation;
                    z[i]    = Measurement.GetDouble(der.Derivation);
                    k[1, i] = z[i] * dt;
                    w[i]    = f[i] + 0.5 * k[1, i];
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), w);
            }
            t = t0 + 0.5 * dt;
            timeProvider.Time = t;
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                s.CalculateDerivations();
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    IDerivation der = m[j] as IDerivation;
                    z[i]    = Measurement.GetDouble(der.Derivation);
                    k[2, i] = z[i] * dt;
                    w[i]    = f[i] + k[2, i];
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), w);
            }
            t = t0 + dt;
            timeProvider.Time = t;
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                s.CalculateDerivations();
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    IDerivation der = m[j] as IDerivation;
                    z[i]    = Measurement.GetDouble(der.Derivation);
                    k[3, i] = z[i] * dt;
                    ++i;
                }
            }
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    f[i] += (k[0, i] + 2 * k[1, i] + 2 * k[2, i] + k[3, i]) / 6;
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), f);
            }
            i = 0;
            foreach (IMeasurements m in equations)
            {
                IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                for (int j = 0; j < s.GetVariablesCount(); j++)
                {
                    IMeasurement measure = m[j];
                    IDerivation  d       = m[j] as IDerivation;
                    IMeasurement der     = d.Derivation;
                    if (!(der is IDistribution))
                    {
                        ++i;
                        continue;
                    }
                    IDistribution distr = der as IDistribution;
                    f[i] += distr.Integral;
                    distr.Reset();
                    ++i;
                }
                s.CopyVariablesToSolver(i - s.GetVariablesCount(), f);
            }
            isBusy = false;
        }
Beispiel #3
0
        /// <summary>
        /// Performs step of integration
        /// </summary>
        /// <param name="t0">Step start</param>
        /// <param name="t1">Step finish</param>
        public override void Step(double t0, double t1)
        {
            isBusy     = true;
            paramCount = 0;
            if (stepCount < order)
            {
                runge.Step(t0, t1);
                foreach (IMeasurements m in equations)
                {
                    runge.Step(t0, t1);
                    IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                    s.CalculateDerivations();
                    for (int j = 0; j < m.Count; j++)
                    {
                        IDerivation der = m[j] as IDerivation;
                        prevDeri[paramCount, stepCount] = Measurement.GetDouble(der.Derivation);
                        prevStep[paramCount]            = (double)m[j].Parameter();
                        ++paramCount;
                    }
                    s.CopyVariablesToSolver(paramCount - m.Count, prevStep);
                    ++stepCount;
                }
                paramCount = 0;
            }

            else
            {
                foreach (IMeasurements m in equations)
                {
                    IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                    s.CalculateDerivations();
                    for (int j = 0; j < m.Count; j++)
                    {
                        prevStep[paramCount] = (double)m[j].Parameter();
                        oldStep[paramCount]  = prevStep[paramCount];
                        for (int i = 0; i < order; i++)
                        {
                            prevStep[paramCount] += prevDeri[paramCount, i] * prCoeff[i] * (t1 - t0);
                        }
                        ++paramCount;
                    }
                    s.CopyVariablesToSolver(paramCount - m.Count, prevStep);
                }

                paramCount = 0;
                foreach (IMeasurements m in equations)
                {
                    for (int j = 0; j < m.Count; j++)
                    {
                        for (int i = 0; i < order - 1; i++)
                        {
                            prevDeri[paramCount, i] = prevDeri[paramCount, i + 1];
                        }
                        ++paramCount;
                    }
                }

                paramCount = 0;
                foreach (IMeasurements m in equations)
                {
                    IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                    s.CalculateDerivations();
                    for (int j = 0; j < m.Count; j++)
                    {
                        IDerivation der = m[j] as IDerivation;
                        prevDeri[paramCount, order - 1] = Measurement.GetDouble(der.Derivation);
                        ++paramCount;
                    }
                }
                paramCount = 0;


                foreach (IMeasurements m in equations)
                {
                    IDifferentialEquationSolver s = m as IDifferentialEquationSolver;
                    for (int j = 0; j < m.Count; j++)
                    {
                        prevStep[paramCount] = oldStep[paramCount];
                        for (int i = 0; i < order; i++)
                        {
                            prevStep[paramCount] += prevDeri[paramCount, i] * aqCoeff[i] * (t1 - t0);
                        }
                        ++paramCount;
                    }
                    s.CopyVariablesToSolver(paramCount - m.Count, prevStep);
                }
                ++stepCount;
            }
            isBusy = false;
        }