Ejemplo n.º 1
0
def test_calculate_trajectory_iterator_RuntimeWarning_kerrnewman():
    M = 0.5 * 5.972e24 * u.kg
    a = 0. * u.one
    Q = 0. * u.C
    q = 0. * u.C / u.kg

    bl = BoyerLindquistDifferential(
        t=0.0 * u.s,
        r=306.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=np.pi / 2 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=-0.01 * u.rad / u.s,
        v_p=10.0 * u.rad / u.s,
    )

    mkn = KerrNewman(coords=bl, M=M, a=a, Q=Q, q=q)

    end_lambda = 200.
    step_size = 0.4e-6
    OdeMethodKwargs = {"stepsize": step_size}

    geod = Timelike(metric=mkn,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=step_size)

    with warnings.catch_warnings(record=True) as w:
        it = geod.calculate_trajectory_iterator(
            OdeMethodKwargs=OdeMethodKwargs, )
        for _, _ in zip(range(1000), it):
            pass
        assert len(w) >= 1
Ejemplo n.º 2
0
def test_kerr_frame_dragging():
    """
    Tests, if higher spin implies a "faster" capture (in terms of lambda),
    owing to frame dragging effects

    """
    q0 = [2.5, np.pi / 2, 0.]
    p0 = [0., 0., -8.5]
    end_lambda = 10.
    step_size = 0.005

    sch_geod = Timelike(position=q0,
                        momentum=p0,
                        a=0.,
                        end_lambda=end_lambda,
                        step_size=step_size,
                        return_cartesian=False,
                        julia=False)

    kerr_geod = Timelike(position=q0,
                         momentum=p0,
                         a=0.9,
                         end_lambda=end_lambda,
                         step_size=step_size,
                         return_cartesian=False,
                         julia=False)

    sch_traj = sch_geod.trajectory
    kerr_traj = kerr_geod.trajectory

    # Final lambda_sch > Final lambda_kerr
    assert sch_traj[0].shape[0] > kerr_traj[0].shape[0]
    assert sch_traj[0][-1] > kerr_traj[0][-1]
    # Final r_sch > Final r_kerr
    assert sch_traj[1][:, 0][-1] > kerr_traj[1][:, 0][-1]
Ejemplo n.º 3
0
def test_kerr0_eq_kn00():
    metric_params = (0.5, 0.)
    q0 = [2.5, np.pi / 2, 0.]
    p0 = [0., 0., -8.5]

    k = Timelike(
        metric="Kerr",
        metric_params=metric_params,
        position=q0,
        momentum=p0,
        steps=50,
        delta=0.5,
        return_cartesian=True,
        suppress_warnings=True,
    )

    kn = Timelike(
        metric="KerrNewman",
        metric_params=metric_params,
        position=q0,
        momentum=p0,
        steps=50,
        delta=0.5,
        return_cartesian=True,
        suppress_warnings=True,
    )

    assert_allclose(k.trajectory[0], kn.trajectory[0], atol=1e-6, rtol=1e-6)
    assert_allclose(k.trajectory[1], kn.trajectory[1], atol=1e-6, rtol=1e-6)
Ejemplo n.º 4
0
def test_kerr0_eq_sch():
    metric_params = (0., )
    q0 = [4., np.pi / 2, 0.]
    p0 = [0., 0., 0.]

    k = Timelike(
        metric="Kerr",
        metric_params=metric_params,
        position=q0,
        momentum=p0,
        steps=50,
        delta=0.5,
        return_cartesian=True,
        suppress_warnings=True,
    )

    s = Timelike(
        metric="Schwarzschild",
        metric_params=metric_params,
        position=q0,
        momentum=p0,
        steps=50,
        delta=0.5,
        return_cartesian=True,
        suppress_warnings=True,
    )

    assert_allclose(k.trajectory[0], s.trajectory[0], atol=1e-6, rtol=1e-6)
    assert_allclose(k.trajectory[1], s.trajectory[1], atol=1e-6, rtol=1e-6)
Ejemplo n.º 5
0
def test_calculate_trajectory_iterator_RuntimeWarning_kerr():
    M = 1e25 * u.kg
    a = 0. * u.one

    bl = BoyerLindquistDifferential(
        t=0.0 * u.s,
        r=306.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=np.pi / 2 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.01 * u.rad / u.s,
        v_p=10.0 * u.rad / u.s,
    )

    mk = Kerr(coords=bl, M=M, a=a)

    end_lambda = 1.
    stepsize = 0.4e-6
    OdeMethodKwargs = {"stepsize": stepsize}

    geod = Timelike(metric=mk,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=stepsize,
                    return_cartesian=False)

    with warnings.catch_warnings(record=True) as w:
        it = geod.calculate_trajectory_iterator(
            OdeMethodKwargs=OdeMethodKwargs, )
        for _, _ in zip(range(1000), it):
            pass

        assert len(w) >= 1
