Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            nMassas = new int[1] {
                10
            };

            //Integrador de EDO
            float x0 = 0;

            float[] y0 = new float[2 * nMassas[0]];

            //y0[0]=posicao, y0[1] = velocidade
            for (int i = 0; i < 2 * nMassas[0]; i += 2)
            {
                y0[i] = 1;
            }

            CLCalc.CLPrograms.floatODE46 ode46 = new CLCalc.CLPrograms.floatODE46(x0, 0.005f, y0, MassaMola);

            //CLCalc.Program.DefaultCQ = 0;

            //Retorno de derivadas
            string[] s = new string[] { CLCalc.EnableDblSupport, floatDerivsMMola };
            CLCalc.Program.Compile(s);
            KernelDerivs = new CLCalc.Program.Kernel("floatDerivs");

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            ode46.Integrate(20);
            sw.Stop();
            this.Text = sw.ElapsedMilliseconds.ToString();
            Application.DoEvents();

            float[] y = ode46.State;

            ode46.Integrate(25);
            y = ode46.State;
            float[] yerr = ode46.AbsError;
            float   x    = ode46.IndepVar;
        }
Example #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            nMassas = new int[1] { 10 };

            //Integrador de EDO
            float x0 = 0;
            float[] y0 = new float[2 * nMassas[0]];

            //y0[0]=posicao, y0[1] = velocidade
            for (int i = 0; i < 2 * nMassas[0]; i += 2)
            {
                y0[i] = 1;
            }

            CLCalc.CLPrograms.floatODE46 ode46 = new CLCalc.CLPrograms.floatODE46(x0, 0.005f, y0, MassaMola);

            //CLCalc.Program.DefaultCQ = 0;

            //Retorno de derivadas
            string[] s = new string[] {CLCalc.EnableDblSupport, floatDerivsMMola };
            CLCalc.Program.Compile(s);
            KernelDerivs = new CLCalc.Program.Kernel("floatDerivs");

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            ode46.Integrate(20);
            sw.Stop();
            this.Text = sw.ElapsedMilliseconds.ToString();
            Application.DoEvents();

            float[] y = ode46.State;

            ode46.Integrate(25);
            y = ode46.State;
            float[] yerr = ode46.AbsError;
            float x = ode46.IndepVar;
        }