예제 #1
0
def test_change_config():
    x, y, z = sympy.symbols("x y z")

    list3d = np.zeros((3, 3, 3), dtype=int).tolist()
    for i in range(3):
        list3d[i][i][i] = (x**i) * (y * (2 - i)) + i * z
    list3d[1][2][0] = list3d[1][0][2] = x * y * z
    list3d[2][1][0] = list3d[2][0][1] = 4 * y

    metriclist = np.identity(3).tolist()
    metric = MetricTensor(metriclist, (x, y, z), "uu")
    ch = ChristoffelSymbols(list3d, (x, y, z), "ull", parent_metric=metric)
    chr_new = ch.change_config("llu")

    for t in range(3):
        i, j, k = t % 3, (int(t / 3)) % 3, (int(t / (3**2))) % 3
        assert sympy.simplify(ch[i, j, k] - chr_new[i, j, k]) == 0
예제 #2
0
def test_TypeError():
    testarr = np.ones((4, 4, 4), dtype=int).tolist()
    syms = 0
    try:
        obj = ChristoffelSymbols(testarr, syms)
        assert False
    except TypeError:
        assert True
예제 #3
0
def test_no_exception_raised_passing_christoffel_with_unconventional_indices():
    sch = schwarzschild_metric()
    ch = ChristoffelSymbols.from_metric(sch)
    ch2 = ch.change_config("uuu")
    try:
        rm = RiemannCurvatureTensor.from_christoffels(ch2)
        assert True
    except:
        assert False
예제 #4
0
def test_properties():
    sch_inv = schwarzschild_metric()
    ch = ChristoffelSymbols.from_metric(sch_inv)
    assert ch.parent_metric == ch._parent_metric
    # test change_config, should raise ValueError
    ch._parent_metric = None
    try:
        ch_new = ch.change_config("lll")
        assert False
    except Exception:
        return True
예제 #5
0
    def get_christoffel_symbols(self, input_vectors=None):
        """
        returns the christoffel symbols in the standard order:
            `cf[i,j,k]`= $\Gamma^i_{jk}$
        einsteinpy is used to obtain the tensor
        """
        cf = ChristoffelSymbols.from_metric(self.get_metric_tensor())

        if input_vectors is not None:            
            cf = self.model.apply(cf.tensor(), input_vectors)
        
        return cf
예제 #6
0
def test_wrong_number_of_indices_ValueError():
    x, y, z = sympy.symbols("x y z")

    list3d = np.zeros((3, 3, 3), dtype=int).tolist()
    for i in range(3):
        list3d[i][i][i] = (x**i) * (y * (2 - i)) + i * z
    list3d[1][2][0] = list3d[1][0][2] = x * y * z
    list3d[2][1][0] = list3d[2][0][1] = 4 * y

    try:
        ch = ChristoffelSymbols(list3d, (x, y, z), "ulll")
        assert False
    except ValueError:
        assert True
예제 #7
0
def test_ChristoffelSymbols():
    sch = schwarzschild_metric()
    chl = ChristoffelSymbols.from_metric(sch)
    mat = chl.tensor()
    symbolstr = "t r theta phi"
    syms = sympy.symbols(symbolstr)
    G, M, c, a = sympy.symbols("G M c a")
    assert (
        sympy.simplify(mat[2, 3, 3] -
                       (-1 * sympy.cos(syms[2]) * sympy.sin(syms[2]))) == 0)
    assert sympy.simplify(mat[3, 3, 1] - syms[1] / (syms[1]**2)) == 0
    assert (sympy.simplify((mat[1, 1, 1].subs({a: (2 * G * M / (c**2))})) -
                           (G * M /
                            (2 * G * M * syms[1] - c**2 * syms[1]**2))) == 0)
    assert chl.symbols() == syms
예제 #8
0
 def christoffel_symbol(self):
     from einsteinpy.symbolic import ChristoffelSymbols
     return ChristoffelSymbols.from_metric(self.metric_tensor)
예제 #9
0
 def get_tensor():
     metric = AntiDeSitter()
     return ChristoffelSymbols.from_metric(metric)