Ejemplo n.º 6
0
def test_calculate_trajectory_iterator_RuntimeWarning_schwarzschild():
    M = 1e25 * u.kg
    sph = SphericalDifferential(
        t=0.0 * u.s,
        r=306.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=-np.pi / 2 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.01 * u.rad / u.s,
        v_p=10.0 * u.rad / u.s,
    )
    ms = Schwarzschild(coords=sph, M=M)

    end_lambda = 1.
    stepsize = 0.4e-6
    OdeMethodKwargs = {"stepsize": stepsize}

    geod = Timelike(metric=ms,
                    coords=sph,
                    end_lambda=end_lambda,
                    step_size=stepsize,
                    return_cartesian=False)

    with warnings.catch_warnings(record=True) as w:
        it = geod.calculate_trajectory_iterator(
            OdeMethodKwargs=OdeMethodKwargs, )
        for _, _ in zip(range(1000), it):
            pass

        assert len(w) >= 1
Ejemplo n.º 7
0
def perihelion():
    """
    An example to showcase the usage of the various modules in ``einsteinpy``. \
    Here, we assume a Schwarzschild spacetime and obtain & plot the apsidal precession of \
    test particle orbit in it.

    Returns
    -------
    geod: ~einsteinpy.geodesic.Geodesic
        Geodesic defining test particle trajectory

    """
    # Mass of the black hole in SI
    M = 6e24 * u.kg

    # Defining the initial coordinates of the test particle
    # in SI
    sph = SphericalDifferential(
        t=10000.0 * u.s,
        r=130.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=-np.pi / 8 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.0 * u.rad / u.s,
        v_p=1900.0 * u.rad / u.s,
    )

    # Schwarzschild Metric Object
    ms = Schwarzschild(coords=sph, M=M)

    # Calculating Geodesic
    geod = Timelike(metric=ms, coords=sph, end_lambda=0.002, step_size=5e-8)

    return geod
Ejemplo n.º 8
0
def precession():
    """
    An example to showcase the usage of the various modules in ``einsteinpy``.
    Here, we assume a Schwarzschild spacetime and obtain a test particle orbit, that
    shows apsidal precession.

    Returns
    -------
    geod: ~einsteinpy.geodesic.Timelike
        Timelike Geodesic, defining test particle trajectory

    """
    # Defining initial conditions
    metric = "Schwarzschild"
    position = [40.0, np.pi / 2, 0.0]
    momentum = [0.0, 0.0, 3.83405]

    # Calculating Geodesic
    geod = Timelike(
        metric=metric,
        metric_params=(),
        position=position,
        momentum=momentum,
        steps=5500,
        delta=1.0,
    )

    return geod
Ejemplo n.º 9
0
def test_calculate_trajectory1_kerrnewman():
    # This needs more investigation
    # the test particle should not move as gravitational & electromagnetic forces are balanced
    M = 0.5 * 5.972e24 * u.kg
    a = 0. * u.one
    Q = 11604461683.91822052001953125 * u.C
    q = _G * M.value / _Cc * u.C / u.kg

    r = 1e6
    end_lambda = 1000.0
    step_size = 0.5

    bl = BoyerLindquistDifferential(
        t=0.0 * u.s,
        r=r * u.m,
        theta=np.pi / 2 * u.rad,
        phi=0.0 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.0 * u.rad / u.s,
        v_p=0.0 * u.rad / u.s,
    )

    mkn = KerrNewman(coords=bl, M=M, a=a, Q=Q, q=q)

    geod = Timelike(metric=mkn,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=False)

    ans = geod.trajectory

    assert_allclose(ans[0][1], ans[-1][1], 1e-2)
Ejemplo n.º 10
0
def precession():
    """
    An example to showcase the usage of the various modules in ``einsteinpy``.
    Here, we assume a Schwarzschild spacetime and obtain a test particle orbit, that
    shows apsidal precession.

    Returns
    -------
    geod: ~einsteinpy.geodesic.Timelike
        Timelike Geodesic, defining test particle trajectory

    """
    # Defining initial conditions
    position = [40.0, np.pi / 2, 0.0]
    momentum = [0.0, 0.0, 3.83405]
    spin = 0.0

    # Calculating Geodesic
    geod = Timelike(
        position=position,
        momentum=momentum,
        a=spin,
        end_lambda=2000.0,
        step_size=0.5,
        return_cartesian=True,
        julia=True,
    )

    return geod
