def test_generate_predictor_dt_func():

    symbs = [Sdts[0], Sdts[1], Sdts[2], Sdts[0] + Sdts[1],
             Sdts[0]/2 + Sdts[1]/2]

    t = sympy.symbols('t')

    fake_ts = utils.dts2ts(t, Sdts[::-1])

    for symb in symbs:
        print fake_ts
        yield utils.assert_sym_eq, symb, generate_p_dt_func(symb)(fake_ts)
Exemple #2
0
def test_generate_predictor_dt_func():

    symbs = [
        Sdts[0], Sdts[1], Sdts[2], Sdts[0] + Sdts[1], Sdts[0] / 2 + Sdts[1] / 2
    ]

    t = sympy.symbols('t')

    fake_ts = utils.dts2ts(t, Sdts[::-1])

    for symb in symbs:
        print fake_ts
        yield utils.assert_sym_eq, symb, generate_p_dt_func(symb)(fake_ts)
def test_symbolic_compare_step_time_residual():

    # Define the symbols we need
    St = sympy.symbols('t')
    Sdts = sympy.symbols('Delta0:9')
    Sys = sympy.symbols('y0:9')
    Sdys = sympy.symbols('dy0:9')

    # Generate the stuff needed to run the residual
    def fake_eqn_residual(ts, ys, dy):
        return Sdys[0] - dy
    fake_ts = utils.dts2ts(St, Sdts[::-1])
    fake_ys = Sys[::-1]

    # Check bdf2
    step_result_bdf2 = ibdf2_step(Sdts[0], Sys[1], Sdys[0], Sdts[1], Sys[2])
    res_result_bdf2 = bdf2_residual(fake_eqn_residual, fake_ts, fake_ys)
    res_bdf2_step = sympy.solve(res_result_bdf2, Sys[0])

    assert len(res_bdf2_step) == 1
    utils.assert_sym_eq(res_bdf2_step[0], step_result_bdf2)
Exemple #4
0
def test_symbolic_compare_step_time_residual():

    # Define the symbols we need
    St = sympy.symbols('t')
    Sdts = sympy.symbols('Delta0:9')
    Sys = sympy.symbols('y0:9')
    Sdys = sympy.symbols('dy0:9')

    # Generate the stuff needed to run the residual
    def fake_eqn_residual(ts, ys, dy):
        return Sdys[0] - dy

    fake_ts = utils.dts2ts(St, Sdts[::-1])
    fake_ys = Sys[::-1]

    # Check bdf2
    step_result_bdf2 = ibdf2_step(Sdts[0], Sys[1], Sdys[0], Sdts[1], Sys[2])
    res_result_bdf2 = bdf2_residual(fake_eqn_residual, fake_ts, fake_ys)
    res_bdf2_step = sympy.solve(res_result_bdf2, Sys[0])

    assert len(res_bdf2_step) == 1
    utils.assert_sym_eq(res_bdf2_step[0], step_result_bdf2)