def test_comparison_adaptive_taylor4_tdrk4():

    # define ODE
    t_0 = 0.0
    t_fin = 3.0
    ode = ODEs(y, f, dfdt,  dfdt, dfdt, f_n, dfdt_n, t_0, t_fin)

    # define the schemes to test
    adapt_taylor = AdaptiveTaylor4Scheme(ode, 'taylor4')
    adapt_tdrk4 = AdaptiveTDRK4Scheme(ode, 'tdrk4')

    # define tolerances
    factor = 1e0
    eps_abs = np.array([1e-2, 1e-4, 1e-6, 1e-8, 1e-10, 1e-12])
    #eps_abs = np.array([1e-8])
    eps_rel = factor * eps_abs

    print('% -------------------------------------------------------------------------------------------- %')
    print(' adaptive taylor4')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_taylor = Test(examples[example_num], test_params, adapt_taylor, 'example-')
    test_taylor.test_adaptive(eps_abs, eps_rel)
    #test_taylor.plot_results('adaptive-taylor4-')

    print('% -------------------------------------------------------------------------------------------- %')
    print(' adaptive tdrk4')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_tdrk4 = Test(examples[example_num], test_params, adapt_tdrk4, 'example-')
    test_tdrk4.test_adaptive(eps_abs, eps_rel)
    #test_tdrk4.plot_results('adaptive-tdrk4-')


    test_tdrk4.compare_results([test_taylor], ['tdrk4', 'taylor'], 'taylor4-tdrk4-')
def test_comparison_srtdrk2_mrtdrk2():

    # define ODE
    t_0 = 0.0
    t_fin = 5.0
    ode = ODEs(y, f, dfdt, J_y, J_t, f_n, dfdt_n, t_0, t_fin, F, JF_y, dFdt)

    # define the schemes to test
    tdrk2_sr = AdaptiveTDRK2SingleRateScheme(ode, 'sr-tdrk2')
    tdrk2_mr = AdaptiveTDRK2MultiRateScheme(ode, 'mr-tdrk2')

    # define tolerances
    factor = 1e0
    if examples[example_num] == 2:  eps_abs = np.array([1e-2, 1e-3, 1e-4, 1e-5, 1e-6])
    else:                           eps_abs = np.array([1e-4, 1e-5, 1e-6, 1e-7, 1e-8])
    eps_rel = factor * eps_abs

    print('% -------------------------------------------------------------------------------------------- %')
    print('  adaptive tdrk2 (2 * neq function call per step)')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_sr = Test(examples[example_num], test_params, tdrk2_sr, 'system-')
    test_sr.test_adaptive(eps_abs, eps_rel)

    print('% -------------------------------------------------------------------------------------------- %')
    print('  multirate adaptive tdrk2')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_mr = Test(examples[example_num], test_params, tdrk2_mr, 'system-')
    test_mr.test_adaptive(eps_abs, eps_rel)

    test_sr.compare_results([test_mr], ['sr-tdrk2', 'mr-tdrk2'], 'sr-vs-mr-tdrk2-')
def test_comparison_adaptive_tdrk2_schemes():

    # define ODE
    t_0 = 0.0
    t_fin = 3.0
    ode = ODEs(y, f, dfdt, dfdt, dfdt, f_n, dfdt_n, t_0, t_fin)

    # define the schemes to test
    adapt_tdrk2 = AdaptiveTDRK2Scheme(ode, 'tdrk2 (our h)')
    adapt_classic_tdrk2 = AdaptiveClassicTDRK2Scheme(ode, 'tdrk2 (classic h)')

    # define tolerances
    factor = 1e0
    eps_abs = np.array([1e-2, 1e-4, 1e-6, 1e-8, 1e-10])
    eps_rel = factor * eps_abs

    print('% -------------------------------------------------------------------------------------------- %')
    print(' classic tdrk2')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_aclassic_tdrk2 = Test(examples[example_num], test_params, adapt_classic_tdrk2, 'comparison-tdrk2-and-4-example-')
    test_aclassic_tdrk2.test_adaptive(eps_abs, eps_rel)
    test_aclassic_tdrk2.plot_results('adaptive-classi-tdrk2-')

    print('% -------------------------------------------------------------------------------------------- %')
    print(' adaptive tdrk2')
    print('% -------------------------------------------------------------------------------------------- %\n')

    test_adapt_tdrk2 = Test(examples[example_num], test_params, adapt_tdrk2, 'comparison-tdrk2-and-4-example-')
    test_adapt_tdrk2.test_adaptive(eps_abs, eps_rel)
    test_adapt_tdrk2.plot_results('adaptive-tdrk2-')


    test_adapt_tdrk2.compare_results([test_aclassic_tdrk2], ['tdrk2 (classic h)'], 'tdrk2s-')