Exemplo n.º 1
0
def test_calculate_trajectory_iterator(
    pos_vec,
    vel_vec,
    time,
    M,
    a,
    start_lambda,
    end_lambda,
    OdeMethodKwargs,
    return_cartesian,
):
    cl1 = Kerr.from_BL(pos_vec, vel_vec, time, M, a)
    arr1 = cl1.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
        return_cartesian=return_cartesian,
    )[1]
    cl2 = Kerr.from_BL(pos_vec, vel_vec, time, M, a)
    it = cl2.calculate_trajectory_iterator(
        start_lambda=start_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
        return_cartesian=return_cartesian,
    )
    arr2_list = list()
    for _, val in zip(range(100), it):
        arr2_list.append(val[1])
    arr2 = np.array(arr2_list)
    assert_allclose(arr1[:100, :], arr2, rtol=1e-10)
Exemplo n.º 2
0
def test_calculate_trajectory(
    pos_vec, vel_vec, time, M, a, start_lambda, end_lambda, OdeMethodKwargs
):
    _scr = schwarzschild_radius(M).value
    obj = Kerr.from_BL(pos_vec, vel_vec, time, M, a)
    ans = obj.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
    )
    ans = ans[1]
    testarray = list()
    for ansi in ans:
        g = kerr_utils.metric(_c, ansi[1], ansi[2], _scr, a)
        tmp = (
            g[0][0] * (ansi[4] ** 2)
            + g[1][1] * (ansi[5] ** 2)
            + g[2][2] * (ansi[6] ** 2)
            + g[3][3] * (ansi[7] ** 2)
            + 2 * g[0][3] * ansi[4] * ansi[7]
        )
        testarray.append(tmp)
    testarray = np.array(testarray, dtype=float)
    comparearray = np.ones(shape=ans[:, 4].shape, dtype=float)
    assert_allclose(testarray, comparearray, 1e-4)
Exemplo n.º 3
0
def test_calculate_trajectory(coords, time, M, start_lambda, end_lambda,
                              OdeMethodKwargs):
    _scr = schwarzschild_radius_dimensionless(M)
    obj = Kerr.from_BL(coords, M, time)
    ans = obj.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
    )
    ans = ans[1]
    testarray = list()
    for i in ans:
        g = kerr_utils.metric(i[1], i[2], M.value, coords.a.to(u.m).value)
        testarray.append(g[0][0] * (i[4]**2) + g[1][1] * (i[5]**2) + g[2][2] *
                         (i[6]**2) + g[3][3] * (i[7]**2) +
                         2 * g[0][3] * i[4] * i[7])
    testarray = np.array(testarray, dtype=float)
    comparearray = np.ones(shape=ans[:, 4].shape, dtype=float)
    assert_allclose(testarray, comparearray, 1e-4)
Exemplo n.º 4
0
def test_calculate_trajectory_iterator_RuntimeWarning():
    bl_obj = BoyerLindquistDifferential(
        306 * u.m,
        np.pi / 2 * u.rad,
        np.pi / 2 * u.rad,
        0 * u.m / u.s,
        0.01 * u.rad / u.s,
        10 * u.rad / u.s,
        0 * u.m,
    )
    M = 1e25 * u.kg
    start_lambda = 0.0
    OdeMethodKwargs = {"stepsize": 0.4e-6}
    cl = Kerr.from_BL(bl_obj, M)
    with warnings.catch_warnings(record=True) as w:
        it = cl.calculate_trajectory_iterator(
            start_lambda=start_lambda,
            OdeMethodKwargs=OdeMethodKwargs,
            stop_on_singularity=True,
        )
        for _, _ in zip(range(1000), it):
            pass
        assert len(w) >= 1