Пример #1
0
def test_po_solver_func():
    mu = 0.01215
    jacobi = 2.992

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func, trans_red, trans_full = sections.generate_poincare_tools(
        mu, jacobi)

    order = 20
    eps_abs = 1e-16
    eps_tol = 1e-16
    solve_events = events.generate_adaptive_event_solver(
        taylor_params, poincare_func, order, eps_abs, eps_tol)
    poincare_map = po_solver.generate_poinare_map(solve_events, trans_red,
                                                  trans_full)

    init_cond = np.array([0.9043, 0.0176, 0.0, 0.0])
    point, period = po_solver.solve_periodic_orbit(poincare_map, init_cond)
    state = trans_full(point)

    po_period = 21.1810525829419
    po_state = np.array([
        0.440148176542848,
        0.783403421942971,
        0.0,
        -0.905419824338076,
        0.540413382924902,
        0.0,
    ])

    assert math.isclose(period, po_period, rel_tol=0.0, abs_tol=1e-8)
    assert np.allclose(state, po_state, rtol=0.0, atol=1e-14)
Пример #2
0
def test_adaptive_dirm_solver():
    mu = 0.01215
    jacobi = 2.992

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func, trans_red, trans_full = sections.generate_poincare_tools(
        mu, jacobi)

    order = 20
    eps_abs = 1e-16
    eps_tol = 1e-16
    solve_events = events.generate_adaptive_event_solver(
        taylor_params, poincare_func, order, eps_abs, eps_tol)
    poincare_map = po_solver.generate_poinare_map(solve_events, trans_red,
                                                  trans_full)

    init_cond = np.array([0.9043, 0.0176, 0.0, 0.0])
    dirm_solver = po_solver.DirmIterator(poincare_map, init_cond)

    for _ in range(1000):
        dirm_solver.iterate(0.1)

    for _ in range(10):
        dirm_solver.iterate(0.01)

    period = dirm_solver.return_time
    distance = dirm_solver.distance

    assert math.isclose(period, 21.1810525829419, rel_tol=5e-15, abs_tol=0.0)
    assert math.isclose(distance, 0.0, rel_tol=0.0, abs_tol=8e-16)
Пример #3
0
def test_poincare_escape_orbit():
    mu = 0.01215

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func = sections.generate_poincare_tools(mu)

    def escape_condition(point):
        return np.linalg.norm(point) > 2.0

    order = 20
    escape_solve = escape.generate_poincare_escape_solver(
        taylor_params, poincare_func, escape_condition, order)

    init_cond = np.array([
        0.42, 0.783403421942971, 0.1, -0.905419824338076, 0.540413382924902,
        0.0
    ])

    point, t = escape_solve(init_cond, 10)

    escaped_point = np.array([
        0.11057721919072513,
        0.21256977910997807,
        -0.072191339909561877,
        -2.3803412262232362,
        0.15226439712815315,
        0.35365331439714465,
    ])
    escaped_time = 801.6231569667372

    rel_tol = 1e-14
    abs_tol = 1e-14

    assert np.allclose(point, escaped_point, rel_tol, abs_tol)
    assert math.isclose(t, escaped_time, rel_tol=rel_tol, abs_tol=abs_tol)
Пример #4
0
def test_poincare_periodic_orbit():
    mu = 0.01215
    period = 21.1810525829419

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func = sections.generate_poincare_tools(mu)

    step = 0.1
    order = 20
    poincare_solve = events.generate_event_solver(taylor_params, poincare_func,
                                                  step, order)

    init_cond = np.array([
        0.440148176542848,
        0.783403421942971,
        0.0,
        -0.905419824338076,
        0.540413382924902,
        0.0,
    ])

    points, t = poincare_solve(init_cond, 3)

    rel_tol = 1e-14
    abs_tol = 1e-14

    assert np.allclose(points[0], points[1], rel_tol, abs_tol)
    assert np.allclose(points[1], points[2], rel_tol, abs_tol)
    assert np.allclose(points[0], points[2], rel_tol, abs_tol)

    assert math.isclose(period, t[2] - t[1], rel_tol=rel_tol, abs_tol=abs_tol)
