コード例 #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
コード例 #2
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
コード例 #3
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
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)