Exemplo n.º 1
0
 public RKResults Trancate(int step)
 {
     if (step == 0)
     {
         return(this);
     }
     if (Count > 1)
     {
         var res = new RKResults();
         int i   = step;
         foreach (RKResult r in this)
         {
             if (i == step)
             {
                 res.Add(r);
                 i--;
             }
             else
             {
                 if (i <= 0)
                 {
                     i = step;
                 }
                 else
                 {
                     i--;
                 }
             }
         }
         return(res);
     }
     else
     {
         throw new ArgumentException();
     }
 }
Exemplo n.º 2
0
        public RKResults SolveWithConstH(int N, RKMetodType type)
        {
            var res = new RKResults();

            t.Clear();
            z.Clear();
            Func <double, Vector, double, Vector> RKfunc = null;

            switch (type)
            {
            case RKMetodType.RK4_1:
                RKfunc = RK4_1;
                break;

            case RKMetodType.RK4_2:
                RKfunc = RK4_2;
                break;

            case RKMetodType.RK3_1:
                RKfunc = RK3_1;
                break;

            case RKMetodType.RK3_2:
                RKfunc = RK3_2;
                break;

            case RKMetodType.RK2_1:
                RKfunc = RK2_1;
                break;

            case RKMetodType.RK2_2:
                RKfunc = RK2_2;
                break;
            }
            double h = (t1 - t0) / N;

            H = h;
            double x;
            Vector y;

            t.Add(t0);
            z.Add(Y0);
            var r = new RKResult(t0, Y0);

            res.Add(r);
            OnResultGeneratedCall(r);
            for (int i = 0; i < N; i++)
            {
                y = RKfunc(t[i], z[i], h);
                x = t0 + (i + 1) * h;
                t.Add(x);
                z.Add(y);
                r = new RKResult(x, y);
                res.Add(r);
                OnResultGeneratedCall(r);
            }
            if (OnSolvingDone != null)
            {
                OnSolvingDone(res, curveName, fe);
            }
            return(res);
        }