Ejemplo n.º 1
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests RK1_TI_STEP.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    06 July 2010
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const double t0 = 0.0;
        const double tn = 1.0;

        Console.WriteLine("");
        Console.WriteLine("TEST01");
        Console.WriteLine("  RK1_TI_STEP uses a first order RK method");
        Console.WriteLine("  for a problem whose right hand side does not");
        Console.WriteLine("  depend explicitly on time.");

        const int n = 10;

        double[]     x    = new double[n + 1];
        const double h    = (tn - t0) / n;
        const double q    = 1.0;
        int          seed = 123456789;

        int    i = 0;
        double t = t0;

        x[i] = 0.0;

        Console.WriteLine("");
        Console.WriteLine("         I           T             X");
        Console.WriteLine("");
        Console.WriteLine("  " + i.ToString().PadLeft(8)
                          + "  " + t.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                          + "  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");

        for (i = 1; i <= n; i++)
        {
            t = ((n - i) * t0
                 + i * tn)
                / n;

            x[i] = RungeKutta.rk1_ti_step(x[i - 1], t, h, q, fi, gi, ref seed);

            Console.WriteLine("  " + i.ToString().PadLeft(8)
                              + "  " + t.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }