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_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_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)