Ejemplo n.º 1
0
def test_compare_metrics_under_limits():
    """
    Tests if KerrNewman Metric reduces to Kerr Metric, in the limit Q -> 0 and to Schwarzschild \
    Metric, in the limits, a -> 0 & Q -> 0

    """
    r, theta = 99.9, 5 * np.pi / 6
    M = 6.73317655e26

    x_vec = np.array([0., r, theta, 0.])
    ms = Schwarzschild(M=M)
    mk = Kerr(coords="BL", M=M, a=0.5)
    mk0 = Kerr(coords="BL", M=M, a=0.)
    mkn = KerrNewman(coords="BL", M=M, a=0.5, Q=0.)
    mkn0 = KerrNewman(coords="BL", M=M, a=0., Q=0.)

    ms_mat = ms.metric_covariant(x_vec)
    mk_mat = mk.metric_covariant(x_vec)
    mk0_mat = mk0.metric_covariant(x_vec)
    mkn_mat = mkn.metric_covariant(x_vec)
    mkn0_mat = mkn0.metric_covariant(x_vec)

    assert_allclose(ms_mat, mk0_mat, rtol=1e-8)
    assert_allclose(mk_mat, mkn_mat, rtol=1e-8)
    assert_allclose(mkn0_mat, ms_mat, rtol=1e-8)
Ejemplo n.º 2
0
def test_compare_metrics_under_limits(sph, bl):
    """
    Tests if KerrNewman Metric reduces to Kerr Metric, in the limit Q -> 0 and to Schwarzschild \
    Metric, in the limits, a -> 0 & Q -> 0

    """
    M = 6.73317655e26 * u.kg
    a1, a2 = 0.5 * u.one, 0. * u.one
    Q = 0. * u.C

    ms = Schwarzschild(coords=sph, M=M)
    mk = Kerr(coords=bl, M=M, a=a1)
    mk0 = Kerr(coords=bl, M=M, a=a2)
    mkn = KerrNewman(coords=bl, M=M, a=a1, Q=Q)
    mkn0 = KerrNewman(coords=bl, M=M, a=a2, Q=Q)

    x_vec_sph = sph.position()
    x_vec_bl = bl.position()

    ms_mat = ms.metric_covariant(x_vec_sph)
    mk_mat = mk.metric_covariant(x_vec_bl)
    mk0_mat = mk0.metric_covariant(x_vec_bl)
    mkn_mat = mkn.metric_covariant(x_vec_bl)
    mkn0_mat = mkn0.metric_covariant(x_vec_bl)

    assert_allclose(ms_mat, mk0_mat, rtol=1e-8)
    assert_allclose(mk_mat, mkn_mat, rtol=1e-8)
    assert_allclose(mkn0_mat, ms_mat, rtol=1e-8)
Ejemplo n.º 3
0
def test_four_velocity(v_vec, time_like):
    """
    Tests, if the 4-Velocity in KerrNewman Metric is the same as that in Kerr Metric, \
    in the limit Q -> 0 and if it becomes the same as that in Schwarzschild \
    Metric, in the limits, a -> 0 & Q -> 0

    """
    M = 1e24
    x_vec = np.array([1.0, np.pi / 2, 0.1])

    x_vec = np.array([1.0, np.pi / 2, 0.1])

    ms = Schwarzschild(M=M)
    mk = Kerr(coords="BL", M=M, a=0.5)
    mk0 = Kerr(coords="BL", M=M, a=0.)
    mkn = KerrNewman(coords="BL", M=M, a=0.5, Q=0.)
    mkn0 = KerrNewman(coords="BL", M=M, a=0., Q=0.)

    ms_mat = ms.metric_covariant(x_vec)
    mk_mat = mk.metric_covariant(x_vec)
    mk0_mat = mk0.metric_covariant(x_vec)
    mkn_mat = mkn.metric_covariant(x_vec)
    mkn0_mat = mkn0.metric_covariant(x_vec)

    v4vec_s = four_velocity(ms_mat, v_vec, time_like)
    v4vec_k = four_velocity(mk_mat, v_vec, time_like)
    v4vec_k0 = four_velocity(mk0_mat, v_vec, time_like)
    v4vec_kn = four_velocity(mkn_mat, v_vec, time_like)
    v4vec_kn0 = four_velocity(mkn0_mat, v_vec, time_like)

    assert_allclose(v4vec_s, v4vec_k0, rtol=1e-8)
    assert_allclose(v4vec_k, v4vec_kn, rtol=1e-8)
    assert_allclose(v4vec_kn0, v4vec_s, rtol=1e-8)
