Exemplo n.º 1
0
        static void Main2(string[] args)
        {
            List <double []> ylist = new List <double []>();
            List <double>    xlist = new List <double>();

            double[]   y0 = { 1, 0, 0, 0, 1, 0 };
            double[]   x  = { 0 * 0.78539816339, 1 * 0.78539816339, 2 * 0.78539816339, 3 * 0.78539816339, 4 * 0.78539816339 };
            double[][] y  = new double[][]
            {
                new double[5],
                new double[5],
                new double[5],
                new double[5],
                new double[5],
                new double[5],
            };

            var watch = System.Diagnostics.Stopwatch.StartNew();

            for (int i = 0; i < 100000; i++)
            {
                ODE.RKDP547FM(centralForce, null, y0, 6, x, y, 1e-9, 0, xlist: xlist, ylist: ylist);
            }
            watch.Stop();
            Console.WriteLine("ms : {0:F6}", watch.ElapsedMilliseconds);
            for (int i = 0; i < xlist.Count; i++)
            {
                Console.Write(xlist[i]);
                if (i != xlist.Count - 1)
                {
                    Console.Write(", ");
                }
            }
            Console.Write("\n");
            for (int i = 0; i < ylist.Count; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    Console.Write(ylist[i][j]);
                    if (j != 5)
                    {
                        Console.Write(", ");
                    }
                }
                Console.Write("\n");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            List <double []> ylist = new List <double []>();
            List <double>    xlist = new List <double>();

            double[]   y0 = { 0, 20 };
            double[]   x  = { 0, 5 };
            double[][] y  = new double[][]
            {
                new double[2],
                new double[2],
            };
            EvtFun[] EvtFuns = { ballevent };
            ODE.RKDP547FM(ball, null, y0, 2, x, y, 1e-9, 0, hmin: 1e-8, xlist: xlist, ylist: ylist, EvtFuns: EvtFuns);
            for (int i = 0; i < xlist.Count; i++)
            {
                Console.Write(xlist[i]);
                if (i != xlist.Count - 1)
                {
                    Console.Write(", ");
                }
            }
            Console.Write("\n");
            for (int i = 0; i < ylist.Count; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Console.Write(ylist[i][j]);
                    if (j != 1)
                    {
                        Console.Write(", ");
                    }
                }
                Console.Write("\n");
            }
        }