Beispiel #1
0
def test_cycle_BLCartesianDifferential(bl_coords):
    M = 1e24
    a = 0.75
    bl_diff = bl_coords
    cart_diff = bl_diff.convert_cartesian(M=M, a=a)
    bl_diff2 = CartesianConversion(*cart_diff).convert_bl(M=M, a=a)
    assert_allclose(bl_diff2, bl_diff.values(), rtol=0.0, atol=1e-6)
Beispiel #2
0
def cartesian_coords():
    return CartesianConversion(t=0.,
                               x=10 / np.sqrt(2),
                               y=10 / np.sqrt(2),
                               z=0.,
                               v_x=-190 / np.sqrt(2),
                               v_y=210 / np.sqrt(2),
                               v_z=200.)
Beispiel #3
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
    t = 0.
    M = 1.989e30
    a = 0.
    Q = 0.
    q = 0.
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 30290

    x_sph = CartesianConversion(distance_at_perihelion / np.sqrt(2),
                                distance_at_perihelion / np.sqrt(2), 0.,
                                -speed_at_perihelion / np.sqrt(2),
                                speed_at_perihelion / np.sqrt(2),
                                0.).convert_spherical()

    x_vec = x_sph[:3]
    v_vec = x_sph[3:]

    mkn_cov = KerrNewman(coords="BL", M=M, a=a, Q=Q, q=q)
    x_4vec = four_position(t, x_vec)
    mkn_cov_mat = mkn_cov.metric_covariant(x_4vec)
    init_vec = stacked_vec(mkn_cov_mat, t, x_vec, v_vec, time_like=True)

    end_lambda = 3.154e7

    geod = Geodesic(
        metric=mkn_cov,
        init_vec=init_vec,
        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)
Beispiel #4
0
def test_calculate_trajectory3_schwarzschild():
    # same test as with test_calculate_trajectory2_schwarzschild(),
    # but initialized with cartesian coordinates
    # and function returning cartesian coordinates
    t = 0.
    M = 1.989e30
    distance_at_perihelion = 147.10e9
    speed_at_perihelion = 30290

    x_sph = CartesianConversion(distance_at_perihelion / np.sqrt(2),
                                distance_at_perihelion / np.sqrt(2), 0.,
                                -speed_at_perihelion / np.sqrt(2),
                                speed_at_perihelion / np.sqrt(2),
                                0.).convert_spherical()

    x_vec = x_sph[:3]
    v_vec = x_sph[3:]

    ms_cov = Schwarzschild(M=M)
    x_4vec = four_position(t, x_vec)
    ms_cov_mat = ms_cov.metric_covariant(x_4vec)
    init_vec = stacked_vec(ms_cov_mat, t, x_vec, v_vec, time_like=True)

    end_lambda = 3.154e7

    geod = Geodesic(
        metric=ms_cov,
        init_vec=init_vec,
        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)
Beispiel #5
0
def cartesian_coords():
    return CartesianConversion(
        10 / np.sqrt(2), 10 / np.sqrt(2), 0, -190 / np.sqrt(2), 210 / np.sqrt(2), 200.0
    )