Ejemplo n.º 4
0
def test_compare_vt_schwarzschild_kerr_kerrnewman():
    """
    Tests, whether the timelike component of 4-Velocity in KerrNewman Metric is the same as that \
    in Kerr Metric, in the limit Q -> 0 and if it becomes the same as that in Schwarzschild \
    Metric, in the limits, a -> 0 & Q -> 0

    """
    M = 1e24
    x_vec = np.array([1.0, np.pi / 2, 0.1])
    v_vec = np.array([-0.1, -0.01, 0.05])

    ms = Schwarzschild(M=M)
    mk = Kerr(coords="BL", M=M, a=0.5)
    mk0 = Kerr(coords="BL", M=M, a=0.)
    mkn = KerrNewman(coords="BL", M=M, a=0.5, Q=0.)
    mkn0 = KerrNewman(coords="BL", M=M, a=0., Q=0.)

    ms_mat = ms.metric_covariant(x_vec)
    mk_mat = mk.metric_covariant(x_vec)
    mk0_mat = mk0.metric_covariant(x_vec)
    mkn_mat = mkn.metric_covariant(x_vec)
    mkn0_mat = mkn0.metric_covariant(x_vec)

    vt_s = v_t(ms_mat, v_vec)
    vt_k = v_t(mk_mat, v_vec)
    vt_k0 = v_t(mk0_mat, v_vec)
    vt_kn = v_t(mkn_mat, v_vec)
    vt_kn0 = v_t(mkn0_mat, v_vec)

    assert_allclose(vt_s, vt_k0, rtol=1e-8)
    assert_allclose(vt_k, vt_kn, rtol=1e-8)
    assert_allclose(vt_kn0, vt_s, rtol=1e-8)
Ejemplo n.º 5
0
def test_calculate_trajectory_iterator_RuntimeWarning_kerrnewman():
    M = 0.5 * 5.972e24
    a = 0.
    Q = 0.
    q = 0.
    t = 0.

    x_vec = np.array([306, np.pi / 2, np.pi / 2])
    v_vec = np.array([0., 0.01, 10.])

    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 = 200.
    step_size = 0.4e-6
    OdeMethodKwargs = {"stepsize": step_size}

    geod = Geodesic(metric=mkn_cov,
                    init_vec=init_vec,
                    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.º 6
0
def test_compare_calculate_trajectory_iterator_cartesian_kerrnewman(
        test_input):
    t, a, Q, q, end_lambda, step_size = test_input
    M = 2e24

    x_vec = np.array([1e6, 1e6, 20.5])
    v_vec = np.array([1e4, 1e4, -30.])

    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)

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

    geod = Geodesic(metric=mkn_cov,
                    init_vec=init_vec,
                    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.º 7
0
def test_calculate_trajectory1_kerrnewman():
    # This needs more investigation
    # the test particle should not move as gravitational & electromagnetic forces are balanced
    t = 0.
    M = 0.5 * 5.972e24
    a = 0.
    Q = 11604461683.91822052001953125
    q = _G * M / _Cc

    r = 1e6
    end_lambda = 1000.0
    step_size = 0.5

    x_vec = np.array([r, 0.5 * np.pi, 0.])
    v_vec = np.array([0., 0., 0.])

    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)

    geod = Geodesic(metric=mkn_cov,
                    init_vec=init_vec,
                    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.º 8
0
def test_compare_kerr_kerrnewman_metric():
    """
    Tests, if covariant & contravariant forms of Kerr & Kerr-Newman metrics match, when Q -> 0

    """
    r, theta, M, a = 0.1, 4 * np.pi / 5, 1e23, 0.99
    x_vec = np.array([0., r, theta, 0.])

    mk = Kerr(coords="BL", M=M, a=a)
    mkn = KerrNewman(coords="BL", M=M, a=a, Q=0.)
    mk_contra = mk.metric_contravariant(x_vec)
    mkn_contra = mkn.metric_contravariant(x_vec)
    mk_cov = mk.metric_covariant(x_vec)
    mkn_cov = mkn.metric_covariant(x_vec)

    assert_allclose(mk_contra, mkn_contra, rtol=1e-10)
    assert_allclose(mk_cov, mkn_cov, rtol=1e-10)
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
def test_compare_kerr_kerrnewman_metric(bl):
    """
    Tests, if covariant & contravariant forms of Kerr & Kerr-Newman metrics match, when Q -> 0

    """
    M = 1e23 * u.kg
    a = 0.99 * u.one
    Q = 0. * u.C

    x_vec = bl.position()

    mk = Kerr(coords=bl, M=M, a=a)
    mkn = KerrNewman(coords=bl, M=M, a=a, Q=Q)
    mk_contra = mk.metric_contravariant(x_vec)
    mkn_contra = mkn.metric_contravariant(x_vec)
    mk_cov = mk.metric_covariant(x_vec)
    mkn_cov = mkn.metric_covariant(x_vec)

    assert_allclose(mk_contra, mkn_contra, rtol=1e-10)
    assert_allclose(mk_cov, mkn_cov, rtol=1e-10)