Пример #5
0
def test_adaptive_event_solver2():
    mu = 0.01215
    period = 21.070381823628498
    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func = sections.generate_poincare_tools(mu)

    order = 50
    eps_abs = 1e-16
    eps_rel = 0.0
    poincare_solve = events.generate_adaptive_event_solver(
        taylor_params, poincare_func, order, eps_abs, eps_rel)

    init_cond = np.array([
        0.48746299023725853,
        0.86535508321234522,
        0.0,
        -0.86638425004587294,
        0.48805050039736497,
        0.0,
    ])

    points, t = poincare_solve(init_cond, 3)

    rel_tol = 1e-14
    abs_tol = 1e-14

    assert np.allclose(points[0], points[1], rel_tol, abs_tol)
    assert np.allclose(points[1], points[2], rel_tol, abs_tol)
    assert np.allclose(points[0], points[2], rel_tol, abs_tol)

    assert math.isclose(period, t[2] - t[1], rel_tol=0.0, abs_tol=1e-8)
Пример #6
0
def test_adaptive_event_generator():
    mu = 0.01215

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func = sections.generate_poincare_tools(mu)
    order = 20

    point_generator = events.generate_adaptive_event_generator(taylor_params,
                                                               poincare_func,
                                                               order,
                                                               tol_abs=1e-16,
                                                               tol_rel=1e-16)

    init_cond = np.array(
        [0.39785, 0.71014, 0.001, -0.98602, 0.571588, 0.00025])
    points = np.array(
        [s for s, t in islice(point_generator(init_cond), None, 3)])

    precomputed_points = np.array([
        [
            0.3978496481075093,
            0.710140221607567,
            0.001000000318880387,
            -0.9860201962698747,
            0.5715876208422852,
            0.0002499976950271774,
        ],
        [
            0.4263632104330913,
            0.7595271602602567,
            -0.000965633500996545,
            -0.9173784469340452,
            0.5684961830311902,
            -0.0005994497329097056,
        ],
        [
            0.4582748256453528,
            0.8147996991594816,
            0.001132265237324626,
            -0.8833310514195326,
            0.5044621880970391,
            -8.366385185794535e-05,
        ],
    ])
    assert np.allclose(precomputed_points, points, 0.0, 1e-15)
Пример #7
0
def test_pss_orbit():
    mu = 0.01215

    taylor_params = coeffs.generate_taylor_coeffs(mu)
    poincare_func = sections.generate_poincare_tools(mu)

    def slice_condition(point):
        pz = point[5]
        return abs(pz) < 1e-3

    order = 20
    pss_solve = pss.generate_adaptive_pss_solver(taylor_params, poincare_func,
                                                 slice_condition, order)

    init_cond = np.array([
        0.440148176542848,
        0.783403421942971,
        0.02,
        -0.905419824338076,
        0.540413382924902,
        0.0,
    ])

    points, t = pss_solve(init_cond, 10)

    last_pss_point = np.array([
        0.44178915227058674,
        0.7862456752774013,
        0.020068511232556891,
        -0.9034821179184479,
        0.53757237305311767,
        0.00081354636533123928,
    ])
    last_pss_time = 10928.635911486037

    rel_tol = 1e-14
    abs_tol = 1e-14

    assert np.allclose(points[-1], last_pss_point, rel_tol, abs_tol)
    assert math.isclose(t[-1], last_pss_time, rel_tol=rel_tol, abs_tol=abs_tol)
Пример #8
0
def test_event_solver_with_escape():
    mu = 0.01215

    taylor_params = coeffs.generate_taylor_coeffs(mu)

    escape_char_func = tools.generate_escape_box_func(0.0, 0.85, 0.0, 3.0, 1.3,
                                                      2.0)
    poincare_func = sections.generate_poincare_tools(mu)

    order = 20
    escape_solve = escape.generate_adaptive_escape_event_solver(
        taylor_params, poincare_func, escape_char_func, order)

    init_cond = np.array([
        0.4318901554339924,
        0.7691001098124562,
        0.0,
        -0.9337249081281812,
        0.5279878799757336,
        0.0,
    ])

    points, times = escape_solve(init_cond, 1500)

    last_point = np.array([
        0.3428822970341644,
        0.6149339767910579,
        0.0,
        -1.1197828725101768,
        0.5848142640570532,
        0.0,
    ])
    last_time = 25447.34707126419

    rel_tol = 1e-14
    abs_tol = 1e-14

    assert points.shape[0] == 1190
    assert np.allclose(points[-1], last_point, rel_tol, abs_tol)
    assert math.isclose(times[-1], last_time, rel_tol=rel_tol, abs_tol=abs_tol)