Ejemplo n.º 11
0
def test_str_repr():
    """
    Tests, if the ``__str__`` and ``__repr__`` messages match

    """
    M = 1e25 * u.kg
    sph = SphericalDifferential(
        t=0.0 * u.s,
        r=306.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=-np.pi / 2 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.01 * u.rad / u.s,
        v_p=10.0 * u.rad / u.s,
    )
    ms = Schwarzschild(coords=sph, M=M)

    end_lambda = 1.
    step_size = 0.4e-6

    geod = Timelike(metric=ms,
                    coords=sph,
                    end_lambda=end_lambda,
                    step_size=step_size)

    assert str(geod) == repr(geod)
Ejemplo n.º 12
0
def test_calculate_trajectory2_schwarzschild():
    # based on the revolution of earth around sun
    # data from https://en.wikipedia.org/wiki/Earth%27s_orbit
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 29290
    angular_vel = (speed_at_perihelion / distance_at_perihelion)

    sph = SphericalDifferential(
        t=0.0 * u.s,
        r=distance_at_perihelion * u.m,
        theta=np.pi / 2 * u.rad,
        phi=0.0 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.0 * u.rad / u.s,
        v_p=angular_vel * u.rad / u.s,
    )
    metric = Schwarzschild(coords=sph, M=1.989e30 * u.kg)

    end_lambda = 3.154e7

    geod = Timelike(metric=metric,
                    coords=sph,
                    end_lambda=end_lambda,
                    step_size=end_lambda / 2e3,
                    return_cartesian=False)

    ans = geod.trajectory

    # velocity should be 29.29 km/s at aphelion(where r is max)
    i = np.argmax(ans[:, 1])  # index where radial distance is max
    v_aphelion = (((ans[i][1] * ans[i][7]) * (u.m / u.s)).to(u.km / u.s)).value

    assert_allclose(v_aphelion, 29.29, rtol=0.01)
Ejemplo n.º 13
0
def test_calculate_state_raises_TypeError():
    """
    Tests, if ``_calculate_state`` raises TypeError, in case of \
    coordinate mismatch

    """
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 29290

    x_sph = CartesianDifferential(
        t=0.0 * u.s,
        x=distance_at_perihelion / np.sqrt(2) * u.m,
        y=distance_at_perihelion / np.sqrt(2) * u.m,
        z=0. * u.m,
        v_x=-speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_y=speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_z=0 * u.m / u.s)  # .spherical_differential()

    metric = Schwarzschild(coords=x_sph.spherical_differential(),
                           M=1.989e30 * u.kg)

    end_lambda = 3.154e7

    with pytest.raises(TypeError):
        geod = Timelike(
            metric=metric,
            coords=x_sph,
            end_lambda=end_lambda,
            step_size=end_lambda / 2e3,
        )
Ejemplo n.º 14
0
def test_Geodesics_has_trajectory(dummy_data):
    sph, metric, end_lambda, step_size = dummy_data
    geo = Timelike(metric=metric,
                   coords=sph,
                   end_lambda=end_lambda,
                   step_size=step_size)

    assert isinstance(geo.trajectory, np.ndarray)
Ejemplo n.º 15
0
def test_str_repr(dummy_time_python):
    q0, p0, a, end_lambda, step_size, julia = dummy_time_python
    geod = Timelike(position=q0,
                    momentum=p0,
                    a=a,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=True,
                    julia=julia)

    assert str(geod) == repr(geod)
Ejemplo n.º 16
0
def test_calculate_trajectory_iterator_kerr(bl, M, a, end_lambda, step_size,
                                            OdeMethodKwargs, return_cartesian):
    mk = Kerr(coords=bl, M=M, a=a)

    geod = Timelike(metric=mk,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=return_cartesian)

    traj = geod.trajectory

    traj_iter = geod.calculate_trajectory_iterator(
        OdeMethodKwargs=OdeMethodKwargs, return_cartesian=return_cartesian)

    traj_iter_list = list()
    for _, val in zip(range(50), traj_iter):
        traj_iter_list.append(val[1])
    traj_iter_arr = np.array(traj_iter_list)

    assert_allclose(traj[:50, :], traj_iter_arr, rtol=1e-10)
Ejemplo n.º 17
0
def dummy_geod():
    return Timelike(
        metric="Kerr",
        metric_params=(0.9,),
        position=[2.15, np.pi / 2, 0.],
        momentum=[0., 0., 1.5],
        steps=50,
        delta=0.5,
        omega=0.01,  # Close orbit
        return_cartesian=True,
        suppress_warnings=True,
    )
