def test_calculate_trajectory_iterator_kerr(x_vec, v_vec, t, M, a, end_lambda, step_size, OdeMethodKwargs, return_cartesian): mk_cov = Kerr(coords="BL", M=M, a=a) x_4vec = four_position(t, x_vec) mk_cov_mat = mk_cov.metric_covariant(x_4vec) init_vec = stacked_vec(mk_cov_mat, t, x_vec, v_vec, time_like=True) geod = Geodesic(metric=mk_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(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)
def test_calculate_trajectory_iterator_RuntimeWarning_kerr(): t = 0. M = 1e25 a = 0. x_vec = np.array([306., np.pi / 2, np.pi / 2]) v_vec = np.array([0., 0.01, 10.]) mk_cov = Kerr(coords="BL", M=M, a=a) x_4vec = four_position(t, x_vec) mk_cov_mat = mk_cov.metric_covariant(x_4vec) init_vec = stacked_vec(mk_cov_mat, t, x_vec, v_vec, time_like=True) end_lambda = 1. stepsize = 0.4e-6 OdeMethodKwargs = {"stepsize": stepsize} geod = Geodesic(metric=mk_cov, init_vec=init_vec, 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
def test_christoffels(bl): """ Compares output produced by optimized function, with that, produced via general method (formula) """ r, theta = 100.0 * u.m, np.pi / 5 * u.rad M, a = 6.73317655e26 * u.kg, 0.2 * u.one x_vec = bl.position() # Output produced by the optimized function mk = Kerr(coords=bl, M=M, a=a) chl1 = mk.christoffels(x_vec) # Calculated using formula g_contra = mk.metric_contravariant(x_vec) dgdx = mk._dg_dx_bl(x_vec) chl2 = np.zeros(shape=(4, 4, 4), dtype=float) tmp = np.array([i for i in range(4**3)]) for t in tmp: i = int(t / (4**2)) % 4 k = int(t / 4) % 4 index = t % 4 for m in range(4): chl2[i, k, index] += g_contra[i, m] * ( dgdx[index, m, k] + dgdx[k, m, index] - dgdx[m, k, index]) chl2 = np.multiply(chl2, 0.5) assert_allclose(chl2, chl1, rtol=1e-8)
def test_calculate_trajectory_kerr(x_vec, v_vec, t, M, a, end_lambda, step_size): mk_cov = Kerr(coords="BL", M=M, a=a) x_4vec = four_position(t, x_vec) mk_cov_mat = mk_cov.metric_covariant(x_4vec) init_vec = stacked_vec(mk_cov_mat, t, x_vec, v_vec, time_like=True) geod = Geodesic(metric=mk_cov, init_vec=init_vec, 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_cov.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, dtype=float) assert_allclose(testarray, 1., 1e-4)
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)
def test_nonzero_christoffels(): """ Compares count of non-zero Christoffel Symbols List in BL coordinates \ with that generated algorithmically """ mk = Kerr(coords="BL", M=1. * u.kg, a=0.5 * u.one) l1 = mk.nonzero_christoffels() l2 = mk._nonzero_christoffels_list_bl assert collections.Counter(l1) == collections.Counter(l2)
def test_compare_kerr_kerrnewman_christoffels(test_input): """ Compares KerrNewman Christoffel Symbols, with that of Kerr metric, when Q -> 0 """ bl, M, a = test_input x_vec = bl.position() mk = Kerr(coords=bl, M=M, a=a) mkn = KerrNewman(coords=bl, M=M, a=a, Q=0. * u.C) mk_chl = mk.christoffels(x_vec) mkn_chl = mkn.christoffels(x_vec) assert_allclose(mk_chl, mkn_chl, rtol=1e-8)
def test_compare_kerr_kerrnewman_dmetric_dx(test_input): """ Tests, if the metric derivatives for Kerr & Kerr-Newman metrics match, when Q -> 0 """ bl, M, a = test_input x_vec = bl.position() mk = Kerr(coords=bl, M=M, a=a) mkn = KerrNewman(coords=bl, M=M, a=a, Q=0. * u.C) mkdx = mk._dg_dx_bl(x_vec) mkndx = mkn._dg_dx_bl(x_vec) assert_allclose(mkdx, mkndx, rtol=1e-8)
def test_singularities_ks_raises_NotImplementedError(): """ Tests, if a NotImplementedError is raised, when KerrSchild coordinates \ are used with ``singularities()`` """ mk = Kerr(coords="KS", M=1e22, a=0.5) try: mk_sing = mk.singularities() assert False except NotImplementedError: assert True
def test_compare_kerr_kerrnewman_dmetric_dx(test_input): """ Tests, if the metric derivatives for Kerr & Kerr-Newman metrics match, when Q -> 0 """ r, theta, M, a = test_input 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.) mkdx = mk._dg_dx_bl(x_vec) mkndx = mkn._dg_dx_bl(x_vec) assert_allclose(mkdx, mkndx, rtol=1e-10)
def test_compare_kerr_kerrnewman_christoffels(test_input): """ Compares KerrNewman Christoffel Symbols, with that of Kerr metric, when Q -> 0 """ r, theta, M, a = test_input 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_chl = mk.christoffels(x_vec) mkn_chl = mkn.christoffels(x_vec) assert_allclose(mk_chl, mkn_chl, rtol=1e-8)
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
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)
def test_calculate_trajectory3(): # Based on the revolution of earth around sun # Data from https://en.wikipedia.org/wiki/Earth%27s_orbit # Initialialized with cartesian coordinates # Function returning cartesian coordinates M = 1.989e30 * u.kg distance_at_perihelion = 147.10e6 * u.km speed_at_perihelion = 30.29 * u.km / u.s cart_obj = CartesianDifferential( distance_at_perihelion / np.sqrt(2), distance_at_perihelion / np.sqrt(2), 0 * u.km, -1 * speed_at_perihelion / np.sqrt(2), speed_at_perihelion / np.sqrt(2), 0 * u.km / u.h, ) end_lambda = ((1 * u.year).to(u.s)).value a = 0 * u.km cl = Kerr.from_cartesian(cart_obj, M, a) ans = cl.calculate_trajectory( start_lambda=0.0, end_lambda=end_lambda, return_cartesian=True, OdeMethodKwargs={"stepsize": end_lambda / 2e3}, )[1] # velocity should be 29.29 km/s at apehelion(where r is max) R = np.sqrt(ans[:, 1]**2 + ans[:, 2]**2 + ans[:, 3]**2) i = np.argmax(R) # index whre radial distance is max v_apehelion = ((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_apehelion, 29.29, rtol=0.01)
def test_wrong_or_no_units_in_init(M, a, Q, q): """ Tests, if wrong or no units are flagged as error, while instantiation """ 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=0.0 * u.rad / u.s, ) bl = BoyerLindquistDifferential( 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=0.0 * u.rad / u.s, ) try: bm = BaseMetric(coords=sph, M=M, a=a, Q=Q) ms = Schwarzschild(coords=sph, M=M) mk = Kerr(coords=bl, M=M, a=a) mkn = KerrNewman(coords=bl, M=M, a=a, Q=Q, q=q) assert False except (u.UnitsError, TypeError): assert True
def test_singularities_raises_NotImplementedError(sph, bl): """ Tests, if ``singularities()`` raises a NotImplementedError, \ when there is a coordinate mismatch between supplied coordinate \ object and the coordinate object, metric was instantiated with """ M = 5e27 * u.kg a = 0. * u.one Q = 0. * u.C theta = np.pi / 4 ms = Schwarzschild(coords=bl, M=M) mk = Kerr(coords=sph, M=M, a=a) mkn = KerrNewman(coords=sph, M=M, a=a, Q=Q) def mssing(ms): mssing = ms.singularities() def mksing(mk): mksing = mk.singularities() def mknsing(mkn): mknsing = mkn.singularities() with pytest.raises(NotImplementedError): mssing(ms) with pytest.raises(NotImplementedError): mksing(mk) with pytest.raises(NotImplementedError): mknsing(mkn)
def test_v_t_getter_setter0(cartesian_differential, spherical_differential, bl_differential): M = 1e24 * u.kg a = 0. * u.one ms = Schwarzschild(coords=spherical_differential, M=M) mk = Kerr(coords=bl_differential, M=M, a=a) def cd_vt(cartesian_differential, ms): cartesian_differential.v_t = (ms, ) def sd_vt(spherical_differential, mk): spherical_differential.v_t = (mk, ) # This should not raise CoordinateError try: spherical_differential.v_t = (ms, ) except CoordinateError: pytest.fail("Unexpected TypeError!") # These 2 should raise CoordinateError with pytest.raises(CoordinateError): cd_vt(cartesian_differential, ms) with pytest.raises(CoordinateError): sd_vt(spherical_differential, mk)
def test_v_t_raises_CoordinateError(cartesian_differential, spherical_differential, bl_differential): M = 1e24 * u.kg a = 0. * u.one ms = Schwarzschild(coords=spherical_differential, M=M) mk = Kerr(coords=bl_differential, M=M, a=a) cd, sd, bd = cartesian_differential, spherical_differential, bl_differential def cd_s(cd, ms): return cd.velocity(metric=ms) def bd_s(bd, ms): return bd.velocity(metric=ms) def cd_k(cd, mk): return cd.velocity(metric=mk) def sd_k(sd, mk): return sd.velocity(metric=mk) with pytest.raises(CoordinateError): cd_s(cd, ms) with pytest.raises(CoordinateError): bd_s(bd, ms) with pytest.raises(CoordinateError): cd_k(cd, mk) with pytest.raises(CoordinateError): sd_k(sd, mk)
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)
def test_velocity2(spherical_differential, bl_differential): M = 1e24 * u.kg a = 0. * u.one ms = Schwarzschild(coords=spherical_differential, M=M) mk = Kerr(coords=bl_differential, M=M, a=a) sd, bd = spherical_differential, bl_differential assert_allclose(sd.velocity(metric=ms)[1:], [sd.v_r.value, sd.v_th.value, sd.v_p.value]) assert_allclose(bd.velocity(metric=mk)[1:], [bd.v_r.value, bd.v_th.value, bd.v_p.value])
def test_deprecation_warning_for_calculate_trajectory(): """ Tests, if a Deprecation Warning is shown, when accessing calculate_trajectory \ for all metric classes """ M, a, Q = 5e27, 0., 0. ms = Schwarzschild(M=M) mk = Kerr(coords="BL", M=M, a=a) mkn = KerrNewman(coords="BL", M=M, a=a, Q=Q) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") ms.calculate_trajectory() mk.calculate_trajectory() mkn.calculate_trajectory() assert len(w) == 3 # 3 warnings to be shown assert issubclass(w[-1].category, DeprecationWarning)
def test_singularities_for_uncharged_nonrotating_case(): """ Tests, if all metric singularities match up across Schwarzschild, Kerr & Kerr-Newman \ spacetimes, when a -> 0 & Q -> 0, subject to choice to coordinates (here, Spherical and BL) """ theta = np.pi / 4 M, a, Q = 5e27, 0., 0. ms = Schwarzschild(M=M) mk = Kerr(coords="BL", M=M, a=a) mkn = KerrNewman(coords="BL", M=M, a=a, Q=Q) mssing = ms.singularities() mksing = mk.singularities() mknsing = mkn.singularities() mssinglist = [ mssing["inner_ergosphere"], mssing["inner_horizon"], mssing["outer_horizon"], mssing["outer_ergosphere"] ] mksinglist = [ mksing["inner_ergosphere"](theta), mksing["inner_horizon"], mksing["outer_horizon"], mksing["outer_ergosphere"](theta) ] mknsinglist = [ mknsing["inner_ergosphere"](theta), mknsing["inner_horizon"], mknsing["outer_horizon"], mknsing["outer_ergosphere"](theta) ] scr = ms.schwarzschild_radius(M) assert_allclose(mssinglist, mksinglist, rtol=1e-4, atol=0.0) assert_allclose(mksinglist, mknsinglist, rtol=1e-4, atol=0.0) assert_allclose(mknsinglist, mssinglist, rtol=1e-4, atol=0.0) assert_allclose(mksinglist[2], scr, rtol=1e-4, atol=0.0)
def test_calculate_trajectory3_kerr(): # 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. 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:] mk_cov = Kerr(coords="BL", M=M, a=a) x_4vec = four_position(t, x_vec) mk_cov_mat = mk_cov.metric_covariant(x_4vec) init_vec = stacked_vec(mk_cov_mat, t, x_vec, v_vec, time_like=True) end_lambda = 3.154e7 geod = Geodesic( metric=mk_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)
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)
def test_str_repr(): """ Tests, if the ``__str__`` and ``__repr__`` messages match """ ms = Schwarzschild(M=1e22) mk = Kerr(coords="BL", M=1e22, a=0.5) mkn = KerrNewman(coords="BL", M=1e22, a=0.5, Q=0.) assert str(ms) == repr(ms) assert str(mk) == repr(mk) assert str(mkn) == repr(mkn)
def test_f_vec_bl_kerr(): M, a = 6.73317655e26 * u.kg, 0.2 * u.one bl = BoyerLindquistDifferential(t=0. * u.s, r=1e6 * u.m, theta=4 * np.pi / 5 * u.rad, phi=0. * u.rad, v_r=0. * u.m / u.s, v_th=0. * u.rad / u.s, v_p=2e6 * u.rad / u.s) f_vec_expected = np.array([ 3.92128321e+03, 0.00000000e+00, 0.00000000e+00, 2.00000000e+06, -0.00000000e+00, 1.38196394e+18, -1.90211303e+12, -0.00000000e+00 ]) mk = Kerr(coords=bl, M=M, a=a) state = np.hstack((bl.position(), bl.velocity(mk))) f_vec = mk._f_vec(0., state) assert isinstance(f_vec, np.ndarray) assert_allclose(f_vec_expected, f_vec, rtol=1e-8)
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)
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)
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)
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)