Ejemplo n.º 1
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);
        }
Ejemplo 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;
 }