Ejemplo n.º 18
0
def test_constant_rad():
    geod = Timelike(
        metric="Kerr",
        metric_params=(0.99, ),
        position=[4., np.pi / 3, 0.],
        momentum=[0., 0.767851, 2.],
        return_cartesian=False,
        steps=50,
        delta=1.,
    )
    r = geod.trajectory[1][:, 1]

    assert_allclose(r, 4., atol=1e-2, rtol=1e-2)
Ejemplo n.º 19
0
def test_equatorial_geodesic(dummy_time_python):
    q0, p0, a, end_lambda, step_size, julia = dummy_time_python

    geod = Timelike(position=q0,
                    momentum=p0,
                    a=a,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=False,
                    julia=julia)

    theta = q0[1]

    assert_allclose(geod.trajectory[1][:, 1], theta, atol=1e-4, rtol=1e-4)
Ejemplo n.º 20
0
def test_geodesic_attribute2(dummy_time_python):
    q0, p0, a, end_lambda, step_size, julia = dummy_time_python
    geod = Timelike(position=q0,
                    momentum=p0,
                    a=a,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=True,
                    julia=julia)
    traj = geod.trajectory

    assert traj
    assert traj[0].shape[0] == traj[1].shape[0]
    assert traj[1].shape[1] == 6
Ejemplo n.º 21
0
def test_geodesic_attribute1(dummy_time_python):
    q0, p0, a, end_lambda, step_size, julia = dummy_time_python
    geod = Timelike(position=q0,
                    momentum=p0,
                    a=a,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=True,
                    julia=julia)
    traj = geod.trajectory

    assert isinstance(traj, tuple)
    assert isinstance(traj[0], np.ndarray)
    assert isinstance(traj[1], np.ndarray)
Ejemplo n.º 22
0
def test_compare_calculate_trajectory_iterator_cartesian_kerrnewman(
        test_input):
    a, Q, q, end_lambda, step_size = test_input
    M = 2e24 * u.kg

    x_bl = CartesianDifferential(t=0.0 * u.s,
                                 x=1e6 * u.m,
                                 y=1e6 * u.m,
                                 z=20.5 * u.m,
                                 v_x=1e4 * u.m / u.s,
                                 v_y=1e4 * u.m / u.s,
                                 v_z=-30.0 * u.m / u.s).bl_differential(M=M,
                                                                        a=a)

    mkn = KerrNewman(coords=x_bl, M=M, a=a, Q=Q, q=q)

    OdeMethodKwargs = {"stepsize": step_size}
    return_cartesian = True

    geod = Timelike(metric=mkn,
                    coords=x_bl,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=return_cartesian)

    traj = geod.trajectory

    traj_iter = geod.calculate_trajectory_iterator(
        OdeMethodKwargs=OdeMethodKwargs, return_cartesian=return_cartesian)

    traj_iter_list = list()
    for _, val in zip(range(20), traj_iter):
        traj_iter_list.append(val[1])
    traj_iter_arr = np.array(traj_iter_list)

    assert_allclose(traj[:20], traj_iter_arr)
Ejemplo n.º 23
0
def test_compare_calculate_trajectory_iterator_bl_kerrnewman(test_input):
    a, Q, q, end_lambda, step_size = test_input
    M = 0.5 * 5.972e24 * u.kg

    bl = BoyerLindquistDifferential(
        t=0.0 * u.s,
        r=1e6 * u.m,
        theta=0.6 * np.pi * u.rad,
        phi=np.pi / 8 * u.rad,
        v_r=1e4 * u.m / u.s,
        v_th=-0.01 * u.rad / u.s,
        v_p=0.0 * u.rad / u.s,
    )

    mkn = KerrNewman(coords=bl, M=M, a=a, Q=Q, q=q)

    OdeMethodKwargs = {"stepsize": step_size}
    return_cartesian = False

    geod = Timelike(metric=mkn,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=return_cartesian)

    traj = geod.trajectory

    traj_iter = geod.calculate_trajectory_iterator(
        OdeMethodKwargs=OdeMethodKwargs, return_cartesian=return_cartesian)

    traj_iter_list = list()
    for _, val in zip(range(20), traj_iter):
        traj_iter_list.append(val[1])
    traj_iter_arr = np.array(traj_iter_list)

    assert_allclose(traj[:20], traj_iter_arr)
