def test_weyl_contraction_1st_3rd_indices_zero(): mw1 = anti_de_sitter_metric() w1 = WeylTensor.from_metric(mw1) t1 = simplify_sympy_array( sympy.tensorcontraction(w1.change_config("ulll").tensor(), (0, 2))) t0 = sympy.Array(np.zeros(shape=t1.shape, dtype=int)) assert t1 == t0
def test_TransformationMatrix_classmethod_new2old(cart2sph_matrix): obj = cart2sph_matrix cmp_array = Array([[1 / cos(q), 1 / sin(q)], [-1 / (p * sin(q)), 1 / (p * cos(q))]]) zero_array = Array(np.zeros(shape=cmp_array.shape, dtype=int)) assert simplify_sympy_array(cmp_array - obj) == zero_array
def test_SchoutenTensor_config_change(): metric = schwarzschild_metric() t1 = SchoutenTensor.from_metric(metric) t2 = t1.change_config("ul") t3 = t2.change_config("ll") assert t1.config == "ll" and t3.config == "ll" compare = sympy.Array(np.zeros((4, 4), dtype=int)) testarr = simplify_sympy_array(t1.tensor() - t3.tensor()) assert testarr == compare
def test_weyl_conformal_rescaling(): # https://en.wikipedia.org/wiki/Weyl_tensor#Conformal_rescaling a = sympy.symbols("a") mw1 = anti_de_sitter_metric() mw2 = MetricTensor(a * mw1.tensor(), mw1.symbols(), mw1.config) w1 = WeylTensor.from_metric(mw1).change_config("ulll") w2 = WeylTensor.from_metric(mw2).change_config("ulll") cmp_arr = sympy.Array(np.zeros(shape=w1.tensor().shape, dtype=int)) assert simplify_sympy_array(w1.tensor() - w2.tensor()) == cmp_arr assert w1.syms == w1.symbols() assert w1.parent_metric == w1._parent_metric
def test_TransformationMatrix_inv_function(cart2sph_matrix): assert cart2sph_matrix._inv is None obj = cart2sph_matrix.inv() assert cart2sph_matrix._inv is not None obj = cart2sph_matrix.inv() cmp_array = Array([[cos(q), sin(q)], [-1 * p * sin(q), p * cos(q)]]) zero_array = Array(np.zeros(shape=cmp_array.shape, dtype=int)) assert simplify_sympy_array(cmp_array - obj) == zero_array
def test_Minkowski_equality(): # Minkowski and MinkowskiCartesian are same assert simplify_sympy_array( MinkowskiCartesian().tensor()) == simplify_sympy_array( Minkowski().tensor())
def test_check_two_metrics_are_equal(m1, m2): zero_arr = Array(np.zeros(shape=m1.tensor().shape, dtype=int)) assert simplify_sympy_array(m1.tensor() - m2.tensor()) == zero_arr
def test_simplify_sympy_array_works_for_all(target): try: simplify_sympy_array(target) assert True except Exception: assert False