Ejemplo n.º 24
0
def test_calculate_trajectory_schwarzschild(sph, M, end_lambda, step_size):
    ms = Schwarzschild(coords=sph, M=M)

    geod = Timelike(metric=ms,
                    coords=sph,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=False)

    ans = geod.trajectory

    testarray = list()
    for i in ans:
        x = i[:4]
        g = ms.metric_covariant(x)
        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))
    testarray = np.array(testarray)

    assert_allclose(testarray, _c**2, 1e-4)
Ejemplo n.º 25
0
def test_calculate_trajectory0_kerrnewman():
    # Based on the revolution of earth around sun
    # Data from https://en.wikipedia.org/wiki/Earth%27s_orbit
    # Initialized with cartesian coordinates
    # Function returning cartesian coordinates
    M = 1.989e30 * u.kg
    a = 0. * u.one
    Q = 0. * u.C
    q = 0. * u.C / u.kg
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 29290

    x_bl = CartesianDifferential(
        t=0.0 * u.s,
        x=distance_at_perihelion / np.sqrt(2) * u.m,
        y=distance_at_perihelion / np.sqrt(2) * u.m,
        z=0.0 * u.m,
        v_x=-speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_y=speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_z=0.0 * u.m / u.s).bl_differential(M=M, a=a)

    mkn = KerrNewman(coords=x_bl, M=M, a=a, Q=Q, q=q)

    end_lambda = 3.154e7

    geod = Timelike(
        metric=mkn,
        coords=x_bl,
        end_lambda=end_lambda,
        step_size=end_lambda / 1.5e3,
    )

    ans = geod.trajectory

    # velocity should be 29.29 km/s at aphelion(where r is max)
    R = np.sqrt(ans[:, 1]**2 + ans[:, 2]**2 + ans[:, 3]**2)
    i = np.argmax(R)  # index where radial distance is max
    v_aphelion = ((np.sqrt(ans[i, 5]**2 + ans[i, 6]**2 + ans[i, 7]**2) *
                   (u.m / u.s)).to(u.km / u.s)).value

    assert_allclose(v_aphelion, 29.29, rtol=0.01)
Ejemplo n.º 26
0
def dummy_data():
    M = 6e24 * u.kg

    sph = SphericalDifferential(
        t=0.0 * u.s,
        r=130.0 * u.m,
        theta=np.pi / 2 * u.rad,
        phi=-np.pi / 8 * u.rad,
        v_r=0.0 * u.m / u.s,
        v_th=0.0 * u.rad / u.s,
        v_p=1900.0 * u.rad / u.s,
    )

    ms = Schwarzschild(coords=sph, M=M)

    end_lambda = 0.002
    step_size = 5e-8

    geod = Timelike(metric=ms, coords=sph, end_lambda=end_lambda, step_size=step_size)

    return geod
Ejemplo n.º 27
0
def test_calculate_trajectory_kerr(bl, M, a, end_lambda, step_size):
    mk = Kerr(coords=bl, M=M, a=a)

    geod = Timelike(metric=mk,
                    coords=bl,
                    end_lambda=end_lambda,
                    step_size=step_size,
                    return_cartesian=False)

    ans = geod.trajectory

    testarray = list()
    for i in ans:
        x = i[:4]
        g = mk.metric_covariant(x)
        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)

    assert_allclose(testarray, _c**2, 1e-8)
Ejemplo n.º 28
0
def test_calculate_trajectory3_schwarzschild():
    # same test as with test_calculate_trajectory2_schwarzschild(),
    # but initialized with cartesian coordinates
    # and function returning cartesian coordinates
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 29290

    x_sph = CartesianDifferential(
        t=0.0 * u.s,
        x=distance_at_perihelion / np.sqrt(2) * u.m,
        y=distance_at_perihelion / np.sqrt(2) * u.m,
        z=0. * u.m,
        v_x=-speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_y=speed_at_perihelion / np.sqrt(2) * u.m / u.s,
        v_z=0 * u.m / u.s).spherical_differential()

    metric = Schwarzschild(coords=x_sph, M=1.989e30 * u.kg)

    end_lambda = 3.154e7

    geod = Timelike(
        metric=metric,
        coords=x_sph,
        end_lambda=end_lambda,
        step_size=end_lambda / 2e3,
    )

    ans = geod.trajectory

    # velocity should be 29.29 km/s at aphelion(where r is max)
    R = np.sqrt(ans[:, 1]**2 + ans[:, 2]**2 + ans[:, 3]**2)
    i = np.argmax(R)  # index where radial distance is max
    v_aphelion = ((np.sqrt(ans[i, 5]**2 + ans[i, 6]**2 + ans[i, 7]**2) *
                   (u.m / u.s)).to(u.km / u.s)).value

    assert_allclose(v_aphelion, 29.29, rtol=0.01)